diff --git a/neutronclient/client.py b/neutronclient/client.py index 3a153b018..49db9c6f1 100644 --- a/neutronclient/client.py +++ b/neutronclient/client.py @@ -99,6 +99,7 @@ class HTTPClient(httplib2.Http): endpoint_url=None, insecure=False, endpoint_type='publicURL', auth_strategy='keystone', ca_cert=None, log_credentials=False, + service_type='network', **kwargs): super(HTTPClient, self).__init__(timeout=timeout, ca_certs=ca_cert) @@ -107,6 +108,7 @@ class HTTPClient(httplib2.Http): self.tenant_id = tenant_id self.password = password self.auth_url = auth_url.rstrip('/') if auth_url else None + self.service_type = service_type self.endpoint_type = endpoint_type self.region_name = region_name self.auth_token = token @@ -212,6 +214,7 @@ class HTTPClient(httplib2.Http): if not self.endpoint_url: self.endpoint_url = self.service_catalog.url_for( attr='region', filter_value=self.region_name, + service_type=self.service_type, endpoint_type=self.endpoint_type) def authenticate(self): diff --git a/neutronclient/common/clientmanager.py b/neutronclient/common/clientmanager.py index 62cc12932..b36d21e5a 100644 --- a/neutronclient/common/clientmanager.py +++ b/neutronclient/common/clientmanager.py @@ -60,10 +60,12 @@ class ClientManager(object): insecure=False, ca_cert=None, log_credentials=False, + service_type=None, ): self._token = token self._url = url self._auth_url = auth_url + self._service_type = service_type self._endpoint_type = endpoint_type self._tenant_name = tenant_name self._tenant_id = tenant_id @@ -87,6 +89,7 @@ class ClientManager(object): password=self._password, region_name=self._region_name, auth_url=self._auth_url, + service_type=self._service_type, endpoint_type=self._endpoint_type, insecure=self._insecure, ca_cert=self._ca_cert, diff --git a/neutronclient/shell.py b/neutronclient/shell.py index 971860446..91e3e8a7a 100644 --- a/neutronclient/shell.py +++ b/neutronclient/shell.py @@ -414,6 +414,11 @@ class NeutronShell(app.App): '--os_token', help=argparse.SUPPRESS) + parser.add_argument( + '--service-type', metavar='<service-type>', + default=env('OS_NETWORK_SERVICE_TYPE', default='network'), + help=_('Defaults to env[OS_NETWORK_SERVICE_TYPE] or network.')) + parser.add_argument( '--endpoint-type', metavar='<endpoint-type>', default=env('OS_ENDPOINT_TYPE', default='publicURL'), @@ -605,6 +610,7 @@ class NeutronShell(app.App): region_name=self.options.os_region_name, api_version=self.api_version, auth_strategy=self.options.os_auth_strategy, + service_type=self.options.service_type, endpoint_type=self.options.endpoint_type, insecure=self.options.insecure, ca_cert=self.options.os_cacert, diff --git a/neutronclient/tests/unit/test_ssl.py b/neutronclient/tests/unit/test_ssl.py index 0fefb7868..9f3970dd5 100644 --- a/neutronclient/tests/unit/test_ssl.py +++ b/neutronclient/tests/unit/test_ssl.py @@ -51,6 +51,7 @@ class TestSSL(testtools.TestCase): api_version=mox.IgnoreArg(), auth_strategy=mox.IgnoreArg(), auth_url=mox.IgnoreArg(), + service_type=mox.IgnoreArg(), endpoint_type=mox.IgnoreArg(), insecure=mox.IgnoreArg(), password=mox.IgnoreArg(), @@ -80,6 +81,7 @@ class TestSSL(testtools.TestCase): api_version=mox.IgnoreArg(), auth_strategy=mox.IgnoreArg(), auth_url=mox.IgnoreArg(), + service_type=mox.IgnoreArg(), endpoint_type=mox.IgnoreArg(), insecure=mox.IgnoreArg(), password=mox.IgnoreArg(), diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py index 99ff6e2f9..c4e888fc0 100644 --- a/neutronclient/v2_0/client.py +++ b/neutronclient/v2_0/client.py @@ -123,6 +123,8 @@ class Client(object): :param string tenant_name: Tenant name. (optional) :param string tenant_id: Tenant id. (optional) :param string auth_url: Keystone service endpoint for authorization. + :param string service_type: Network service type to pull from the + keystone catalog (e.g. 'network') (optional) :param string endpoint_type: Network service endpoint type to pull from the keystone catalog (e.g. 'publicURL', 'internalURL', or 'adminURL') (optional)