From 4227264153e06d576387f76b267f3d35ff17f391 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Sat, 2 Jul 2011 01:28:13 +0400 Subject: Improvements to nova-manage: network list now includes vlan and projectID, added servers list filtered by zone if needed --- bin/nova-manage | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7dfe91698..8ba78a56a 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -615,15 +615,19 @@ class NetworkCommands(object): def list(self): """List all created networks""" - print "%-18s\t%-15s\t%-15s\t%-15s" % (_('network'), - _('netmask'), - _('start address'), - 'DNS') + print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (_('network'), + _('netmask'), + _('start address'), + _('DNS'), + _('VlanID'), + 'project') for network in db.network_get_all(context.get_admin_context()): - print "%-18s\t%-15s\t%-15s\t%-15s" % (network.cidr, - network.netmask, - network.dhcp_start, - network.dns) + print "%-18s\t%-15s\t%-15s\t%-15s\t%-15s\t%-15s" % (network.cidr, + network.netmask, + network.dhcp_start, + network.dns, + network.vlan, + network.project_id) def delete(self, fixed_range): """Deletes a network""" @@ -812,6 +816,28 @@ class ServiceCommands(object): {"method": "update_available_resource"}) +class ServerCommands(object): + """List servers""" + + def list(self, zone=None): + """Show a list of all servers. Filter by zone. + args: [zone]""" + print "%-25s\t%-15s" % (_('host'), + _('zone')) + ctxt = context.get_admin_context() + now = utils.utcnow() + services = db.service_get_all(ctxt) + if zone: + services = [s for s in services if s['availability_zone'] == zone] + servers = [] + for srv in services: + if not [s for s in servers if s['host'] == srv['host']]: + servers.append(srv) + + for srv in servers: + print "%-25s\t%-15s" % (srv['host'], srv['availability_zone']) + + class DbCommands(object): """Class for managing the database.""" @@ -1191,6 +1217,7 @@ CATEGORIES = [ ('project', ProjectCommands), ('role', RoleCommands), ('service', ServiceCommands), + ('server', ServerCommands), ('shell', ShellCommands), ('user', UserCommands), ('version', VersionCommands), -- cgit From 915c7d52fa1b2afe6af9686210982d5bc043be97 Mon Sep 17 00:00:00 2001 From: Mike Scherbakov Date: Tue, 12 Jul 2011 11:07:30 -0700 Subject: Renamed 'nova-manage server list' -> 'nova-manage host list' to differentiate physical hosts from VMs --- bin/nova-manage | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 8ba78a56a..94ab22092 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -816,11 +816,11 @@ class ServiceCommands(object): {"method": "update_available_resource"}) -class ServerCommands(object): - """List servers""" +class HostCommands(object): + """List hosts""" def list(self, zone=None): - """Show a list of all servers. Filter by zone. + """Show a list of all physical hosts. Filter by zone. args: [zone]""" print "%-25s\t%-15s" % (_('host'), _('zone')) @@ -829,13 +829,13 @@ class ServerCommands(object): services = db.service_get_all(ctxt) if zone: services = [s for s in services if s['availability_zone'] == zone] - servers = [] + hosts = [] for srv in services: - if not [s for s in servers if s['host'] == srv['host']]: - servers.append(srv) + if not [h for h in hosts if h['host'] == srv['host']]: + hosts.append(srv) - for srv in servers: - print "%-25s\t%-15s" % (srv['host'], srv['availability_zone']) + for h in hosts: + print "%-25s\t%-15s" % (h['host'], h['availability_zone']) class DbCommands(object): @@ -1211,13 +1211,13 @@ CATEGORIES = [ ('fixed', FixedIpCommands), ('flavor', InstanceTypeCommands), ('floating', FloatingIpCommands), + ('host', HostCommands), ('instance_type', InstanceTypeCommands), ('image', ImageCommands), ('network', NetworkCommands), ('project', ProjectCommands), ('role', RoleCommands), ('service', ServiceCommands), - ('server', ServerCommands), ('shell', ShellCommands), ('user', UserCommands), ('version', VersionCommands), -- cgit From b9ea0f43c186d5fbc232b0ddd11c3e64898136ab Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 17:16:27 -0400 Subject: support '-' to indicate stdout in nova-manage project 'environment' and 'zip' This just adds support to do: nova-manage project zip test-project admin - > out.zip nova-manage project environment test-project admin - | grep NOVA_URL --- bin/nova-manage | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7dfe91698..b5247f8c3 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -414,8 +414,11 @@ class ProjectCommands(object): except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise - with open(filename, 'w') as f: - f.write(rc) + if filename == "-": + f = sys.stdout + else: + f = open(filename, 'w') + f.write(rc) def list(self, username=None): """Lists all projects @@ -465,8 +468,11 @@ class ProjectCommands(object): arguments: project_id user_id [filename='nova.zip]""" try: zip_file = self.manager.get_credentials(user_id, project_id) - with open(filename, 'w') as f: - f.write(zip_file) + if filename == "-": + f = sys.stdout + else: + f = open(filename, 'w') + f.write(zip_file) except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise -- cgit From 7ed74cb999483e589e186944cb9116f507dbe60d Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 13 Jul 2011 22:01:52 -0400 Subject: use 'with' so that close is called on file handle --- bin/nova-manage | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index b5247f8c3..a83fe70f8 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -415,10 +415,10 @@ class ProjectCommands(object): print ex raise if filename == "-": - f = sys.stdout + sys.stdout.write(rc) else: - f = open(filename, 'w') - f.write(rc) + with open(filename, 'w') as f: + f.write(rc) def list(self, username=None): """Lists all projects @@ -469,10 +469,10 @@ class ProjectCommands(object): try: zip_file = self.manager.get_credentials(user_id, project_id) if filename == "-": - f = sys.stdout + sys.stdout.write(zip_file) else: - f = open(filename, 'w') - f.write(zip_file) + with open(filename, 'w') as f: + f.write(zip_file) except (exception.UserNotFound, exception.ProjectNotFound) as ex: print ex raise -- cgit