Prevent KeyError when getting value of optional key
Closes-Bug: #2066115 Change-Id: Ica10eb749b48410583cb34bfa2fda0433a26c664 Signed-off-by: MinhNLH2 <minh.nlh.work@gmail.com>
This commit is contained in:
parent
47823cce7c
commit
fcce68a914
@ -180,7 +180,7 @@ class CreateAggregateWorkflow(workflows.Workflow):
|
|||||||
api.nova.aggregate_create(
|
api.nova.aggregate_create(
|
||||||
request,
|
request,
|
||||||
name=context['name'],
|
name=context['name'],
|
||||||
availability_zone=context['availability_zone'] or None)
|
availability_zone=context.get('availability_zone') or None)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, _('Unable to create host aggregate.'))
|
exceptions.handle(request, _('Unable to create host aggregate.'))
|
||||||
return False
|
return False
|
||||||
|
@ -109,8 +109,8 @@ class CreateApplicationCredentialForm(forms.SelfHandlingForm):
|
|||||||
new_app_cred = api.keystone.application_credential_create(
|
new_app_cred = api.keystone.application_credential_create(
|
||||||
request,
|
request,
|
||||||
name=data['name'],
|
name=data['name'],
|
||||||
description=data['description'] or None,
|
description=data.get('description') or None,
|
||||||
secret=data['secret'] or None,
|
secret=data.get('secret') or None,
|
||||||
expires_at=expiration or None,
|
expires_at=expiration or None,
|
||||||
roles=roles,
|
roles=roles,
|
||||||
access_rules=access_rules,
|
access_rules=access_rules,
|
||||||
|
@ -162,8 +162,6 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn):
|
|||||||
try:
|
try:
|
||||||
LOG.info('Creating user with name "%s"', data['name'])
|
LOG.info('Creating user with name "%s"', data['name'])
|
||||||
desc = data["description"]
|
desc = data["description"]
|
||||||
if "email" in data:
|
|
||||||
data['email'] = data['email'] or None
|
|
||||||
|
|
||||||
# add extra information
|
# add extra information
|
||||||
EXTRA_INFO = settings.USER_TABLE_EXTRA_INFO
|
EXTRA_INFO = settings.USER_TABLE_EXTRA_INFO
|
||||||
@ -176,10 +174,10 @@ class CreateUserForm(PasswordMixin, BaseUserForm, AddExtraColumnMixIn):
|
|||||||
new_user = \
|
new_user = \
|
||||||
api.keystone.user_create(request,
|
api.keystone.user_create(request,
|
||||||
name=data['name'],
|
name=data['name'],
|
||||||
email=data['email'],
|
email=data.get('email') or None,
|
||||||
description=desc or None,
|
description=desc or None,
|
||||||
password=data['password'],
|
password=data['password'],
|
||||||
project=data['project'] or None,
|
project=data.get('project') or None,
|
||||||
enabled=data['enabled'],
|
enabled=data['enabled'],
|
||||||
domain=domain.id,
|
domain=domain.id,
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
@ -87,7 +87,7 @@ class UpdateInstanceInfoAction(workflows.Action):
|
|||||||
api.nova.server_update(request,
|
api.nova.server_update(request,
|
||||||
data['instance_id'],
|
data['instance_id'],
|
||||||
data['name'],
|
data['name'],
|
||||||
description=data.get('description'))
|
description=data.get('description') or None)
|
||||||
except Exception:
|
except Exception:
|
||||||
exceptions.handle(request, ignore=True)
|
exceptions.handle(request, ignore=True)
|
||||||
return False
|
return False
|
||||||
|
@ -81,9 +81,8 @@ class UpdateView(workflows.WorkflowView):
|
|||||||
for key in ('cidr', 'ip_version', 'enable_dhcp'):
|
for key in ('cidr', 'ip_version', 'enable_dhcp'):
|
||||||
initial[key] = subnet[key]
|
initial[key] = subnet[key]
|
||||||
|
|
||||||
initial['gateway_ip'] = subnet['gateway_ip'] or ''
|
initial['gateway_ip'] = subnet.get('gateway_ip', '')
|
||||||
initial['no_gateway'] = (subnet['gateway_ip'] is None)
|
initial['no_gateway'] = not initial['gateway_ip']
|
||||||
|
|
||||||
if initial['ip_version'] == 6:
|
if initial['ip_version'] == 6:
|
||||||
initial['ipv6_modes'] = utils.get_ipv6_modes_menu_from_attrs(
|
initial['ipv6_modes'] = utils.get_ipv6_modes_menu_from_attrs(
|
||||||
subnet['ipv6_ra_mode'], subnet['ipv6_address_mode'])
|
subnet['ipv6_ra_mode'], subnet['ipv6_address_mode'])
|
||||||
|
Loading…
Reference in New Issue
Block a user