Tolerate missing keys from role_data in service templates
authorSteven Hardy <shardy@redhat.com>
Wed, 21 Sep 2016 13:42:52 +0000 (14:42 +0100)
committerSteven Hardy <shardy@redhat.com>
Thu, 22 Sep 2016 13:21:24 +0000 (14:21 +0100)
Currently we have a few keys which may be considered optional,
such as monitoring_subscription, logging* and global_config_settings.

Currently we dereference these directly via get_attr, but this will
break when heat output validation is fixed, ref bug #1599114 is fixed
(patches are up for this, so it may be soon).

Change-Id: If4eed1ca39c10ace9b1cb5ce2dc4b9c70a3dd2f4
Partial-Bug: #1620829

puppet/services/services.yaml

index c8d5642..6a9bab7 100644 (file)
@@ -54,8 +54,8 @@ outputs:
           data: {s_names: {get_attr: [ServiceChain, role_data, service_name]}}
       monitoring_subscriptions:
         yaql:
-          expression: list($.data.subscriptions.where($ != null))
-          data: {subscriptions: {get_attr: [ServiceChain, role_data, monitoring_subscription]}}
+          expression: list($.data.where($ != null).select($.get('monitoring_subscription')).where($ != null))
+          data: {get_attr: [ServiceChain, role_data]}
       logging_sources:
         # Transform the individual logging_source configuration from
         # each service in the chain into a global list, adding some
@@ -77,7 +77,9 @@ outputs:
           data:
             sources:
               - {get_attr: [LoggingConfiguration, LoggingDefaultSources]}
-              - {get_attr: [ServiceChain, role_data, logging_source]}
+              - yaql:
+                  expression: list($.data.where($ != null).select($.get('logging_sources')).where($ != null))
+                  data: {get_attr: [ServiceChain, role_data]}
               - {get_attr: [LoggingConfiguration, LoggingExtraSources]}
             default_format: {get_attr: [LoggingConfiguration, LoggingDefaultFormat]}
             pos_file_path: {get_attr: [LoggingConfiguration, LoggingPosFilePath]}
@@ -90,12 +92,14 @@ outputs:
           data:
             groups:
               - [{get_attr: [LoggingConfiguration, LoggingDefaultGroups]}]
-              - {get_attr: [ServiceChain, role_data, logging_groups]}
+              - yaql:
+                  expression: list($.data.where($ != null).select($.get('logging_groups')).where($ != null))
+                  data: {get_attr: [ServiceChain, role_data]}
               - [{get_attr: [LoggingConfiguration, LoggingExtraGroups]}]
       config_settings: {map_merge: {get_attr: [ServiceChain, role_data, config_settings]}}
       global_config_settings:
         map_merge:
           yaql:
-            expression: list($.data.configs.where($ != null))
-            data: {configs: {get_attr: [ServiceChain, role_data, global_config_settings]}}
+            expression: list($.data.where($ != null).select($.get('global_config_settings')).where($ != null))
+            data: {get_attr: [ServiceChain, role_data]}
       step_config: {list_join: ["\n", {get_attr: [ServiceChain, role_data, step_config]}]}