Initial commit

This commit is contained in:
awlx committed 2016-11-29 09:56:23 +01:00
1 parent 2c29dcca1f
commit ac46128168
3 files changed
+69

No files matched your search

+45
View File
@@ -261,6 +261,51 @@ class FortiOSDriver(NetworkDriver):
if search in l:
return l
def get_firewall_policies(self):
cmd = self.execute_command_with_vdom('show firewall policy')
policy = dict()
policy_id = None
default_policy = dict()
position = 1
for line in cmd:
policy_data = line.strip()
if policy_data.find("edit") == 0:
policy_id = policy_data.split()[1]
policy[policy_id] = dict()
if policy_id is not None:
if len(policy_data.split()) > 2:
policy_setting = policy_data.split()[1]
policy[policy_id][policy_setting] = policy_data.split()[2].replace("\"", "")
for key in policy:
enabled = 'status' in policy[key]
logtraffic = policy[key]['logtraffic'] if 'logtraffic' in policy[key] else False
action = 'permit' if 'action' in policy[key] else 'reject'
policy_item = dict()
default_policy[key] = list()
policy_item['position'] = position
policy_item['packet_hits'] = -1
policy_item['byte_hits'] = -1
policy_item['id'] = unicode(key)
policy_item['enabled'] = enabled
policy_item['schedule'] = unicode(policy[key]['schedule'])
policy_item['log'] = unicode(logtraffic)
policy_item['l3_src'] = unicode(policy[key]['srcaddr'])
policy_item['l3_dst'] = unicode(policy[key]['dstaddr'])
policy_item['service'] = unicode(policy[key]['service'])
policy_item['src_zone'] = unicode(policy[key]['srcintf'])
policy_item['dst_zone'] = unicode(policy[key]['dstintf'])
policy_item['action'] = unicode(action)
default_policy[key].append(policy_item)
position = position + 1
return default_policy
def get_bgp_neighbors(self):
families = ['ipv4', 'ipv6']
@@ -0,0 +1 @@
{'1': [{'src_zone': u'any', 'log': u'False', 'service': u'ALL', 'schedule': u'always', 'l3_src': u'all', 'enabled': False, 'packet_hits': -1, 'l3_dst': u'all', 'dst_zone': u'any', 'action': u'permit', 'position': 1, 'byte_hits': -1, 'id': u'1'}], '2': [{'src_zone': u'port3', 'log': u'all', 'service': u'ALL', 'schedule': u'always', 'l3_src': u'all', 'enabled': False, 'packet_hits': -1, 'l3_dst': u'all', 'dst_zone': u'port2', 'action': u'reject', 'position': 2, 'byte_hits': -1, 'id': u'2'}]}
@@ -0,0 +1,23 @@
config firewall policy
edit 1
set uuid 9d747de8-dad4-51e5-7a7e-d078aa77140a
set srcintf "any"
set dstintf "any"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 2
set name "bla"
set uuid de597b64-aca8-51e6-5d00-b7874e6b72b8
set srcintf "port3"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set schedule "always"
set service "ALL"
set logtraffic all
next
end