NSX|V: fix edge case with admin utility and spoofguard

If a space is passed as the spoofguard ID then the admin utility
will throw a cryptic exception. This handles that case.

Change-Id: I722a3b084a35eb23589e4d0fbbcf60e14ac73666
This commit is contained in:
Gary Kotton 2016-06-30 05:42:26 -07:00
parent ddfb880d5a
commit 95d18ce938

View File

@ -115,11 +115,14 @@ def nsx_clean_spoofguard_policy(resource, event, trigger, **kwargs):
LOG.error(_LE("%s"), errmsg)
return
try:
nsxv.get_spoofguard_policy(policy_id)
h, c = nsxv.get_spoofguard_policy(policy_id)
except exceptions.NeutronException as e:
LOG.error(_LE("Unable to retrieve policy %(p)s: %(e)s"),
{'p': policy_id, 'e': str(e)})
else:
if not c['spoofguardList']:
LOG.error(_LE("Policy %s does not exist"), policy_id)
return
confirm = admin_utils.query_yes_no(
"Do you want to delete spoofguard-policy: %s" % policy_id,
default="no")