Skip to content

Instantly share code, notes, and snippets.

@zaibon
Forked from maxux/set40g.py
Last active March 21, 2017 16:06
Show Gist options
  • Save zaibon/f19083fdd5cc07a6ce30a7d05808914b to your computer and use it in GitHub Desktop.
Save zaibon/f19083fdd5cc07a6ce30a7d05808914b to your computer and use it in GitHub Desktop.
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