NSX-T: nsxadmin UTs

Enable nsxadmin UTs that were nulled due to lib version mock.
Adjust dynamic criteria migration code.

Change-Id: I2c0dd2e79d653d5b56b1848fa323a9f841605a64
This commit is contained in:
Anna Khmelnitsky 2017-03-03 16:20:14 -08:00
parent 6a38e51c9a
commit c522c64a2d
3 changed files with 12 additions and 27 deletions

View File

@ -31,10 +31,8 @@ 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.admin.plugins.nsxv3.resources import utils as v3_utils
from vmware_nsx.shell import resources as shell from vmware_nsx.shell import resources as shell
from vmware_nsx._i18n import _LE, _LW 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 nsx_constants as consts
from vmware_nsxlib.v3 import security from vmware_nsxlib.v3 import security
from vmware_nsxlib.v3 import utils as nsxlib_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -256,16 +254,8 @@ def _update_ports_dynamic_criteria_tags():
continue continue
_, lport_id = neutron_db.get_lswitch_and_lport_id(port['id']) _, lport_id = neutron_db.get_lswitch_and_lport_id(port['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) criteria_tags = nsxlib.ns_group.get_lport_tags(secgroups)
lport['tags'] = nsxlib_utils.update_v3_tags( port_client.update(lport_id, False, tags_update=criteria_tags)
lport.get('tags', []), criteria_tags)
port_client._client.update(lport_id, body=lport)
def _update_security_group_dynamic_criteria(): def _update_security_group_dynamic_criteria():

View File

@ -138,10 +138,6 @@ def _mock_nsx_backend_calls():
"vmware_nsxlib.v3.resources.LogicalDhcpServer.create_binding", "vmware_nsxlib.v3.resources.LogicalDhcpServer.create_binding",
side_effect=_return_id_key).start() side_effect=_return_id_key).start()
mock.patch(
"vmware_nsxlib.v3.NsxLib.get_version",
return_value="0.6.0").start()
class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase, class NsxV3PluginTestCaseMixin(test_plugin.NeutronDbPluginV2TestCase,
nsxlib_testcase.NsxClientTestCase): nsxlib_testcase.NsxClientTestCase):

View File

@ -230,21 +230,20 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils,
test_v3_plugin._mock_nsx_backend_calls() test_v3_plugin._mock_nsx_backend_calls()
# mock resources # mock resources
self._patch_object(nsx_v3_resources.LogicalPort, for cls in (nsx_v3_resources.LogicalPort,
'__init__', return_value=None) nsx_v3_resources.LogicalDhcpServer,
self._patch_object(nsx_v3_resources.LogicalDhcpServer, nsx_v3_resources.LogicalRouter,
'__init__', return_value=None) nsx_v3_resources.SwitchingProfile):
self._patch_object(nsx_v3_resources.LogicalDhcpServer,
'list', return_value={'results': []}) self._patch_object(cls, '__init__', return_value=None)
self._patch_object(nsx_v3_resources.LogicalRouter, self._patch_object(cls, 'list', return_value={'results': []})
'__init__', return_value=None) self._patch_object(cls, 'get',
self._patch_object(nsx_v3_resources.SwitchingProfile, return_value={'id': uuidutils.generate_uuid()})
'__init__', return_value=None) self._patch_object(cls, 'update')
self._patch_object(nsx_v3_resources.SwitchingProfile, self._patch_object(nsx_v3_resources.SwitchingProfile,
'find_by_display_name', 'find_by_display_name',
return_value=[{'id': uuidutils.generate_uuid()}]) return_value=[{'id': uuidutils.generate_uuid()}])
self._patch_object(nsx_v3_resources.LogicalRouterPort,
'__init__', return_value=None)
super(TestNsxv3AdminUtils, self)._init_mock_plugin() super(TestNsxv3AdminUtils, self)._init_mock_plugin()
def _get_plugin_name(self): def _get_plugin_name(self):