Single definition of top-level SoftwareConfig keys

Consolidate the two sets of literals and standardise on the RPC API as the
source of the top-level keys.

Change-Id: I827e5b4eb0ba02ba9d1897dbc1c1da6f42823675
This commit is contained in:
Zane Bitter 2016-08-02 17:49:16 -04:00
parent 0f9a18555c
commit e79727dfde
6 changed files with 46 additions and 33 deletions

View File

@ -53,9 +53,9 @@ class CloudConfig(software_config.SoftwareConfig):
self.properties[self.CLOUD_CONFIG],
Dumper=template_format.yaml_dumper)
props = {
self.NAME: self.physical_resource_name(),
self.CONFIG: '#cloud-config\n%s' % cloud_config,
self.GROUP: 'Heat::Ungrouped'
rpc_api.SOFTWARE_CONFIG_NAME: self.physical_resource_name(),
rpc_api.SOFTWARE_CONFIG_CONFIG: '#cloud-config\n%s' % cloud_config,
rpc_api.SOFTWARE_CONFIG_GROUP: 'Heat::Ungrouped'
}
sc = self.rpc_client().create_software_config(self.context, **props)
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])

View File

@ -94,9 +94,9 @@ class MultipartMime(software_config.SoftwareConfig):
def handle_create(self):
props = {
self.NAME: self.physical_resource_name(),
self.CONFIG: self.get_message(),
self.GROUP: 'Heat::Ungrouped'
rpc_api.SOFTWARE_CONFIG_NAME: self.physical_resource_name(),
rpc_api.SOFTWARE_CONFIG_CONFIG: self.get_message(),
rpc_api.SOFTWARE_CONFIG_GROUP: 'Heat::Ungrouped'
}
sc = self.rpc_client().create_software_config(self.context, **props)
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])

View File

@ -38,9 +38,13 @@ class SoftwareComponent(sc.SoftwareConfig):
support_status = support.SupportStatus(version='2014.2')
PROPERTIES = (
CONFIGS, INPUTS, OUTPUTS, OPTIONS,
CONFIGS,
INPUTS, OUTPUTS,
OPTIONS,
) = (
'configs', 'inputs', 'outputs', 'options'
'configs',
sc.SoftwareConfig.INPUTS, sc.SoftwareConfig.OUTPUTS,
sc.SoftwareConfig.OPTIONS,
)
CONFIG_PROPERTIES = (
@ -108,13 +112,12 @@ class SoftwareComponent(sc.SoftwareConfig):
def handle_create(self):
props = dict(self.properties)
props[self.NAME] = self.physical_resource_name()
props[rpc_api.SOFTWARE_CONFIG_NAME] = self.physical_resource_name()
# use config property of SoftwareConfig to store configs list
configs = self.properties[self.CONFIGS]
props[self.CONFIG] = {self.CONFIGS: configs}
configs = props.pop(self.CONFIGS)
props[rpc_api.SOFTWARE_CONFIG_CONFIG] = {self.CONFIGS: configs}
# set 'group' to enable component processing by in-instance hook
props[self.GROUP] = 'component'
del props['configs']
props[rpc_api.SOFTWARE_CONFIG_GROUP] = 'component'
sc = self.rpc_client().create_software_config(self.context, **props)
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])

View File

@ -45,9 +45,13 @@ class SoftwareConfig(resource.Resource):
support_status = support.SupportStatus(version='2014.1')
PROPERTIES = (
GROUP, CONFIG, OPTIONS, INPUTS, OUTPUTS
GROUP, CONFIG,
OPTIONS,
INPUTS, OUTPUTS
) = (
'group', 'config', 'options', 'inputs', 'outputs'
rpc_api.SOFTWARE_CONFIG_GROUP, rpc_api.SOFTWARE_CONFIG_CONFIG,
rpc_api.SOFTWARE_CONFIG_OPTIONS,
rpc_api.SOFTWARE_CONFIG_INPUTS, rpc_api.SOFTWARE_CONFIG_OUTPUTS,
)
IO_PROPERTIES = (
@ -153,7 +157,7 @@ class SoftwareConfig(resource.Resource):
def handle_create(self):
props = dict(self.properties)
props[self.NAME] = self.physical_resource_name()
props[rpc_api.SOFTWARE_CONFIG_NAME] = self.physical_resource_name()
sc = self.rpc_client().create_software_config(self.context, **props)
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])

View File

@ -232,7 +232,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
if config.get(rpc_api.SOFTWARE_CONFIG_GROUP) == 'component':
valid_actions = set()
for conf in config['config']['configs']:
for conf in config[rpc_api.SOFTWARE_CONFIG_CONFIG]['configs']:
valid_actions.update(conf['actions'])
if action not in valid_actions:
return
@ -293,31 +293,36 @@ class SoftwareDeployment(signal_responder.SignalResponder):
return ''
def _build_derived_config_params(self, action, source):
scl = sc.SoftwareConfig
derived_inputs = self._build_derived_inputs(action, source)
derived_options = self._build_derived_options(action, source)
derived_config = self._build_derived_config(
action, source, derived_inputs, derived_options)
derived_name = self.properties.get(self.NAME) or source.get(scl.NAME)
derived_name = (self.properties.get(self.NAME) or
source.get(rpc_api.SOFTWARE_CONFIG_NAME))
return {
scl.GROUP: source.get(scl.GROUP) or 'Heat::Ungrouped',
scl.CONFIG: derived_config or self.empty_config(),
scl.OPTIONS: derived_options,
scl.INPUTS: derived_inputs,
scl.OUTPUTS: source.get(scl.OUTPUTS),
scl.NAME: derived_name or self.physical_resource_name()
rpc_api.SOFTWARE_CONFIG_GROUP:
source.get(rpc_api.SOFTWARE_CONFIG_GROUP) or 'Heat::Ungrouped',
rpc_api.SOFTWARE_CONFIG_CONFIG:
derived_config or self.empty_config(),
rpc_api.SOFTWARE_CONFIG_OPTIONS: derived_options,
rpc_api.SOFTWARE_CONFIG_INPUTS: derived_inputs,
rpc_api.SOFTWARE_CONFIG_OUTPUTS:
source.get(rpc_api.SOFTWARE_CONFIG_OUTPUTS),
rpc_api.SOFTWARE_CONFIG_NAME:
derived_name or self.physical_resource_name()
}
def _build_derived_config(self, action, source,
derived_inputs, derived_options):
return source.get(sc.SoftwareConfig.CONFIG)
return source.get(rpc_api.SOFTWARE_CONFIG_CONFIG)
def _build_derived_options(self, action, source):
return source.get(sc.SoftwareConfig.OPTIONS)
return source.get(rpc_api.SOFTWARE_CONFIG_OPTIONS)
def _build_derived_inputs(self, action, source):
scl = sc.SoftwareConfig
inputs = copy.deepcopy(source.get(scl.INPUTS)) or []
inputs = copy.deepcopy(source.get(rpc_api.SOFTWARE_CONFIG_INPUTS) or
[])
input_values = dict(self.properties.get(self.INPUT_VALUES) or {})
for inp in inputs:

View File

@ -59,10 +59,10 @@ class SoftwareConfigService(service.Service):
'group': group,
'name': name,
'config': {
'inputs': inputs,
'outputs': outputs,
'options': options,
'config': config
rpc_api.SOFTWARE_CONFIG_INPUTS: inputs,
rpc_api.SOFTWARE_CONFIG_OUTPUTS: outputs,
rpc_api.SOFTWARE_CONFIG_OPTIONS: options,
rpc_api.SOFTWARE_CONFIG_CONFIG: config
},
'tenant': cnxt.tenant_id})
return api.format_software_config(sc)
@ -220,7 +220,8 @@ class SoftwareConfigService(service.Service):
cnxt, deployment_id)
if sd.status == rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
c = sd.config.config
input_values = dict((i['name'], i['value']) for i in c['inputs'])
input_values = {i['name']: i['value']
for i in c[rpc_api.SOFTWARE_CONFIG_INPUTS]}
transport = input_values.get('deploy_signal_transport')
if transport == 'TEMP_URL_SIGNAL':
sd = self._refresh_swift_software_deployment(