2
# vim: tabstop=4 shiftwidth=4 softtabstop=4
4
# Copyright (c) 2011 Openstack, LLC.
7
# Licensed under the Apache License, Version 2.0 (the "License"); you may
8
# not use this file except in compliance with the License. You may obtain
9
# a copy of the License at
11
# http://www.apache.org/licenses/LICENSE-2.0
13
# Unless required by applicable law or agreed to in writing, software
14
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
# License for the specific language governing permissions and limitations
19
"""Admin/debug script to wipe rabbitMQ (AMQP) queues nova uses.
20
This can be used if you need to change durable options on queues,
21
or to wipe all messages in the queue system if things are in a
32
# If ../nova/__init__.py exists, add ../ to Python search path, so that
33
# it will override what happens to be installed in /usr/(local/)lib/python...
34
POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
37
if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
38
sys.path.insert(0, POSSIBLE_TOPDIR)
40
gettext.install('nova', unicode=1)
43
from nova import context
44
from nova import exception
45
from nova import flags
46
from nova import log as logging
48
from nova import utils
52
flags.DEFINE_boolean('delete_exchange', False, 'delete nova exchange too.')
55
def delete_exchange(exch):
56
conn = rpc.create_connection()
57
x = conn.get_channel()
58
x.exchange_delete(exch)
61
def delete_queues(queues):
62
conn = rpc.create_connection()
63
x = conn.get_channel()
67
if __name__ == '__main__':
68
utils.default_flagfile()
69
args = flags.FLAGS(sys.argv)
71
delete_queues(args[1:])
72
if FLAGS.delete_exchange:
73
delete_exchange(FLAGS.control_exchange)