Implementation plan
import paramiko
def execute_commands(host, username, password, commands):
ssh = [Link]()
ssh.set_missing_host_key_policy([Link]())
[Link](host, username=username, password=password)
for command in commands:
stdin, stdout, stderr = ssh.exec_command(command)
print([Link]().decode())
print([Link]().decode())
[Link]()
# Define the hosts and credentials
hosts = [
{"host": "ENS-LF001-UK3", "username": "your_username", "password":
"your_password"},
{"host": "ENS-LF002-UK3", "username": "your_username", "password":
"your_password"}
]
# Define the commands for each host
commands_1 = [
"sh ip bgp vrf ens_mo_core su",
"configure terminal",
"router bgp 65400",
"vrf ens_mo_core",
"no neighbor [Link]",
"end",
"copy run start"
]
commands_2 = [
"sh ip bgp vrf ens_mo_core su",
"configure terminal",
"router bgp 65400",
"vrf ens_mo_core",
"no neighbor [Link]",
"end",
"copy run start"
]
# Execute the commands on each host
execute_commands(hosts[0]["host"], hosts[0]["username"], hosts[0]["password"],
commands_1)
execute_commands(hosts[1]["host"], hosts[1]["username"], hosts[1]["password"],
commands_2)
-----------------------------------------------
Backout plan
import paramiko
def execute_commands(host, username, password, commands):
ssh = [Link]()
ssh.set_missing_host_key_policy([Link]())
[Link](host, username=username, password=password)
for command in commands:
stdin, stdout, stderr = ssh.exec_command(command)
print([Link]().decode())
print([Link]().decode())
[Link]()
# Define the hosts and credentials
hosts = [
{"host": "ENS-LF001-UK3", "username": "your_username", "password":
"your_password"},
{"host": "ENS-LF002-UK3", "username": "your_username", "password":
"your_password"}
]
# Define the commands for each host
commands_1 = [
"configure terminal",
"router bgp 65400",
"vrf ens_mo_core",
"neighbor [Link]",
"remote-as 64850",
"description BGP Session to MO Core NSX_T0",
"password 7 0230294C0A140A700D78240E0405175A4D",
"ebgp-multihop 5",
"address-family ipv4 unicast",
"send-community",
"route-map ENS_MO_CORE_NSX-T_IN in",
"route-map ENS_MO_CORE_NSX-T_OUT out",
"maximum-prefix 100 90",
"end",
"sh ip bgp vrf ens_mo_core su",
"copy run start"
]
commands_2 = [
"configure terminal",
"router bgp 65400",
"vrf ens_mo_core",
"neighbor [Link]",
"remote-as 64850",
"description BGP Session to MO Core NSX_T0",
"password 7 0230294C0A140A700D78240E0405175A4D",
"ebgp-multihop 5",
"address-family ipv4 unicast",
"send-community",
"route-map ENS_MO_CORE_NSX-T_IN in",
"route-map ENS_MO_CORE_NSX-T_OUT out",
"maximum-prefix 100 90",
"end",
"sh ip bgp vrf ens_mo_core su",
"copy run start"
]
# Execute the commands on each host
execute_commands(hosts[0]["host"], hosts[0]["username"], hosts[0]["password"],
commands_1)
execute_commands(hosts[1]["host"], hosts[1]["username"], hosts[1]["password"],
commands_2)
-----------------------------------