Clean redundant argument to dict.get
`dict.get()` returns `None` by default, if a key wasn't found. Removing `None` as second argument to avoid redundancy. Change-Id: I2ac806b9d337b9701da92434192376c79d77a85e
This commit is contained in:
parent
4c2fb85765
commit
f8b8cc5ba1
@ -245,7 +245,7 @@ class ExtensionController(wsgi.Controller):
|
||||
|
||||
def show(self, request, id):
|
||||
# NOTE(dprince): the extensions alias is used as the 'id' for show
|
||||
ext = self.extension_manager.extensions.get(id, None)
|
||||
ext = self.extension_manager.extensions.get(id)
|
||||
if not ext:
|
||||
raise webob.exc.HTTPNotFound(
|
||||
_("Extension with alias %s does not exist") % id)
|
||||
@ -482,7 +482,7 @@ class ExtensionManager(object):
|
||||
extended_attrs = ext.get_extended_resources(version)
|
||||
for resource, resource_attrs in six.iteritems(
|
||||
extended_attrs):
|
||||
if attr_map.get(resource, None):
|
||||
if attr_map.get(resource):
|
||||
attr_map[resource].update(resource_attrs)
|
||||
else:
|
||||
attr_map[resource] = resource_attrs
|
||||
|
@ -68,8 +68,8 @@ class OpenStack_Driver(abstract_vim_driver.VimAbstractDriver):
|
||||
if keystone_version not in auth_url:
|
||||
vim_obj['auth_url'] = auth_url + '/' + keystone_version
|
||||
if keystone_version == 'v3':
|
||||
auth_cred['project_id'] = vim_project.get('id', None)
|
||||
auth_cred['project_name'] = vim_project.get('name', None)
|
||||
auth_cred['project_id'] = vim_project.get('id')
|
||||
auth_cred['project_name'] = vim_project.get('name')
|
||||
if 'project_domain_id' not in auth_cred:
|
||||
auth_cred[
|
||||
'project_domain_id'
|
||||
@ -79,8 +79,8 @@ class OpenStack_Driver(abstract_vim_driver.VimAbstractDriver):
|
||||
'user_domain_id'
|
||||
] = CONF.keystone_authtoken.user_domain_id
|
||||
else:
|
||||
auth_cred['tenant_id'] = vim_project.get('id', None)
|
||||
auth_cred['tenant_name'] = vim_project.get('name', None)
|
||||
auth_cred['tenant_id'] = vim_project.get('id')
|
||||
auth_cred['tenant_name'] = vim_project.get('name')
|
||||
# user_id is not supported in keystone v2
|
||||
auth_cred.pop('user_id', None)
|
||||
auth_cred['auth_url'] = vim_obj['auth_url']
|
||||
|
@ -568,7 +568,7 @@ class ContextFormatter(logging.Formatter):
|
||||
if key not in record.__dict__:
|
||||
record.__dict__[key] = ''
|
||||
|
||||
if record.__dict__.get('request_id', None):
|
||||
if record.__dict__.get('request_id'):
|
||||
self._fmt = CONF.logging_context_format_string
|
||||
else:
|
||||
self._fmt = CONF.logging_default_format_string
|
||||
|
@ -260,7 +260,7 @@ class ActionRespawnHeat(ActionPolicy):
|
||||
new_device[key] = device_dict[key]
|
||||
LOG.debug(_('new_device %s'), new_device)
|
||||
placement_attr = device_dict.get('placement_attr', {})
|
||||
region_name = placement_attr.get('region_name', None)
|
||||
region_name = placement_attr.get('region_name')
|
||||
# kill heat stack
|
||||
heatclient = heat.HeatClient(auth_attr=auth_attr,
|
||||
region_name=region_name)
|
||||
|
@ -294,7 +294,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||
}
|
||||
new_status = constants.ACTIVE
|
||||
placement_attr = device_dict['placement_attr']
|
||||
region_name = placement_attr.get('region_name', None)
|
||||
region_name = placement_attr.get('region_name')
|
||||
|
||||
try:
|
||||
self._device_manager.invoke(
|
||||
@ -337,7 +337,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||
instance_id = self._instance_id(device_dict)
|
||||
e = None
|
||||
placement_attr = device_dict['placement_attr']
|
||||
region_name = placement_attr.get('region_name', None)
|
||||
region_name = placement_attr.get('region_name')
|
||||
try:
|
||||
self._device_manager.invoke(
|
||||
driver_name, 'delete_wait', plugin=self,
|
||||
@ -358,7 +358,7 @@ class VNFMPlugin(vm_db.VNFMPluginDb, VNFMMgmtMixin):
|
||||
driver_name = self._infra_driver_name(device_dict)
|
||||
instance_id = self._instance_id(device_dict)
|
||||
placement_attr = device_dict['placement_attr']
|
||||
region_name = placement_attr.get('region_name', None)
|
||||
region_name = placement_attr.get('region_name')
|
||||
kwargs = {
|
||||
mgmt_constants.KEY_ACTION: mgmt_constants.ACTION_DELETE_DEVICE,
|
||||
mgmt_constants.KEY_KWARGS: {'device': device_dict},
|
||||
|
@ -252,10 +252,10 @@ def get_flavor_dict(template, flavor_extra_input=None):
|
||||
flavor_dict = {}
|
||||
vdus = findvdus(template)
|
||||
for nt in vdus:
|
||||
flavor_tmp = nt.get_properties().get('flavor', None)
|
||||
flavor_tmp = nt.get_properties().get('flavor')
|
||||
if flavor_tmp:
|
||||
continue
|
||||
if nt.get_capabilities().get("nfv_compute", None):
|
||||
if nt.get_capabilities().get("nfv_compute"):
|
||||
flavor_dict[nt.name] = {}
|
||||
properties = nt.get_capabilities()["nfv_compute"].get_properties()
|
||||
for prop, (hot_prop, default, unit) in \
|
||||
@ -328,7 +328,7 @@ def get_image_dict(template):
|
||||
image_dict = {}
|
||||
vdus = findvdus(template)
|
||||
for vdu in vdus:
|
||||
if not vdu.entity_tpl.get("artifacts", None):
|
||||
if not vdu.entity_tpl.get("artifacts"):
|
||||
continue
|
||||
artifacts = vdu.entity_tpl["artifacts"]
|
||||
for name, artifact in iteritems(artifacts):
|
||||
|
Loading…
Reference in New Issue
Block a user