diff options
| author | Ed Leafe <ed@leafe.com> | 2011-01-21 16:10:26 -0500 |
|---|---|---|
| committer | Ed Leafe <ed@leafe.com> | 2011-01-21 16:10:26 -0500 |
| commit | 09188c61d5359750f9deadcf912f0fa5fbf005b7 (patch) | |
| tree | 53006dc213fc28f8c74179516f109c93603f429a /bin | |
| parent | 75f93d83be59a85b63a267dc22458a133c591f8e (diff) | |
| parent | ec60562b1a6d18e6df4024870468c0501dc692f9 (diff) | |
Resolved trunk merge conflicts
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-api | 3 | ||||
| -rwxr-xr-x | bin/nova-direct-api | 2 | ||||
| -rwxr-xr-x | bin/nova-manage | 55 | ||||
| -rwxr-xr-x | bin/stack | 10 |
4 files changed, 65 insertions, 5 deletions
diff --git a/bin/nova-api b/bin/nova-api index 605f0067c..11176a021 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) 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) diff --git a/bin/nova-manage b/bin/nova-manage index d0901ddfc..a347e86ce 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -79,7 +79,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.cloudpipe import pipelib from nova.db import migration @@ -95,6 +97,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.""" @@ -535,6 +547,46 @@ class DbCommands(object): print migration.db_version() +class VolumeCommands(object): + """Methods for dealing with a cloud in an odd state""" + + def delete(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, param2id(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(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, param2id(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), @@ -545,7 +597,8 @@ CATEGORIES = [ ('network', NetworkCommands), ('service', ServiceCommands), ('log', LogCommands), - ('db', DbCommands)] + ('db', DbCommands), + ('volume', VolumeCommands)] def lazy_match(name, key_value_tuples): @@ -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__': |
