From c214e3d757ce1deb935102e29f9d476290e3a7f2 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 3 Jul 2016 10:42:16 +0300 Subject: [PATCH] NSX|V - fix exclude list error handling The correct exception that should be expected is RequestBad Also - the order of the logs was changed to provide more information in case of exception. Change-Id: I5f4968e6ad769de5e297c39f8af643a930eda0fa --- vmware_nsx/plugins/nsx_v/plugin.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index e5bc614136..fe170f85f4 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -1263,15 +1263,17 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, vm_moref = self._dvs.get_vm_moref(device_id) if vm_moref is not None: try: - self.nsx_v.vcns.add_vm_to_exclude_list(vm_moref) LOG.info(_LI("Add VM %(dev)s to exclude list on " "behalf of port %(port)s: added to " "list"), {"dev": device_id, "port": port_id}) - except n_exc.BadRequest: + self.nsx_v.vcns.add_vm_to_exclude_list(vm_moref) + except vsh_exc.RequestBad as e: LOG.error(_LE("Failed to add vm %(device)s " - "moref %(moref)s to exclusion list"), - {'device': device_id, 'moref': vm_moref}) + "moref %(moref)s to exclude list: " + "%(err)s"), + {'device': device_id, 'moref': vm_moref, + 'err': e}) else: LOG.info(_LI("Add VM %(dev)s to exclude list on behalf of " "port %(port)s: already in list"), @@ -1289,15 +1291,17 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, vm_moref = self._dvs.get_vm_moref(device_id) if vm_moref is not None: try: - self.nsx_v.vcns.delete_vm_from_exclude_list(vm_moref) LOG.info(_LI("Remove VM %(dev)s from exclude list on " "behalf of port %(port)s: removed from " "list"), {"dev": device_id, "port": port_id}) - except n_exc.BadRequest: + self.nsx_v.vcns.delete_vm_from_exclude_list(vm_moref) + except vsh_exc.RequestBad as e: LOG.error(_LE("Failed to delete vm %(device)s " - "moref %(moref)s from exclusion list"), - {'device': device_id, 'moref': vm_moref}) + "moref %(moref)s from exclude list: " + "%(err)s"), + {'device': device_id, 'moref': vm_moref, + 'err': e}) else: LOG.info(_LI("Remove VM %(dev)s from exclude list on behalf " "of port %(port)s: other ports still in list"),