Merge pull request #149 from SandyWalsh/endpoint_name

added --endpoint_name support

Rushed through for gerrit move
This commit is contained in:
Sandy Walsh 2011-11-16 08:49:12 -08:00
commit 007c795a93
7 changed files with 32 additions and 16 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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):
"""

View File

@ -113,8 +113,7 @@ class BootingManagerWithFind(base.ManagerWithFind):
# The mapping is in the format:
# <id>:[<type>]:[<size(GB)>]:[<delete_on_terminate>]
#
bdm_dict = {
'device_name': device_name }
bdm_dict = {'device_name': device_name}
mapping_parts = mapping.split(':')
id = mapping_parts[0]

View File

@ -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):
"""

View File

@ -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.

View File

@ -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()