summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjaypipes@gmail.com <>2010-10-15 16:24:19 -0400
committerjaypipes@gmail.com <>2010-10-15 16:24:19 -0400
commit3fdced0a19315732fec0ead200604e396f06823c (patch)
treecf4675fdf71e8c126888432007e15d1bbf9c2360 /bin
parentff60af51cc2990c7b60ca97cc899f0719560bc6f (diff)
parentb70742cd442e8477d15c82a825641d934529bedf (diff)
downloadnova-3fdced0a19315732fec0ead200604e396f06823c.tar.gz
nova-3fdced0a19315732fec0ead200604e396f06823c.tar.xz
nova-3fdced0a19315732fec0ead200604e396f06823c.zip
Merge trunk
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-dhcpbridge26
-rwxr-xr-xbin/nova-manage31
2 files changed, 36 insertions, 21 deletions
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index a127ed03c..2b7a083d2 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -33,6 +33,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+from nova import context
from nova import db
from nova import flags
from nova import rpc
@@ -52,12 +53,14 @@ def add_lease(mac, ip_address, _hostname, _interface):
if FLAGS.fake_rabbit:
logging.debug("leasing ip")
network_manager = utils.import_object(FLAGS.network_manager)
- network_manager.lease_fixed_ip(None, mac, ip_address)
+ network_manager.lease_fixed_ip(context.get_admin_context(),
+ mac,
+ ip_address)
else:
- rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host),
+ rpc.cast(context.get_admin_context(),
+ "%s.%s" % (FLAGS.network_topic, FLAGS.host),
{"method": "lease_fixed_ip",
- "args": {"context": None,
- "mac": mac,
+ "args": {"mac": mac,
"address": ip_address}})
@@ -71,19 +74,22 @@ def del_lease(mac, ip_address, _hostname, _interface):
if FLAGS.fake_rabbit:
logging.debug("releasing ip")
network_manager = utils.import_object(FLAGS.network_manager)
- network_manager.release_fixed_ip(None, mac, ip_address)
+ network_manager.release_fixed_ip(context.get_admin_context(),
+ mac,
+ ip_address)
else:
- rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host),
+ rpc.cast(context.get_admin_context(),
+ "%s.%s" % (FLAGS.network_topic, FLAGS.host),
{"method": "release_fixed_ip",
- "args": {"context": None,
- "mac": mac,
+ "args": {"mac": mac,
"address": ip_address}})
def init_leases(interface):
"""Get the list of hosts for an interface."""
- network_ref = db.network_get_by_bridge(None, interface)
- return linux_net.get_dhcp_hosts(None, network_ref['id'])
+ ctxt = context.get_admin_context()
+ network_ref = db.network_get_by_bridge(ctxt, interface)
+ return linux_net.get_dhcp_hosts(ctxt, network_ref['id'])
def main():
diff --git a/bin/nova-manage b/bin/nova-manage
index d36b0f53a..1c5700190 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -67,17 +67,22 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')):
sys.path.insert(0, possible_topdir)
+from nova import context
from nova import db
from nova import exception
from nova import flags
from nova import quota
from nova import utils
from nova.auth import manager
-from nova.network import manager as network_manager
from nova.cloudpipe import pipelib
FLAGS = flags.FLAGS
+flags.DECLARE('fixed_range', 'nova.network.manager')
+flags.DECLARE('num_networks', 'nova.network.manager')
+flags.DECLARE('network_size', 'nova.network.manager')
+flags.DECLARE('vlan_start', 'nova.network.manager')
+flags.DECLARE('vpn_start', 'nova.network.manager')
class VpnCommands(object):
@@ -121,7 +126,7 @@ class VpnCommands(object):
def _vpn_for(self, project_id):
"""Get the VPN instance for a project ID."""
- for instance in db.instance_get_all(None):
+ for instance in db.instance_get_all(context.get_admin_context()):
if (instance['image_id'] == FLAGS.vpn_image_id
and not instance['state_description'] in
['shutting_down', 'shutdown']
@@ -323,13 +328,14 @@ class ProjectCommands(object):
def quota(self, project_id, key=None, value=None):
"""Set or display quotas for project
arguments: project_id [key] [value]"""
+ ctxt = context.get_admin_context()
if key:
quo = {'project_id': project_id, key: value}
try:
- db.quota_update(None, project_id, quo)
+ db.quota_update(ctxt, project_id, quo)
except exception.NotFound:
- db.quota_create(None, quo)
- project_quota = quota.get_quota(None, project_id)
+ db.quota_create(ctxt, quo)
+ project_quota = quota.get_quota(ctxt, project_id)
for key, value in project_quota.iteritems():
print '%s: %s' % (key, value)
@@ -353,23 +359,26 @@ class FloatingIpCommands(object):
"""Creates floating ips for host by range
arguments: host ip_range"""
for address in IPy.IP(range):
- db.floating_ip_create(None, {'address': str(address),
- 'host': host})
+ db.floating_ip_create(context.get_admin_context(),
+ {'address': str(address),
+ 'host': host})
def delete(self, ip_range):
"""Deletes floating ips by range
arguments: range"""
for address in IPy.IP(ip_range):
- db.floating_ip_destroy(None, str(address))
+ db.floating_ip_destroy(context.get_admin_context(),
+ str(address))
def list(self, host=None):
"""Lists all floating ips (optionally by host)
arguments: [host]"""
+ ctxt = context.get_admin_context()
if host == None:
- floating_ips = db.floating_ip_get_all(None)
+ floating_ips = db.floating_ip_get_all(ctxt)
else:
- floating_ips = db.floating_ip_get_all_by_host(None, host)
+ floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
for floating_ip in floating_ips:
instance = None
if floating_ip['fixed_ip']:
@@ -451,7 +460,7 @@ def main():
if FLAGS.verbose:
logging.getLogger().setLevel(logging.DEBUG)
-
+
script_name = argv.pop(0)
if len(argv) < 1:
print script_name + " category action [<args>]"