From: armando-migliaccio Date: Tue, 31 Dec 2013 16:08:24 +0000 (-0800) Subject: Rename check_nvp_config utility tool X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=34c42166176b7b90871b485e6dafd6c815ba0e3d;p=openstack-build%2Fneutron-build.git Rename check_nvp_config utility tool Add new entry point whilst preserving the old ones for backward compatibility. Partial-implements blueprint nicira-plugin-renaming Change-Id: I3c5b5dcd316df3867f434bbc35483a2636b715d8 --- diff --git a/neutron/plugins/nicira/check_nvp_config.py b/neutron/plugins/nicira/check_nsx_config.py similarity index 75% rename from neutron/plugins/nicira/check_nvp_config.py rename to neutron/plugins/nicira/check_nsx_config.py index 628892216..2b69131b3 100644 --- a/neutron/plugins/nicira/check_nvp_config.py +++ b/neutron/plugins/nicira/check_nsx_config.py @@ -1,6 +1,6 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2013 Nicira, Inc. +# Copyright 2013 VMware, Inc. # All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -14,9 +14,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# -# -# @author: Aaron Rosen, VMware from __future__ import print_function @@ -33,21 +30,41 @@ config.setup_logging(cfg.CONF) def help(name): - print("Usage: %s path/to/nvp.ini" % name) + print("Usage: %s path/to/neutron/plugin/ini/config/file" % name) sys.exit(1) +def get_nsx_controllers(cluster): + return cluster.nvp_controllers + + +def config_helper(config_entity, cluster): + try: + return nvplib.do_request('GET', + "/ws.v1/%s?fields=uuid" % config_entity, + cluster=cluster).get('results', []) + except Exception as e: + msg = (_("Error '%(err)s' when connecting to controller(s): %(ctl)s.") + % {'err': str(e), + 'ctl': ', '.join(get_nsx_controllers(cluster))}) + raise Exception(msg) + + +def get_control_cluster_nodes(cluster): + return config_helper("control-cluster/node", cluster) + + def get_gateway_services(cluster): ret_gw_services = {"L2GatewayServiceConfig": [], "L3GatewayServiceConfig": []} - gw_services = nvplib.get_gateway_services(cluster).get('results', []) + gw_services = config_helper("gateway-service", cluster) for gw_service in gw_services: ret_gw_services[gw_service['type']].append(gw_service['uuid']) return ret_gw_services def get_transport_zones(cluster): - transport_zones = nvplib.get_transport_zones(cluster).get('results') + transport_zones = config_helper("transport-zone", cluster) return [transport_zone['uuid'] for transport_zone in transport_zones] @@ -61,8 +78,8 @@ def main(): print("\tconnection: %s" % cfg.CONF.database.connection) print("\tretry_interval: %d" % cfg.CONF.database.retry_interval) print("\tmax_retries: %d" % cfg.CONF.database.max_retries) - print("----------------------- NVP Options -----------------------") - print("\tNVP Generation Timeout %d" % cfg.CONF.NVP.nvp_gen_timeout) + print("----------------------- NSX Options -----------------------") + print("\tNSX Generation Timeout %d" % cfg.CONF.NVP.nvp_gen_timeout) print("\tNumber of concurrent connections to each controller %d" % cfg.CONF.NVP.concurrent_connections) print("\tmax_lp_per_bridged_ls: %s" % cfg.CONF.NVP.max_lp_per_bridged_ls) @@ -76,15 +93,16 @@ def main(): cfg.CONF, cfg.CONF.NVP.concurrent_connections, cfg.CONF.NVP.nvp_gen_timeout) - num_controllers = len(cluster.nvp_controllers) + nsx_controllers = get_nsx_controllers(cluster) + num_controllers = len(nsx_controllers) print("Number of controllers found: %s" % num_controllers) if num_controllers == 0: print("You must specify at least one controller!") sys.exit(1) - for controller in cluster.nvp_controllers: + get_control_cluster_nodes(cluster) + for controller in nsx_controllers: print("\tController endpoint: %s" % controller) - nvplib.check_cluster_connectivity(cluster) gateway_services = get_gateway_services(cluster) default_gateways = { "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid, @@ -94,9 +112,9 @@ def main(): for uuid in gateway_services[svc_type]: print("\t\tGateway(%s) uuid: %s" % (svc_type, uuid)) if (default_gateways[svc_type] and - default_gateways[svc_type] not in gateway_services): + default_gateways[svc_type] not in gateway_services[svc_type]): print("\t\t\tError: specified default %s gateway (%s) is " - "missing from NVP Gateway Services!" % ( + "missing from NSX Gateway Services!" % ( svc_type, default_gateways[svc_type])) errors += 1 @@ -104,7 +122,7 @@ def main(): print("\tTransport zones: %s" % transport_zones) if cfg.CONF.default_tz_uuid not in transport_zones: print("\t\tError: specified default transport zone " - "(%s) is missing from NVP transport zones!" + "(%s) is missing from NSX transport zones!" % cfg.CONF.default_tz_uuid) errors += 1 diff --git a/neutron/plugins/nicira/nvplib.py b/neutron/plugins/nicira/nvplib.py index 5345b1166..b7b3655ba 100644 --- a/neutron/plugins/nicira/nvplib.py +++ b/neutron/plugins/nicira/nvplib.py @@ -1415,36 +1415,3 @@ def delete_lqueue(cluster, id): # FIXME(salv-orlando): This should not raise QauntumException LOG.exception(_("Failed to delete logical queue")) raise exception.NeutronException() - - -# ----------------------------------------------------------------------------- -# NVP API Calls for check_nvp_config utility -# ----------------------------------------------------------------------------- -def config_helper(http_method, http_uri, cluster): - try: - return do_request(http_method, - http_uri, - cluster=cluster) - except Exception as e: - msg = (_("Error '%(err)s' when connecting to controller(s): %(ctl)s.") - % {'err': str(e), 'ctl': ', '.join(cluster.nvp_controllers)}) - raise Exception(msg) - - -def check_cluster_connectivity(cluster): - """Make sure that we can issue a request to each of the cluster nodes.""" - return config_helper(HTTP_GET, - "/ws.v1/control-cluster", - cluster) - - -def get_gateway_services(cluster): - return config_helper(HTTP_GET, - "/ws.v1/gateway-service?fields=uuid", - cluster) - - -def get_transport_zones(cluster): - return config_helper(HTTP_GET, - "/ws.v1/transport-zone?fields=uuid", - cluster) diff --git a/setup.cfg b/setup.cfg index 636c2a1d3..8714e34ad 100644 --- a/setup.cfg +++ b/setup.cfg @@ -77,7 +77,8 @@ setup-hooks = [entry_points] console_scripts = - neutron-check-nvp-config = neutron.plugins.nicira.check_nvp_config:main + neutron-check-nsx-config = neutron.plugins.nicira.check_nsx_config:main + neutron-check-nvp-config = neutron.plugins.nicira.check_nsx_config:main neutron-db-manage = neutron.db.migration.cli:main neutron-debug = neutron.debug.shell:main neutron-dhcp-agent = neutron.agent.dhcp_agent:main @@ -96,7 +97,7 @@ console_scripts = neutron-server = neutron.server:main neutron-rootwrap = neutron.openstack.common.rootwrap.cmd:main neutron-usage-audit = neutron.cmd.usage_audit:main - quantum-check-nvp-config = neutron.plugins.nicira.check_nvp_config:main + quantum-check-nvp-config = neutron.plugins.nicira.check_nsx_config:main quantum-db-manage = neutron.db.migration.cli:main neutron-vpn-agent = neutron.services.vpn.agent:main quantum-debug = neutron.debug.shell:main