From 57dac0bc3add71d6c491e2cecc60ef756b75ac32 Mon Sep 17 00:00:00 2001 From: Richard Theis Date: Wed, 2 Dec 2015 14:43:01 -0600 Subject: Refactor network endpoint enablement checking Move the network endpoint enablement checking from the 'server create' command to the common client manager. This allows future network commands to use either nova or neutron networking based on the cloud environment. This patch set also includes related unit test enhancements to the common client manager to trigger authentication on the tests. Change-Id: Ia37e81d4fb05a1e2fceb3e5d367bda769ab8e64b Related-Bug: #1519511 Related-to: blueprint neutron-client --- openstackclient/compute/v2/server.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'openstackclient/compute') diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index be0ad8cb..7afd18f2 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -257,10 +257,6 @@ class CreateServer(show.ShowOne): log = logging.getLogger(__name__ + '.CreateServer') - def _is_neutron_enabled(self): - service_catalog = self.app.client_manager.auth_ref.service_catalog - return 'network' in service_catalog.get_endpoints() - def get_parser(self, prog_name): parser = super(CreateServer, self).get_parser(prog_name) parser.add_argument( @@ -460,8 +456,6 @@ class CreateServer(show.ShowOne): block_device_mapping.update({dev_key: block_volume}) nics = [] - if parsed_args.nic: - neutron_enabled = self._is_neutron_enabled() for nic_str in parsed_args.nic: nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "", "port-id": ""} @@ -471,7 +465,7 @@ class CreateServer(show.ShowOne): msg = _("either net-id or port-id should be specified " "but not both") raise exceptions.CommandError(msg) - if neutron_enabled: + if self.app.client_manager.is_network_endpoint_enabled(): network_client = self.app.client_manager.network if nic_info["net-id"]: net = network_client.find_network( @@ -489,7 +483,7 @@ class CreateServer(show.ShowOne): ).id if nic_info["port-id"]: msg = _("can't create server with port specified " - "since neutron not enabled") + "since network endpoint not enabled") raise exceptions.CommandError(msg) nics.append(nic_info) -- cgit v1.2.1