From bae9c576445078353e79211f4fc06a741e2cc3c3 Mon Sep 17 00:00:00 2001 From: Roey Chen Date: Thu, 24 Nov 2016 04:28:09 -0800 Subject: [PATCH] NSXv3-Admin: fix migrate-nsgroups-to-dynamic-criteria The nsx-admin allow user to migrate between two different NSX APIs which the plugin use to implement security-groups. While migrating, a backend logical-port resource may be missing, in that case log a warning and continue the work for other logical-ports. Change-Id: I6a22d2d316d668d5ccf6fc053b501dc7f1b977c8 --- .../shell/admin/plugins/nsxv3/resources/securitygroups.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py index 74493a5cbc..4b09f14214 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py @@ -32,6 +32,7 @@ from vmware_nsx.shell.admin.plugins.nsxv3.resources import ports from vmware_nsx.shell.admin.plugins.nsxv3.resources import utils as v3_utils from vmware_nsx.shell import resources as shell from vmware_nsx._i18n import _LE, _LW +from vmware_nsxlib.v3 import exceptions as exc from vmware_nsxlib.v3 import nsx_constants as consts from vmware_nsxlib.v3 import security from vmware_nsxlib.v3 import utils as nsxlib_utils @@ -258,7 +259,12 @@ def _update_ports_dynamic_criteria_tags(): continue _, lport_id = neutron_db.get_lswitch_and_lport_id(port['id']) - lport = port_client.get(lport_id) + try: + lport = port_client.get(lport_id) + except exc.ResourceNotFound: + LOG.warning(_LW("Failed to update logical-port %s, resource " + "doesn't exists on backend."), lport_id) + continue criteria_tags = nsxlib.ns_group.get_lport_tags(secgroups) lport['tags'] = nsxlib_utils.update_v3_tags( lport.get('tags', []), criteria_tags)