fixed public private ip list

This commit is contained in:
Sandy Walsh 2011-07-12 14:41:56 -07:00
parent 6efed32d28
commit d76d6c9f1f
4 changed files with 16 additions and 4 deletions

@ -18,7 +18,7 @@
novaclient module.
"""
__version__ = '2.4'
__version__ = '2.5'
from novaclient.accounts import Account, AccountManager
from novaclient.backup_schedules import (

@ -34,6 +34,7 @@ class OpenStackClient(httplib2.Http):
self.apikey = apikey
self.projectid = projectid
self.auth_url = auth_url
self.version = 'v1.0'
self.management_url = None
self.auth_token = None
@ -120,12 +121,21 @@ class OpenStackClient(httplib2.Http):
return self._cs_request(url, 'DELETE', **kwargs)
def authenticate(self):
scheme, netloc, path, query, frag = urlparse.urlsplit(
self.auth_url)
path_parts = path.split('/')
for part in path_parts:
if len(part) > 0 and part[0] == 'v':
self.version = part
break
headers = {'X-Auth-User': self.user,
'X-Auth-Key': self.apikey}
if self.projectid:
headers['X-Auth-Project-Id'] = self.projectid
resp, body = self.request(self.auth_url, 'GET', headers=headers)
self.management_url = resp['x-server-management-url']
self.auth_token = resp['x-auth-token']
def _munge_get_url(self, url):

@ -186,7 +186,7 @@ class Server(base.Resource):
"""
if len(self.addresses['public']) == 0:
return ""
return self.addresses['public'][0]
return self.addresses['public']
@property
def private_ip(self):
@ -195,7 +195,7 @@ class Server(base.Resource):
"""
if len(self.addresses['private']) == 0:
return ""
return self.addresses['private'][0]
return self.addresses['private']
class ServerManager(base.BootingManagerWithFind):

@ -853,7 +853,9 @@ def print_list(objs, fields, formatters={}):
if field in formatters:
row.append(formatters[field](o))
else:
row.append(getattr(o, field.lower().replace(' ', '_'), ''))
field_name = field.lower().replace(' ', '_')
data = getattr(o, field_name, '')
row.append(data)
pt.add_row(row)
pt.printt(sortby=fields[0])