Merge lp:~anso/nova/fix-context-deprecation into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Todd Willey
Approved revision: 333
Merged at revision: 353
Proposed branch: lp:~anso/nova/fix-context-deprecation
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 68 lines (+16/-6)
2 files modified
bin/nova-manage (+5/-0)
nova/network/manager.py (+11/-6)
To merge this branch: bzr merge lp:~anso/nova/fix-context-deprecation
Reviewer Review Type Date Requested Status
Todd Willey (community) Approve
Devin Carlen (community) Approve
Review via email: mp+38482@code.launchpad.net

Commit message

A few more fixes for deprecations.

Description of the change

A few more fixes for deprecations.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Todd Willey (xtoddx) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/nova-manage'
--- bin/nova-manage 2010-10-14 06:44:04 +0000
+++ bin/nova-manage 2010-10-15 00:51:02 +0000
@@ -78,6 +78,11 @@
7878
7979
80FLAGS = flags.FLAGS80FLAGS = flags.FLAGS
81flags.DECLARE('fixed_range', 'nova.network.manager')
82flags.DECLARE('num_networks', 'nova.network.manager')
83flags.DECLARE('network_size', 'nova.network.manager')
84flags.DECLARE('vlan_start', 'nova.network.manager')
85flags.DECLARE('vpn_start', 'nova.network.manager')
8186
8287
83class VpnCommands(object):88class VpnCommands(object):
8489
=== modified file 'nova/network/manager.py'
--- nova/network/manager.py 2010-10-14 05:05:21 +0000
+++ nova/network/manager.py 2010-10-15 00:51:02 +0000
@@ -27,6 +27,7 @@
27import IPy27import IPy
28from twisted.internet import defer28from twisted.internet import defer
2929
30from nova import context
30from nova import db31from nova import db
31from nova import exception32from nova import exception
32from nova import flags33from nova import flags
@@ -79,8 +80,9 @@
79 def init_host(self):80 def init_host(self):
80 # Set up networking for the projects for which we're already81 # Set up networking for the projects for which we're already
81 # the designated network host.82 # the designated network host.
82 for network in self.db.host_get_networks(None, self.host):83 ctxt = context.get_admin_context()
83 self._on_set_network_host(None, network['id'])84 for network in self.db.host_get_networks(ctxt, self.host):
85 self._on_set_network_host(ctxt, network['id'])
8486
85 def set_network_host(self, context, network_id):87 def set_network_host(self, context, network_id):
86 """Safely sets the host of the network"""88 """Safely sets the host of the network"""
@@ -238,7 +240,7 @@
238 def deallocate_fixed_ip(self, context, address, *args, **kwargs):240 def deallocate_fixed_ip(self, context, address, *args, **kwargs):
239 """Returns a fixed ip to the pool"""241 """Returns a fixed ip to the pool"""
240 self.db.fixed_ip_update(context, address, {'allocated': False})242 self.db.fixed_ip_update(context, address, {'allocated': False})
241 self.db.fixed_ip_disassociate(None, address)243 self.db.fixed_ip_disassociate(context.elevated(), address)
242244
243 def setup_compute_network(self, context, instance_id):245 def setup_compute_network(self, context, instance_id):
244 """Network is created manually"""246 """Network is created manually"""
@@ -338,13 +340,16 @@
338 # TODO(vish): This should probably be getting project_id from340 # TODO(vish): This should probably be getting project_id from
339 # the instance, but it is another trip to the db.341 # the instance, but it is another trip to the db.
340 # Perhaps this method should take an instance_ref.342 # Perhaps this method should take an instance_ref.
341 network_ref = self.db.project_get_network(context.elevated(),343 ctxt = context.elevated()
344 network_ref = self.db.project_get_network(ctxt,
342 context.project_id)345 context.project_id)
343 if kwargs.get('vpn', None):346 if kwargs.get('vpn', None):
344 address = network_ref['vpn_private_address']347 address = network_ref['vpn_private_address']
345 self.db.fixed_ip_associate(None, address, instance_id)348 self.db.fixed_ip_associate(ctxt,
349 address,
350 instance_id)
346 else:351 else:
347 address = self.db.fixed_ip_associate_pool(context.elevated(),352 address = self.db.fixed_ip_associate_pool(ctxt,
348 network_ref['id'],353 network_ref['id'],
349 instance_id)354 instance_id)
350 self.db.fixed_ip_update(context, address, {'allocated': True})355 self.db.fixed_ip_update(context, address, {'allocated': True})