From 6ad9c5365cb690832f75d455b6c1eb6f54029917 Mon Sep 17 00:00:00 2001 From: Sandy Walsh <sandy@sandywalsh.com> Date: Tue, 15 Feb 2011 11:34:06 -0400 Subject: [PATCH 1/4] get this zone status --- novatools/shell.py | 9 +++++++-- novatools/zones.py | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/novatools/shell.py b/novatools/shell.py index f6ae02d71..4a11f549c 100644 --- a/novatools/shell.py +++ b/novatools/shell.py @@ -484,13 +484,18 @@ class OpenStackShell(object): self._find_server(args.server).delete() # --zone_username is required since --username is already used. - @arg('zone', metavar='<zone>', help='Name or ID of the zone') + @arg('zone', metavar='<zone_id>', help='ID of the zone', default=None) @arg('--api_url', dest='api_url', default=None, help='New URL.') @arg('--zone_username', dest='zone_username', default=None, help='New zone username.') @arg('--password', dest='password', default=None, help='New password.') def do_zone(self, args): - """Show or edit a zone.""" + """Show or edit a child zone. No zone arg for this zone.""" + if args.zone == None: + zone = self.cs.zones.info() + print_dict(zone) + return + zone = self.cs.zones.get(args.zone) # If we have some flags, update the zone diff --git a/novatools/zones.py b/novatools/zones.py index 1a348dcbe..e370123e6 100644 --- a/novatools/zones.py +++ b/novatools/zones.py @@ -25,6 +25,14 @@ class Zone(base.Resource): class ZoneManager(base.ManagerWithFind): resource_class = Zone + def info(self): + """ + Get info on this zone. + + :rtype: :class:`Zone` + """ + return self._get("/zones/", "zone") + def get(self, zone): """ Get a child zone. From 82227aa77f25a0dc629da7435603116378fe7a6a Mon Sep 17 00:00:00 2001 From: Sandy Walsh <sandy@sandywalsh.com> Date: Tue, 15 Feb 2011 11:16:30 -0800 Subject: [PATCH 2/4] zone info works --- novatools/base.py | 3 ++- novatools/shell.py | 10 +++++----- novatools/zones.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/novatools/base.py b/novatools/base.py index fce18553c..10c28d21e 100644 --- a/novatools/base.py +++ b/novatools/base.py @@ -109,7 +109,8 @@ class Resource(object): def get(self): new = self.manager.get(self.id) - self._add_details(new._info) + if new: + self._add_details(new._info) def __eq__(self, other): if not isinstance(other, self.__class__): diff --git a/novatools/shell.py b/novatools/shell.py index 4a11f549c..733cfcf8f 100644 --- a/novatools/shell.py +++ b/novatools/shell.py @@ -491,11 +491,6 @@ class OpenStackShell(object): @arg('--password', dest='password', default=None, help='New password.') def do_zone(self, args): """Show or edit a child zone. No zone arg for this zone.""" - if args.zone == None: - zone = self.cs.zones.info() - print_dict(zone) - return - zone = self.cs.zones.get(args.zone) # If we have some flags, update the zone @@ -511,6 +506,11 @@ class OpenStackShell(object): else: print_dict(zone._info) + def do_zone_info(self, args): + """Get this zones name and capabilities.""" + zone = self.cs.zones.info() + print_dict(zone._info) + @arg('api_url', metavar='<api_url>', help="URL for the Zone's API") @arg('zone_username', metavar='<zone_username>', help='Authentication username.') diff --git a/novatools/zones.py b/novatools/zones.py index e370123e6..3a171cb96 100644 --- a/novatools/zones.py +++ b/novatools/zones.py @@ -31,7 +31,7 @@ class ZoneManager(base.ManagerWithFind): :rtype: :class:`Zone` """ - return self._get("/zones/", "zone") + return self._get("/zones/info", "zone") def get(self, zone): """ From db357e580de1afcdaa0321d64e2bb5f0d68e06d9 Mon Sep 17 00:00:00 2001 From: Sandy Walsh <sandy@sandywalsh.com> Date: Thu, 17 Feb 2011 12:09:24 -0800 Subject: [PATCH 3/4] longer zone list --- novatools/shell.py | 3 ++- novatools/zones.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/novatools/shell.py b/novatools/shell.py index 733cfcf8f..a296e46cc 100644 --- a/novatools/shell.py +++ b/novatools/shell.py @@ -528,7 +528,8 @@ class OpenStackShell(object): def do_zone_list(self, args): """List the children of a zone.""" - print_list(self.cs.zones.list(), ['ID', 'API URL']) + print_list(self.cs.zones.list(), ['ID', 'Name', 'Is Active', + 'Capabilities', 'API URL']) def _find_server(self, server): """Get a server by name or ID.""" diff --git a/novatools/zones.py b/novatools/zones.py index 3a171cb96..b70d429f9 100644 --- a/novatools/zones.py +++ b/novatools/zones.py @@ -2,6 +2,12 @@ from novatools import base class Zone(base.Resource): + def __init__(self, manager, info): + self.name = "n/a" + self.is_active = "n/a" + self.capabilities = "n/a" + super(Zone, self).__init__(manager, info) + def __repr__(self): return "<Zone: %s>" % self.api_url From c65a0a186771a0d8248f0213e77cc77025fbbaeb Mon Sep 17 00:00:00 2001 From: Sandy Walsh <sandy@sandywalsh.com> Date: Thu, 17 Feb 2011 17:56:16 -0400 Subject: [PATCH 4/4] fixed setup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d3b33a6eb..f3ec70cfb 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ if sys.version_info < (2,6): setup( name = "python-novatools", - version = "1.2", + version = "2.0", description = "Client library for OpenStack Nova API", long_description = read('README.rst'), url = 'https://github.com/rackspace/python-novatools',