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/common/clientmanager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'openstackclient/common/clientmanager.py') diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py index edabf65e..dce19725 100644 --- a/openstackclient/common/clientmanager.py +++ b/openstackclient/common/clientmanager.py @@ -191,6 +191,26 @@ class ClientManager(object): self._auth_ref = self.auth.get_auth_ref(self.session) return self._auth_ref + def is_network_endpoint_enabled(self): + """Check if the network endpoint is enabled""" + # Trigger authentication necessary to determine if the network + # endpoint is enabled. + if self.auth_ref: + service_catalog = self.auth_ref.service_catalog + else: + service_catalog = None + # Assume that the network endpoint is enabled. + network_endpoint_enabled = True + if service_catalog: + if 'network' in service_catalog.get_endpoints(): + LOG.debug("Network endpoint in service catalog") + else: + LOG.debug("No network endpoint in service catalog") + network_endpoint_enabled = False + else: + LOG.debug("No service catalog, assuming network endpoint enabled") + return network_endpoint_enabled + def get_endpoint_for_service_type(self, service_type, region_name=None, interface='public'): """Return the endpoint URL for the service type.""" -- cgit v1.2.1