diff options
| author | Richard Theis <rtheis@us.ibm.com> | 2015-12-02 14:43:01 -0600 |
|---|---|---|
| committer | Richard Theis <rtheis@us.ibm.com> | 2016-01-04 13:49:49 -0600 |
| commit | 57dac0bc3add71d6c491e2cecc60ef756b75ac32 (patch) | |
| tree | 5d9194944724b4ff8448649180c5ac4b7ed8e020 /openstackclient/common/clientmanager.py | |
| parent | 74a0b2a1901f8ba31ce9faee7ab18a48c6e558f9 (diff) | |
| download | python-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/common/clientmanager.py')
| -rw-r--r-- | openstackclient/common/clientmanager.py | 20 |
1 files changed, 20 insertions, 0 deletions
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.""" |
