Merge "NSX-T: nsxadmin UTs"

This commit is contained in:
Jenkins 2017-03-05 08:50:47 +00:00 committed by Gerrit Code Review
commit 1fbbadb65a
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 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
LOG = logging.getLogger(__name__)
@ -256,16 +254,8 @@ def _update_ports_dynamic_criteria_tags():
continue
_, 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)
lport['tags'] = nsxlib_utils.update_v3_tags(
lport.get('tags', []), criteria_tags)
port_client._client.update(lport_id, body=lport)
port_client.update(lport_id, False, tags_update=criteria_tags)
def _update_security_group_dynamic_criteria():

View File

@ -138,10 +138,6 @@ def _mock_nsx_backend_calls():
"vmware_nsxlib.v3.resources.LogicalDhcpServer.create_binding",
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,
nsxlib_testcase.NsxClientTestCase):

View File

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