-
-
Save zaibon/f19083fdd5cc07a6ce30a7d05808914b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from g8core import client | |
hosts = { | |
"10.101.200.1": "10.120.0.1", | |
"10.101.200.2": "10.120.0.2", | |
"10.101.200.3": "10.120.0.3", | |
"10.101.200.4": "10.120.0.4" | |
} | |
for host in hosts.keys(): | |
# host = "10.101.200.4" | |
intf = "enp4s0" | |
print("Connecting: %s" % host) | |
cl = client.Client(host) | |
cl.ping() | |
print("Starting 40G network: %s" % hosts[host]) | |
test = cl.system("ip l show dev enp4s0").get() | |
if test.stderr != "": | |
intf = "eth0" | |
cl.system("ip l set dev %s mtu 9000" % intf).get() | |
cl.system("ip l add link %s name %s.1234 type vlan id 1234" % (intf, intf)).get() | |
cl.system("ip a add %s/24 dev %s.1234" % (hosts[host], intf)).get() | |
cl.system("ip l set dev %s up" % intf).get() | |
cl.system("ip l set dev %s.1234 up" % intf).get() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment