misc networking fixes

o fixed dns bug where dns was gotten from the wrong subnet
o project_id passed to get_instance_nw_info for when context.project_id
  is null
o removed line breaks around quantum client request to improve
  readability
o project_id passed into vif creation instead of using context
o exception handling around get_attached_ports in quantum connection
o updated object id generation to start with 1 in network_fake
o updated the fake subnets returned in the network_fake
o added proper v6 address generation to network_fake
o improved get_instance_nw_info test
o update api.openstack.compute.test_servers around improved network fake

Change-Id: I74d0a9dbfcbd38e2fbc7d7fefc2587e578980b6e
This commit is contained in:
Trey Morris
2012-02-13 18:33:18 -06:00
parent b0bd0fbe54
commit d11c5921c5
2 changed files with 24 additions and 22 deletions

View File

@@ -146,45 +146,46 @@ class FlatNetworkTestCase(test.TestCase):
nw_info = fake_get_instance_nw_info(self.stubs, 1, 2)
for i, (nw, info) in enumerate(nw_info):
check = {'bridge': 'fake_br%d' % i,
'cidr': '192.168.%s.0/24' % i,
'cidr_v6': 'DONTCARE',
'id': 'DONTCARE',
nid = i + 1
check = {'bridge': 'fake_br%d' % nid,
'cidr': '192.168.%s.0/24' % nid,
'cidr_v6': '2001:db8:0:%x::/64' % nid,
'id': '00000000-0000-0000-0000-00000000000000%02d' % nid,
'multi_host': False,
'injected': False,
'bridge_interface': 'DONTCARE',
'bridge_interface': None,
'vlan': None}
self.assertDictMatch(nw, check)
check = {'broadcast': '192.168.%d.255' % i,
'dhcp_server': '192.168.%d.1' % i,
'dns': 'DONTCARE',
'gateway': '192.168.%d.1' % i,
'gateway_v6': 'DONTCARE',
check = {'broadcast': '192.168.%d.255' % nid,
'dhcp_server': '192.168.%d.1' % nid,
'dns': ['192.168.%d.3' % nid, '192.168.%d.4' % nid],
'gateway': '192.168.%d.1' % nid,
'gateway_v6': 'fe80::def',
'ip6s': 'DONTCARE',
'ips': 'DONTCARE',
'label': 'test%d' % i,
'mac': 'DE:AD:BE:EF:00:%02x' % i,
'vif_uuid':
'00000000-0000-0000-0000-00000000000000%02d' % i,
'label': 'test%d' % nid,
'mac': 'DE:AD:BE:EF:00:%02x' % nid,
'rxtx_cap': 0,
'vif_uuid':
'00000000-0000-0000-0000-00000000000000%02d' % nid,
'should_create_vlan': False,
'should_create_bridge': False}
self.assertDictMatch(info, check)
check = [{'enabled': 'DONTCARE',
'ip': 'DONTCARE',
'gateway': 'DONTCARE',
'netmask': 64}]
'ip': '2001:db8:0:1::%x' % nid,
'netmask': 64,
'gateway': 'fe80::def'}]
self.assertDictListMatch(info['ip6s'], check)
num_fixed_ips = len(info['ips'])
check = [{'enabled': 'DONTCARE',
'ip': '192.168.%d.1%02d' % (i, ip_num),
'gateway': 'DONTCARE',
'netmask': '255.255.255.0'}
for ip_num in xrange(num_fixed_ips)]
'ip': '192.168.%d.%03d' % (nid, ip_num + 99),
'netmask': '255.255.255.0',
'gateway': '192.168.%d.1' % nid}
for ip_num in xrange(1, num_fixed_ips + 1)]
self.assertDictListMatch(info['ips'], check)
def test_validate_networks(self):

View File

@@ -301,7 +301,8 @@ class QuantumManagerTestCase(QuantumNovaTestCase):
nw_info = self.net_man.get_instance_nw_info(ctx, instance_ref['id'],
instance_ref['uuid'],
instance_ref['instance_type_id'], "")
instance_ref['instance_type_id'], "",
project_id=project_id)
self._check_vifs(len(nw_info))
self._validate_nw_info(nw_info, expected_labels)