add sdn_controller_ip to admin_openrc.sh 41/37241/4
authorroot <zhou.ya@zte.com.cn>
Wed, 12 Jul 2017 06:44:59 +0000 (14:44 +0800)
committerroot <zhou.ya@zte.com.cn>
Thu, 13 Jul 2017 07:45:34 +0000 (15:45 +0800)
Change-Id: I3af46368109bc5358fd0cc61a43f5be60479eab3
Signed-off-by: root <zhou.ya@zte.com.cn>
deploy/post/execute.py

index 24061e0..f64b9af 100644 (file)
@@ -10,12 +10,23 @@ import os
 
 import glance
 import argparse
-
+import yaml
 import neutron
 import nova
 from deploy.config.network import NetworkConfig
 
 
+def _config_kolla_admin_openrc(kolla_config_path):
+    with open('%s/globals.yml' % kolla_config_path, 'r') as f:
+        kolla_config = yaml.safe_load(f.read())
+    if kolla_config.get('opendaylight_leader_ip_address'):
+        sdn_controller_ip = kolla_config.get('opendaylight_leader_ip_address')
+        openrc_file = file('%s/admin-openrc.sh' % kolla_config_path, 'a')
+        sdn_ctl_ip = 'export SDN_CONTROLLER_IP=' + sdn_controller_ip + '\n'
+        openrc_file.write(sdn_ctl_ip)
+        openrc_file.close()
+
+
 def _config_external_network(ext_name, physnet):
     body = {
         'network': {
@@ -115,6 +126,7 @@ def main():
     _create_external_network(args.network_file)
     _create_flavor_m1_micro()
     _create_image_TestVM()
+    _config_kolla_admin_openrc('/etc/kolla/')
 
 
 if __name__ == '__main__':