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
This commit is contained in:
Shih-Hao Li 2015-09-17 16:48:16 -07:00
parent 4bf8308494
commit 4965074703
28 changed files with 204 additions and 204 deletions

View File

@ -22,7 +22,7 @@ from oslo_config import cfg
from neutron.common import config from neutron.common import config
from vmware_nsx.common import config as nsx_config # noqa from vmware_nsx.common import config as nsx_config # noqa
from vmware_nsx.common import nsx_utils from vmware_nsx.common import nsx_utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
config.setup_logging() config.setup_logging()

View File

@ -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 db as nsx_db
from vmware_nsx.db import networkgw_db from vmware_nsx.db import networkgw_db
from vmware_nsx import nsx_cluster from vmware_nsx import nsx_cluster
from vmware_nsx.nsxlib import l2gateway as l2gwlib from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
from vmware_nsx.nsxlib import router as routerlib from vmware_nsx.nsxlib.mh import router as routerlib
from vmware_nsx.nsxlib import secgroup as secgrouplib from vmware_nsx.nsxlib.mh import secgroup as secgrouplib
from vmware_nsx.nsxlib import switch as switchlib from vmware_nsx.nsxlib.mh import switch as switchlib
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -33,9 +33,9 @@ from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import nsx_utils from vmware_nsx.common import nsx_utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import router as routerlib from vmware_nsx.nsxlib.mh import router as routerlib
from vmware_nsx.nsxlib import switch as switchlib from vmware_nsx.nsxlib.mh import switch as switchlib
# Maximum page size for a single request # Maximum page size for a single request
# NOTE(salv-orlando): This might become a version-dependent map should the # NOTE(salv-orlando): This might become a version-dependent map should the

View File

@ -27,8 +27,8 @@ from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.common import nsx_utils from vmware_nsx.common import nsx_utils
from vmware_nsx.db import lsn_db from vmware_nsx.db import lsn_db
from vmware_nsx.dhcp_meta import constants as const from vmware_nsx.dhcp_meta import constants as const
from vmware_nsx.nsxlib import lsn as lsn_api from vmware_nsx.nsxlib.mh import lsn as lsn_api
from vmware_nsx.nsxlib import switch as switch_api from vmware_nsx.nsxlib.mh import switch as switch_api
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -28,7 +28,7 @@ from neutron.extensions import external_net
from neutron.i18n import _LE, _LI from neutron.i18n import _LE, _LI
from vmware_nsx.common import exceptions as p_exc from vmware_nsx.common import exceptions as p_exc
from vmware_nsx.dhcp_meta import constants as d_const 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__) LOG = logging.getLogger(__name__)

View File

@ -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)

View File

@ -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)

View File

@ -21,8 +21,8 @@ from oslo_serialization import jsonutils
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import switch from vmware_nsx.nsxlib.mh import switch
HTTP_GET = "GET" HTTP_GET = "GET"
HTTP_POST = "POST" HTTP_POST = "POST"

View File

@ -21,7 +21,7 @@ import six
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
HTTP_GET = "GET" HTTP_GET = "GET"
HTTP_POST = "POST" HTTP_POST = "POST"

View File

@ -22,7 +22,7 @@ import six
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
HTTP_POST = "POST" HTTP_POST = "POST"
HTTP_DELETE = "DELETE" HTTP_DELETE = "DELETE"

View File

@ -24,9 +24,9 @@ from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import switch from vmware_nsx.nsxlib.mh import switch
from vmware_nsx.nsxlib import versioning from vmware_nsx.nsxlib.mh import versioning
# @versioning.versioned decorator makes the apparent function body # @versioning.versioned decorator makes the apparent function body
# totally unrelated to the real function. This confuses pylint :( # totally unrelated to the real function. This confuses pylint :(

View File

@ -22,7 +22,7 @@ from neutron.common import exceptions
from neutron.i18n import _LW from neutron.i18n import _LW
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
HTTP_GET = "GET" HTTP_GET = "GET"
HTTP_POST = "POST" HTTP_POST = "POST"

View File

@ -25,7 +25,7 @@ from neutron.i18n import _LE, _LI, _LW
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
HTTP_GET = "GET" HTTP_GET = "GET"
HTTP_POST = "POST" HTTP_POST = "POST"

View File

@ -76,11 +76,11 @@ from vmware_nsx import dhcpmeta_modes
from vmware_nsx.extensions import maclearning as mac_ext from vmware_nsx.extensions import maclearning as mac_ext
from vmware_nsx.extensions import networkgw from vmware_nsx.extensions import networkgw
from vmware_nsx.extensions import qos from vmware_nsx.extensions import qos
from vmware_nsx.nsxlib import l2gateway as l2gwlib from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
from vmware_nsx.nsxlib import queue as queuelib from vmware_nsx.nsxlib.mh import queue as queuelib
from vmware_nsx.nsxlib import router as routerlib from vmware_nsx.nsxlib.mh import router as routerlib
from vmware_nsx.nsxlib import secgroup as secgrouplib from vmware_nsx.nsxlib.mh import secgroup as secgrouplib
from vmware_nsx.nsxlib import switch as switchlib from vmware_nsx.nsxlib.mh import switch as switchlib
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)

View File

@ -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 networkgw_db
from vmware_nsx.db import nsx_models from vmware_nsx.db import nsx_models
from vmware_nsx.extensions import networkgw from vmware_nsx.extensions import networkgw
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import l2gateway as l2gwlib from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit import vmware
from vmware_nsx.tests.unit.vmware import test_nsx_plugin from vmware_nsx.tests.unit.vmware import test_nsx_plugin

View File

@ -23,7 +23,7 @@ from neutron import context
from neutron.tests.unit.api import test_extensions from neutron.tests.unit.api import test_extensions
from vmware_nsx.db import qos_db from vmware_nsx.db import qos_db
from vmware_nsx.extensions import qos as ext_qos 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 import vmware
from vmware_nsx.tests.unit.vmware import test_nsx_plugin from vmware_nsx.tests.unit.vmware import test_nsx_plugin

View File

@ -21,9 +21,9 @@ from oslo_serialization import jsonutils
from vmware_nsx.api_client import exception from vmware_nsx.api_client import exception
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils as nsx_utils from vmware_nsx.common import utils as nsx_utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import l2gateway as l2gwlib from vmware_nsx.nsxlib.mh import l2gateway as l2gwlib
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 from vmware_nsx.tests.unit.vmware.nsxlib import base
_uuid = test_base._uuid _uuid = test_base._uuid

View File

@ -22,7 +22,7 @@ import six
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils 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): class LSNTestCase(base.BaseTestCase):
@ -30,7 +30,7 @@ class LSNTestCase(base.BaseTestCase):
def setUp(self): def setUp(self):
super(LSNTestCase, self).setUp() super(LSNTestCase, self).setUp()
self.mock_request_p = mock.patch( 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.mock_request = self.mock_request_p.start()
self.cluster = mock.Mock() self.cluster = mock.Mock()
self.cluster.default_service_cluster_uuid = 'foo' self.cluster.default_service_cluster_uuid = 'foo'

View File

@ -18,8 +18,8 @@ import mock
from neutron.common import exceptions from neutron.common import exceptions
from vmware_nsx.api_client import exception as api_exc from vmware_nsx.api_client import exception as api_exc
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import queue as queuelib from vmware_nsx.nsxlib.mh import queue as queuelib
from vmware_nsx.tests.unit.vmware.nsxlib import base from vmware_nsx.tests.unit.vmware.nsxlib import base

View File

@ -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.api_client import version as ver_module
from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import router as routerlib from vmware_nsx.nsxlib.mh import router as routerlib
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 from vmware_nsx.tests.unit.vmware.nsxlib import base
_uuid = test_base._uuid _uuid = test_base._uuid

View File

@ -18,8 +18,8 @@ from neutron.common import constants
from neutron.common import exceptions from neutron.common import exceptions
from neutron.tests.unit.api.v2 import test_base from neutron.tests.unit.api.v2 import test_base
from vmware_nsx import nsxlib from vmware_nsx.nsxlib import mh as nsxlib
from vmware_nsx.nsxlib import secgroup as secgrouplib from vmware_nsx.nsxlib.mh import secgroup as secgrouplib
from vmware_nsx.tests.unit.vmware.nsxlib import base from vmware_nsx.tests.unit.vmware.nsxlib import base
_uuid = test_base._uuid _uuid = test_base._uuid

View File

@ -22,7 +22,7 @@ from neutron.common import exceptions
from neutron.tests.unit.api.v2 import test_base from neutron.tests.unit.api.v2 import test_base
from vmware_nsx.common import utils 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 from vmware_nsx.tests.unit.vmware.nsxlib import base
_uuid = test_base._uuid _uuid = test_base._uuid

View File

@ -19,8 +19,8 @@ from neutron.tests import base
from vmware_nsx.api_client import ( from vmware_nsx.api_client import (
version as version_module) version as version_module)
from vmware_nsx.api_client import exception from vmware_nsx.api_client import exception
from vmware_nsx.nsxlib import router as routerlib from vmware_nsx.nsxlib.mh import router as routerlib
from vmware_nsx.nsxlib import versioning from vmware_nsx.nsxlib.mh import versioning
class TestVersioning(base.BaseTestCase): class TestVersioning(base.BaseTestCase):

View File

@ -28,7 +28,7 @@ from vmware_nsx.common import config # noqa
from vmware_nsx.common import exceptions from vmware_nsx.common import exceptions
from vmware_nsx.common import sync from vmware_nsx.common import sync
from vmware_nsx import nsx_cluster 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 from vmware_nsx.tests.unit import vmware
BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test') BASE_CONF_PATH = vmware.get_fake_conf('neutron.conf.test')

View File

@ -50,7 +50,7 @@ from vmware_nsx.common import exceptions as nsx_exc
from vmware_nsx.common import sync from vmware_nsx.common import sync
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx.db import db as nsx_db 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 import vmware
from vmware_nsx.tests.unit.vmware.apiclient import fake from vmware_nsx.tests.unit.vmware.apiclient import fake
from vmware_nsx.tests.unit.vmware import test_utils from vmware_nsx.tests.unit.vmware import test_utils

View File

@ -37,7 +37,7 @@ from vmware_nsx.api_client import version
from vmware_nsx.common import sync from vmware_nsx.common import sync
from vmware_nsx.db import db from vmware_nsx.db import db
from vmware_nsx import nsx_cluster as cluster 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 import plugin
from vmware_nsx.tests.unit import vmware from vmware_nsx.tests.unit import vmware
from vmware_nsx.tests.unit.vmware.apiclient import fake from vmware_nsx.tests.unit.vmware.apiclient import fake

View File

@ -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 nsx_utils
from vmware_nsx.common import utils from vmware_nsx.common import utils
from vmware_nsx.db import nsx_models 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 import vmware
from vmware_nsx.tests.unit.vmware.nsxlib import base as nsx_base 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 ret_value = None, exp_lp_uuid
self._mock_port_mapping_db_calls(ret_value) self._mock_port_mapping_db_calls(ret_value)
with mock.patch(vmware.nsx_method('query_lswitch_lports', with mock.patch(vmware.nsx_method('query_lswitch_lports',
module_name='nsxlib.switch'), module_name='nsxlib.mh.switch'),
return_value=[{'uuid': exp_lp_uuid, return_value=[{'uuid': exp_lp_uuid,
'_relations': { '_relations': {
'LogicalSwitchConfig': { 'LogicalSwitchConfig': {
@ -121,7 +121,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
ret_value = None, None ret_value = None, None
self._mock_port_mapping_db_calls(ret_value) self._mock_port_mapping_db_calls(ret_value)
with mock.patch(vmware.nsx_method('query_lswitch_lports', with mock.patch(vmware.nsx_method('query_lswitch_lports',
module_name='nsxlib.switch'), module_name='nsxlib.mh.switch'),
return_value=[{'uuid': exp_lp_uuid, return_value=[{'uuid': exp_lp_uuid,
'_relations': { '_relations': {
'LogicalSwitchConfig': { 'LogicalSwitchConfig': {
@ -135,7 +135,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
ret_value = None, None ret_value = None, None
self._mock_port_mapping_db_calls(ret_value) self._mock_port_mapping_db_calls(ret_value)
with mock.patch(vmware.nsx_method('query_lswitch_lports', with mock.patch(vmware.nsx_method('query_lswitch_lports',
module_name='nsxlib.switch'), module_name='nsxlib.mh.switch'),
return_value=[]): return_value=[]):
self._verify_get_nsx_switch_and_port_id(None, None) self._verify_get_nsx_switch_and_port_id(None, None)
@ -152,7 +152,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
exp_ls_uuids = [uuidutils.generate_uuid()] exp_ls_uuids = [uuidutils.generate_uuid()]
self._mock_network_mapping_db_calls(None) self._mock_network_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('get_lswitches', with mock.patch(vmware.nsx_method('get_lswitches',
module_name='nsxlib.switch'), module_name='nsxlib.mh.switch'),
return_value=[{'uuid': uuid} return_value=[{'uuid': uuid}
for uuid in exp_ls_uuids]): for uuid in exp_ls_uuids]):
self._verify_get_nsx_switch_ids(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 # are not found both in the db and in the backend
self._mock_network_mapping_db_calls(None) self._mock_network_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('get_lswitches', with mock.patch(vmware.nsx_method('get_lswitches',
module_name='nsxlib.switch'), module_name='nsxlib.mh.switch'),
return_value=[]): return_value=[]):
self._verify_get_nsx_switch_ids(None) self._verify_get_nsx_switch_ids(None)
@ -179,7 +179,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
exp_lr_uuid = uuidutils.generate_uuid() exp_lr_uuid = uuidutils.generate_uuid()
self._mock_router_mapping_db_calls(None) self._mock_router_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('query_lrouters', with mock.patch(vmware.nsx_method('query_lrouters',
module_name='nsxlib.router'), module_name='nsxlib.mh.router'),
return_value=[{'uuid': exp_lr_uuid}]): return_value=[{'uuid': exp_lr_uuid}]):
self._verify_get_nsx_router_id(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 # are not found both in the db and in the backend
self._mock_router_mapping_db_calls(None) self._mock_router_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('query_lrouters', with mock.patch(vmware.nsx_method('query_lrouters',
module_name='nsxlib.router'), module_name='nsxlib.mh.router'),
return_value=[]): return_value=[]):
self._verify_get_nsx_router_id(None) self._verify_get_nsx_router_id(None)
@ -296,7 +296,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
exp_sec_prof_uuid = uuidutils.generate_uuid() exp_sec_prof_uuid = uuidutils.generate_uuid()
self._mock_sec_group_mapping_db_calls(None) self._mock_sec_group_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('query_security_profiles', 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}]): return_value=[{'uuid': exp_sec_prof_uuid}]):
self._verify_get_nsx_sec_profile_id(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 # are not found both in the db and in the backend
self._mock_sec_group_mapping_db_calls(None) self._mock_sec_group_mapping_db_calls(None)
with mock.patch(vmware.nsx_method('query_security_profiles', with mock.patch(vmware.nsx_method('query_security_profiles',
module_name='nsxlib.secgroup'), module_name='nsxlib.mh.secgroup'),
return_value=[]): return_value=[]):
self._verify_get_nsx_sec_profile_id(None) self._verify_get_nsx_sec_profile_id(None)