Skip to content

Commit 0f1e22e

Browse files
Update Fortimanager_Master.py
1 parent d65d083 commit 0f1e22e

File tree

1 file changed

+0
-74
lines changed

1 file changed

+0
-74
lines changed

Fortimanager/Fortimanager_Master.py

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ def add_access_list(self, device_name, advertise_subnet, access_list):
174174
{
175175
"url": "/pm/config/device/"+ device_name +"/vdom/root/router/access-list",
176176
"data": [{"rule":[{ "id":0,"prefix": advertise_subnet}],"name": access_list}],
177-
#"data": [{"rule":[{ "edit":0,"prefix": advertise_subnet}],"name": access_list}],
178177

179178
}
180179
],
@@ -289,76 +288,3 @@ def get_interface_block(self, device_name, interface_block):
289288
res = res.json()
290289
print(json.dumps(res, indent=4))
291290
return res
292-
"""
293-
def append_access_list(self, device_name, advertise_subnet, t7,access_list):
294-
new_data = [{"rule":[{ "id":0,"prefix": advertise_subnet}],}],
295-
print(new_data)
296-
res = t7
297-
curr_data = res["result"][0]["data"]
298-
print(curr_data)
299-
rules=curr_data[0]["rule"].append(new_data)
300-
print(rules)
301-
#print("Configure the FM to create the access_list and then add the prefixes"
302-
params = {
303-
"method": "set",
304-
"params": [
305-
{
306-
"url": "/pm/config/device/"+ device_name +"/vdom/root/router/access-list",
307-
"data": [{"rule":rules,"name": access_list}],
308-
309-
310-
}
311-
],
312-
"id": 1,
313-
"session": self.session,
314-
}
315-
res = requests.post(url=self.URL, headers=self.HEADERS, json=params, verify=False)
316-
res = res.json()
317-
#print(json.dumps(params, indent=4))
318-
return res
319-
320-
def append_access_list(self, device_name, advertise_subnet, access_list):
321-
print("Configure the FM to create the access_list and then add the prefixes")
322-
params = {
323-
"method": "set",
324-
"params": [
325-
{
326-
"url": "/pm/config/device/"+ device_name +"/vdom/root/router/access-list",
327-
"data": [{"rule":[{ "id":0,"prefix": advertise_subnet}],"name": access_list}],
328-
#"data": [{"rule":[{ "edit":0,"prefix": advertise_subnet}],"name": access_list}],
329-
330-
}
331-
],
332-
"id": 1,
333-
"session": self.session,
334-
}
335-
res = requests.post(url=self.URL, headers=self.HEADERS, json=params, verify=False)
336-
res = res.json()
337-
#print(json.dumps(params, indent=4))
338-
return res
339-
340-
# Pull the configuration from the Fortimanager Database.
341-
def get_config_block(self, device_name, scope, config_block):
342-
print("\n Pulling current REST API configuration from the controller for :{}\n".format(config_block))
343-
params = {
344-
"method": "get",
345-
"params": [{"url": "/pm/config/device/" + device_name + "/" + scope + "/" + config_block, }],
346-
"id": 1,
347-
"session": self.session,
348-
}
349-
res = requests.post(url=self.URL, headers=self.HEADERS, json=params, verify=False)
350-
res = res.json()
351-
#print(json.dumps(res, indent=4))
352-
return res
353-
def update_access_list(device_name, list_name, data):
354-
355-
fmg = FortiManager("fortiapi", "fortiapi", "https://172.19.255.53/jsonrpc")
356-
fmg.login()
357-
res = get_config_block(device_name, "vdom/root", "router/access-list" + list_name)
358-
url = res["result"][0]["url"]
359-
curr_data = res["result"][0]["data"]
360-
curr_data[0]["rule"].append(data)
361-
362-
res = fmg.add_config_block(curr_data, url)
363-
364-
"""

0 commit comments

Comments
 (0)