From 49650747039a4bb626925445a2c6bed5b7871fe6 Mon Sep 17 00:00:00 2001 From: Shih-Hao Li Date: Thu, 17 Sep 2015 16:48:16 -0700 Subject: [PATCH] Divide vmware_nsx/nsxlib/ into mh and v3 subdirectories This patch adds a new subdirectory "mh" under vmware_nsx/nsxlib/ and moves all current vmware_nsx/nsxlib/*.py to "mh". This will make vmware_nsx/nsxlib/ consisted of only mh and v3 subdirectories. This is part of new vmware_nsx directory structure proposed in https://goo.gl/GdWXyH. Change-Id: I31e4558b648c9982208739b19623002e1fa181ff --- vmware_nsx/check_nsx_config.py | 2 +- vmware_nsx/common/nsx_utils.py | 8 +- vmware_nsx/common/sync.py | 6 +- vmware_nsx/dhcp_meta/lsnmanager.py | 4 +- vmware_nsx/dhcp_meta/nsx.py | 2 +- vmware_nsx/nsxlib/__init__.py | 148 ------------------ vmware_nsx/nsxlib/mh/__init__.py | 148 ++++++++++++++++++ vmware_nsx/nsxlib/{ => mh}/l2gateway.py | 4 +- vmware_nsx/nsxlib/{ => mh}/lsn.py | 2 +- vmware_nsx/nsxlib/{ => mh}/queue.py | 2 +- vmware_nsx/nsxlib/{ => mh}/router.py | 6 +- vmware_nsx/nsxlib/{ => mh}/secgroup.py | 2 +- vmware_nsx/nsxlib/{ => mh}/switch.py | 2 +- vmware_nsx/nsxlib/{ => mh}/versioning.py | 0 vmware_nsx/plugins/nsx_mh/plugin.py | 10 +- .../unit/vmware/extensions/test_networkgw.py | 4 +- .../unit/vmware/extensions/test_qosqueues.py | 2 +- .../unit/vmware/nsxlib/test_l2gateway.py | 6 +- .../tests/unit/vmware/nsxlib/test_lsn.py | 4 +- .../tests/unit/vmware/nsxlib/test_queue.py | 4 +- .../tests/unit/vmware/nsxlib/test_router.py | 6 +- .../tests/unit/vmware/nsxlib/test_secgroup.py | 4 +- .../tests/unit/vmware/nsxlib/test_switch.py | 2 +- .../unit/vmware/nsxlib/test_versioning.py | 4 +- vmware_nsx/tests/unit/vmware/test_nsx_opts.py | 2 +- .../tests/unit/vmware/test_nsx_plugin.py | 2 +- vmware_nsx/tests/unit/vmware/test_nsx_sync.py | 2 +- .../tests/unit/vmware/test_nsx_utils.py | 20 +-- 28 files changed, 204 insertions(+), 204 deletions(-) create mode 100644 vmware_nsx/nsxlib/mh/__init__.py rename vmware_nsx/nsxlib/{ => mh}/l2gateway.py (99%) rename vmware_nsx/nsxlib/{ => mh}/lsn.py (99%) rename vmware_nsx/nsxlib/{ => mh}/queue.py (98%) rename vmware_nsx/nsxlib/{ => mh}/router.py (99%) rename vmware_nsx/nsxlib/{ => mh}/secgroup.py (99%) rename vmware_nsx/nsxlib/{ => mh}/switch.py (99%) rename vmware_nsx/nsxlib/{ => mh}/versioning.py (100%) diff --git a/vmware_nsx/check_nsx_config.py b/vmware_nsx/check_nsx_config.py index 38275a3f58..6ca75ef037 100644 --- a/vmware_nsx/check_nsx_config.py +++ b/vmware_nsx/check_nsx_config.py @@ -22,7 +22,7 @@ from oslo_config import cfg from neutron.common import config from vmware_nsx.common import config as nsx_config # noqa from vmware_nsx.common import nsx_utils -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib config.setup_logging() diff --git a/vmware_nsx/common/nsx_utils.py b/vmware_nsx/common/nsx_utils.py index 0deab82be1..48acbdf85a 100644 --- a/vmware_nsx/common/nsx_utils.py +++ b/vmware_nsx/common/nsx_utils.py @@ -27,10 +27,10 @@ from vmware_nsx.common import utils as vmw_utils from vmware_nsx.db import db as nsx_db from vmware_nsx.db import networkgw_db from vmware_nsx import nsx_cluster -from vmware_nsx.nsxlib import l2gateway as l2gwlib -from vmware_nsx.nsxlib import router as routerlib -from vmware_nsx.nsxlib import secgroup as secgrouplib -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib +from vmware_nsx.nsxlib.mh import router as routerlib +from vmware_nsx.nsxlib.mh import secgroup as secgrouplib +from vmware_nsx.nsxlib.mh import switch as switchlib LOG = log.getLogger(__name__) diff --git a/vmware_nsx/common/sync.py b/vmware_nsx/common/sync.py index f5c147b7ba..db48fc2eef 100644 --- a/vmware_nsx/common/sync.py +++ b/vmware_nsx/common/sync.py @@ -33,9 +33,9 @@ from neutron.i18n import _LE, _LI, _LW from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import nsx_utils -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import router as routerlib -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import router as routerlib +from vmware_nsx.nsxlib.mh import switch as switchlib # Maximum page size for a single request # NOTE(salv-orlando): This might become a version-dependent map should the diff --git a/vmware_nsx/dhcp_meta/lsnmanager.py b/vmware_nsx/dhcp_meta/lsnmanager.py index cd2ef6a700..7761e1cd4b 100644 --- a/vmware_nsx/dhcp_meta/lsnmanager.py +++ b/vmware_nsx/dhcp_meta/lsnmanager.py @@ -27,8 +27,8 @@ from vmware_nsx.common import exceptions as p_exc from vmware_nsx.common import nsx_utils from vmware_nsx.db import lsn_db from vmware_nsx.dhcp_meta import constants as const -from vmware_nsx.nsxlib import lsn as lsn_api -from vmware_nsx.nsxlib import switch as switch_api +from vmware_nsx.nsxlib.mh import lsn as lsn_api +from vmware_nsx.nsxlib.mh import switch as switch_api LOG = logging.getLogger(__name__) diff --git a/vmware_nsx/dhcp_meta/nsx.py b/vmware_nsx/dhcp_meta/nsx.py index 9fd79f9027..0ea7916bb4 100644 --- a/vmware_nsx/dhcp_meta/nsx.py +++ b/vmware_nsx/dhcp_meta/nsx.py @@ -28,7 +28,7 @@ from neutron.extensions import external_net from neutron.i18n import _LE, _LI from vmware_nsx.common import exceptions as p_exc from vmware_nsx.dhcp_meta import constants as d_const -from vmware_nsx.nsxlib import lsn as lsn_api +from vmware_nsx.nsxlib.mh import lsn as lsn_api LOG = logging.getLogger(__name__) diff --git a/vmware_nsx/nsxlib/__init__.py b/vmware_nsx/nsxlib/__init__.py index 19abe24c05..e69de29bb2 100644 --- a/vmware_nsx/nsxlib/__init__.py +++ b/vmware_nsx/nsxlib/__init__.py @@ -1,148 +0,0 @@ -# Copyright 2014 VMware, Inc. -# All Rights Reserved -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from neutron.common import exceptions as exception -from neutron import version -from oslo_log import log -from oslo_serialization import jsonutils -import six - -from vmware_nsx.api_client import exception as api_exc -from vmware_nsx.common import exceptions as nsx_exc - -HTTP_GET = "GET" -HTTP_POST = "POST" -HTTP_DELETE = "DELETE" -HTTP_PUT = "PUT" -# Prefix to be used for all NSX API calls -URI_PREFIX = "/ws.v1" -NEUTRON_VERSION = version.version_info.release_string() - -LOG = log.getLogger(__name__) - - -def _build_uri_path(resource, - resource_id=None, - parent_resource_id=None, - fields=None, - relations=None, - filters=None, - types=None, - is_attachment=False, - extra_action=None): - resources = resource.split('/') - res_path = resources[0] - if resource_id: - res_path += "/%s" % resource_id - if len(resources) > 1: - # There is also a parent resource to account for in the uri - res_path = "%s/%s/%s" % (resources[1], - parent_resource_id, - res_path) - if is_attachment: - res_path = "%s/attachment" % res_path - elif extra_action: - res_path = "%s/%s" % (res_path, extra_action) - params = [] - params.append(fields and "fields=%s" % fields) - params.append(relations and "relations=%s" % relations) - params.append(types and "types=%s" % types) - if filters: - sorted_filters = [ - '%s=%s' % (k, filters[k]) for k in sorted(filters.keys()) - ] - params.extend(sorted_filters) - uri_path = "%s/%s" % (URI_PREFIX, res_path) - non_empty_params = [x for x in params if x is not None] - if non_empty_params: - query_string = '&'.join(non_empty_params) - if query_string: - uri_path += "?%s" % query_string - return uri_path - - -def format_exception(etype, e, exception_locals): - """Consistent formatting for exceptions. - - :param etype: a string describing the exception type. - :param e: the exception. - :param execption_locals: calling context local variable dict. - :returns: a formatted string. - """ - msg = [_("Error. %(type)s exception: %(exc)s.") % - {'type': etype, 'exc': e}] - l = dict((k, v) for k, v in six.iteritems(exception_locals) - if k != 'request') - msg.append(_("locals=[%s]") % str(l)) - return ' '.join(msg) - - -def do_request(*args, **kwargs): - """Issue a request to the cluster specified in kwargs. - - :param args: a list of positional arguments. - :param kwargs: a list of keyworkds arguments. - :returns: the result of the operation loaded into a python - object or None. - """ - cluster = kwargs["cluster"] - try: - res = cluster.api_client.request(*args) - if res: - return jsonutils.loads(res) - except api_exc.ResourceNotFound: - raise exception.NotFound() - except api_exc.ReadOnlyMode: - raise nsx_exc.MaintenanceInProgress() - - -def get_single_query_page(path, cluster, page_cursor=None, - page_length=1000, neutron_only=True): - params = [] - if page_cursor: - params.append("_page_cursor=%s" % page_cursor) - params.append("_page_length=%s" % page_length) - # NOTE(salv-orlando): On the NSX backend the 'Quantum' tag is still - # used for marking Neutron entities in order to preserve compatibility - if neutron_only: - params.append("tag_scope=quantum") - query_params = "&".join(params) - path = "%s%s%s" % (path, "&" if (path.find("?") != -1) else "?", - query_params) - body = do_request(HTTP_GET, path, cluster=cluster) - # Result_count won't be returned if _page_cursor is supplied - return body['results'], body.get('page_cursor'), body.get('result_count') - - -def get_all_query_pages(path, cluster): - need_more_results = True - result_list = [] - page_cursor = None - while need_more_results: - results, page_cursor = get_single_query_page( - path, cluster, page_cursor)[:2] - if not page_cursor: - need_more_results = False - result_list.extend(results) - return result_list - - -def mk_body(**kwargs): - """Convenience function creates and dumps dictionary to string. - - :param kwargs: the key/value pirs to be dumped into a json string. - :returns: a json string. - """ - return jsonutils.dumps(kwargs, ensure_ascii=False) diff --git a/vmware_nsx/nsxlib/mh/__init__.py b/vmware_nsx/nsxlib/mh/__init__.py new file mode 100644 index 0000000000..19abe24c05 --- /dev/null +++ b/vmware_nsx/nsxlib/mh/__init__.py @@ -0,0 +1,148 @@ +# Copyright 2014 VMware, Inc. +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron.common import exceptions as exception +from neutron import version +from oslo_log import log +from oslo_serialization import jsonutils +import six + +from vmware_nsx.api_client import exception as api_exc +from vmware_nsx.common import exceptions as nsx_exc + +HTTP_GET = "GET" +HTTP_POST = "POST" +HTTP_DELETE = "DELETE" +HTTP_PUT = "PUT" +# Prefix to be used for all NSX API calls +URI_PREFIX = "/ws.v1" +NEUTRON_VERSION = version.version_info.release_string() + +LOG = log.getLogger(__name__) + + +def _build_uri_path(resource, + resource_id=None, + parent_resource_id=None, + fields=None, + relations=None, + filters=None, + types=None, + is_attachment=False, + extra_action=None): + resources = resource.split('/') + res_path = resources[0] + if resource_id: + res_path += "/%s" % resource_id + if len(resources) > 1: + # There is also a parent resource to account for in the uri + res_path = "%s/%s/%s" % (resources[1], + parent_resource_id, + res_path) + if is_attachment: + res_path = "%s/attachment" % res_path + elif extra_action: + res_path = "%s/%s" % (res_path, extra_action) + params = [] + params.append(fields and "fields=%s" % fields) + params.append(relations and "relations=%s" % relations) + params.append(types and "types=%s" % types) + if filters: + sorted_filters = [ + '%s=%s' % (k, filters[k]) for k in sorted(filters.keys()) + ] + params.extend(sorted_filters) + uri_path = "%s/%s" % (URI_PREFIX, res_path) + non_empty_params = [x for x in params if x is not None] + if non_empty_params: + query_string = '&'.join(non_empty_params) + if query_string: + uri_path += "?%s" % query_string + return uri_path + + +def format_exception(etype, e, exception_locals): + """Consistent formatting for exceptions. + + :param etype: a string describing the exception type. + :param e: the exception. + :param execption_locals: calling context local variable dict. + :returns: a formatted string. + """ + msg = [_("Error. %(type)s exception: %(exc)s.") % + {'type': etype, 'exc': e}] + l = dict((k, v) for k, v in six.iteritems(exception_locals) + if k != 'request') + msg.append(_("locals=[%s]") % str(l)) + return ' '.join(msg) + + +def do_request(*args, **kwargs): + """Issue a request to the cluster specified in kwargs. + + :param args: a list of positional arguments. + :param kwargs: a list of keyworkds arguments. + :returns: the result of the operation loaded into a python + object or None. + """ + cluster = kwargs["cluster"] + try: + res = cluster.api_client.request(*args) + if res: + return jsonutils.loads(res) + except api_exc.ResourceNotFound: + raise exception.NotFound() + except api_exc.ReadOnlyMode: + raise nsx_exc.MaintenanceInProgress() + + +def get_single_query_page(path, cluster, page_cursor=None, + page_length=1000, neutron_only=True): + params = [] + if page_cursor: + params.append("_page_cursor=%s" % page_cursor) + params.append("_page_length=%s" % page_length) + # NOTE(salv-orlando): On the NSX backend the 'Quantum' tag is still + # used for marking Neutron entities in order to preserve compatibility + if neutron_only: + params.append("tag_scope=quantum") + query_params = "&".join(params) + path = "%s%s%s" % (path, "&" if (path.find("?") != -1) else "?", + query_params) + body = do_request(HTTP_GET, path, cluster=cluster) + # Result_count won't be returned if _page_cursor is supplied + return body['results'], body.get('page_cursor'), body.get('result_count') + + +def get_all_query_pages(path, cluster): + need_more_results = True + result_list = [] + page_cursor = None + while need_more_results: + results, page_cursor = get_single_query_page( + path, cluster, page_cursor)[:2] + if not page_cursor: + need_more_results = False + result_list.extend(results) + return result_list + + +def mk_body(**kwargs): + """Convenience function creates and dumps dictionary to string. + + :param kwargs: the key/value pirs to be dumped into a json string. + :returns: a json string. + """ + return jsonutils.dumps(kwargs, ensure_ascii=False) diff --git a/vmware_nsx/nsxlib/l2gateway.py b/vmware_nsx/nsxlib/mh/l2gateway.py similarity index 99% rename from vmware_nsx/nsxlib/l2gateway.py rename to vmware_nsx/nsxlib/mh/l2gateway.py index 5610d64250..94c6e190ec 100644 --- a/vmware_nsx/nsxlib/l2gateway.py +++ b/vmware_nsx/nsxlib/mh/l2gateway.py @@ -21,8 +21,8 @@ from oslo_serialization import jsonutils from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import switch +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import switch HTTP_GET = "GET" HTTP_POST = "POST" diff --git a/vmware_nsx/nsxlib/lsn.py b/vmware_nsx/nsxlib/mh/lsn.py similarity index 99% rename from vmware_nsx/nsxlib/lsn.py rename to vmware_nsx/nsxlib/mh/lsn.py index 31c4ba11d9..c623f13004 100644 --- a/vmware_nsx/nsxlib/lsn.py +++ b/vmware_nsx/nsxlib/mh/lsn.py @@ -21,7 +21,7 @@ import six from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib HTTP_GET = "GET" HTTP_POST = "POST" diff --git a/vmware_nsx/nsxlib/queue.py b/vmware_nsx/nsxlib/mh/queue.py similarity index 98% rename from vmware_nsx/nsxlib/queue.py rename to vmware_nsx/nsxlib/mh/queue.py index c65341287c..7b40a81772 100644 --- a/vmware_nsx/nsxlib/queue.py +++ b/vmware_nsx/nsxlib/mh/queue.py @@ -22,7 +22,7 @@ import six from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib HTTP_POST = "POST" HTTP_DELETE = "DELETE" diff --git a/vmware_nsx/nsxlib/router.py b/vmware_nsx/nsxlib/mh/router.py similarity index 99% rename from vmware_nsx/nsxlib/router.py rename to vmware_nsx/nsxlib/mh/router.py index ac90e4a800..e3edb127df 100644 --- a/vmware_nsx/nsxlib/router.py +++ b/vmware_nsx/nsxlib/mh/router.py @@ -24,9 +24,9 @@ from neutron.i18n import _LE, _LI, _LW from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import switch -from vmware_nsx.nsxlib import versioning +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import switch +from vmware_nsx.nsxlib.mh import versioning # @versioning.versioned decorator makes the apparent function body # totally unrelated to the real function. This confuses pylint :( diff --git a/vmware_nsx/nsxlib/secgroup.py b/vmware_nsx/nsxlib/mh/secgroup.py similarity index 99% rename from vmware_nsx/nsxlib/secgroup.py rename to vmware_nsx/nsxlib/mh/secgroup.py index a447f6747c..7fde4c088a 100644 --- a/vmware_nsx/nsxlib/secgroup.py +++ b/vmware_nsx/nsxlib/mh/secgroup.py @@ -22,7 +22,7 @@ from neutron.common import exceptions from neutron.i18n import _LW from vmware_nsx.common import utils -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib HTTP_GET = "GET" HTTP_POST = "POST" diff --git a/vmware_nsx/nsxlib/switch.py b/vmware_nsx/nsxlib/mh/switch.py similarity index 99% rename from vmware_nsx/nsxlib/switch.py rename to vmware_nsx/nsxlib/mh/switch.py index 905d99a7e3..2ca773b489 100644 --- a/vmware_nsx/nsxlib/switch.py +++ b/vmware_nsx/nsxlib/mh/switch.py @@ -25,7 +25,7 @@ from neutron.i18n import _LE, _LI, _LW from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib HTTP_GET = "GET" HTTP_POST = "POST" diff --git a/vmware_nsx/nsxlib/versioning.py b/vmware_nsx/nsxlib/mh/versioning.py similarity index 100% rename from vmware_nsx/nsxlib/versioning.py rename to vmware_nsx/nsxlib/mh/versioning.py diff --git a/vmware_nsx/plugins/nsx_mh/plugin.py b/vmware_nsx/plugins/nsx_mh/plugin.py index 6658192b75..f85707a4bb 100644 --- a/vmware_nsx/plugins/nsx_mh/plugin.py +++ b/vmware_nsx/plugins/nsx_mh/plugin.py @@ -76,11 +76,11 @@ from vmware_nsx import dhcpmeta_modes from vmware_nsx.extensions import maclearning as mac_ext from vmware_nsx.extensions import networkgw from vmware_nsx.extensions import qos -from vmware_nsx.nsxlib import l2gateway as l2gwlib -from vmware_nsx.nsxlib import queue as queuelib -from vmware_nsx.nsxlib import router as routerlib -from vmware_nsx.nsxlib import secgroup as secgrouplib -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib +from vmware_nsx.nsxlib.mh import queue as queuelib +from vmware_nsx.nsxlib.mh import router as routerlib +from vmware_nsx.nsxlib.mh import secgroup as secgrouplib +from vmware_nsx.nsxlib.mh import switch as switchlib LOG = logging.getLogger(__name__) diff --git a/vmware_nsx/tests/unit/vmware/extensions/test_networkgw.py b/vmware_nsx/tests/unit/vmware/extensions/test_networkgw.py index fbefab7319..922c086a88 100644 --- a/vmware_nsx/tests/unit/vmware/extensions/test_networkgw.py +++ b/vmware_nsx/tests/unit/vmware/extensions/test_networkgw.py @@ -36,8 +36,8 @@ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.db import networkgw_db from vmware_nsx.db import nsx_models from vmware_nsx.extensions import networkgw -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import l2gateway as l2gwlib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit.vmware import test_nsx_plugin diff --git a/vmware_nsx/tests/unit/vmware/extensions/test_qosqueues.py b/vmware_nsx/tests/unit/vmware/extensions/test_qosqueues.py index a0d400f26a..c0b7387588 100644 --- a/vmware_nsx/tests/unit/vmware/extensions/test_qosqueues.py +++ b/vmware_nsx/tests/unit/vmware/extensions/test_qosqueues.py @@ -23,7 +23,7 @@ from neutron import context from neutron.tests.unit.api import test_extensions from vmware_nsx.db import qos_db from vmware_nsx.extensions import qos as ext_qos -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit.vmware import test_nsx_plugin diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_l2gateway.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_l2gateway.py index d460c8bb35..c6054102ee 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_l2gateway.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_l2gateway.py @@ -21,9 +21,9 @@ from oslo_serialization import jsonutils from vmware_nsx.api_client import exception from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils as nsx_utils -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import l2gateway as l2gwlib -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib +from vmware_nsx.nsxlib.mh import switch as switchlib from vmware_nsx.tests.unit.vmware.nsxlib import base _uuid = test_base._uuid diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_lsn.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_lsn.py index 3f4f17010f..a24cc83f49 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_lsn.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_lsn.py @@ -22,7 +22,7 @@ import six from vmware_nsx.api_client import exception as api_exc from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx.nsxlib import lsn as lsnlib +from vmware_nsx.nsxlib.mh import lsn as lsnlib class LSNTestCase(base.BaseTestCase): @@ -30,7 +30,7 @@ class LSNTestCase(base.BaseTestCase): def setUp(self): super(LSNTestCase, self).setUp() self.mock_request_p = mock.patch( - 'vmware_nsx.nsxlib.do_request') + 'vmware_nsx.nsxlib.mh.do_request') self.mock_request = self.mock_request_p.start() self.cluster = mock.Mock() self.cluster.default_service_cluster_uuid = 'foo' diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_queue.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_queue.py index bee576d599..bce07f8557 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_queue.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_queue.py @@ -18,8 +18,8 @@ import mock from neutron.common import exceptions from vmware_nsx.api_client import exception as api_exc -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import queue as queuelib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import queue as queuelib from vmware_nsx.tests.unit.vmware.nsxlib import base diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_router.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_router.py index 29b1650258..9cf28455d9 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_router.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_router.py @@ -24,9 +24,9 @@ from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import version as ver_module from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import router as routerlib -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import router as routerlib +from vmware_nsx.nsxlib.mh import switch as switchlib from vmware_nsx.tests.unit.vmware.nsxlib import base _uuid = test_base._uuid diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_secgroup.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_secgroup.py index b05bc9e453..076d9538bf 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_secgroup.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_secgroup.py @@ -18,8 +18,8 @@ from neutron.common import constants from neutron.common import exceptions from neutron.tests.unit.api.v2 import test_base -from vmware_nsx import nsxlib -from vmware_nsx.nsxlib import secgroup as secgrouplib +from vmware_nsx.nsxlib import mh as nsxlib +from vmware_nsx.nsxlib.mh import secgroup as secgrouplib from vmware_nsx.tests.unit.vmware.nsxlib import base _uuid = test_base._uuid diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_switch.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_switch.py index 25a3258e7b..1d8641962b 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_switch.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_switch.py @@ -22,7 +22,7 @@ from neutron.common import exceptions from neutron.tests.unit.api.v2 import test_base from vmware_nsx.common import utils -from vmware_nsx.nsxlib import switch as switchlib +from vmware_nsx.nsxlib.mh import switch as switchlib from vmware_nsx.tests.unit.vmware.nsxlib import base _uuid = test_base._uuid diff --git a/vmware_nsx/tests/unit/vmware/nsxlib/test_versioning.py b/vmware_nsx/tests/unit/vmware/nsxlib/test_versioning.py index 4ee80621d3..9c20ac749b 100644 --- a/vmware_nsx/tests/unit/vmware/nsxlib/test_versioning.py +++ b/vmware_nsx/tests/unit/vmware/nsxlib/test_versioning.py @@ -19,8 +19,8 @@ from neutron.tests import base from vmware_nsx.api_client import ( version as version_module) from vmware_nsx.api_client import exception -from vmware_nsx.nsxlib import router as routerlib -from vmware_nsx.nsxlib import versioning +from vmware_nsx.nsxlib.mh import router as routerlib +from vmware_nsx.nsxlib.mh import versioning class TestVersioning(base.BaseTestCase): diff --git a/vmware_nsx/tests/unit/vmware/test_nsx_opts.py b/vmware_nsx/tests/unit/vmware/test_nsx_opts.py index 20d15558e2..f71ccae891 100644 --- a/vmware_nsx/tests/unit/vmware/test_nsx_opts.py +++ b/vmware_nsx/tests/unit/vmware/test_nsx_opts.py @@ -28,7 +28,7 @@ from vmware_nsx.common import config # noqa from vmware_nsx.common import exceptions from vmware_nsx.common import sync from vmware_nsx import nsx_cluster -from vmware_nsx.nsxlib import lsn as lsnlib +from vmware_nsx.nsxlib.mh import lsn as lsnlib from vmware_nsx.tests.unit import vmware BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test') diff --git a/vmware_nsx/tests/unit/vmware/test_nsx_plugin.py b/vmware_nsx/tests/unit/vmware/test_nsx_plugin.py index 187b9f7402..4e5acfd828 100644 --- a/vmware_nsx/tests/unit/vmware/test_nsx_plugin.py +++ b/vmware_nsx/tests/unit/vmware/test_nsx_plugin.py @@ -50,7 +50,7 @@ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import sync from vmware_nsx.common import utils from vmware_nsx.db import db as nsx_db -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit.vmware.apiclient import fake from vmware_nsx.tests.unit.vmware import test_utils diff --git a/vmware_nsx/tests/unit/vmware/test_nsx_sync.py b/vmware_nsx/tests/unit/vmware/test_nsx_sync.py index 2d2e9e4680..adb7418023 100644 --- a/vmware_nsx/tests/unit/vmware/test_nsx_sync.py +++ b/vmware_nsx/tests/unit/vmware/test_nsx_sync.py @@ -37,7 +37,7 @@ from vmware_nsx.api_client import version from vmware_nsx.common import sync from vmware_nsx.db import db from vmware_nsx import nsx_cluster as cluster -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib from vmware_nsx import plugin from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit.vmware.apiclient import fake diff --git a/vmware_nsx/tests/unit/vmware/test_nsx_utils.py b/vmware_nsx/tests/unit/vmware/test_nsx_utils.py index c85fe2b4f6..40be58e97e 100644 --- a/vmware_nsx/tests/unit/vmware/test_nsx_utils.py +++ b/vmware_nsx/tests/unit/vmware/test_nsx_utils.py @@ -25,7 +25,7 @@ from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import nsx_utils from vmware_nsx.common import utils from vmware_nsx.db import nsx_models -from vmware_nsx import nsxlib +from vmware_nsx.nsxlib import mh as nsxlib from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit.vmware.nsxlib import base as nsx_base @@ -105,7 +105,7 @@ class NsxUtilsTestCase(base.BaseTestCase): ret_value = None, exp_lp_uuid self._mock_port_mapping_db_calls(ret_value) with mock.patch(vmware.nsx_method('query_lswitch_lports', - module_name='nsxlib.switch'), + module_name='nsxlib.mh.switch'), return_value=[{'uuid': exp_lp_uuid, '_relations': { 'LogicalSwitchConfig': { @@ -121,7 +121,7 @@ class NsxUtilsTestCase(base.BaseTestCase): ret_value = None, None self._mock_port_mapping_db_calls(ret_value) with mock.patch(vmware.nsx_method('query_lswitch_lports', - module_name='nsxlib.switch'), + module_name='nsxlib.mh.switch'), return_value=[{'uuid': exp_lp_uuid, '_relations': { 'LogicalSwitchConfig': { @@ -135,7 +135,7 @@ class NsxUtilsTestCase(base.BaseTestCase): ret_value = None, None self._mock_port_mapping_db_calls(ret_value) with mock.patch(vmware.nsx_method('query_lswitch_lports', - module_name='nsxlib.switch'), + module_name='nsxlib.mh.switch'), return_value=[]): self._verify_get_nsx_switch_and_port_id(None, None) @@ -152,7 +152,7 @@ class NsxUtilsTestCase(base.BaseTestCase): exp_ls_uuids = [uuidutils.generate_uuid()] self._mock_network_mapping_db_calls(None) with mock.patch(vmware.nsx_method('get_lswitches', - module_name='nsxlib.switch'), + module_name='nsxlib.mh.switch'), return_value=[{'uuid': uuid} for uuid in exp_ls_uuids]): self._verify_get_nsx_switch_ids(exp_ls_uuids) @@ -162,7 +162,7 @@ class NsxUtilsTestCase(base.BaseTestCase): # are not found both in the db and in the backend self._mock_network_mapping_db_calls(None) with mock.patch(vmware.nsx_method('get_lswitches', - module_name='nsxlib.switch'), + module_name='nsxlib.mh.switch'), return_value=[]): self._verify_get_nsx_switch_ids(None) @@ -179,7 +179,7 @@ class NsxUtilsTestCase(base.BaseTestCase): exp_lr_uuid = uuidutils.generate_uuid() self._mock_router_mapping_db_calls(None) with mock.patch(vmware.nsx_method('query_lrouters', - module_name='nsxlib.router'), + module_name='nsxlib.mh.router'), return_value=[{'uuid': exp_lr_uuid}]): self._verify_get_nsx_router_id(exp_lr_uuid) @@ -188,7 +188,7 @@ class NsxUtilsTestCase(base.BaseTestCase): # are not found both in the db and in the backend self._mock_router_mapping_db_calls(None) with mock.patch(vmware.nsx_method('query_lrouters', - module_name='nsxlib.router'), + module_name='nsxlib.mh.router'), return_value=[]): self._verify_get_nsx_router_id(None) @@ -296,7 +296,7 @@ class NsxUtilsTestCase(base.BaseTestCase): exp_sec_prof_uuid = uuidutils.generate_uuid() self._mock_sec_group_mapping_db_calls(None) with mock.patch(vmware.nsx_method('query_security_profiles', - module_name='nsxlib.secgroup'), + module_name='nsxlib.mh.secgroup'), return_value=[{'uuid': exp_sec_prof_uuid}]): self._verify_get_nsx_sec_profile_id(exp_sec_prof_uuid) @@ -305,7 +305,7 @@ class NsxUtilsTestCase(base.BaseTestCase): # are not found both in the db and in the backend self._mock_sec_group_mapping_db_calls(None) with mock.patch(vmware.nsx_method('query_security_profiles', - module_name='nsxlib.secgroup'), + module_name='nsxlib.mh.secgroup'), return_value=[]): self._verify_get_nsx_sec_profile_id(None)