Browse Source

openshift on openstack: fix non kuryr non API LB

The previous patches in the branch left kuryr working but made things
break when no LB nor kuryr were in the deployment.

Change-Id: I3a40d5934b901ba50e098c8c3bcef033cb1c931f
Signed-off-by: Antoni Segura Puimedon <antonisp@celebdor.com>
Antoni Segura Puimedon 7 years ago
parent
commit
195b60b1e2
1 changed files with 15 additions and 6 deletions
  1. 15 6
      playbooks/openstack/inventory.py

+ 15 - 6
playbooks/openstack/inventory.py

@@ -151,12 +151,21 @@ def build_inventory():
 
     stout = _get_stack_outputs(cloud)
     if stout is not None:
-        inventory['localhost']['openshift_openstack_api_lb_provider'] = stout['api_lb_provider']
-        inventory['localhost']['openshift_openstack_api_lb_port_id'] = stout['api_lb_vip_port_id']
-        inventory['localhost']['openshift_openstack_api_lb_sg_id'] = stout['api_lb_sg_id']
-        kuryr_vars = _get_kuryr_vars(cloud, stout)
-        if kuryr_vars:
-            inventory['OSEv3']['vars'] = kuryr_vars
+        try:
+            inventory['localhost'].update({
+                'openshift_openstack_api_lb_provider':
+                stout['api_lb_provider'],
+                'openshift_openstack_api_lb_port_id':
+                stout['api_lb_vip_port_id'],
+                'openshift_openstack_api_lb_sg_id':
+                stout['api_lb_sg_id']})
+        except KeyError:
+            pass  # Not an API load balanced deployment
+
+        try:
+            inventory['OSEv3']['vars'] = _get_kuryr_vars(cloud, stout)
+        except KeyError:
+            pass  # Not a kuryr deployment
     return inventory