From c9610db6c4d573568bd4b6dc390df99349b0a4ea Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 08:48:50 -0500 Subject: ComputeAPI -> compute.API in bin/nova-direct-api. Fixes LP#704422 --- bin/nova-direct-api | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-direct-api b/bin/nova-direct-api index e7dd14fb2..173b39bdb 100755 --- a/bin/nova-direct-api +++ b/bin/nova-direct-api @@ -49,7 +49,7 @@ if __name__ == '__main__': utils.default_flagfile() FLAGS(sys.argv) - direct.register_service('compute', compute_api.ComputeAPI()) + direct.register_service('compute', compute_api.API()) direct.register_service('reflect', direct.Reflection()) router = direct.Router() with_json = direct.JsonParamsMiddleware(router) -- cgit From 785c5df3d17bb158ef2c1a66ce59ee8e6d4236b1 Mon Sep 17 00:00:00 2001 From: "jaypipes@gmail.com" <> Date: Tue, 18 Jan 2011 10:24:20 -0500 Subject: Removes circular import issues from bin/stack and replaces utils.loads with json.loads. Fixes Bug#704424 --- bin/stack | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/stack b/bin/stack index 7a6ce5960..25caca06f 100755 --- a/bin/stack +++ b/bin/stack @@ -22,6 +22,7 @@ import eventlet eventlet.monkey_patch() +import json import os import pprint import sys @@ -38,7 +39,6 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) import gflags -from nova import utils FLAGS = gflags.FLAGS @@ -106,8 +106,12 @@ def do_request(controller, method, params=None): 'X-OpenStack-Project': FLAGS.project} req = urllib2.Request(url, data, headers) - resp = urllib2.urlopen(req) - return utils.loads(resp.read()) + try: + resp = urllib2.urlopen(req) + except urllib2.HTTPError, e: + print e.read() + sys.exit(1) + return json.loads(resp.read()) if __name__ == '__main__': -- cgit From 25f9c308714a41c93450ae4c5b14e90615d75425 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 13:46:06 -0800 Subject: fixes related to #701749. Also, added nova-manage commands to recover from certain states: # Delete a volume that is in an error state nova-manage cleanup delete_volume vol-id # reattach a volume. this is typically required after a host reboot nova-manage cleanup reattach_volume vol-id --- bin/nova-manage | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 1ad3120b8..f8523f18b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -80,7 +80,9 @@ from nova import exception from nova import flags from nova import log as logging from nova import quota +from nova import rpc from nova import utils +from nova.api.ec2.cloud import ec2_id_to_id from nova.auth import manager from nova import rpc from nova.cloudpipe import pipelib @@ -597,6 +599,45 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) +class CleanupCommands(object): + """Methods for dealing with a cloud in an odd state""" + + def delete_volume(self, volume_id): + """Delete a volume, bypassing the check that it + must be available. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + host = volume['host'] + if volume['status'] == 'in-use': + print "Volume is in-use." + print "Detach volume from instance and then try again." + return + + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.volume_topic, host), + {"method": "delete_volume", + "args": {"volume_id": volume['id']}}) + + def reattach_volume(self, volume_id): + """Re-attach a volume that has previously been attached + to an instance. Typically called after a compute host + has been rebooted. + args: volume_id_id""" + ctxt = context.get_admin_context() + volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + if not volume['instance_id']: + print "volume is not attached to an instance" + return + instance = db.instance_get(ctxt, volume['instance_id']) + host = instance['host'] + rpc.cast(ctxt, + db.queue_get_for(ctxt, FLAGS.compute_topic, host), + {"method": "attach_volume", + "args": {"instance_id": instance['id'], + "volume_id": volume['id'], + "mountpoint": volume['mountpoint']}}) + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), @@ -608,7 +649,8 @@ CATEGORIES = [ ('instance', InstanceCommands), ('host', HostCommands), ('service', ServiceCommands), - ('log', LogCommands)] + ('log', LogCommands), + ('cleanup', CleanupCommands)] def lazy_match(name, key_value_tuples): -- cgit From a0af78323131b05a76eb7959df38f6a18e2b39ed Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 14:17:54 -0800 Subject: s/cleanup/volume. volume commands will need their own ns in the long run --- bin/nova-manage | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index f8523f18b..3e4f28fe5 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -599,10 +599,10 @@ class LogCommands(object): print re.sub('#012', "\n", "\n".join(lines)) -class CleanupCommands(object): +class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" - def delete_volume(self, volume_id): + def delete(self, volume_id): """Delete a volume, bypassing the check that it must be available. args: volume_id_id""" @@ -619,7 +619,7 @@ class CleanupCommands(object): {"method": "delete_volume", "args": {"volume_id": volume['id']}}) - def reattach_volume(self, volume_id): + def reattach(self, volume_id): """Re-attach a volume that has previously been attached to an instance. Typically called after a compute host has been rebooted. @@ -650,7 +650,7 @@ CATEGORIES = [ ('host', HostCommands), ('service', ServiceCommands), ('log', LogCommands), - ('cleanup', CleanupCommands)] + ('volume', VolumeCommands)] def lazy_match(name, key_value_tuples): -- cgit From 76a4d683d973c7f8120ae6b409d9fd9c09a3ab98 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Tue, 18 Jan 2011 16:12:52 -0800 Subject: per vish's feedback, allow admin to specify volume id in any of the acceptable manners (vol-, volume-, and int) Also, have manager only attempt to export volumes that are in-use or available --- bin/nova-manage | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 3e4f28fe5..654a13820 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -98,6 +98,16 @@ flags.DECLARE('vpn_start', 'nova.network.manager') flags.DECLARE('fixed_range_v6', 'nova.network.manager') +def param2id(object_id): + """Helper function to convert various id types to internal id. + args: [object_id], e.g. 'vol-0000000a' or 'volume-0000000a' or '10' + """ + if '-' in object_id: + return ec2_id_to_id(object_id) + else: + return int(object_id) + + class VpnCommands(object): """Class for managing VPNs.""" @@ -607,7 +617,7 @@ class VolumeCommands(object): must be available. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) host = volume['host'] if volume['status'] == 'in-use': print "Volume is in-use." @@ -625,7 +635,7 @@ class VolumeCommands(object): has been rebooted. args: volume_id_id""" ctxt = context.get_admin_context() - volume = db.volume_get(ctxt, ec2_id_to_id(volume_id)) + volume = db.volume_get(ctxt, param2id(volume_id)) if not volume['instance_id']: print "volume is not attached to an instance" return -- cgit From 68c9c8930038fe3af3092f3de75591146d57c9e4 Mon Sep 17 00:00:00 2001 From: Ed Leafe Date: Tue, 18 Jan 2011 21:00:28 -0500 Subject: Completed first pass at converting all localized strings with multiple format substitutions. --- bin/nova-api | 2 +- bin/nova-dhcpbridge | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 7b4fbeab1..605f0067c 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -55,7 +55,7 @@ def run_app(paste_config_file): if config is None: LOG.debug(_("No paste configuration for app: %s"), api) continue - LOG.debug(_("App Config: %s\n%r"), api, config) + LOG.debug(_("App Config: %(api)s\n%(config)r") % locals()) wsgi.paste_config_to_flags(config, { "verbose": FLAGS.verbose, "%s_host" % api: config.get('host', '0.0.0.0'), diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 1a994d956..b2c706bd8 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -120,9 +120,9 @@ def main(): mac = argv[2] ip = argv[3] hostname = argv[4] - LOG.debug(_("Called %s for mac %s with ip %s and " - "hostname %s on interface %s"), - action, mac, ip, hostname, interface) + msg = _("Called %(action)s for mac %(mac)s with ip %(ip)s and" + " hostname %(hostname)s on interface %(interface)s") % locals() + LOG.debug(msg) globals()[action + '_lease'](mac, ip, hostname, interface) else: print init_leases(interface) -- cgit From 6ef429d425b82db6dc87fa40241d97bea897bd23 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Jan 2011 12:26:19 +0100 Subject: Also print version at nova-api startup, for consistency --- bin/nova-api | 3 +++ 1 file changed, 3 insertions(+) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 7b4fbeab1..44bbfaf86 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -36,6 +36,7 @@ gettext.install('nova', unicode=1) from nova import flags from nova import log as logging +from nova import version from nova import wsgi logging.basicConfig() @@ -79,6 +80,8 @@ def run_app(paste_config_file): if __name__ == '__main__': FLAGS(sys.argv) + LOG.audit(_("Starting nova-api node (version %s)"), + version.version_string_with_vcs()) conf = wsgi.paste_config_file('nova-api.conf') if conf: run_app(conf) -- cgit From be58eddf4d254db3d225bfa3740cf4d19c7c22db Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Mon, 24 Jan 2011 12:07:12 -0600 Subject: changed nova-manage to use named arguments to net_manager.create_networks --- bin/nova-manage | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index a347e86ce..1c885f8a6 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -473,9 +473,12 @@ class NetworkCommands(object): fixed_range_v6 = FLAGS.fixed_range_v6 net_manager = utils.import_object(FLAGS.network_manager) net_manager.create_networks(context.get_admin_context(), - fixed_range, int(num_networks), - int(network_size), int(vlan_start), - int(vpn_start), fixed_range_v6) + cidr=fixed_range, + num_networks=int(num_networks), + network_size=int(network_size), + vlan_start=int(vlan_start), + vpn_start=int(vpn_start), + cidr_v6=fixed_range_v6) class ServiceCommands(object): -- cgit From 6e7364cb00fd33e82d87aa2006be1b512ae35cc2 Mon Sep 17 00:00:00 2001 From: John Dewey Date: Mon, 24 Jan 2011 18:31:04 -0800 Subject: Updated a couple data structures to pass pep8. --- bin/nova-spoolsentry | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry index ab20268a9..325e92191 100644 --- a/bin/nova-spoolsentry +++ b/bin/nova-spoolsentry @@ -74,10 +74,8 @@ class SpoolSentry(object): return rv def send_data(self, data): - data = { - 'data': base64.b64encode(pickle.dumps(data).encode('zlib')), - 'key': self.key - } + data = {'data': base64.b64encode(pickle.dumps(data).encode('zlib')), + 'key': self.key} req = urllib2.Request(self.sentry_url) res = urllib2.urlopen(req, urllib.urlencode(data)) if res.getcode() != 200: -- cgit From c0514b68b03b4409fd553c08e4599ef153a2875d Mon Sep 17 00:00:00 2001 From: John Dewey Date: Mon, 24 Jan 2011 18:39:47 -0800 Subject: corrected nesting of the data dictionary --- bin/nova-spoolsentry | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry index 325e92191..c53482852 100644 --- a/bin/nova-spoolsentry +++ b/bin/nova-spoolsentry @@ -75,7 +75,7 @@ class SpoolSentry(object): def send_data(self, data): data = {'data': base64.b64encode(pickle.dumps(data).encode('zlib')), - 'key': self.key} + 'key': self.key} req = urllib2.Request(self.sentry_url) res = urllib2.urlopen(req, urllib.urlencode(data)) if res.getcode() != 200: -- cgit