summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorTushar Patil <tushar.vitthal.patil@gmail.com>2011-08-17 17:17:47 -0700
committerTushar Patil <tushar.vitthal.patil@gmail.com>2011-08-17 17:17:47 -0700
commitc3ef50fd4b866ec6dc90ad114e36b16c857ca206 (patch)
tree68d6b7c352d7b0a6ab0fc2096486ba983af46ed8 /bin
parent19a4ddaf157ebb388cce37ddc142dfad304b8cf0 (diff)
parentaca07a42fabb7f506cf132b995b4ad0139987b02 (diff)
Merged with trunk and fixed broken testcases
Diffstat (limited to 'bin')
-rwxr-xr-xbin/clear_rabbit_queues73
-rwxr-xr-xbin/nova-dhcpbridge12
-rwxr-xr-xbin/nova-manage62
3 files changed, 130 insertions, 17 deletions
diff --git a/bin/clear_rabbit_queues b/bin/clear_rabbit_queues
new file mode 100755
index 000000000..7a000e5d8
--- /dev/null
+++ b/bin/clear_rabbit_queues
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
+# Copyright (c) 2011 Openstack, LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""Admin/debug script to wipe rabbitMQ (AMQP) queues nova uses.
+ This can be used if you need to change durable options on queues,
+ or to wipe all messages in the queue system if things are in a
+ serious bad way.
+
+"""
+
+import datetime
+import gettext
+import os
+import sys
+import time
+
+# If ../nova/__init__.py exists, add ../ to Python search path, so that
+# it will override what happens to be installed in /usr/(local/)lib/python...
+POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
+ os.pardir,
+ os.pardir))
+if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
+ sys.path.insert(0, POSSIBLE_TOPDIR)
+
+gettext.install('nova', unicode=1)
+
+
+from nova import context
+from nova import exception
+from nova import flags
+from nova import log as logging
+from nova import rpc
+from nova import utils
+
+
+FLAGS = flags.FLAGS
+flags.DEFINE_boolean('delete_exchange', False, 'delete nova exchange too.')
+
+
+def delete_exchange(exch):
+ conn = rpc.create_connection()
+ x = conn.get_channel()
+ x.exchange_delete(exch)
+
+
+def delete_queues(queues):
+ conn = rpc.create_connection()
+ x = conn.get_channel()
+ for q in queues:
+ x.queue_delete(q)
+
+if __name__ == '__main__':
+ utils.default_flagfile()
+ args = flags.FLAGS(sys.argv)
+ logging.setup()
+ delete_queues(args[1:])
+ if FLAGS.delete_exchange:
+ delete_exchange(FLAGS.control_exchange)
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index 621222d8f..a47ea7a76 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -48,7 +48,6 @@ flags.DECLARE('auth_driver', 'nova.auth.manager')
flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('num_networks', 'nova.network.manager')
flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager')
-flags.DEFINE_string('dnsmasq_interface', 'br0', 'Default Dnsmasq interface')
LOG = logging.getLogger('nova.dhcpbridge')
@@ -87,10 +86,10 @@ def del_lease(mac, ip_address, _interface):
"args": {"address": ip_address}})
-def init_leases(interface):
- """Get the list of hosts for an interface."""
+def init_leases(network_id):
+ """Get the list of hosts for a network."""
ctxt = context.get_admin_context()
- network_ref = db.network_get_by_bridge(ctxt, interface)
+ network_ref = db.network_get(ctxt, network_id)
return linux_net.get_dhcp_leases(ctxt, network_ref)
@@ -101,7 +100,8 @@ def main():
argv = FLAGS(sys.argv)
logging.setup()
# check ENV first so we don't break any older deploys
- interface = os.environ.get('DNSMASQ_INTERFACE', FLAGS.dnsmasq_interface)
+ network_id = int(os.environ.get('NETWORK_ID'))
+
if int(os.environ.get('TESTING', '0')):
from nova.tests import fake_flags
@@ -120,7 +120,7 @@ def main():
LOG.debug(msg)
globals()[action + '_lease'](mac, ip, interface)
else:
- print init_leases(interface)
+ print init_leases(network_id)
if __name__ == "__main__":
main()
diff --git a/bin/nova-manage b/bin/nova-manage
index 077a89d6f..8e6419c0b 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -719,7 +719,7 @@ class NetworkCommands(object):
# sanitize other input using FLAGS if necessary
if not num_networks:
num_networks = FLAGS.num_networks
- if not network_size:
+ if not network_size and fixed_range_v4:
fixnet = netaddr.IPNetwork(fixed_range_v4)
each_subnet_size = fixnet.size / int(num_networks)
if each_subnet_size > FLAGS.network_size:
@@ -741,6 +741,9 @@ class NetworkCommands(object):
if not dns1 and FLAGS.flat_network_dns:
dns1 = FLAGS.flat_network_dns
+ if not network_size:
+ network_size = FLAGS.network_size
+
# create the network
net_manager = utils.import_object(FLAGS.network_manager)
net_manager.create_networks(context.get_admin_context(),
@@ -834,11 +837,13 @@ class VmCommands(object):
instance['availability_zone'],
instance['launch_index'])
- @args('--ec2_id', dest='ec2_id', metavar='<ec2 id>', help='EC2 ID')
- @args('--dest', dest='dest', metavar='<Destanation>',
- help='destanation node')
- def live_migration(self, ec2_id, dest):
- """Migrates a running instance to a new machine."""
+ def _migration(self, ec2_id, dest, block_migration=False):
+ """Migrates a running instance to a new machine.
+ :param ec2_id: instance id which comes from euca-describe-instance.
+ :param dest: destination host name.
+ :param block_migration: if True, do block_migration.
+
+ """
ctxt = context.get_admin_context()
instance_id = ec2utils.ec2_id_to_id(ec2_id)
@@ -859,11 +864,28 @@ class VmCommands(object):
{"method": "live_migration",
"args": {"instance_id": instance_id,
"dest": dest,
- "topic": FLAGS.compute_topic}})
+ "topic": FLAGS.compute_topic,
+ "block_migration": block_migration}})
print _('Migration of %s initiated.'
'Check its progress using euca-describe-instances.') % ec2_id
+ @args('--ec2_id', dest='ec2_id', metavar='<ec2 id>', help='EC2 ID')
+ @args('--dest', dest='dest', metavar='<Destanation>',
+ help='destanation node')
+ def live_migration(self, ec2_id, dest):
+ """Migrates a running instance to a new machine."""
+
+ self._migration(ec2_id, dest)
+
+ @args('--ec2_id', dest='ec2_id', metavar='<ec2 id>', help='EC2 ID')
+ @args('--dest', dest='dest', metavar='<Destanation>',
+ help='destanation node')
+ def block_migration(self, ec2_id, dest):
+ """Migrates a running instance to a new machine with storage data."""
+
+ self._migration(ec2_id, dest, True)
+
class ServiceCommands(object):
"""Enable and disable running services"""
@@ -882,6 +904,14 @@ class ServiceCommands(object):
services = [s for s in services if s['host'] == host]
if service:
services = [s for s in services if s['binary'] == service]
+ print_format = "%-16s %-36s %-16s %-10s %-5s %-10s"
+ print print_format % (
+ _('Binary'),
+ _('Host'),
+ _('Zone'),
+ _('Status'),
+ _('State'),
+ _('Updated_At'))
for svc in services:
delta = now - (svc['updated_at'] or svc['created_at'])
alive = (delta.seconds <= 15)
@@ -889,9 +919,9 @@ class ServiceCommands(object):
active = 'enabled'
if svc['disabled']:
active = 'disabled'
- print "%-10s %-10s %-8s %s %s" % (svc['host'], svc['binary'],
- active, art,
- svc['updated_at'])
+ print print_format % (svc['binary'], svc['host'],
+ svc['availability_zone'], active, art,
+ svc['updated_at'])
@args('--host', dest='host', metavar='<host>', help='Host')
@args('--service', dest='service', metavar='<service>',
@@ -937,9 +967,19 @@ class ServiceCommands(object):
mem_u = result['resource']['memory_mb_used']
hdd_u = result['resource']['local_gb_used']
+ cpu_sum = 0
+ mem_sum = 0
+ hdd_sum = 0
print 'HOST\t\t\tPROJECT\t\tcpu\tmem(mb)\tdisk(gb)'
print '%s(total)\t\t\t%s\t%s\t%s' % (host, cpu, mem, hdd)
- print '%s(used)\t\t\t%s\t%s\t%s' % (host, cpu_u, mem_u, hdd_u)
+ print '%s(used_now)\t\t\t%s\t%s\t%s' % (host, cpu_u, mem_u, hdd_u)
+ for p_id, val in result['usage'].items():
+ cpu_sum += val['vcpus']
+ mem_sum += val['memory_mb']
+ hdd_sum += val['local_gb']
+ print '%s(used_max)\t\t\t%s\t%s\t%s' % (host, cpu_sum,
+ mem_sum, hdd_sum)
+
for p_id, val in result['usage'].items():
print '%s\t\t%s\t\t%s\t%s\t%s' % (host,
p_id,