Add name property where missing

All SoftwareDeployment resources should use the name property when using
config-download.

This also adds a validation to check that the name property is set in
yaml-validate.py

Change-Id: I621e282a2e2c041a0701da0296881c615f0bfda4
Closes-Bug: #1733586
This commit is contained in:
James Slagle 2017-11-21 14:48:27 -05:00
parent eeabc17247
commit 7a3fc67559
5 changed files with 29 additions and 0 deletions

View File

@ -42,6 +42,7 @@ resources:
{{role.name}}DeliverUpgradeScriptConfig: {{role.name}}DeliverUpgradeScriptConfig:
type: OS::Heat::SoftwareConfig type: OS::Heat::SoftwareConfig
properties: properties:
name: {{role.name}}DeliverUpgradeScriptConfig
group: script group: script
config: config:
list_join: list_join:
@ -59,6 +60,7 @@ resources:
{{role.name}}DeliverUpgradeScriptDeployment: {{role.name}}DeliverUpgradeScriptDeployment:
type: OS::Heat::SoftwareDeploymentGroup type: OS::Heat::SoftwareDeploymentGroup
properties: properties:
name: {{role.name}}DeliverUpgradeScriptDeployment
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}DeliverUpgradeScriptConfig} config: {get_resource: {{role.name}}DeliverUpgradeScriptConfig}
{% endfor %} {% endfor %}
@ -120,6 +122,7 @@ resources:
rolling_update: rolling_update:
max_batch_size: {{role.upgrade_batch_size|default(1)}} max_batch_size: {{role.upgrade_batch_size|default(1)}}
properties: properties:
name: {{role.name}}UpgradeBatch_Step{{step}}
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}UpgradeBatchConfig_Step{{step}}} config: {get_resource: {{role.name}}UpgradeBatchConfig_Step{{step}}}
input_values: input_values:
@ -164,6 +167,7 @@ resources:
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
properties: properties:
name: {{role.name}}Upgrade_Step{{step}}
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}UpgradeConfig_Step{{step}}} config: {get_resource: {{role.name}}UpgradeConfig_Step{{step}}}
input_values: input_values:
@ -216,6 +220,7 @@ resources:
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
properties: properties:
name: {{role.name}}PostUpgradeConfig_Deployment{{step}}
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
config: {get_resource: {{role.name}}PostUpgradeConfig_Config{{step}}} config: {get_resource: {{role.name}}PostUpgradeConfig_Config{{step}}}
input_values: input_values:

View File

@ -35,6 +35,7 @@ resources:
{{role.name}}SwapDeployment: {{role.name}}SwapDeployment:
type: OS::Heat::SoftwareDeploymentGroup type: OS::Heat::SoftwareDeploymentGroup
properties: properties:
name: {{role.name}}SwapDeployment
config: {get_resource: SwapConfig} config: {get_resource: SwapConfig}
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
input_values: input_values:

View File

@ -43,6 +43,7 @@ resources:
{{role.name}}SwapDeployment: {{role.name}}SwapDeployment:
type: OS::Heat::SoftwareDeploymentGroup type: OS::Heat::SoftwareDeploymentGroup
properties: properties:
name: {{role.name}}SwapDeployment
config: {get_resource: SwapConfig} config: {get_resource: SwapConfig}
servers: {get_param: [servers, {{role.name}}]} servers: {get_param: [servers, {{role.name}}]}
input_values: input_values:

View File

@ -92,11 +92,13 @@ resources:
NetworkMidonetDeploymentControllers: NetworkMidonetDeploymentControllers:
type: OS::Heat::StructuredDeploymentGroup type: OS::Heat::StructuredDeploymentGroup
properties: properties:
name: NetworkMidonetDeploymentControllers
config: {get_resource: NetworkMidoNetConfig} config: {get_resource: NetworkMidoNetConfig}
servers: {get_param: [servers, Controller]} servers: {get_param: [servers, Controller]}
NetworkMidonetDeploymentComputes: NetworkMidonetDeploymentComputes:
type: OS::Heat::StructuredDeploymentGroup type: OS::Heat::StructuredDeploymentGroup
properties: properties:
name: NetworkMidonetDeploymentComputes
config: {get_resource: NetworkMidoNetConfig} config: {get_resource: NetworkMidoNetConfig}
servers: {get_param: [servers, Compute]} servers: {get_param: [servers, Compute]}

View File

@ -150,6 +150,15 @@ VALIDATE_DOCKER_OVERRIDE = {
# docker/service/sshd.yaml is a variation of the puppet sshd service # docker/service/sshd.yaml is a variation of the puppet sshd service
'./docker/services/sshd.yaml': False, './docker/services/sshd.yaml': False,
} }
DEPLOYMENT_RESOURCE_TYPES = [
'OS::Heat::SoftwareDeploymentGroup',
'OS::Heat::StructuredDeploymentGroup',
'OS::Heat::StructuredDeployments',
'OS::Heat::SoftwareDeployments',
'OS::Heat::SoftwareDeployment',
'OS::Heat::StructuredDeployment',
'OS::TripleO::SoftwareDeployment'
]
def exit_usage(): def exit_usage():
print('Usage %s <yaml file or directory>' % sys.argv[0]) print('Usage %s <yaml file or directory>' % sys.argv[0])
@ -548,6 +557,16 @@ def validate(filename, param_map):
print('Warning: parameter %s in template %s ' print('Warning: parameter %s in template %s '
'appears to be unused' % (p, filename)) 'appears to be unused' % (p, filename))
resources = tpl.get('resources')
if resources:
for resource, data in resources.items():
if data['type'] not in DEPLOYMENT_RESOURCE_TYPES:
continue
if 'name' not in data['properties']:
print('ERROR: resource %s from %s missing name property.'
% (resource, filename))
return 1
return retval return retval
def validate_upgrade_tasks(upgrade_steps): def validate_upgrade_tasks(upgrade_steps):
@ -576,6 +595,7 @@ def parse_args():
p.add_argument('--quiet', '-q', p.add_argument('--quiet', '-q',
action='count', action='count',
default=0,
help='output warnings and errors (-q) or only errors (-qq)') help='output warnings and errors (-q) or only errors (-qq)')
p.add_argument('path_args', p.add_argument('path_args',
nargs='*', nargs='*',