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
1=== modified file 'bin/nova-manage'
2--- bin/nova-manage 2010-10-14 06:44:04 +0000
3+++ bin/nova-manage 2010-10-15 00:51:02 +0000
4@@ -78,6 +78,11 @@
5
6
7 FLAGS = flags.FLAGS
8+flags.DECLARE('fixed_range', 'nova.network.manager')
9+flags.DECLARE('num_networks', 'nova.network.manager')
10+flags.DECLARE('network_size', 'nova.network.manager')
11+flags.DECLARE('vlan_start', 'nova.network.manager')
12+flags.DECLARE('vpn_start', 'nova.network.manager')
13
14
15 class VpnCommands(object):
16
17=== modified file 'nova/network/manager.py'
18--- nova/network/manager.py 2010-10-14 05:05:21 +0000
19+++ nova/network/manager.py 2010-10-15 00:51:02 +0000
20@@ -27,6 +27,7 @@
21 import IPy
22 from twisted.internet import defer
23
24+from nova import context
25 from nova import db
26 from nova import exception
27 from nova import flags
28@@ -79,8 +80,9 @@
29 def init_host(self):
30 # Set up networking for the projects for which we're already
31 # the designated network host.
32- for network in self.db.host_get_networks(None, self.host):
33- self._on_set_network_host(None, network['id'])
34+ ctxt = context.get_admin_context()
35+ for network in self.db.host_get_networks(ctxt, self.host):
36+ self._on_set_network_host(ctxt, network['id'])
37
38 def set_network_host(self, context, network_id):
39 """Safely sets the host of the network"""
40@@ -238,7 +240,7 @@
41 def deallocate_fixed_ip(self, context, address, *args, **kwargs):
42 """Returns a fixed ip to the pool"""
43 self.db.fixed_ip_update(context, address, {'allocated': False})
44- self.db.fixed_ip_disassociate(None, address)
45+ self.db.fixed_ip_disassociate(context.elevated(), address)
46
47 def setup_compute_network(self, context, instance_id):
48 """Network is created manually"""
49@@ -338,13 +340,16 @@
50 # TODO(vish): This should probably be getting project_id from
51 # the instance, but it is another trip to the db.
52 # Perhaps this method should take an instance_ref.
53- network_ref = self.db.project_get_network(context.elevated(),
54+ ctxt = context.elevated()
55+ network_ref = self.db.project_get_network(ctxt,
56 context.project_id)
57 if kwargs.get('vpn', None):
58 address = network_ref['vpn_private_address']
59- self.db.fixed_ip_associate(None, address, instance_id)
60+ self.db.fixed_ip_associate(ctxt,
61+ address,
62+ instance_id)
63 else:
64- address = self.db.fixed_ip_associate_pool(context.elevated(),
65+ address = self.db.fixed_ip_associate_pool(ctxt,
66 network_ref['id'],
67 instance_id)
68 self.db.fixed_ip_update(context, address, {'allocated': True})