summaryrefslogtreecommitdiff
path: root/openstackclient/compute
diff options
context:
space:
mode:
authorRichard Theis <rtheis@us.ibm.com>2015-12-02 14:43:01 -0600
committerRichard Theis <rtheis@us.ibm.com>2016-01-04 13:49:49 -0600
commit57dac0bc3add71d6c491e2cecc60ef756b75ac32 (patch)
tree5d9194944724b4ff8448649180c5ac4b7ed8e020 /openstackclient/compute
parent74a0b2a1901f8ba31ce9faee7ab18a48c6e558f9 (diff)
downloadpython-openstackclient-57dac0bc3add71d6c491e2cecc60ef756b75ac32.tar.gz
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
Diffstat (limited to 'openstackclient/compute')
-rw-r--r--openstackclient/compute/v2/server.py10
1 files changed, 2 insertions, 8 deletions
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)