[Admin-Util]: Add error handling to nsxv update_dhcp_edge_binding

'nsxadmin -r dhcp-binding -o nsx-update' can fail if given the wrong edge-id
Now we expect this error and log a proper message.
Output example:
NSX Plugin in use: nsxv
==== [NSX] Update Dhcp Edge Binding ====
Updating NSXv Edge: edge-4
Edge edge-4 not found

Change-Id: I4840d55333fc84fbe0494873799283cea000914f
This commit is contained in:
Adit Sarfaty 2016-04-19 12:18:20 +03:00
parent 17c839a7af
commit d5d53032ed

View File

@ -27,6 +27,7 @@ from neutron.db import db_base_plugin_v2
from vmware_nsx._i18n import _LE, _LI
from vmware_nsx.db import nsxv_db
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions
from vmware_nsx.plugins.nsx_v.vshield import edge_utils
from vmware_nsx.plugins.nsx_v.vshield import vcns_driver
@ -100,15 +101,19 @@ def nsx_update_dhcp_edge_binding(resource, event, trigger, **kwargs):
return
else:
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
LOG.info(_LI("Updating NSXv Edge: %s"), properties.get('edge-id'))
edge_id = properties.get('edge-id')
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.
plugin = db_base_plugin_v2.NeutronDbPluginV2()
nsxv_manager = vcns_driver.VcnsDriver(
edge_utils.NsxVCallbacks(plugin))
edge_manager = edge_utils.EdgeManager(nsxv_manager, plugin)
edge_manager.update_dhcp_service_config(
neutron_db.context, properties.get('edge-id'))
try:
edge_manager.update_dhcp_service_config(
neutron_db.context, edge_id)
except exceptions.ResourceNotFound:
LOG.error(_LE("Edge %s not found"), edge_id)
registry.subscribe(list_missing_dhcp_bindings,