Merge "Correct the usage of properties.get() with default value"

This commit is contained in:
Jenkins 2016-06-28 12:40:51 +00:00 committed by Gerrit Code Review
commit baf386fde5
5 changed files with 6 additions and 6 deletions

View File

@ -1150,7 +1150,7 @@ class CloudLoadBalancer(resource.Resource):
self._validate_https_redirect()
# if a vip specifies and id, it can't specify version or type;
# otherwise version and type are required
for vip in self.properties.get(self.VIRTUAL_IPS, []):
for vip in self.properties[self.VIRTUAL_IPS]:
has_id = vip.get(self.VIRTUAL_IP_ID) is not None
has_version = vip.get(self.VIRTUAL_IP_IP_VERSION) is not None
has_type = vip.get(self.VIRTUAL_IP_TYPE) is not None

View File

@ -119,7 +119,7 @@ class CloudServer(server.Server):
self._rack_connect_started_event_sent = False
def _config_drive(self):
user_data_format = self.properties.get(self.USER_DATA_FORMAT, "")
user_data_format = self.properties[self.USER_DATA_FORMAT]
is_sw_config = user_data_format == self.SOFTWARE_CONFIG
user_data = self.properties.get(self.USER_DATA)
config_drive = self.properties.get(self.CONFIG_DRIVE)

View File

@ -362,7 +362,7 @@ class InstanceGroup(stack_resource.StackResource):
self._lb_reload()
def _lb_reload(self, exclude=None):
lb_names = self.properties.get(self.LOAD_BALANCER_NAMES, None)
lb_names = self.properties.get(self.LOAD_BALANCER_NAMES) or []
if lb_names:
lb_dict = dict((name, self.stack[name]) for name in lb_names)
lbutils.reload_loadbalancers(self, lb_dict, exclude)

View File

@ -142,7 +142,7 @@ class SoftwareComponent(sc.SoftwareConfig):
# One lifecycle action (e.g. CREATE) can only be associated with one
# config; otherwise a way to define ordering would be required.
configs = self.properties.get(self.CONFIGS, [])
configs = self.properties[self.CONFIGS]
config_actions = set()
for config in configs:
actions = config.get(self.CONFIG_ACTIONS)

View File

@ -614,10 +614,10 @@ class SoftwareDeploymentGroup(resource_group.ResourceGroup):
update_policy_schema = {}
def get_size(self):
return len(self.properties.get(self.SERVERS, {}))
return len(self.properties[self.SERVERS])
def _resource_names(self):
return iter(self.properties.get(self.SERVERS, {}))
return iter(self.properties[self.SERVERS])
def get_resource_def(self, include_all=False):
return dict(self.properties)