Merge lp:~tr3buchet/nova/ipv6_inject_bug into lp:~hudson-openstack/nova/trunk

Proposed by Trey Morris
Status: Merged
Approved by: Cory Wright
Approved revision: 952
Merged at revision: 951
Proposed branch: lp:~tr3buchet/nova/ipv6_inject_bug
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 169 lines (+49/-30)
4 files modified
nova/tests/test_xenapi.py (+3/-3)
nova/virt/libvirt_conn.py (+18/-18)
nova/virt/xenapi/vm_utils.py (+1/-1)
nova/virt/xenapi/vmops.py (+27/-8)
To merge this branch: bzr merge lp:~tr3buchet/nova/ipv6_inject_bug
Reviewer Review Type Date Requested Status
Sandy Walsh (community) Approve
Chris Behrens (community) Approve
Cory Wright (community) Approve
Review via email: mp+56483@code.launchpad.net

Description of the change

fixed the way ip6 address were retrieved/returned in _get_network_info in nova/virt/xenapi/vmops

To post a comment you must log in.
Revision history for this message
Mark Washenberger (markwash) wrote :

Is it possible to add tests for this change?

Revision history for this message
Trey Morris (tr3buchet) wrote :

right now tests are failing as a result. I'm fixing the tests now.

Revision history for this message
Trey Morris (tr3buchet) wrote :

alright tests are passing. The tests in xenapi test to make sure that the network_info dict is of the correct form. It's within check_vm_record. If tests which call this function pass, then it's working.

Revision history for this message
Trey Morris (tr3buchet) wrote :

This was supposed to be a quick bug fix, but it turned into a little more. Sorry for long diff.

Revision history for this message
Cory Wright (corywright) wrote :

Looks ok to me.

review: Approve
Revision history for this message
Chris Behrens (cbehrens) wrote :

Looks good to me.

Revision history for this message
Chris Behrens (cbehrens) :
review: Approve
Revision history for this message
Sandy Walsh (sandy-walsh) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/tests/test_xenapi.py'
2--- nova/tests/test_xenapi.py 2011-03-28 21:00:17 +0000
3+++ nova/tests/test_xenapi.py 2011-04-06 18:44:33 +0000
4@@ -289,11 +289,11 @@
5 'enabled':'1'}],
6 'ip6s': [{'ip': 'fe80::a8bb:ccff:fedd:eeff',
7 'netmask': '120',
8- 'enabled': '1',
9- 'gateway': 'fe80::a00:1'}],
10+ 'enabled': '1'}],
11 'mac': 'aa:bb:cc:dd:ee:ff',
12 'dns': ['10.0.0.2'],
13- 'gateway': '10.0.0.1'})
14+ 'gateway': '10.0.0.1',
15+ 'gateway6': 'fe80::a00:1'})
16
17 def check_vm_params_for_windows(self):
18 self.assertEquals(self.vm['platform']['nx'], 'true')
19
20=== modified file 'nova/virt/libvirt_conn.py'
21--- nova/virt/libvirt_conn.py 2011-04-05 14:17:29 +0000
22+++ nova/virt/libvirt_conn.py 2011-04-06 18:44:33 +0000
23@@ -169,34 +169,34 @@
24 instance['id'])
25 network_info = []
26
27- def ip_dict(ip):
28- return {
29- "ip": ip.address,
30- "netmask": network["netmask"],
31- "enabled": "1"}
32-
33- def ip6_dict(ip6):
34- prefix = ip6.network.cidr_v6
35- mac = instance.mac_address
36- return {
37- "ip": utils.to_global_ipv6(prefix, mac),
38- "netmask": ip6.network.netmask_v6,
39- "gateway": ip6.network.gateway_v6,
40- "enabled": "1"}
41-
42 for network in networks:
43 network_ips = [ip for ip in ip_addresses
44- if ip.network_id == network.id]
45+ if ip['network_id'] == network['id']]
46+
47+ def ip_dict(ip):
48+ return {
49+ 'ip': ip['address'],
50+ 'netmask': network['netmask'],
51+ 'enabled': '1'}
52+
53+ def ip6_dict():
54+ prefix = network['cidr_v6']
55+ mac = instance['mac_address']
56+ return {
57+ 'ip': utils.to_global_ipv6(prefix, mac),
58+ 'netmask': network['netmask_v6'],
59+ 'enabled': '1'}
60
61 mapping = {
62 'label': network['label'],
63 'gateway': network['gateway'],
64- 'mac': instance.mac_address,
65+ 'mac': instance['mac_address'],
66 'dns': [network['dns']],
67 'ips': [ip_dict(ip) for ip in network_ips]}
68
69 if FLAGS.use_ipv6:
70- mapping['ip6s'] = [ip6_dict(ip) for ip in network_ips]
71+ mapping['ip6s'] = [ip6_dict()]
72+ mapping['gateway6'] = network['gateway_v6']
73
74 network_info.append((network, mapping))
75 return network_info
76
77=== modified file 'nova/virt/xenapi/vm_utils.py'
78--- nova/virt/xenapi/vm_utils.py 2011-03-29 19:30:06 +0000
79+++ nova/virt/xenapi/vm_utils.py 2011-04-06 18:44:33 +0000
80@@ -1130,7 +1130,7 @@
81 'dns': dns,
82 'address_v6': ip_v6 and ip_v6['ip'] or '',
83 'netmask_v6': ip_v6 and ip_v6['netmask'] or '',
84- 'gateway_v6': ip_v6 and ip_v6['gateway'] or '',
85+ 'gateway_v6': ip_v6 and info['gateway6'] or '',
86 'use_ipv6': FLAGS.use_ipv6}
87 interfaces_info.append(interface_info)
88
89
90=== modified file 'nova/virt/xenapi/vmops.py'
91--- nova/virt/xenapi/vmops.py 2011-03-29 10:20:16 +0000
92+++ nova/virt/xenapi/vmops.py 2011-04-06 18:44:33 +0000
93@@ -176,7 +176,7 @@
94 vdi_ref, network_info)
95
96 self.create_vifs(vm_ref, network_info)
97- self.inject_network_info(instance, vm_ref, network_info)
98+ self.inject_network_info(instance, network_info, vm_ref)
99 return vm_ref
100
101 def _spawn(self, instance, vm_ref):
102@@ -814,12 +814,11 @@
103 "netmask": network["netmask"],
104 "enabled": "1"}
105
106- def ip6_dict(ip6):
107+ def ip6_dict():
108 return {
109 "ip": utils.to_global_ipv6(network['cidr_v6'],
110 instance['mac_address']),
111 "netmask": network['netmask_v6'],
112- "gateway": network['gateway_v6'],
113 "enabled": "1"}
114
115 info = {
116@@ -831,19 +830,37 @@
117 'dns': [network['dns']],
118 'ips': [ip_dict(ip) for ip in network_IPs]}
119 if network['cidr_v6']:
120- info['ip6s'] = [ip6_dict(ip) for ip in network_IPs]
121+ info['ip6s'] = [ip6_dict()]
122+ if network['gateway_v6']:
123+ info['gateway6'] = network['gateway_v6']
124 network_info.append((network, info))
125 return network_info
126
127- def inject_network_info(self, instance, vm_ref, network_info):
128+ #TODO{tr3buchet) remove this shim with nova-multi-nic
129+ def inject_network_info(self, instance, network_info=None, vm_ref=None):
130+ """
131+ shim in place which makes inject_network_info work without being
132+ passed network_info.
133+ shim goes away after nova-multi-nic
134+ """
135+ if not network_info:
136+ network_info = self._get_network_info(instance)
137+ self._inject_network_info(instance, network_info, vm_ref)
138+
139+ def _inject_network_info(self, instance, network_info, vm_ref=None):
140 """
141 Generate the network info and make calls to place it into the
142 xenstore and the xenstore param list.
143+ vm_ref can be passed in because it will sometimes be different than
144+ what VMHelper.lookup(session, instance.name) will find (ex: rescue)
145 """
146 logging.debug(_("injecting network info to xs for vm: |%s|"), vm_ref)
147
148- # this function raises if vm_ref is not a vm_opaque_ref
149- self._session.get_xenapi().VM.get_record(vm_ref)
150+ if vm_ref:
151+ # this function raises if vm_ref is not a vm_opaque_ref
152+ self._session.get_xenapi().VM.get_record(vm_ref)
153+ else:
154+ vm_ref = VMHelper.lookup(self._session, instance.name)
155
156 for (network, info) in network_info:
157 location = 'vm-data/networking/%s' % info['mac'].replace(':', '')
158@@ -875,8 +892,10 @@
159 VMHelper.create_vif(self._session, vm_ref, network_ref,
160 mac_address, device, rxtx_cap)
161
162- def reset_network(self, instance, vm_ref):
163+ def reset_network(self, instance, vm_ref=None):
164 """Creates uuid arg to pass to make_agent_call and calls it."""
165+ if not vm_ref:
166+ vm_ref = VMHelper.lookup(self._session, instance.name)
167 args = {'id': str(uuid.uuid4())}
168 # TODO(tr3buchet): fix function call after refactor
169 #resp = self._make_agent_call('resetnetwork', instance, '', args)