Compatible with the no mapping in network.yml 09/34409/1
authorzhongjun <zhong.jun@zte.com.cn>
Mon, 8 May 2017 02:26:00 +0000 (10:26 +0800)
committerzhongjun <zhong.jun@zte.com.cn>
Mon, 8 May 2017 02:26:00 +0000 (10:26 +0800)
1)resolve the error  ' AttributeError: 'NetworkConfig' object has
no attribute 'ext_mapping'' with the no mapping in network.yml.

2)resolve the creating external subnet failure if the external
netwok exists.

Change-Id: I578365d91b8b61f9f88a5d4ff2c9db9ecc512edc
Signed-off-by: zhongjun <zhong.jun@zte.com.cn>
deploy/post/execute.py

index 37a67b4..24061e0 100644 (file)
@@ -50,11 +50,12 @@ def _config_external_subnet(ext_id, network_conf):
 def _create_external_network(network_file):
     network_conf = NetworkConfig(network_file=network_file)
     ext_name = network_conf.ext_network_name
-    physnet = network_conf.ext_mapping
+    physnet = network_conf.ext_mapping if hasattr(network_conf, 'ext_mapping') else 'physnet1'
     neutronclient = neutron.Neutron()
     ext_id = neutronclient.create_network(ext_name,
                                           _config_external_network(ext_name, physnet))
-    neutronclient.create_subnet(_config_external_subnet(ext_id, network_conf))
+    if ext_id:
+        neutronclient.create_subnet(_config_external_subnet(ext_id, network_conf))
 
 
 def _create_flavor_m1_micro():