Defaults to parent_resource name correctly

When name attribute of deployment is an empty
string, dict.get will return that empty string
instead of returning the default value set in
the second param of dict.get(first, second).
This patch fixes it by returning the default
value.

Change-Id: I7b48414fd18e01594f6d9b0d106c2abb71b7f676
Related-Bug: #1755078
(cherry picked from commit 204947c908)
This commit is contained in:
Zenghui Shi 2018-03-13 12:14:59 +08:00 committed by Lukas Bezdicka
parent 206c639c81
commit 2dd6d146c7
1 changed files with 3 additions and 3 deletions

View File

@ -217,10 +217,10 @@ class Config(object):
config_dict = self.get_config_dict(deployment)
# deployment_name should be set via the name property on the
# Deployment resources in the templates, however, if it's None,
# default to the name of the parent_resource
# Deployment resources in the templates, however, if it's None
# or empty string, default to the name of the parent_resource.
deployment_name = deployment.attributes['value'].get(
'name', deployment.parent_resource)
'name') or deployment.parent_resource
config_dict['deployment_name'] = deployment_name
# reset deploy_server_id to the actual server_id since we have to