summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2016-01-30 18:43:30 +0800
committerJustin chi <chigang@huawei.com>2016-01-31 00:39:00 +0000
commit81752c48ce4674e9084de3303bfb6f088365b30b (patch)
tree9d2d686e44065518ad0b996320ad8ea94a2cc08b
parent33f158ba8b717531b4f7122f713a6c0eeb4db003 (diff)
bugfix: rename nic based on mac
Change-Id: I2771a87a41ab884dbda1fcffa8ab0833489fb5ef Signed-off-by: carey.xu <carey.xuhan@huawei.com>
-rw-r--r--deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-nosdn-nofeature-ha.yml10
-rwxr-xr-xdeploy/deploy_host.sh8
-rw-r--r--deploy/rename_nics.py29
3 files changed, 45 insertions, 2 deletions
diff --git a/deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-nosdn-nofeature-ha.yml b/deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-nosdn-nofeature-ha.yml
index 4b812dfb..18b9f072 100644
--- a/deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-nosdn-nofeature-ha.yml
+++ b/deploy/conf/hardware_environment/huawei-us-deploy-bare-1/os-nosdn-nofeature-ha.yml
@@ -9,6 +9,8 @@ ipmiVer: '2.0'
hosts:
- name: host1
mac: 'F8:4A:BF:55:A2:8D'
+ interfaces:
+ eth1: 'F8:4A:BF:55:A2:8E'
ipmiIp: 172.16.130.26
ipmiPass: Huawei@123
roles:
@@ -17,6 +19,8 @@ hosts:
- name: host2
mac: 'D8:49:0B:DA:5A:B7'
+ interfaces:
+ eth1: 'D8:49:0B:DA:5A:B8'
ipmiIp: 172.16.130.27
ipmiPass: huawei@123
roles:
@@ -25,6 +29,8 @@ hosts:
- name: host3
mac: 'D8:49:0B:DA:2A:28'
+ interfaces:
+ eth1: 'D8:49:0B:DA:2A:29'
ipmiIp: 172.16.130.29
ipmiPass: Huawei@123
roles:
@@ -33,6 +39,8 @@ hosts:
- name: host4
mac: 'D8:49:0B:DA:5B:5D'
+ interfaces:
+ eth1: 'D8:49:0B:DA:5B:5E'
ipmiIp: 172.16.130.30
ipmiPass: Huawei@123
roles:
@@ -40,6 +48,8 @@ hosts:
- name: host5
mac: 'D8:49:0B:DA:56:85'
+ interfaces:
+ eth1: 'D8:49:0B:DA:56:86'
ipmiIp: 172.16.130.31
ipmiPass: Huawei@123
roles:
diff --git a/deploy/deploy_host.sh b/deploy/deploy_host.sh
index 1b03f043..9617b241 100755
--- a/deploy/deploy_host.sh
+++ b/deploy/deploy_host.sh
@@ -8,14 +8,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
rsa_file=$compass_vm_dir/boot.rsa
+
+function rename_nics(){
+ python $COMPASS_DIR/deploy/rename_nics.py $DHA $rsa_file $MGMT_IP
+}
+
function deploy_host(){
ssh $ssh_args root@${MGMT_IP} mkdir -p /opt/compass/bin/ansible_callbacks
scp $ssh_args -r ${COMPASS_DIR}/deploy/status_callback.py root@${MGMT_IP}:/opt/compass/bin/ansible_callbacks/status_callback.py
# avoid nodes reboot to fast, cobbler can not give response
- (sleep 20;reboot_hosts) &
-
+ (sleep 20; rename_nics; reboot_hosts) &
if [[ "$REDEPLOY_HOST" == true ]]; then
deploy_flag="redeploy"
else
diff --git a/deploy/rename_nics.py b/deploy/rename_nics.py
new file mode 100644
index 00000000..ef52d63a
--- /dev/null
+++ b/deploy/rename_nics.py
@@ -0,0 +1,29 @@
+import os
+import sys
+import yaml
+
+def exec_cmd(cmd):
+ print cmd
+ os.system(cmd)
+
+def rename_nics(dha_info, rsa_file, compass_ip):
+ for host in dha_info['hosts']:
+ host_name = host['name']
+ interfaces = host.get('interfaces')
+ if interfaces:
+ for interface in interfaces:
+ nic_name = interfaces.keys()[0]
+ mac = interfaces.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'" \
+ % (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])