Skip to content

Commit 5300e81

Browse files
Add files via upload
1 parent 0f1e22e commit 5300e81

File tree

5 files changed

+493
-0
lines changed

5 files changed

+493
-0
lines changed

Fortimanager_1/Cutover.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def main():
2+
from Fortimanager_Master import FortiManager
3+
import fwinput_cfg as data
4+
host= "https://172.19.254.43/jsonrpc"
5+
usr="fortiapi"
6+
pwd= "fortiapi"
7+
i = input("Enter the no.of vlan's you want to Migration:")
8+
for x in range(int(i)):
9+
try:
10+
device_name=(data.vlan_list[x]["device_name"])
11+
scope=(data.vlan_list[x]["scope"])
12+
adom=(data.vlan_list[x]["adom"])
13+
vdom_name=(data.vlan_list[x]["vdom_name"])
14+
gw_subnet=(data.vlan_list[x]["gw_subnet"])
15+
current_phy_interface=(data.vlan_list[x]["current_phy_interface"])
16+
current_vlan_interface = (data.vlan_list[x]["current_vlan_interface"])
17+
print ("")
18+
print("Logging into Fortimanager Controller:{}".format(host))
19+
print("Configure the FW :{}".format(device_name))
20+
print("Disable the old interface :{} on Subnet {}".format(current_vlan_interface,gw_subnet))
21+
ACTION = input("Are you sure you want to push the configuration (y/n): ")
22+
if ACTION in ("y","yes","Y","YES"):
23+
FM=FortiManager(usr, pwd, host)
24+
print("Calling the Master function -> Authenticating into the FM Controller")
25+
t0=FM.login()
26+
t1=FM.cutover_vlan_interface(device_name, vdom_name,current_vlan_interface,current_phy_interface)
27+
t8=FM.quick_install_device(adom, device_name,current_vlan_interface) ### Push the configuration from Fortimanager to Fortigate Firewall.
28+
t10=FM.logout()
29+
elif ACTION in ("n","no","N","No"):
30+
print("Ending the script")
31+
else:
32+
print("Please enter yes or no.")
33+
except IndexError:
34+
print("Oops! Out of the vlan migration range. please check and Try again...")
35+
36+
if __name__ == '__main__':
37+
main()

Fortimanager_1/FMPrework.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
def main():
2+
from Fortimanager_Master import FortiManager
3+
import fwinput_cfg as data
4+
host= "https://172.19.254.43/jsonrpc"
5+
usr="fortiapi"
6+
pwd= "fortiapi"
7+
i = input("Enter the no.of vlan's you want to Migration:")
8+
for x in range(int(i)):
9+
try:
10+
device_name=(data.vlan_list[x]["device_name"])
11+
scope=(data.vlan_list[x]["scope"])
12+
adom=(data.vlan_list[x]["adom"])
13+
vdom_name=(data.vlan_list[x]["vdom_name"])
14+
l3out_int_name=(data.vlan_list[x]["l3out_int_name"])
15+
vlan_id = (data.vlan_list[x]["vlan_id"])
16+
gw_subnet=(data.vlan_list[x]["gw_subnet"])
17+
l3out_phy_interface=(data.vlan_list[x]["l3out_phy_interface"])
18+
l3out_ipadd=(data.vlan_list[x]["l3out_ipadd"])
19+
aci_l3out_nexthop=(data.vlan_list[x]["aci_l3out_nexthop"])
20+
l3out_rm_name=(data.vlan_list[x]["l3out_rm_name"])
21+
l3out_nh_interface=l3out_int_name
22+
l3out_vlan_name=l3out_int_name+"_L3out"
23+
distance = "10"
24+
zone_name= l3out_int_name+"_Zone"
25+
access_list = "rof_adv_list"
26+
config_block="router/access-list" #"system/zone" or "router/ospf" or "router/static" or "router/access-list" or "router/route-map"
27+
interface_block="global/system/interface"
28+
print ("")
29+
print("Logging into Fortimanager Controller:{}".format(host))
30+
print("Configure the FW :{}".format(device_name))
31+
print("Configure the new L3out interface :{}".format(l3out_int_name))
32+
print("Associate the new L3out int. into member of :{}".format(zone_name))
33+
print("Configure the .1Q Sub-interface vlan for L3out #:{}".format(vlan_id))
34+
print("Configure the Physical interface for new L3out:{}".format(l3out_phy_interface))
35+
print("Configure the Next-hop IP address ACI :{}".format(aci_l3out_nexthop))
36+
print("Configure the IP address on L3out interface:{}".format(l3out_ipadd))
37+
print("Configure the Route-map {} on FW:{}".format(l3out_rm_name,device_name))
38+
print("Configure the Access-list {} on the FW:{}".format(access_list,device_name))
39+
40+
41+
ACTION = input("Are you sure you want to push the configuration (y/n): ")
42+
if ACTION in ("y","yes","Y","YES"):
43+
FM=FortiManager(usr, pwd, host)
44+
print("Calling the Master function -> Authenticating into the FM Controller")
45+
t0=FM.login()
46+
t1=FM.add_vlan_interface(device_name, l3out_vlan_name, vdom_name, l3out_ipadd,vlan_id,l3out_phy_interface)
47+
t2=FM.add_zone_interface(device_name, zone_name, l3out_vlan_name)
48+
t3=FM.add_static_route(device_name, l3out_vlan_name, gw_subnet, distance, aci_l3out_nexthop)
49+
t4= FM.add_access_list(device_name, gw_subnet, access_list)
50+
t5= FM.add_acl_to_rm(device_name, l3out_rm_name, access_list)
51+
t6=FM.add_rm_to_ospf(device_name, l3out_rm_name)
52+
#t7=FM.get_config_block(device_name,scope, config_block)
53+
t8=FM.get_interface_block(device_name, interface_block)
54+
t8=FM.quick_install_device(adom, device_name,l3out_vlan_name) ### Push the configuration from Fortimanager to Fortigate Firewall.
55+
t10=FM.logout()
56+
elif ACTION in ("n","no","N","No"):
57+
print("Ending the script")
58+
else:
59+
print("Please enter yes or no.")
60+
except IndexError:
61+
print("Oops! Out of the vlan migration range. please check and Try again...")
62+
63+
if __name__ == '__main__':
64+
main()

0 commit comments

Comments
 (0)