From 70fa5320322153f97a334b0163e255a8e05a3fcf Mon Sep 17 00:00:00 2001 From: Boden R Date: Thu, 17 Dec 2015 15:34:45 -0700 Subject: [PATCH] Move python_nsxadmin out of a top-level namespace It is not a good idea to have a top-level "tools" namespace, this name is too generic and already taken in PyPi (see https://pypi.python.org/pypi/tools). This patch moves python_nsxadmin to the vmware_nsx.tools namespace, adjusting all imports and making sure setup.cfg is adapted accordingly. Change-Id: I75922db2010194fe59db424cc4615c7ba57c1b81 --- setup.cfg | 3 +-- tools/python_nsxadmin/admin/__init__.py | 18 ------------------ vmware_nsx/shell/__init__.py | 5 ++++- .../shell/admin}/README.rst | 0 .../shell/admin}/__init__.py | 0 .../shell}/admin/plugins/__init__.py | 0 .../shell}/admin/plugins/common/__init__.py | 0 .../shell}/admin/plugins/common/constants.py | 0 .../shell}/admin/plugins/common/formatters.py | 0 .../shell}/admin/plugins/common/utils.py | 0 .../shell}/admin/plugins/nsxv/__init__.py | 0 .../admin/plugins/nsxv/resources/__init__.py | 0 .../plugins/nsxv/resources/backup_edges.py | 10 +++++----- .../plugins/nsxv/resources/dhcp_binding.py | 8 ++++---- .../admin/plugins/nsxv/resources/edges.py | 10 +++++----- .../nsxv/resources/spoofguard_policy.py | 10 +++++----- .../admin/plugins/nsxv/resources/utils.py | 0 .../shell}/admin/plugins/nsxv3/__init__.py | 0 .../admin/plugins/nsxv3/resources/__init__.py | 0 .../plugins/nsxv3/resources/securitygroups.py | 8 ++++---- .../shell}/admin/version.py | 0 .../shell.py => vmware_nsx/shell/nsxadmin.py | 8 ++++---- 22 files changed, 32 insertions(+), 48 deletions(-) delete mode 100644 tools/python_nsxadmin/admin/__init__.py rename {tools/python_nsxadmin => vmware_nsx/shell/admin}/README.rst (100%) rename {tools/python_nsxadmin => vmware_nsx/shell/admin}/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/common/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/common/constants.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/common/formatters.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/common/utils.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/backup_edges.py (91%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/dhcp_binding.py (94%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/edges.py (94%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/spoofguard_policy.py (91%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv/resources/utils.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv3/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv3/resources/__init__.py (100%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/plugins/nsxv3/resources/securitygroups.py (96%) rename {tools/python_nsxadmin => vmware_nsx/shell}/admin/version.py (100%) rename tools/python_nsxadmin/admin/shell.py => vmware_nsx/shell/nsxadmin.py (97%) diff --git a/setup.cfg b/setup.cfg index 668fac555d..118cc202fb 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,14 +21,13 @@ classifier = [files] packages = vmware_nsx - tools data_files = etc/neutron/plugins/vmware = etc/nsx.ini [entry_points] console_scripts = neutron-check-nsx-config = vmware_nsx.check_nsx_config:main - nsxadmin = tools.python_nsxadmin.admin.shell:main + nsxadmin = vmware_nsx.shell.nsxadmin:main neutron.db.alembic_migrations = vmware-nsx = vmware_nsx.db.migration:alembic_migrations neutron.core_plugins = diff --git a/tools/python_nsxadmin/admin/__init__.py b/tools/python_nsxadmin/admin/__init__.py deleted file mode 100644 index 60b3a3adbe..0000000000 --- a/tools/python_nsxadmin/admin/__init__.py +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2015 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. - -import logging - -logging.basicConfig(format='%(message)s', level=logging.INFO) -logging.getLogger('requests').setLevel(logging.WARNING) diff --git a/vmware_nsx/shell/__init__.py b/vmware_nsx/shell/__init__.py index b709fdd500..6146996a7e 100644 --- a/vmware_nsx/shell/__init__.py +++ b/vmware_nsx/shell/__init__.py @@ -13,12 +13,15 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - +import logging import sys from neutronclient import shell from vmware_nsx.shell import commands as cmd +logging.basicConfig(format='%(message)s', level=logging.INFO) +logging.getLogger('requests').setLevel(logging.WARNING) + class NsxManage(shell.NeutronShell): diff --git a/tools/python_nsxadmin/README.rst b/vmware_nsx/shell/admin/README.rst similarity index 100% rename from tools/python_nsxadmin/README.rst rename to vmware_nsx/shell/admin/README.rst diff --git a/tools/python_nsxadmin/__init__.py b/vmware_nsx/shell/admin/__init__.py similarity index 100% rename from tools/python_nsxadmin/__init__.py rename to vmware_nsx/shell/admin/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/__init__.py b/vmware_nsx/shell/admin/plugins/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/__init__.py rename to vmware_nsx/shell/admin/plugins/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/common/__init__.py b/vmware_nsx/shell/admin/plugins/common/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/common/__init__.py rename to vmware_nsx/shell/admin/plugins/common/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/common/constants.py b/vmware_nsx/shell/admin/plugins/common/constants.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/common/constants.py rename to vmware_nsx/shell/admin/plugins/common/constants.py diff --git a/tools/python_nsxadmin/admin/plugins/common/formatters.py b/vmware_nsx/shell/admin/plugins/common/formatters.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/common/formatters.py rename to vmware_nsx/shell/admin/plugins/common/formatters.py diff --git a/tools/python_nsxadmin/admin/plugins/common/utils.py b/vmware_nsx/shell/admin/plugins/common/utils.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/common/utils.py rename to vmware_nsx/shell/admin/plugins/common/utils.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/__init__.py b/vmware_nsx/shell/admin/plugins/nsxv/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/nsxv/__init__.py rename to vmware_nsx/shell/admin/plugins/nsxv/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/__init__.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/__init__.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py similarity index 91% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py index 1305343ee8..ada6ac153c 100644 --- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/backup_edges.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/backup_edges.py @@ -15,12 +15,12 @@ import logging -from tools.python_nsxadmin.admin.plugins.common import constants -from tools.python_nsxadmin.admin.plugins.common import formatters +from vmware_nsx.shell.admin.plugins.common import constants +from vmware_nsx.shell.admin.plugins.common import formatters -import tools.python_nsxadmin.admin.plugins.common.utils as admin_utils -import tools.python_nsxadmin.admin.plugins.nsxv.resources.utils as utils -import tools.python_nsxadmin.admin.shell as shell +import vmware_nsx.shell.admin.plugins.common.utils as admin_utils +import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +import vmware_nsx.shell.nsxadmin as shell from neutron.callbacks import registry from neutron.common import exceptions diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/dhcp_binding.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py similarity index 94% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/dhcp_binding.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py index 2bc542fc59..a49b64f2af 100644 --- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/dhcp_binding.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py @@ -16,11 +16,11 @@ import logging import pprint -from tools.python_nsxadmin.admin.plugins.common import constants -import tools.python_nsxadmin.admin.plugins.common.utils as admin_utils -import tools.python_nsxadmin.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.common import constants +import vmware_nsx.shell.admin.plugins.common.utils as admin_utils +import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils -import tools.python_nsxadmin.admin.shell as shell +import vmware_nsx.shell.nsxadmin as shell from neutron.callbacks import registry from neutron.db import db_base_plugin_v2 diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py similarity index 94% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py index fe8cb15ee1..04f4c5cb6a 100644 --- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/edges.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/edges.py @@ -16,12 +16,12 @@ import logging import pprint -from tools.python_nsxadmin.admin.plugins.common import constants -from tools.python_nsxadmin.admin.plugins.common import formatters +from vmware_nsx.shell.admin.plugins.common import constants +from vmware_nsx.shell.admin.plugins.common import formatters -import tools.python_nsxadmin.admin.plugins.common.utils as admin_utils -import tools.python_nsxadmin.admin.plugins.nsxv.resources.utils as utils -import tools.python_nsxadmin.admin.shell as shell +import vmware_nsx.shell.admin.plugins.common.utils as admin_utils +import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +import vmware_nsx.shell.nsxadmin as shell from neutron.callbacks import registry from neutron.common import exceptions diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py similarity index 91% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py index ba23a6d56a..51ed977016 100644 --- a/tools/python_nsxadmin/admin/plugins/nsxv/resources/spoofguard_policy.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/spoofguard_policy.py @@ -15,13 +15,13 @@ import logging -from tools.python_nsxadmin.admin.plugins.common import constants -from tools.python_nsxadmin.admin.plugins.common import formatters -import tools.python_nsxadmin.admin.plugins.common.utils as admin_utils -import tools.python_nsxadmin.admin.plugins.nsxv.resources.utils as utils +from vmware_nsx.shell.admin.plugins.common import constants +from vmware_nsx.shell.admin.plugins.common import formatters -import tools.python_nsxadmin.admin.shell as shell +import vmware_nsx.shell.admin.plugins.common.utils as admin_utils +import vmware_nsx.shell.admin.plugins.nsxv.resources.utils as utils +import vmware_nsx.shell.nsxadmin as shell from neutron.callbacks import registry diff --git a/tools/python_nsxadmin/admin/plugins/nsxv/resources/utils.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/nsxv/resources/utils.py rename to vmware_nsx/shell/admin/plugins/nsxv/resources/utils.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv3/__init__.py b/vmware_nsx/shell/admin/plugins/nsxv3/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/nsxv3/__init__.py rename to vmware_nsx/shell/admin/plugins/nsxv3/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv3/resources/__init__.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/__init__.py similarity index 100% rename from tools/python_nsxadmin/admin/plugins/nsxv3/resources/__init__.py rename to vmware_nsx/shell/admin/plugins/nsxv3/resources/__init__.py diff --git a/tools/python_nsxadmin/admin/plugins/nsxv3/resources/securitygroups.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py similarity index 96% rename from tools/python_nsxadmin/admin/plugins/nsxv3/resources/securitygroups.py rename to vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py index a00c8b8350..8e54f4ec53 100644 --- a/tools/python_nsxadmin/admin/plugins/nsxv3/resources/securitygroups.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/securitygroups.py @@ -14,10 +14,10 @@ import logging -from tools.python_nsxadmin.admin.plugins.common import constants -from tools.python_nsxadmin.admin.plugins.common import formatters -from tools.python_nsxadmin.admin.plugins.common import utils as admin_utils -from tools.python_nsxadmin.admin import shell +from vmware_nsx.shell.admin.plugins.common import constants +from vmware_nsx.shell.admin.plugins.common import formatters +from vmware_nsx.shell.admin.plugins.common import utils as admin_utils +from vmware_nsx.shell import nsxadmin as shell from neutron.callbacks import registry from neutron import context as neutron_context diff --git a/tools/python_nsxadmin/admin/version.py b/vmware_nsx/shell/admin/version.py similarity index 100% rename from tools/python_nsxadmin/admin/version.py rename to vmware_nsx/shell/admin/version.py diff --git a/tools/python_nsxadmin/admin/shell.py b/vmware_nsx/shell/nsxadmin.py similarity index 97% rename from tools/python_nsxadmin/admin/shell.py rename to vmware_nsx/shell/nsxadmin.py index 3562b74e34..e149da8e3f 100644 --- a/tools/python_nsxadmin/admin/shell.py +++ b/vmware_nsx/shell/nsxadmin.py @@ -41,8 +41,8 @@ from vmware_nsx.common import config # noqa from oslo_config import cfg from oslo_log import _options -from tools.python_nsxadmin.admin.plugins.common import constants -from tools.python_nsxadmin.admin import version +from vmware_nsx.shell.admin.plugins.common import constants +from vmware_nsx.shell.admin import version # Suppress the Insecure request warning requests.packages.urllib3.disable_warnings() @@ -110,7 +110,7 @@ def _get_plugin(): def _get_plugin_dir(): - plugin_dir = os.path.dirname(os.path.realpath(__file__)) + "/plugins" + plugin_dir = os.path.dirname(os.path.realpath(__file__)) + "/admin/plugins" return '{}/{}/resources'.format(plugin_dir, _get_plugin()) @@ -151,7 +151,7 @@ def _init_resource_plugin(): for resource in resources: if resource != '__init__': importlib.import_module("." + resource, - "tools.python_nsxadmin.admin.plugins." + "vmware_nsx.shell.admin.plugins." "{}.resources".format(_get_plugin()))