[Admin-Util] cleanup to avoid crashing in extreme cases
As a preparation to creating unit test for the admin utils, we need some cleanup in order to avoid crashing on missing inputs Change-Id: I59c2e01110c90222c8d6069013ea58e13c37f114
This commit is contained in:
parent
a7d630fe6f
commit
2ca5f17dd7
@ -95,13 +95,15 @@ def list_missing_dhcp_bindings(resource, event, trigger, **kwargs):
|
||||
@admin_utils.output_header
|
||||
def nsx_update_dhcp_edge_binding(resource, event, trigger, **kwargs):
|
||||
"""Resync DHCP bindings on NSXv Edge"""
|
||||
|
||||
if not kwargs['property']:
|
||||
if not kwargs.get('property'):
|
||||
LOG.error(_LE("Need to specify edge-id parameter"))
|
||||
return
|
||||
else:
|
||||
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
|
||||
edge_id = properties.get('edge-id')
|
||||
if not edge_id:
|
||||
LOG.error(_LE("Need to specify edge-id parameter"))
|
||||
return
|
||||
LOG.info(_LI("Updating NSXv Edge: %s"), edge_id)
|
||||
# Need to create a NeutronDbPlugin object; so that we are able to
|
||||
# do neutron list-ports.
|
||||
|
@ -100,7 +100,7 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
|
||||
orphaned_edges = get_orphaned_edges()
|
||||
LOG.info(_LI("Before delete; Orphaned Edges: %s"), orphaned_edges)
|
||||
|
||||
if not kwargs['force']:
|
||||
if not kwargs.get('force'):
|
||||
if len(orphaned_edges):
|
||||
user_confirm = admin_utils.query_yes_no("Do you want to delete "
|
||||
"orphaned edges",
|
||||
|
@ -108,7 +108,8 @@ def nsx_redo_metadata_cfg(resource, event, trigger, **kwargs):
|
||||
lb.submit_to_backend(nsxv, edge_id, False)
|
||||
|
||||
|
||||
def update_shared_secret():
|
||||
@admin_utils.output_header
|
||||
def update_shared_secret(resource, event, trigger, **kwargs):
|
||||
edgeapi = utils.NeutronDbClient()
|
||||
edge_list = nsxv_db.get_nsxv_internal_edges_by_purpose(
|
||||
edgeapi.context.session,
|
||||
|
@ -60,7 +60,7 @@ def nsx_list_security_groups(resource, event, trigger, **kwargs):
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_delete_security_groups(resource, event, trigger, **kwargs):
|
||||
if kwargs['force'] is False:
|
||||
if 'force' in kwargs and kwargs['force'] is False:
|
||||
if nsx_list_security_groups(resource, event, trigger, **kwargs):
|
||||
msg = ('Do you want to delete the following NSX firewall '
|
||||
'sections/nsgroups?')
|
||||
@ -103,7 +103,7 @@ def neutron_list_security_groups(resource, event, trigger, **kwargs):
|
||||
|
||||
@admin_utils.output_header
|
||||
def neutron_delete_security_groups(resource, event, trigger, **kwargs):
|
||||
if kwargs['force'] is False:
|
||||
if 'force' in kwargs and kwargs['force'] is False:
|
||||
if neutron_list_security_groups(resource, event, trigger, **kwargs):
|
||||
msg = ('Do you want to delete the following neutron '
|
||||
'security groups?')
|
||||
|
Loading…
x
Reference in New Issue
Block a user