summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorChristian Berendt <berendt@b1-systems.de>2011-03-16 17:06:30 +0000
committerTarmac <>2011-03-16 17:06:30 +0000
commitce205ea2c92de2a77f2c308a71551040fa2444df (patch)
tree748a5e69257e0cf51df9a9acbc306d84f2b2151c /bin
parentd36b4d5f3797521b1c2d13a0d30fe98a0671768e (diff)
parent8b3e35b157c688fd38d5aa0eb10ddef33653003d (diff)
downloadnova-ce205ea2c92de2a77f2c308a71551040fa2444df.tar.gz
nova-ce205ea2c92de2a77f2c308a71551040fa2444df.tar.xz
nova-ce205ea2c92de2a77f2c308a71551040fa2444df.zip
added new class Instances for managaging instances
added new method list in class Instances: # nova-manage instance list instance node type state launched image kernel ramdisk project user zone index i-00000547 XXXXXXX m1.small running 2011-02-18 08:36:37 ami-a03ndz0q ami-0isqekvw testing berendt None 0 i-00000548 XXXXXXX m1.small running 2011-02-18 08:37:17 ami-a03ndz0q ami-0isqekvw testing berendt None 1 i-00000549 XXXXXXX m1.small running 2011-02-18 08:37:52 ami-a03ndz0q ami-0isqekvw testing berendt None 2 # nova-manage instance list ares instance node type state launched image kernel ramdisk project user zone index i-00000c1c ares m1.tiny running 2011-02-26 22:51:40 ami-pus9dj84 ami-zhcv0yyx ami-av96fu30 testing berendt None 1 extended the method list in class FixedIps to lookup ip addresses assigned to a specified node: # nova-manage fixed list ares network IP address MAC address hostname host 192.168.3.0/24 192.168.3.6 02:16:3e:75:d7:9a i-00000c1c ares
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-manage65
1 files changed, 57 insertions, 8 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 2b42dfff5..a4d820209 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -446,10 +446,15 @@ class FixedIpCommands(object):
def list(self, host=None):
"""Lists all fixed ips (optionally by host) arguments: [host]"""
ctxt = context.get_admin_context()
- if host == None:
- fixed_ips = db.fixed_ip_get_all(ctxt)
- else:
- fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host)
+
+ try:
+ if host == None:
+ fixed_ips = db.fixed_ip_get_all(ctxt)
+ else:
+ fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host)
+ except exception.NotFound as ex:
+ print "error: %s" % ex
+ sys.exit(2)
print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (_('network'),
_('IP address'),
@@ -466,9 +471,9 @@ class FixedIpCommands(object):
host = instance['host']
mac_address = instance['mac_address']
print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (
- fixed_ip['network']['cidr'],
- fixed_ip['address'],
- mac_address, hostname, host)
+ fixed_ip['network']['cidr'],
+ fixed_ip['address'],
+ mac_address, hostname, host)
class FloatingIpCommands(object):
@@ -716,6 +721,49 @@ class DbCommands(object):
print migration.db_version()
+class InstanceCommands(object):
+ """Class for managing instances."""
+
+ def list(self, host=None, instance=None):
+ """Show a list of all instances"""
+ print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \
+ " %-10s %-10s %-10s %-5s" % (
+ _('instance'),
+ _('node'),
+ _('type'),
+ _('state'),
+ _('launched'),
+ _('image'),
+ _('kernel'),
+ _('ramdisk'),
+ _('project'),
+ _('user'),
+ _('zone'),
+ _('index'))
+
+ if host == None:
+ instances = db.instance_get_all(context.get_admin_context())
+ else:
+ instances = db.instance_get_all_by_host(
+ context.get_admin_context(), host)
+
+ for instance in instances:
+ print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \
+ " %-10s %-10s %-10s %-5d" % (
+ instance['hostname'],
+ instance['host'],
+ instance['instance_type'],
+ instance['state_description'],
+ instance['launched_at'],
+ instance['image_id'],
+ instance['kernel_id'],
+ instance['ramdisk_id'],
+ instance['project_id'],
+ instance['user_id'],
+ instance['availability_zone'],
+ instance['launch_index'])
+
+
class VolumeCommands(object):
"""Methods for dealing with a cloud in an odd state"""
@@ -1002,7 +1050,8 @@ CATEGORIES = [
('volume', VolumeCommands),
('instance_type', InstanceTypeCommands),
('image', ImageCommands),
- ('flavor', InstanceTypeCommands)]
+ ('flavor', InstanceTypeCommands),
+ ('instance', InstanceCommands)]
def lazy_match(name, key_value_tuples):