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' USER_AGENT = 'python-novaclient'
def __init__(self, user, password, projectid, auth_url, insecure=False, 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) super(HTTPClient, self).__init__(timeout=timeout)
self.user = user self.user = user
self.password = password self.password = password
@ -46,6 +47,7 @@ class HTTPClient(httplib2.Http):
self.auth_url = auth_url self.auth_url = auth_url
self.version = 'v1.0' self.version = 'v1.0'
self.region_name = region_name self.region_name = region_name
self.endpoint_name = endpoint_name
self.management_url = None self.management_url = None
self.auth_token = None self.auth_token = None
@ -155,7 +157,8 @@ class HTTPClient(httplib2.Http):
self.auth_token = self.service_catalog.get_token() self.auth_token = self.service_catalog.get_token()
self.management_url = self.service_catalog.url_for( self.management_url = self.service_catalog.url_for(
attr='region', attr='region',
filter_value=self.region_name) filter_value=self.region_name,
endpoint_type=self.endpoint_name)
return None return None
except KeyError: except KeyError:
raise exceptions.AuthorizationFailure() raise exceptions.AuthorizationFailure()

View File

@ -78,6 +78,10 @@ class OpenStackComputeShell(object):
default=env('NOVA_REGION_NAME'), default=env('NOVA_REGION_NAME'),
help='Defaults to 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', parser.add_argument('--version',
default=env('NOVA_VERSION'), default=env('NOVA_VERSION'),
help='Accepts 1.0 or 1.1, defaults to 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) self.do_help(args)
return 0 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.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 #FIXME(usrleon): Here should be restrict for project id same as
# for username or password but for compatibility it is not. # for username or password but for compatibility it is not.
@ -179,8 +186,10 @@ class OpenStackComputeShell(object):
"via --url or via" "via --url or via"
"env[NOVA_URL") "env[NOVA_URL")
self.cs = self.get_api_class(options.version)(user, password, projectid, self.cs = self.get_api_class(options.version)(user, password,
url, insecure, region_name=region_name) projectid, url, insecure,
region_name=region_name,
endpoint_name=endpoint_name)
try: try:
self.cs.authenticate() self.cs.authenticate()

View File

@ -26,7 +26,8 @@ class Client(object):
""" """
def __init__(self, username, password, project_id, auth_url=None, 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.accounts = accounts.AccountManager(self)
self.backup_schedules = backup_schedules.BackupScheduleManager(self) self.backup_schedules = backup_schedules.BackupScheduleManager(self)
@ -45,7 +46,8 @@ class Client(object):
insecure=insecure, insecure=insecure,
timeout=timeout, timeout=timeout,
token=token, token=token,
region_name=region_name) region_name=region_name,
endpoint_name=endpoint_name)
def authenticate(self): def authenticate(self):
""" """

View File

@ -113,8 +113,7 @@ class BootingManagerWithFind(base.ManagerWithFind):
# The mapping is in the format: # The mapping is in the format:
# <id>:[<type>]:[<size(GB)>]:[<delete_on_terminate>] # <id>:[<type>]:[<size(GB)>]:[<delete_on_terminate>]
# #
bdm_dict = { bdm_dict = {'device_name': device_name}
'device_name': device_name }
mapping_parts = mapping.split(':') mapping_parts = mapping.split(':')
id = mapping_parts[0] 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, 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.flavors = flavors.FlavorManager(self)
self.floating_ips = floating_ips.FloatingIPManager(self) self.floating_ips = floating_ips.FloatingIPManager(self)
self.images = images.ImageManager(self) self.images = images.ImageManager(self)
@ -54,7 +55,8 @@ class Client(object):
insecure=insecure, insecure=insecure,
timeout=timeout, timeout=timeout,
token=token, token=token,
region_name=region_name) region_name=region_name,
endpoint_name=endpoint_name)
def authenticate(self): def authenticate(self):
""" """

View File

@ -355,8 +355,8 @@ class ServerManager(local_base.BootingManagerWithFind):
:param key_name: (optional extension) name of previously created :param key_name: (optional extension) name of previously created
keypair to inject into the instance. keypair to inject into the instance.
:param availability_zone: The :class:`Zone`. :param availability_zone: The :class:`Zone`.
:param block_device_mapping: (optional extension) A dict of block device :param block_device_mapping: (optional extension) A dict of block
mappings for this server. device mappings for this server.
:param nics: (optional extension) an ordered list of nics to be :param nics: (optional extension) an ordered list of nics to be
added to this server, with information about added to this server, with information about
connected networks, fixed ips, etc. 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: for nic_str in args.nics:
nic_info = {"net-id": "", "v4-fixed-ip": ""} nic_info = {"net-id": "", "v4-fixed-ip": ""}
for kv_str in nic_str.split(","): for kv_str in nic_str.split(","):
k,v = kv_str.split("=") k, v = kv_str.split("=")
nic_info[k] = v nic_info[k] = v
nics.append(nic_info) 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, cs.volumes.delete_server_volume(_find_server(cs, args.server).id,
args.attachment_id) args.attachment_id)
def do_volume_snapshot_list(cs, args): def do_volume_snapshot_list(cs, args):
"""List all the snapshots.""" """List all the snapshots."""
snapshots = cs.volume_snapshots.list() snapshots = cs.volume_snapshots.list()