summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@yahoo.com>2010-10-14 16:44:58 -0700
committerVishvananda Ishaya <vishvananda@yahoo.com>2010-10-14 16:44:58 -0700
commit951f4f2f8bfcdc2fc1f638a1c568979eb01dcb1b (patch)
tree32e440ac097d51022300332f250d0b58a33e3a01
parent81cdbc42d41509f629fe8ec0c7605958134e9ed0 (diff)
downloadnova-951f4f2f8bfcdc2fc1f638a1c568979eb01dcb1b.tar.gz
nova-951f4f2f8bfcdc2fc1f638a1c568979eb01dcb1b.tar.xz
nova-951f4f2f8bfcdc2fc1f638a1c568979eb01dcb1b.zip
get flags for nova-manage and fix a couple more deprecations
-rwxr-xr-xbin/nova-manage5
-rw-r--r--nova/network/manager.py17
2 files changed, 16 insertions, 6 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index cf574c6b3..1c5700190 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -78,6 +78,11 @@ 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):
diff --git a/nova/network/manager.py b/nova/network/manager.py
index cb5759a2b..c7080ccd8 100644
--- a/nova/network/manager.py
+++ b/nova/network/manager.py
@@ -27,6 +27,7 @@ import math
import IPy
from twisted.internet import defer
+from nova import context
from nova import db
from nova import exception
from nova import flags
@@ -79,8 +80,9 @@ class NetworkManager(manager.Manager):
def init_host(self):
# Set up networking for the projects for which we're already
# the designated network host.
- for network in self.db.host_get_networks(None, self.host):
- self._on_set_network_host(None, network['id'])
+ ctxt = context.get_admin_context()
+ for network in self.db.host_get_networks(ctxt, self.host):
+ self._on_set_network_host(ctxt, network['id'])
def set_network_host(self, context, network_id):
"""Safely sets the host of the network"""
@@ -238,7 +240,7 @@ class FlatManager(NetworkManager):
def deallocate_fixed_ip(self, context, address, *args, **kwargs):
"""Returns a fixed ip to the pool"""
self.db.fixed_ip_update(context, address, {'allocated': False})
- self.db.fixed_ip_disassociate(None, address)
+ self.db.fixed_ip_disassociate(context.elevated(), address)
def setup_compute_network(self, context, instance_id):
"""Network is created manually"""
@@ -338,13 +340,16 @@ class VlanManager(NetworkManager):
# TODO(vish): This should probably be getting project_id from
# the instance, but it is another trip to the db.
# Perhaps this method should take an instance_ref.
- network_ref = self.db.project_get_network(context.elevated(),
+ ctxt = context.elevated()
+ network_ref = self.db.project_get_network(ctxt,
context.project_id)
if kwargs.get('vpn', None):
address = network_ref['vpn_private_address']
- self.db.fixed_ip_associate(None, address, instance_id)
+ self.db.fixed_ip_associate(ctxt,
+ address,
+ instance_id)
else:
- address = self.db.fixed_ip_associate_pool(context.elevated(),
+ address = self.db.fixed_ip_associate_pool(ctxt,
network_ref['id'],
instance_id)
self.db.fixed_ip_update(context, address, {'allocated': True})