diff --git a/novaclient/client.py b/novaclient/client.py index f4d3bb863..d43e42c5b 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -38,7 +38,8 @@ class HTTPClient(httplib2.Http): USER_AGENT = 'python-novaclient' def __init__(self, user, password, projectid, auth_url, insecure=False, - timeout=None, token=None, region_name=None): + timeout=None, token=None, region_name=None, + endpoint_name='publicURL'): super(HTTPClient, self).__init__(timeout=timeout) self.user = user self.password = password @@ -46,6 +47,7 @@ class HTTPClient(httplib2.Http): self.auth_url = auth_url self.version = 'v1.0' self.region_name = region_name + self.endpoint_name = endpoint_name self.management_url = None self.auth_token = None @@ -155,7 +157,8 @@ class HTTPClient(httplib2.Http): self.auth_token = self.service_catalog.get_token() self.management_url = self.service_catalog.url_for( attr='region', - filter_value=self.region_name) + filter_value=self.region_name, + endpoint_type=self.endpoint_name) return None except KeyError: raise exceptions.AuthorizationFailure() diff --git a/novaclient/shell.py b/novaclient/shell.py index 1afcd0695..5e0eef40b 100644 --- a/novaclient/shell.py +++ b/novaclient/shell.py @@ -78,6 +78,10 @@ class OpenStackComputeShell(object): default=env('NOVA_REGION_NAME'), help='Defaults to env[NOVA_REGION_NAME].') + parser.add_argument('--endpoint_name', + default=env('NOVA_ENDPOINT_NAME'), + help='Defaults to env[NOVA_ENDPOINT_NAME] or "publicURL.') + parser.add_argument('--version', default=env('NOVA_VERSION'), help='Accepts 1.0 or 1.1, defaults to env[NOVA_VERSION].') @@ -153,9 +157,12 @@ class OpenStackComputeShell(object): self.do_help(args) return 0 - user, password, projectid, url, region_name, insecure = \ + user, password, projectid, url, region_name, endpoint_name, insecure =\ args.username, args.password, args.projectid, args.url, \ - args.region_name, args.insecure + args.region_name, args.endpoint_name, args.insecure + + if not endpoint_name: + endpoint_name = 'publicURL' #FIXME(usrleon): Here should be restrict for project id same as # for username or password but for compatibility it is not. @@ -179,8 +186,10 @@ class OpenStackComputeShell(object): "via --url or via" "env[NOVA_URL") - self.cs = self.get_api_class(options.version)(user, password, projectid, - url, insecure, region_name=region_name) + self.cs = self.get_api_class(options.version)(user, password, + projectid, url, insecure, + region_name=region_name, + endpoint_name=endpoint_name) try: self.cs.authenticate() diff --git a/novaclient/v1_0/client.py b/novaclient/v1_0/client.py index 9c3111176..794ed9516 100644 --- a/novaclient/v1_0/client.py +++ b/novaclient/v1_0/client.py @@ -26,7 +26,8 @@ class Client(object): """ def __init__(self, username, password, project_id, auth_url=None, - insecure=False, timeout=None, token=None, region_name=None): + insecure=False, timeout=None, token=None, region_name=None, + endpoint_name='publicURL'): self.accounts = accounts.AccountManager(self) self.backup_schedules = backup_schedules.BackupScheduleManager(self) @@ -45,7 +46,8 @@ class Client(object): insecure=insecure, timeout=timeout, token=token, - region_name=region_name) + region_name=region_name, + endpoint_name=endpoint_name) def authenticate(self): """ diff --git a/novaclient/v1_1/base.py b/novaclient/v1_1/base.py index 67fc5dc57..ba5682768 100644 --- a/novaclient/v1_1/base.py +++ b/novaclient/v1_1/base.py @@ -113,8 +113,7 @@ class BootingManagerWithFind(base.ManagerWithFind): # The mapping is in the format: # :[]:[]:[] # - bdm_dict = { - 'device_name': device_name } + bdm_dict = {'device_name': device_name} mapping_parts = mapping.split(':') id = mapping_parts[0] diff --git a/novaclient/v1_1/client.py b/novaclient/v1_1/client.py index dd07cff05..b89d40478 100644 --- a/novaclient/v1_1/client.py +++ b/novaclient/v1_1/client.py @@ -29,9 +29,10 @@ class Client(object): """ - # FIXME(jesse): project_id isn't required to autenticate + # FIXME(jesse): project_id isn't required to authenticate def __init__(self, username, password, project_id, auth_url, - insecure=False, timeout=None, token=None, region_name=None): + insecure=False, timeout=None, token=None, region_name=None, + endpoint_name='publicURL'): self.flavors = flavors.FlavorManager(self) self.floating_ips = floating_ips.FloatingIPManager(self) self.images = images.ImageManager(self) @@ -54,7 +55,8 @@ class Client(object): insecure=insecure, timeout=timeout, token=token, - region_name=region_name) + region_name=region_name, + endpoint_name=endpoint_name) def authenticate(self): """ diff --git a/novaclient/v1_1/servers.py b/novaclient/v1_1/servers.py index d555ae178..4869f4128 100644 --- a/novaclient/v1_1/servers.py +++ b/novaclient/v1_1/servers.py @@ -355,8 +355,8 @@ class ServerManager(local_base.BootingManagerWithFind): :param key_name: (optional extension) name of previously created keypair to inject into the instance. :param availability_zone: The :class:`Zone`. - :param block_device_mapping: (optional extension) A dict of block device - mappings for this server. + :param block_device_mapping: (optional extension) A dict of block + device mappings for this server. :param nics: (optional extension) an ordered list of nics to be added to this server, with information about connected networks, fixed ips, etc. diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index f13faae33..54e28ba1a 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -115,7 +115,7 @@ def _boot(cs, args, reservation_id=None, min_count=None, max_count=None): for nic_str in args.nics: nic_info = {"net-id": "", "v4-fixed-ip": ""} for kv_str in nic_str.split(","): - k,v = kv_str.split("=") + k, v = kv_str.split("=") nic_info[k] = v nics.append(nic_info) @@ -905,6 +905,7 @@ def do_volume_detach(cs, args): cs.volumes.delete_server_volume(_find_server(cs, args.server).id, args.attachment_id) + def do_volume_snapshot_list(cs, args): """List all the snapshots.""" snapshots = cs.volume_snapshots.list()