Permalink
Browse files

refactored --service_name to only work with compute calls and added

--volume_service_name for volume calls

Change-Id: I2b1188fb57f9576daebfaceaddc6eea44a47b4ee
  • Loading branch information...
creiht committed Apr 12, 2012
1 parent d743f92 commit 636f32b00aef03202efc2c7fb16ee36c166f2bfc
Showing with 40 additions and 24 deletions.
  1. +1 −0 AUTHORS
  2. +8 −6 novaclient/client.py
  3. +7 −2 novaclient/service_catalog.py
  4. +10 −4 novaclient/shell.py
  5. +14 −12 novaclient/v1_1/client.py
View
@@ -12,6 +12,7 @@ Chmouel Boudjnah <chmouel.boudjnah@rackspace.co.uk>
Chris Behrens <cbehrens+github@codestud.com>
Christian Berendt <berendt@b1-systems.de>
Christopher MacGown <ignoti+github@gmail.com>
+Chuck Thier <cthier@gmail.com>
Cole Robinson <crobinso@redhat.com>
Dan Prince <dprince@redhat.com>
Dan Wendlandt <dan@nicira.com>
View
@@ -42,7 +42,7 @@ def __init__(self, user, password, projectid, auth_url, insecure=False,
timeout=None, proxy_tenant_id=None,
proxy_token=None, region_name=None,
endpoint_type='publicURL', service_type=None,
- service_name=None):
+ service_name=None, volume_service_name=None):
super(HTTPClient, self).__init__(timeout=timeout)
self.user = user
self.password = password
@@ -53,6 +53,7 @@ def __init__(self, user, password, projectid, auth_url, insecure=False,
self.endpoint_type = endpoint_type
self.service_type = service_type
self.service_name = service_name
+ self.volume_service_name = volume_service_name
self.management_url = None
self.auth_token = None
@@ -159,11 +160,12 @@ def _extract_service_catalog(self, url, resp, body, extract_token=True):
self.auth_token = self.service_catalog.get_token()
management_url = self.service_catalog.url_for(
- attr='region',
- filter_value=self.region_name,
- endpoint_type=self.endpoint_type,
- service_type=self.service_type,
- service_name=self.service_name)
+ attr='region',
+ filter_value=self.region_name,
+ endpoint_type=self.endpoint_type,
+ service_type=self.service_type,
+ service_name=self.service_name,
+ volume_service_name=self.volume_service_name,)
self.management_url = management_url.rstrip('/')
return None
except exceptions.AmbiguousEndpoints:
@@ -30,7 +30,7 @@ def get_token(self):
def url_for(self, attr=None, filter_value=None,
service_type=None, endpoint_type='publicURL',
- service_name=None):
+ service_name=None, volume_service_name=None):
"""Fetch the public URL from the Compute service for
a particular endpoint attribute. If none given, return
the first. See tests for sample service catalog."""
@@ -54,7 +54,12 @@ def url_for(self, attr=None, filter_value=None,
if service.get("type") != service_type:
continue
- if service_name and service.get('name') != service_name:
+ if (service_name and service_type == 'compute' and
+ service.get('name') != service_name):
+ continue
+
+ if (volume_service_name and service_type == 'volume' and
+ service.get('name') != volume_service_name):
continue
endpoints = service['endpoints']
View
@@ -113,6 +113,10 @@ def get_base_parser(self):
default=utils.env('NOVA_SERVICE_NAME'),
help='Defaults to env[NOVA_SERVICE_NAME]')
+ parser.add_argument('--volume_service_name',
+ default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
+ help='Defaults to env[NOVA_VOLUME_SERVICE_NAME]')
+
parser.add_argument('--endpoint_type',
default=utils.env('NOVA_ENDPOINT_TYPE',
default=DEFAULT_NOVA_ENDPOINT_TYPE),
@@ -292,14 +296,15 @@ def main(self, argv):
return 0
(os_username, os_password, os_tenant_name, os_auth_url,
- os_region_name, endpoint_type,
- insecure, service_type, service_name,
+ os_region_name, endpoint_type, insecure,
+ service_type, service_name, volume_service_name,
username, apikey, projectid, url, region_name) = (
args.os_username, args.os_password,
args.os_tenant_name, args.os_auth_url,
args.os_region_name, args.endpoint_type,
args.insecure, args.service_type, args.service_name,
- args.username, args.apikey, args.projectid,
+ args.volume_service_name, args.username,
+ args.apikey, args.projectid,
args.url, args.region_name)
if not endpoint_type:
@@ -360,7 +365,8 @@ def main(self, argv):
os_password, os_tenant_name, os_auth_url, insecure,
region_name=os_region_name, endpoint_type=endpoint_type,
extensions=self.extensions, service_type=service_type,
- service_name=service_name)
+ service_name=service_name,
+ volume_service_name=volume_service_name)
try:
if not utils.isunauthenticated(args.func):
View
@@ -44,7 +44,8 @@ def __init__(self, username, api_key, project_id, auth_url,
insecure=False, timeout=None, proxy_tenant_id=None,
proxy_token=None, region_name=None,
endpoint_type='publicURL', extensions=None,
- service_type='compute', service_name=None):
+ service_type='compute', service_name=None,
+ volume_service_name=None):
# FIXME(comstud): Rename the api_key argument above when we
# know it's not being used as keyword argument
password = api_key
@@ -83,17 +84,18 @@ def __init__(self, username, api_key, project_id, auth_url,
extension.manager_class(self))
self.client = client.HTTPClient(username,
- password,
- project_id,
- auth_url,
- insecure=insecure,
- timeout=timeout,
- proxy_token=proxy_token,
- proxy_tenant_id=proxy_tenant_id,
- region_name=region_name,
- endpoint_type=endpoint_type,
- service_type=service_type,
- service_name=service_name)
+ password,
+ project_id,
+ auth_url,
+ insecure=insecure,
+ timeout=timeout,
+ proxy_token=proxy_token,
+ proxy_tenant_id=proxy_tenant_id,
+ region_name=region_name,
+ endpoint_type=endpoint_type,
+ service_type=service_type,
+ service_name=service_name,
+ volume_service_name=volume_service_name)
def authenticate(self):
"""

0 comments on commit 636f32b

Please sign in to comment.