Since 'net' is of nova.network.model.VIF class and 'ips' is an empty
list, net needs to be pulled from hydrated nw_info.fixed_ips(), and appended to ips. bug 942593 Change-Id: I9c2f55e300d1dad503b15c261027d988073e8e61
This commit is contained in:
1
Authors
1
Authors
@@ -13,6 +13,7 @@ Andrey Brindeyev <abrindeyev@griddynamics.com>
|
|||||||
Andy Smith <code@term.ie>
|
Andy Smith <code@term.ie>
|
||||||
Andy Southgate <andy.southgate@citrix.com>
|
Andy Southgate <andy.southgate@citrix.com>
|
||||||
Anne Gentle <anne@openstack.org>
|
Anne Gentle <anne@openstack.org>
|
||||||
|
Ante Karamatić <ivoks@ubuntu.com>
|
||||||
Anthony Young <sleepsonthefloor@gmail.com>
|
Anthony Young <sleepsonthefloor@gmail.com>
|
||||||
Antony Messerli <ant@openstack.org>
|
Antony Messerli <ant@openstack.org>
|
||||||
Armando Migliaccio <Armando.Migliaccio@eu.citrix.com>
|
Armando Migliaccio <Armando.Migliaccio@eu.citrix.com>
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ from nova import utils
|
|||||||
from nova.api.ec2 import cloud
|
from nova.api.ec2 import cloud
|
||||||
from nova.compute import instance_types
|
from nova.compute import instance_types
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
|
from nova.compute import utils as compute_utils
|
||||||
from nova.compute import vm_states
|
from nova.compute import vm_states
|
||||||
from nova.virt import images
|
from nova.virt import images
|
||||||
from nova.virt import driver
|
from nova.virt import driver
|
||||||
@@ -60,6 +61,7 @@ FLAGS = flags.FLAGS
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
_fake_network_info = fake_network.fake_get_instance_nw_info
|
_fake_network_info = fake_network.fake_get_instance_nw_info
|
||||||
|
_fake_stub_out_get_nw_info = fake_network.stub_out_nw_api_get_instance_nw_info
|
||||||
_ipv4_like = fake_network.ipv4_like
|
_ipv4_like = fake_network.ipv4_like
|
||||||
|
|
||||||
|
|
||||||
@@ -1491,22 +1493,14 @@ class IptablesFirewallTestCase(test.TestCase):
|
|||||||
return '', ''
|
return '', ''
|
||||||
print cmd, kwargs
|
print cmd, kwargs
|
||||||
|
|
||||||
network_info = _fake_network_info(self.stubs, 1)
|
network_model = _fake_network_info(self.stubs, 1, spectacular=True)
|
||||||
|
|
||||||
def get_fixed_ips(*args, **kwargs):
|
|
||||||
ips = []
|
|
||||||
for network, info in network_info:
|
|
||||||
ips.extend(info['ips'])
|
|
||||||
return [ip['ip'] for ip in ips]
|
|
||||||
|
|
||||||
def nw_info(*args, **kwargs):
|
|
||||||
return network_info
|
|
||||||
|
|
||||||
from nova.network import linux_net
|
from nova.network import linux_net
|
||||||
linux_net.iptables_manager.execute = fake_iptables_execute
|
linux_net.iptables_manager.execute = fake_iptables_execute
|
||||||
|
|
||||||
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
_fake_stub_out_get_nw_info(self.stubs, lambda *a, **kw: network_model)
|
||||||
nw_info)
|
|
||||||
|
network_info = compute_utils.legacy_network_info(network_model)
|
||||||
self.fw.prepare_instance_filter(instance_ref, network_info)
|
self.fw.prepare_instance_filter(instance_ref, network_info)
|
||||||
self.fw.apply_instance_filter(instance_ref, network_info)
|
self.fw.apply_instance_filter(instance_ref, network_info)
|
||||||
|
|
||||||
@@ -1544,9 +1538,11 @@ class IptablesFirewallTestCase(test.TestCase):
|
|||||||
self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
|
self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
|
||||||
"ICMP Echo Request acceptance rule wasn't added")
|
"ICMP Echo Request acceptance rule wasn't added")
|
||||||
|
|
||||||
for ip in get_fixed_ips():
|
for ip in network_model.fixed_ips():
|
||||||
|
if ip['version'] != 4:
|
||||||
|
continue
|
||||||
regex = re.compile('-A .* -j ACCEPT -p tcp -m multiport '
|
regex = re.compile('-A .* -j ACCEPT -p tcp -m multiport '
|
||||||
'--dports 80:81 -s %s' % ip)
|
'--dports 80:81 -s %s' % ip['address'])
|
||||||
self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
|
self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
|
||||||
"TCP port 80/81 acceptance rule wasn't added")
|
"TCP port 80/81 acceptance rule wasn't added")
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ from nova import utils
|
|||||||
from nova.compute import aggregate_states
|
from nova.compute import aggregate_states
|
||||||
from nova.compute import instance_types
|
from nova.compute import instance_types
|
||||||
from nova.compute import power_state
|
from nova.compute import power_state
|
||||||
|
from nova.compute import utils as compute_utils
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova.virt import xenapi_conn
|
from nova.virt import xenapi_conn
|
||||||
from nova.virt.xenapi import fake as xenapi_fake
|
from nova.virt.xenapi import fake as xenapi_fake
|
||||||
@@ -1527,27 +1528,23 @@ class XenAPIDom0IptablesFirewallTestCase(test.TestCase):
|
|||||||
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
|
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
|
||||||
src_instance_ref = db.instance_get(admin_ctxt, src_instance_ref['id'])
|
src_instance_ref = db.instance_get(admin_ctxt, src_instance_ref['id'])
|
||||||
|
|
||||||
network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)
|
network_model = fake_network.fake_get_instance_nw_info(self.stubs,
|
||||||
|
1, spectacular=True)
|
||||||
def get_fixed_ips(*args, **kwargs):
|
|
||||||
ips = []
|
|
||||||
for _n, info in network_info:
|
|
||||||
ips.extend(info['ips'])
|
|
||||||
return [ip['ip'] for ip in ips]
|
|
||||||
|
|
||||||
def nw_info(*args, **kwargs):
|
|
||||||
return network_info
|
|
||||||
|
|
||||||
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
||||||
nw_info)
|
lambda *a, **kw: network_model)
|
||||||
|
|
||||||
|
network_info = compute_utils.legacy_network_info(network_model)
|
||||||
self.fw.prepare_instance_filter(instance_ref, network_info)
|
self.fw.prepare_instance_filter(instance_ref, network_info)
|
||||||
self.fw.apply_instance_filter(instance_ref, network_info)
|
self.fw.apply_instance_filter(instance_ref, network_info)
|
||||||
|
|
||||||
self._validate_security_group()
|
self._validate_security_group()
|
||||||
# Extra test for TCP acceptance rules
|
# Extra test for TCP acceptance rules
|
||||||
for ip in get_fixed_ips():
|
for ip in network_model.fixed_ips():
|
||||||
|
if ip['version'] != 4:
|
||||||
|
continue
|
||||||
regex = re.compile('-A .* -j ACCEPT -p tcp'
|
regex = re.compile('-A .* -j ACCEPT -p tcp'
|
||||||
' --dport 80:81 -s %s' % ip)
|
' --dport 80:81 -s %s' % ip['address'])
|
||||||
self.assertTrue(len(filter(regex.match, self._out_rules)) > 0,
|
self.assertTrue(len(filter(regex.match, self._out_rules)) > 0,
|
||||||
"TCP port 80/81 acceptance rule wasn't added")
|
"TCP port 80/81 acceptance rule wasn't added")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user