From 43b140625be059f7b8194939e01ca44570730e08 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 24 Dec 2017 15:04:14 +0200 Subject: [PATCH] AdminUtils NSX-v3: Add config import Added import for l2 configuration that was missing and cause the core to crash on unknown config. Also added some more v3 unittests for the admin utils to help us catch similar problems in the future Change-Id: Ieb2fde77e0be4e32a0976cdeedb9680fda19001d --- .../shell/admin/plugins/nsxv3/resources/utils.py | 1 + vmware_nsx/tests/unit/shell/test_admin_utils.py | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py index 82c9ff52e0..4d067e9593 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/utils.py @@ -16,6 +16,7 @@ from oslo_config import cfg from neutron.db import db_base_plugin_v2 +from neutron.db import l3_dvr_db # noqa from neutron import manager from neutron_lib import context from neutron_lib.plugins import constants as const diff --git a/vmware_nsx/tests/unit/shell/test_admin_utils.py b/vmware_nsx/tests/unit/shell/test_admin_utils.py index f0e9ed7f79..6d410e30b3 100644 --- a/vmware_nsx/tests/unit/shell/test_admin_utils.py +++ b/vmware_nsx/tests/unit/shell/test_admin_utils.py @@ -278,8 +278,12 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils, """ args = ["dhcp_profile_uuid=e5b9b249-0034-4729-8ab6-fe4dacaa3a12", "metadata_proxy_uuid=e5b9b249-0034-4729-8ab6-fe4dacaa3a12", + "nsx-id=e5b9b249-0034-4729-8ab6-fe4dacaa3a12", + "availability-zone=default", + "server-ip=1.1.1.1" ] # Create some neutron objects for the utilities to run on + self._create_router() with self._create_l3_ext_network() as network: with self.subnet(network=network) as subnet: with self.port(subnet=subnet): @@ -287,6 +291,15 @@ class TestNsxv3AdminUtils(AbstractTestAdminUtils, self._test_resources_with_args( resources.nsxv3_resources, args) + def _create_router(self): + tenant_id = uuidutils.generate_uuid() + data = {'router': {'tenant_id': tenant_id}} + data['router']['name'] = 'dummy' + data['router']['admin_state_up'] = True + + edgeapi = nsxv_utils.NeutronDbClient() + return self._plugin.create_router(edgeapi.context, data) + class TestNsxtvdAdminUtils(AbstractTestAdminUtils):