From d76d6c9f1f2e83da86c15e11c3609476a7e0cf1f Mon Sep 17 00:00:00 2001
From: Sandy Walsh <sandy@sandywalsh.com>
Date: Tue, 12 Jul 2011 14:41:56 -0700
Subject: [PATCH] fixed public private ip list

---
 novaclient/__init__.py |  2 +-
 novaclient/client.py   | 10 ++++++++++
 novaclient/servers.py  |  4 ++--
 novaclient/shell.py    |  4 +++-
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/novaclient/__init__.py b/novaclient/__init__.py
index b59970c57..b5ca918f9 100644
--- a/novaclient/__init__.py
+++ b/novaclient/__init__.py
@@ -18,7 +18,7 @@
 novaclient module.
 """
 
-__version__ = '2.4'
+__version__ = '2.5'
 
 from novaclient.accounts import Account, AccountManager
 from novaclient.backup_schedules import (
diff --git a/novaclient/client.py b/novaclient/client.py
index cf3555fc5..d2aef2f6f 100644
--- a/novaclient/client.py
+++ b/novaclient/client.py
@@ -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):
diff --git a/novaclient/servers.py b/novaclient/servers.py
index ce802eb9c..e7ecb0006 100644
--- a/novaclient/servers.py
+++ b/novaclient/servers.py
@@ -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):
diff --git a/novaclient/shell.py b/novaclient/shell.py
index 1dec8ca0e..82ac348b8 100644
--- a/novaclient/shell.py
+++ b/novaclient/shell.py
@@ -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])