Remove deprecated legacy network info model in Hypervisor drivers

This patch removes legacy network info wihch is unused in any Hypervisor
drivers, clean up related tests and Also removes legacy method from
nova.network.model.

Partly implement blueprint nova-network-legacy

Change-Id: Ia3f11b1a162878817445619575b35187110dafb5
This commit is contained in:
Yaguang Tang 2013-07-27 16:45:57 +08:00
parent 146dd7aa22
commit afcd38ec2d
30 changed files with 106 additions and 381 deletions

View File

@ -76,7 +76,8 @@ class IP(Model):
try:
self['version'] = netaddr.IPAddress(self['address']).version
except netaddr.AddrFormatError:
raise exception.InvalidIpAddressError(self['address'])
msg = _("Invalid IP format %s") % self['address']
raise exception.InvalidIpAddressError(msg)
def __eq__(self, other):
return self['address'] == other['address']
@ -328,116 +329,6 @@ class NetworkInfo(list):
def json(self):
return jsonutils.dumps(self)
def legacy(self):
"""
Return the legacy network_info representation of self
"""
def get_ip(ip):
if not ip:
return None
return ip['address']
def fixed_ip_dict(ip, subnet):
netmask = get_netmask(ip, subnet)
return {'ip': ip['address'],
'enabled': '1',
'netmask': netmask,
'gateway': get_ip(subnet['gateway'])}
def convert_routes(routes):
routes_list = []
for route in routes:
r = {'route': str(netaddr.IPNetwork(route['cidr']).network),
'netmask': str(netaddr.IPNetwork(route['cidr']).netmask),
'gateway': get_ip(route['gateway'])}
routes_list.append(r)
return routes_list
network_info = []
for vif in self:
# if vif doesn't have network or that network has no subnets, quit
if not vif['network'] or not vif['network']['subnets']:
continue
network = vif['network']
# NOTE(jkoelker) The legacy format only supports one subnet per
# network, so we only use the 1st one of each type
# NOTE(tr3buchet): o.O
v4_subnets = []
v6_subnets = []
for subnet in vif['network']['subnets']:
if subnet['version'] == 4:
v4_subnets.append(subnet)
else:
v6_subnets.append(subnet)
subnet_v4 = None
subnet_v6 = None
if v4_subnets:
subnet_v4 = v4_subnets[0]
if v6_subnets:
subnet_v6 = v6_subnets[0]
if not subnet_v4:
msg = _('v4 subnets are required for legacy nw_info')
raise exception.NovaException(message=msg)
routes = convert_routes(subnet_v4['routes'])
should_create_bridge = network.get_meta('should_create_bridge',
False)
should_create_vlan = network.get_meta('should_create_vlan', False)
gateway = get_ip(subnet_v4['gateway'])
dhcp_server = subnet_v4.get_meta('dhcp_server', gateway)
network_dict = {
'bridge': network['bridge'],
'id': network['id'],
'cidr': subnet_v4['cidr'],
'cidr_v6': subnet_v6['cidr'] if subnet_v6 else None,
'vlan': network.get_meta('vlan'),
'injected': network.get_meta('injected', False),
'multi_host': network.get_meta('multi_host', False),
'bridge_interface': network.get_meta('bridge_interface')
}
# NOTE(tr3buchet): 'ips' bit here is tricky, we support a single
# subnet but we want all the IPs to be there
# so use the v4_subnets[0] and its IPs are first
# so that eth0 will be from subnet_v4, the rest of
# the IPs will be aliased eth0:1 etc and the
# gateways from their subnets will not be used
info_dict = {'label': network['label'],
'broadcast': str(subnet_v4.as_netaddr().broadcast),
'mac': vif['address'],
'vif_type': vif['type'],
'vif_devname': vif.get('devname'),
'vif_uuid': vif['id'],
'ovs_interfaceid': vif.get('ovs_interfaceid'),
'qbh_params': vif.get('qbh_params'),
'qbg_params': vif.get('qbg_params'),
'rxtx_cap': vif.get_meta('rxtx_cap', 0),
'dns': [get_ip(ip) for ip in subnet_v4['dns']],
'gateway': gateway,
'ips': [fixed_ip_dict(ip, subnet)
for subnet in v4_subnets
for ip in subnet['ips']],
'should_create_bridge': should_create_bridge,
'should_create_vlan': should_create_vlan,
'dhcp_server': dhcp_server}
if routes:
info_dict['routes'] = routes
if v6_subnets:
info_dict['gateway_v6'] = get_ip(subnet_v6['gateway'])
# NOTE(tr3buchet): only supporting single v6 subnet here
info_dict['ip6s'] = [fixed_ip_dict(ip, subnet_v6)
for ip in subnet_v6['ips']]
network_info.append((network_dict, info_dict))
return network_info
class NetworkInfoAsyncWrapper(NetworkInfo):
"""Wrapper around NetworkInfo that allows retrieving NetworkInfo
@ -462,7 +353,7 @@ class NetworkInfoAsyncWrapper(NetworkInfo):
def __init__(self, async_method, *args, **kwargs):
self._gt = eventlet.spawn(async_method, *args, **kwargs)
methods = ['json', 'legacy', 'fixed_ips', 'floating_ips']
methods = ['json', 'fixed_ips', 'floating_ips']
for method in methods:
fn = getattr(self, method)
wrapper = functools.partial(self._sync_wrapper, fn)

View File

@ -83,8 +83,7 @@ class CloudpipeTest(test.TestCase):
'vpn_public_port': 22}
def fake_get_nw_info_for_instance(instance):
return fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
return fake_network.fake_get_instance_nw_info(self.stubs)
self.stubs.Set(compute_utils, "get_nw_info_for_instance",
fake_get_nw_info_for_instance)

View File

@ -94,7 +94,7 @@ def fake_instance_get(context, instance_id):
def stub_nw_info(stubs):
def get_nw_info_for_instance(instance):
return fake_network.fake_get_instance_nw_info(stubs, spectacular=True)
return fake_network.fake_get_instance_nw_info(stubs)
return get_nw_info_for_instance
@ -148,8 +148,7 @@ class FloatingIpTest(test.TestCase):
'nova.api.openstack.compute.contrib.select_extensions'],
osapi_compute_ext_list=['Floating_ips'])
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
self.stubs.Set(db, 'instance_get',
fake_instance_get)
@ -614,8 +613,7 @@ class ExtendedFloatingIpTest(test.TestCase):
'nova.api.openstack.compute.contrib.select_extensions'],
osapi_compute_ext_list=['Floating_ips', 'Extended_floating_ips'])
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
self.stubs.Set(db, 'instance_get',
fake_instance_get)

View File

@ -182,8 +182,7 @@ class ControllerTest(test.TestCase):
self.ips_controller = ips.IPsController()
policy.reset()
policy.init()
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
class ServersControllerTest(ControllerTest):

View File

@ -176,8 +176,7 @@ class ControllerTest(test.TestCase):
self.ips_controller = ips.Controller()
policy.reset()
policy.init()
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
class ServersControllerTest(ControllerTest):

View File

@ -208,8 +208,7 @@ class stub_out_compute_api_backup(object):
def stub_out_nw_api_get_instance_nw_info(stubs, num_networks=1, func=None):
fake_network.stub_out_nw_api_get_instance_nw_info(stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(stubs)
def stub_out_nw_api_get_floating_ips_by_fixed_address(stubs, func=None):
@ -240,7 +239,7 @@ def stub_out_nw_api(stubs, cls=None, private=None, publics=None):
if cls is None:
cls = Fake
stubs.Set(network_api, 'API', cls)
fake_network.stub_out_nw_api_get_instance_nw_info(stubs, spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(stubs)
def _make_image_fixtures():

View File

@ -223,8 +223,7 @@ class BaseTestCase(test.TestCase):
def fake_get_nw_info(cls, ctxt, instance, *args, **kwargs):
self.assertTrue(ctxt.is_admin)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
self.stubs.Set(network_api.API, 'get_instance_nw_info',
fake_get_nw_info)
@ -2647,8 +2646,8 @@ class ComputeTestCase(BaseTestCase):
vpn=False, macs=macs,
conductor_api=self.compute.conductor_api,
security_groups=[], dhcp_options=None).AndReturn(
fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True))
fake_network.fake_get_instance_nw_info(self.stubs, 1, 1))
self.mox.StubOutWithMock(self.compute.driver, "macs_for_instance")
self.compute.driver.macs_for_instance(instance).AndReturn(macs)
self.mox.ReplayAll()
@ -4098,8 +4097,7 @@ class ComputeTestCase(BaseTestCase):
def test_pre_live_migration_works_correctly(self):
# Confirm setup_compute_volume is called when volume is mounted.
def stupid(*args, **kwargs):
return fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
return fake_network.fake_get_instance_nw_info(self.stubs)
self.stubs.Set(nova.compute.manager.ComputeManager,
'_get_instance_nw_info', stupid)
@ -4107,8 +4105,7 @@ class ComputeTestCase(BaseTestCase):
instance = jsonutils.to_primitive(self._create_fake_instance(
{'host': 'dummy'}))
c = context.get_admin_context()
nw_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
nw_info = fake_network.fake_get_instance_nw_info(self.stubs)
# creating mocks
self.mox.StubOutWithMock(self.compute.driver, 'pre_live_migration')
@ -5388,8 +5385,7 @@ class ComputeAPITestCase(BaseTestCase):
def setUp(self):
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
super(ComputeAPITestCase, self).setUp()
self.stubs.Set(network_api.API, 'get_instance_nw_info',

View File

@ -229,8 +229,7 @@ class UsageInfoTestCase(test.TestCase):
def setUp(self):
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True)
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
super(UsageInfoTestCase, self).setUp()
self.stubs.Set(network_api.API, 'get_instance_nw_info',

View File

@ -52,9 +52,6 @@ class UnsupportedVirtDriver(driver.ComputeDriver):
# no support for getting resource usage info
return {}
def legacy_nwinfo(self):
return True
class FakeVirtDriver(driver.ComputeDriver):
@ -92,9 +89,6 @@ class FakeVirtDriver(driver.ComputeDriver):
}
return overhead # just return a constant value for testing
def legacy_nwinfo(self):
return True
class BaseTestCase(test.TestCase):

View File

@ -269,8 +269,7 @@ def ipv4_like(ip, match_string):
def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
floating_ips_per_fixed_ip=0,
spectacular=False):
floating_ips_per_fixed_ip=0):
# stubs is the self.stubs from the test
# ips_per_vif is the number of ips each vif will have
# num_floating_ips is number of float ips for each fixed ip
@ -378,14 +377,12 @@ def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
def stub_out_nw_api_get_instance_nw_info(stubs, func=None,
num_networks=1,
ips_per_vif=1,
floating_ips_per_fixed_ip=0,
spectacular=False):
floating_ips_per_fixed_ip=0):
def get_instance_nw_info(self, context, instance, conductor_api=None):
return fake_get_instance_nw_info(stubs, num_networks=num_networks,
ips_per_vif=ips_per_vif,
floating_ips_per_fixed_ip=floating_ips_per_fixed_ip,
spectacular=spectacular)
floating_ips_per_fixed_ip=floating_ips_per_fixed_ip)
if func is None:
func = get_instance_nw_info

View File

@ -139,8 +139,7 @@ class MetadataTestCase(test.TestCase):
self.instance = INSTANCES[0]
self.instance['system_metadata'] = get_default_sys_meta()
self.flags(use_local=True, group='conductor')
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
def test_can_pickle_metadata(self):
# Make sure that InstanceMetadata is possible to pickle. This is
@ -316,8 +315,7 @@ class OpenStackMetadataTestCase(test.TestCase):
self.instance = INSTANCES[0]
self.instance['system_metadata'] = get_default_sys_meta()
self.flags(use_local=True, group='conductor')
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
def test_top_level_listing(self):
# request for /openstack/<version>/ should show metadata.json
@ -488,8 +486,7 @@ class MetadataHandlerTestCase(test.TestCase):
def setUp(self):
super(MetadataHandlerTestCase, self).setUp()
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
self.instance = INSTANCES[0]
self.instance['system_metadata'] = get_default_sys_meta()
self.flags(use_local=True, group='conductor')
@ -665,8 +662,7 @@ class MetadataHandlerTestCase(test.TestCase):
class MetadataPasswordTestCase(test.TestCase):
def setUp(self):
super(MetadataPasswordTestCase, self).setUp()
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
spectacular=True)
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
self.instance = copy.copy(INSTANCES[0])
self.instance['system_metadata'] = get_default_sys_meta()
self.flags(use_local=True, group='conductor')

View File

@ -43,7 +43,7 @@ class NotificationsTestCase(test.TestCase):
super(NotificationsTestCase, self).setUp()
self.net_info = fake_network.fake_get_instance_nw_info(self.stubs, 1,
1, spectacular=True)
1)
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)

View File

@ -92,7 +92,7 @@ def get_test_instance(context=None, instance_type=None):
return instance_ref
def get_test_network_info(count=1, legacy_model=False):
def get_test_network_info(count=1):
ipv6 = CONF.use_ipv6
fake = 'fake'
fake_ip = '0.0.0.0'

View File

@ -121,7 +121,7 @@ class BareMetalDriverWithDBTestCase(bm_db_base.BMDBTestCase):
None, result['instance']),
injected_files=[('/fake/path', 'hello world')],
instance=result['instance'],
network_info=utils.get_test_network_info(legacy_model=False),
network_info=utils.get_test_network_info(),
)
result['destroy_params'] = dict(
instance=result['instance'],

View File

@ -69,8 +69,7 @@ class BareMetalPXETestCase(bm_db_base.BMDBTestCase):
self.context = utils.get_test_admin_context()
self.test_block_device_info = None,
self.instance = utils.get_test_instance()
self.test_network_info = utils.get_test_network_info(
legacy_model=False),
self.test_network_info = utils.get_test_network_info()
self.node_info = bm_db_utils.new_bm_node(
service_host='test_host',
cpus=4,
@ -147,23 +146,23 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
pxe_network_config=True,
group='baremetal',
)
net = utils.get_test_network_info(1, legacy_model=False)
net = utils.get_test_network_info(1)
config = pxe.build_pxe_network_config(net)
self.assertIn('eth0:off', config)
self.assertNotIn('eth1', config)
net = utils.get_test_network_info(2, legacy_model=False)
net = utils.get_test_network_info(2)
config = pxe.build_pxe_network_config(net)
self.assertIn('eth0:off', config)
self.assertIn('eth1:off', config)
def test_build_network_config(self):
net = utils.get_test_network_info(1, legacy_model=False)
net = utils.get_test_network_info(1)
config = pxe.build_network_config(net)
self.assertIn('eth0', config)
self.assertNotIn('eth1', config)
net = utils.get_test_network_info(2, legacy_model=False)
net = utils.get_test_network_info(2)
config = pxe.build_network_config(net)
self.assertIn('eth0', config)
self.assertIn('eth1', config)
@ -174,7 +173,7 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
'net-dhcp.ubuntu.template',
group='baremetal',
)
net = utils.get_test_network_info(legacy_model=False)
net = utils.get_test_network_info()
net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4'
config = pxe.build_network_config(net)
self.assertIn('iface eth0 inet dhcp', config)
@ -186,7 +185,7 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
'net-static.ubuntu.template',
group='baremetal',
)
net = utils.get_test_network_info(legacy_model=False)
net = utils.get_test_network_info()
net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4'
config = pxe.build_network_config(net)
self.assertIn('iface eth0 inet static', config)
@ -200,7 +199,7 @@ class PXEClassMethodsTestCase(BareMetalPXETestCase):
group='baremetal'
)
net = utils.get_test_network_info(legacy_model=False)
net = utils.get_test_network_info()
net[0]['network']['subnets'][0]['cidr'] = '10.1.1.0/24'
net[0]['network']['subnets'][0]['gateway']['address'] = '10.1.1.1'
net[0]['network']['subnets'][0]['dns'][0]['address'] = '10.1.1.2'
@ -408,7 +407,7 @@ class PXEPrivateMethodsTestCase(BareMetalPXETestCase):
self.instance['hostname'] = 'fake hostname'
files.append(('/etc/hostname', 'fake hostname'))
self.instance['key_data'] = 'fake ssh key'
net_info = utils.get_test_network_info(1, legacy_model=False)
net_info = utils.get_test_network_info(1)
net = pxe.build_network_config(net_info)
admin_password = 'fake password'

View File

@ -65,8 +65,7 @@ class BareMetalTileraTestCase(bm_db_base.BMDBTestCase):
self.context = utils.get_test_admin_context()
self.test_block_device_info = None,
self.instance = utils.get_test_instance()
self.test_network_info = utils.get_test_network_info(
legacy_model=False),
self.test_network_info = utils.get_test_network_info()
self.node_info = bm_db_utils.new_bm_node(
service_host='test_host',
cpus=4,
@ -105,12 +104,12 @@ class BareMetalTileraTestCase(bm_db_base.BMDBTestCase):
class TileraClassMethodsTestCase(BareMetalTileraTestCase):
def test_build_network_config(self):
net = utils.get_test_network_info(1, legacy_model=False)
net = utils.get_test_network_info(1)
config = tilera.build_network_config(net)
self.assertIn('eth0', config)
self.assertNotIn('eth1', config)
net = utils.get_test_network_info(2, legacy_model=False)
net = utils.get_test_network_info(2)
config = tilera.build_network_config(net)
self.assertIn('eth0', config)
self.assertIn('eth1', config)
@ -121,7 +120,7 @@ class TileraClassMethodsTestCase(BareMetalTileraTestCase):
'net-dhcp.ubuntu.template',
group='baremetal',
)
net = utils.get_test_network_info(legacy_model=False)
net = utils.get_test_network_info()
net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4'
config = tilera.build_network_config(net)
self.assertIn('iface eth0 inet dhcp', config)
@ -133,7 +132,7 @@ class TileraClassMethodsTestCase(BareMetalTileraTestCase):
'net-static.ubuntu.template',
group='baremetal',
)
net = utils.get_test_network_info(legacy_model=False)
net = utils.get_test_network_info()
net[0]['network']['subnets'][0]['ips'][0]['address'] = '1.2.3.4'
config = tilera.build_network_config(net)
self.assertIn('iface eth0 inet static', config)
@ -236,7 +235,7 @@ class TileraPrivateMethodsTestCase(BareMetalTileraTestCase):
self.instance['hostname'] = 'fake hostname'
files.append(('/etc/hostname', 'fake hostname'))
self.instance['key_data'] = 'fake ssh key'
net_info = utils.get_test_network_info(1, legacy_model=False)
net_info = utils.get_test_network_info(1)
net = tilera.build_network_config(net_info)
admin_password = 'fake password'

View File

@ -516,8 +516,7 @@ class HyperVAPITestCase(test.TestCase):
def test_power_on(self):
self._instance_data = self._get_instance_data()
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
vmutils.VMUtils.set_vm_state(mox.Func(self._check_instance_name),
constants.HYPERV_VM_STATE_ENABLED)
self._mox.ReplayAll()
@ -526,8 +525,7 @@ class HyperVAPITestCase(test.TestCase):
def test_power_on_already_running(self):
self._instance_data = self._get_instance_data()
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
vmutils.VMUtils.set_vm_state(mox.Func(self._check_instance_name),
constants.HYPERV_VM_STATE_ENABLED)
self._mox.ReplayAll()
@ -536,8 +534,7 @@ class HyperVAPITestCase(test.TestCase):
def test_reboot(self):
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
self._instance_data = self._get_instance_data()
vmutils.VMUtils.set_vm_state(mox.Func(self._check_instance_name),
@ -662,8 +659,7 @@ class HyperVAPITestCase(test.TestCase):
instance = db.instance_create(self._context, instance_data)
instance['system_metadata'] = {}
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
m = livemigrationutils.LiveMigrationUtils.check_live_migration_config()
m.AndReturn(True)
@ -822,8 +818,7 @@ class HyperVAPITestCase(test.TestCase):
image = db_fakes.get_fake_image_data(self._project_id, self._user_id)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
self._conn.spawn(self._context, instance, image,
injected_files=[], admin_password=None,
@ -1122,8 +1117,7 @@ class HyperVAPITestCase(test.TestCase):
size_exception=False):
self._instance_data = self._get_instance_data()
instance = db.instance_create(self._context, self._instance_data)
network_info = fake_network.fake_get_instance_nw_info(
self.stubs, spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
instance['root_gb'] = 10
@ -1238,8 +1232,7 @@ class HyperVAPITestCase(test.TestCase):
self._instance_data = self._get_instance_data()
instance = db.instance_create(self._context, self._instance_data)
instance['system_metadata'] = {}
network_info = fake_network.fake_get_instance_nw_info(
self.stubs, spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
m = basevolumeutils.BaseVolumeUtils.volume_in_mapping(mox.IsA(str),
None)
@ -1291,8 +1284,7 @@ class HyperVAPITestCase(test.TestCase):
def test_confirm_migration(self):
self._instance_data = self._get_instance_data()
instance = db.instance_create(self._context, self._instance_data)
network_info = fake_network.fake_get_instance_nw_info(
self.stubs, spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
pathutils.PathUtils.get_instance_migr_revert_dir(instance['name'],
remove_dir=True)
@ -1303,8 +1295,7 @@ class HyperVAPITestCase(test.TestCase):
def _test_finish_revert_migration(self, power_on):
self._instance_data = self._get_instance_data()
instance = db.instance_create(self._context, self._instance_data)
network_info = fake_network.fake_get_instance_nw_info(
self.stubs, spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
fake_revert_path = ('C:\\FakeInstancesPath\\%s\\_revert' %
instance['name'])

View File

@ -463,8 +463,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
cfg = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(cfg.acpi, True)
self.assertEquals(cfg.apic, True)
@ -511,8 +510,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
cfg = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 2,
spectacular=True),
_fake_network_info(self.stubs, 2),
None, disk_info)
self.assertEquals(cfg.acpi, True)
self.assertEquals(cfg.memory, 1024 * 1024 * 2)
@ -783,8 +781,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(conf.cpu, None)
@ -804,8 +801,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -822,8 +818,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(conf.cpu, None)
@ -837,8 +832,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(conf.cpu, None)
@ -856,8 +850,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -878,8 +871,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -901,8 +893,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -925,8 +916,7 @@ class LibvirtConnTestCase(test.TestCase):
self.assertRaises(exception.NovaException,
conn.get_guest_config,
instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None,
disk_info)
@ -961,8 +951,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -988,8 +977,7 @@ class LibvirtConnTestCase(test.TestCase):
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
conf = conn.get_guest_config(instance_ref,
_fake_network_info(self.stubs, 1,
spectacular=True),
_fake_network_info(self.stubs, 1),
None, disk_info)
self.assertEquals(type(conf.cpu),
vconfig.LibvirtConfigGuestCPU)
@ -1919,8 +1907,7 @@ class LibvirtConnTestCase(test.TestCase):
def test_multi_nic(self):
instance_data = dict(self.test_instance)
network_info = _fake_network_info(self.stubs, 2,
spectacular=True)
network_info = _fake_network_info(self.stubs, 2)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
instance_ref = db.instance_create(self.context, instance_data)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
@ -1941,8 +1928,7 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEquals(conn.uri(), 'lxc:///')
network_info = _fake_network_info(self.stubs, 1,
spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
xml = conn.to_xml(instance_ref, network_info, disk_info)
@ -1996,8 +1982,7 @@ class LibvirtConnTestCase(test.TestCase):
self.flags(libvirt_disk_prefix=prefix)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
network_info = _fake_network_info(self.stubs, 1,
spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref)
xml = conn.to_xml(instance_ref, network_info, disk_info)
@ -2031,7 +2016,7 @@ class LibvirtConnTestCase(test.TestCase):
user_context = context.RequestContext(self.user_id, self.project_id)
instance_ref = db.instance_create(user_context, self.test_instance)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
@ -2059,7 +2044,7 @@ class LibvirtConnTestCase(test.TestCase):
block_device_info, wantConfig):
user_context = context.RequestContext(self.user_id, self.project_id)
instance_ref = db.instance_create(user_context, self.test_instance)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
@ -2088,7 +2073,7 @@ class LibvirtConnTestCase(test.TestCase):
def _check_xml_and_uuid(self, image_meta):
user_context = context.RequestContext(self.user_id, self.project_id)
instance_ref = db.instance_create(user_context, self.test_instance)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
@ -2245,7 +2230,7 @@ class LibvirtConnTestCase(test.TestCase):
self.assertEquals(conn.uri(), expected_uri)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt_type,
instance_ref,
rescue=rescue)
@ -2307,7 +2292,7 @@ class LibvirtConnTestCase(test.TestCase):
# _fake_network_info must be called before create_fake_libvirt_mock(),
# as _fake_network_info calls importutils.import_class() and
# create_fake_libvirt_mock() mocks importutils.import_class().
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.create_fake_libvirt_mock()
instance_ref = db.instance_create(self.context, self.test_instance)
@ -2825,7 +2810,7 @@ class LibvirtConnTestCase(test.TestCase):
# _fake_network_info must be called before create_fake_libvirt_mock(),
# as _fake_network_info calls importutils.import_class() and
# create_fake_libvirt_mock() mocks importutils.import_class().
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.create_fake_libvirt_mock(getLibVersion=fake_getLibVersion,
getCapabilities=fake_getCapabilities,
getVersion=lambda: 1005001)
@ -4433,7 +4418,7 @@ class LibvirtConnTestCase(test.TestCase):
test_instance = copy.deepcopy(self.test_instance)
test_instance['name'] = "test"
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
conn = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
if method_name == "attach_interface":
@ -4723,7 +4708,7 @@ class IptablesFirewallTestCase(test.TestCase):
self.out6_rules = lines
return '', ''
network_model = _fake_network_info(self.stubs, 1, spectacular=True)
network_model = _fake_network_info(self.stubs, 1)
from nova.network import linux_net
linux_net.iptables_manager.execute = fake_iptables_execute
@ -4790,14 +4775,14 @@ class IptablesFirewallTestCase(test.TestCase):
def test_filters_for_instance_with_ip_v6(self):
self.flags(use_ipv6=True)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEquals(len(rulesv4), 2)
self.assertEquals(len(rulesv6), 1)
def test_filters_for_instance_without_ip_v6(self):
self.flags(use_ipv6=False)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEquals(len(rulesv4), 2)
self.assertEquals(len(rulesv6), 0)
@ -4810,7 +4795,7 @@ class IptablesFirewallTestCase(test.TestCase):
networks_count = 5
instance_ref = self._create_instance_ref()
network_info = _fake_network_info(self.stubs, networks_count,
ipv4_addr_per_network, spectacular=True)
ipv4_addr_per_network)
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
'1.1.1.1'
ipv4_len = len(self.fw.iptables.ipv4['filter'].rules)
@ -4861,7 +4846,7 @@ class IptablesFirewallTestCase(test.TestCase):
self.fw.nwfilter._conn.nwfilterLookupByName = _lookup_name
instance_ref = self._create_instance_ref()
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
self.fw.prepare_instance_filter(instance_ref, network_info)
self.fw.apply_instance_filter(instance_ref, network_info)
@ -4881,7 +4866,7 @@ class IptablesFirewallTestCase(test.TestCase):
# create a firewall via setup_basic_filtering like libvirt_conn.spawn
# should have a chain with 0 rules
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
self.assertTrue('provider' in self.fw.iptables.ipv4['filter'].chains)
rules = [rule for rule in self.fw.iptables.ipv4['filter'].rules
@ -5064,7 +5049,7 @@ class NWFilterTestCase(test.TestCase):
db.instance_add_security_group(self.context, inst_uuid,
self.security_group['id'])
instance = db.instance_get(self.context, inst_id)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
# since there is one (network_info) there is one vif
# pass this vif's mac to _ensure_all_called()
# to set the instance_filter properly
@ -5102,7 +5087,7 @@ class NWFilterTestCase(test.TestCase):
instance = db.instance_get(self.context, inst_id)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.fw.setup_basic_filtering(instance, network_info)
original_filter_count = len(fakefilter.filters)
self.fw.unfilter_instance(instance, network_info)
@ -5128,7 +5113,7 @@ class NWFilterTestCase(test.TestCase):
instance = db.instance_get(self.context, inst_id)
network_info = _fake_network_info(self.stubs, 1, spectacular=True)
network_info = _fake_network_info(self.stubs, 1)
self.fw.setup_basic_filtering(instance, network_info)
vif = network_info[0]
@ -5843,13 +5828,11 @@ class LibvirtDriverTestCase(test.TestCase):
self.mox.StubOutWithMock(self.libvirtconnection, "_cleanup_resize")
self.libvirtconnection._cleanup_resize(ins_ref,
_fake_network_info(self.stubs, 1,
spectacular=True))
_fake_network_info(self.stubs, 1))
self.mox.ReplayAll()
self.libvirtconnection.confirm_migration("migration_ref", ins_ref,
_fake_network_info(self.stubs, 1,
spectacular=True))
_fake_network_info(self.stubs, 1))
def test_cleanup_resize_same_host(self):
ins_ref = self._create_instance({'host': CONF.host})
@ -5865,8 +5848,7 @@ class LibvirtDriverTestCase(test.TestCase):
self.mox.ReplayAll()
self.libvirtconnection._cleanup_resize(ins_ref,
_fake_network_info(self.stubs, 1,
spectacular=True))
_fake_network_info(self.stubs, 1))
def test_cleanup_resize_not_same_host(self):
host = 'not' + CONF.host
@ -5898,8 +5880,7 @@ class LibvirtDriverTestCase(test.TestCase):
self.mox.ReplayAll()
self.libvirtconnection._cleanup_resize(ins_ref,
_fake_network_info(self.stubs, 1,
spectacular=True))
_fake_network_info(self.stubs, 1))
def test_get_instance_disk_info_exception(self):
instance_name = "fake-instance-name"

View File

@ -204,7 +204,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
def _get_running_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info(legacy_model=False)
network_info = test_utils.get_test_network_info()
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
'1.1.1.1'
image_info = test_utils.get_test_image_info(None, instance_ref)
@ -398,7 +398,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
def test_destroy_instance_nonexistent(self):
fake_instance = {'id': 42, 'name': 'I just made this up!',
'uuid': 'bda5fb9e-b347-40e8-8256-42397848cb00'}
network_info = test_utils.get_test_network_info(legacy_model=False)
network_info = test_utils.get_test_network_info()
self.connection.destroy(fake_instance, network_info)
@catch_notimplementederror
@ -552,14 +552,14 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
@catch_notimplementederror
def test_ensure_filtering_for_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info(legacy_model=False)
network_info = test_utils.get_test_network_info()
self.connection.ensure_filtering_rules_for_instance(instance_ref,
network_info)
@catch_notimplementederror
def test_unfilter_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info(legacy_model=False)
network_info = test_utils.get_test_network_info()
self.connection.unfilter_instance(instance_ref, network_info)
@catch_notimplementederror

View File

@ -131,7 +131,7 @@ class VMwareAPIVMTestCase(test.TestCase):
self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
# NOTE(vish): none of the network plugging code is actually
# being tested
self.network_info = utils.get_test_network_info(legacy_model=False)
self.network_info = utils.get_test_network_info()
self.image = {
'id': 'c1c8ce3d-c2e0-4247-890c-ccf5cc1c004c',

View File

@ -721,8 +721,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
else:
instance = db.instance_get(self.context, instance_id)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
if empty_dns:
# NOTE(tr3buchet): this is a terrible way to do this...
network_info[0]['network']['subnets'][0]['dns'] = []
@ -1397,8 +1396,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
instance = create_instance_with_system_metadata(self.context,
instance_values)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
image_meta = {'id': IMAGE_VHD,
'disk_format': 'vhd'}
if spawn:
@ -1580,8 +1578,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
base = xenapi_fake.create_vdi('hurr', 'fake')
base_uuid = xenapi_fake.get_record('VDI', base)['uuid']
@ -1623,8 +1620,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
dict(base_copy='hurr', cow='durr'),
@ -1653,8 +1649,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize_online", fake_vdi_resize)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
dict(base_copy='hurr', cow='durr'),
@ -1670,8 +1665,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize_online", fake_vdi_resize)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs)
# Resize instance would be determined by the compute call
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
@ -2493,8 +2487,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
src_instance_ref = db.instance_get(admin_ctxt, src_instance_ref['id'])
network_model = fake_network.fake_get_instance_nw_info(self.stubs,
1, spectacular=True)
network_model = fake_network.fake_get_instance_nw_info(self.stubs, 1)
from nova.compute import utils as compute_utils
self.stubs.Set(compute_utils, 'get_nw_info_for_instance',
@ -2517,16 +2510,14 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
def test_filters_for_instance_with_ip_v6(self):
self.flags(use_ipv6=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEquals(len(rulesv4), 2)
self.assertEquals(len(rulesv6), 1)
def test_filters_for_instance_without_ip_v6(self):
self.flags(use_ipv6=False)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEquals(len(rulesv4), 2)
self.assertEquals(len(rulesv6), 0)
@ -2541,8 +2532,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
_get_instance_nw_info = fake_network.fake_get_instance_nw_info
network_info = _get_instance_nw_info(self.stubs,
networks_count,
ipv4_addr_per_network,
spectacular=True)
ipv4_addr_per_network)
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
'1.1.1.1'
ipv4_len = len(self.fw.iptables.ipv4['filter'].rules)
@ -2564,8 +2554,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
def test_do_refresh_security_group_rules(self):
admin_ctxt = context.get_admin_context()
instance_ref = self._create_instance_ref()
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
secgroup = self._create_test_security_group()
db.instance_add_security_group(admin_ctxt, instance_ref['uuid'],
secgroup['id'])
@ -2594,8 +2583,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
# peeks at how the firewall names chains
chain_name = 'inst-%s' % instance_ref['id']
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1,
spectacular=True)
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
self.fw.prepare_instance_filter(instance_ref, network_info)
self.assertTrue('provider' in self.fw.iptables.ipv4['filter'].chains)
rules = [rule for rule in self.fw.iptables.ipv4['filter'].rules

View File

@ -169,9 +169,6 @@ class BareMetalDriver(driver.ComputeDriver):
# TODO(deva): define the version properly elsewhere
return 1
def legacy_nwinfo(self):
return False
def list_instances(self):
l = []
context = nova_context.get_admin_context()

View File

@ -830,12 +830,6 @@ class ComputeDriver(object):
"""
raise NotImplementedError()
def legacy_nwinfo(self):
"""True if the driver requires the legacy network_info format."""
# TODO(tr3buchet): update all subclasses and remove this method and
# related helpers.
raise NotImplementedError(self.legacy_nwinfo)
def macs_for_instance(self, instance):
"""What MAC addresses must this instance have?

View File

@ -449,9 +449,6 @@ class FakeDriver(driver.ComputeDriver):
def list_instance_uuids(self):
return []
def legacy_nwinfo(self):
return True
class FakeVirtAPI(virtapi.VirtAPI):
def instance_update(self, context, instance_uuid, updates):

View File

@ -192,6 +192,3 @@ class HyperVDriver(driver.ComputeDriver):
def get_console_output(self, instance):
LOG.debug(_("get_console_output called"), instance=instance)
return ''
def legacy_nwinfo(self):
return False

View File

@ -686,9 +686,6 @@ class LibvirtDriver(driver.ComputeDriver):
except exception.NovaException:
return False
def legacy_nwinfo(self):
return False
# TODO(Shrews): Remove when libvirt Bugzilla bug # 836647 is fixed.
def list_instance_ids(self):
if self._conn.numOfDomains() == 0:

View File

@ -58,15 +58,9 @@ def get_ip_version(cidr):
return int(net.version)
def get_non_legacy_network_template(network_info, use_ipv6=CONF.use_ipv6,
def get_injected_network_template(network_info, use_ipv6=CONF.use_ipv6,
template=CONF.injected_network_template):
"""A new version of get_injected_network_template that does not rely on
legacy network info.
Returns a rendered network template for the given network_info. When
libvirt's dependency on using legacy network info for network config
injection goes away, this function can replace
get_injected_network_template entirely.
"""Returns a rendered network template for the given network_info.
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
@ -143,66 +137,6 @@ def get_non_legacy_network_template(network_info, use_ipv6=CONF.use_ipv6,
return build_template(template, nets, ipv6_is_available)
def get_injected_network_template(network_info, use_ipv6=CONF.use_ipv6,
template=CONF.injected_network_template):
"""
return a rendered network template for the given network_info
:param network_info:
:py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info`
:param use_ipv6: If False, do not return IPv6 template information
even if an IPv6 subnet is present in network_info.
:param template: Path to the interfaces template file.
"""
if not (network_info and template):
return
# If we're passed new network_info, make use of it instead of forcing
# it to the legacy format required below.
if isinstance(network_info, model.NetworkInfo):
return get_non_legacy_network_template(network_info,
use_ipv6,
template)
nets = []
ifc_num = -1
have_injected_networks = False
for (network_ref, mapping) in network_info:
ifc_num += 1
if not network_ref['injected']:
continue
have_injected_networks = True
address = mapping['ips'][0]['ip']
netmask = mapping['ips'][0]['netmask']
address_v6 = None
gateway_v6 = None
netmask_v6 = None
ipv6_is_available = use_ipv6 and 'ip6s' in mapping
if ipv6_is_available:
address_v6 = mapping['ip6s'][0]['ip']
netmask_v6 = mapping['ip6s'][0]['netmask']
gateway_v6 = mapping['gateway_v6']
net_info = {'name': 'eth%d' % ifc_num,
'address': address,
'netmask': netmask,
'gateway': mapping['gateway'],
'broadcast': mapping['broadcast'],
'dns': ' '.join(mapping['dns']),
'address_v6': address_v6,
'gateway_v6': gateway_v6,
'netmask_v6': netmask_v6}
nets.append(net_info)
if have_injected_networks is False:
return
return build_template(template, nets, ipv6_is_available)
def build_template(template, nets, ipv6_is_available):
_late_load_cheetah()

View File

@ -211,12 +211,6 @@ class PowerVMDriver(driver.ComputeDriver):
raise NotImplementedError(_("Host power action is not supported by the"
"PowerVM driver."))
def legacy_nwinfo(self):
"""
Indicate if the driver requires the legacy network_info format.
"""
return False
def migrate_disk_and_power_off(self, context, instance, dest,
instance_type, network_info,
block_device_info=None):

View File

@ -190,9 +190,6 @@ class VMwareESXDriver(driver.ComputeDriver):
# FIXME(sateesh): implement this
pass
def legacy_nwinfo(self):
return False
def list_instances(self):
"""List VM instances."""
return self._vmops.list_instances()

View File

@ -597,13 +597,6 @@ class XenAPIDriver(driver.ComputeDriver):
return self._pool.undo_aggregate_operation(context, op,
aggregate, host, set_error)
def legacy_nwinfo(self):
"""
Indicate if the driver requires the legacy network_info format.
"""
# TODO(tr3buchet): remove this function once all virts return false
return False
def resume_state_on_host_boot(self, context, instance, network_info,
block_device_info=None):
"""resume guest state when a host is booted."""