summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-01-25 13:34:50 -0600
committerSandy Walsh <sandy.walsh@rackspace.com>2011-01-25 13:34:50 -0600
commita6052241ec7bce94b81e8d4fa1d43353e4eec51b (patch)
treead4a2dc6a1495bf546d2095ff9f975714ba81421 /bin
parent5ff189808d45582f0799c14eaaec687a3cf8ad5e (diff)
parentb2d0a77c53d1bd108d233e58f68655381cec4e16 (diff)
downloadnova-a6052241ec7bce94b81e8d4fa1d43353e4eec51b.tar.gz
nova-a6052241ec7bce94b81e8d4fa1d43353e4eec51b.tar.xz
nova-a6052241ec7bce94b81e8d4fa1d43353e4eec51b.zip
merge with trunk
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-api5
-rwxr-xr-xbin/nova-dhcpbridge6
-rwxr-xr-xbin/nova-direct-api2
-rwxr-xr-xbin/nova-manage64
-rw-r--r--bin/nova-spoolsentry6
-rwxr-xr-xbin/stack10
6 files changed, 77 insertions, 16 deletions
diff --git a/bin/nova-api b/bin/nova-api
index 7b4fbeab1..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()
@@ -55,7 +56,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'),
@@ -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-dhcpbridge b/bin/nova-dhcpbridge
index 1a994d956..d38ba2543 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)
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..1c885f8a6 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."""
@@ -461,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):
@@ -535,6 +550,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 +600,8 @@ CATEGORIES = [
('network', NetworkCommands),
('service', ServiceCommands),
('log', LogCommands),
- ('db', DbCommands)]
+ ('db', DbCommands),
+ ('volume', VolumeCommands)]
def lazy_match(name, key_value_tuples):
diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry
index ab20268a9..c53482852 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:
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__':