aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/rename_nics.py
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/rename_nics.py')
-rw-r--r--deploy/rename_nics.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/deploy/rename_nics.py b/deploy/rename_nics.py
index 6163188e..dcec51df 100644
--- a/deploy/rename_nics.py
+++ b/deploy/rename_nics.py
@@ -6,7 +6,7 @@ def exec_cmd(cmd):
print cmd
os.system(cmd)
-def rename_nics(dha_info, rsa_file, compass_ip):
+def rename_nics(dha_info, rsa_file, compass_ip, os_version):
for host in dha_info['hosts']:
host_name = host['name']
interfaces = host.get('interfaces')
@@ -15,15 +15,21 @@ def rename_nics(dha_info, rsa_file, compass_ip):
nic_name = interface.keys()[0]
mac = interface.values()[0]
- exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
- -i %s root@%s \
- 'cobbler system edit --name=%s --interface=%s --mac=%s --interface_type=static'" \
- % (rsa_file, compass_ip, host_name, nic_name, mac))
+ if os_version == 'xenial':
+ exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -i %s root@%s \
+ 'cobbler system edit --name=%s --interface=%s --mac=%s --interface_type=static'" \
+ % (rsa_file, compass_ip, host_name, nic_name, mac))
+ else:
+ exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
+ -i %s root@%s \
+ 'cobbler system edit --name=%s --interface=%s --mac=%s'" \
+ % (rsa_file, compass_ip, host_name, nic_name, mac))
exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-i %s root@%s \
'cobbler sync'" % (rsa_file, compass_ip))
if __name__ == "__main__":
- assert(len(sys.argv) == 4)
- rename_nics(yaml.load(open(sys.argv[1])), sys.argv[2], sys.argv[3])
+ assert(len(sys.argv) == 5)
+ rename_nics(yaml.load(open(sys.argv[1])), sys.argv[2], sys.argv[3], sys.argv[4])