summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorSoren Hansen <sorhanse@cisco.com>2012-06-11 09:23:33 +0200
committerSoren Hansen <sorhanse@cisco.com>2012-06-11 11:37:30 +0200
commitbbdf82c5ec3e31a5dc43948291c4f37ce1098714 (patch)
treef9637239d753b9a31870b22b5f31333e490d3ce2 /nova
parent3ea7dcc6432d6247cb1dc536c31684b595841633 (diff)
Only invoke .lower() on non-None protocols
When using source group based security group rules (rather than CIDR based ones), it's permissible to not set a protocol and port. However, Nova would always try to convert the protocol to lower case, which would fail if the protocol wasn't set. Fixes bug 1010514 Change-Id: I9b1519a52ececd16a497acebfe022508cbe96126
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/test_libvirt.py7
-rw-r--r--nova/virt/firewall.py6
2 files changed, 12 insertions, 1 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index ef2374fca..937c47867 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -1871,6 +1871,10 @@ class IptablesFirewallTestCase(test.TestCase):
'to_port': 81,
'group_id': src_secgroup['id']})
+ db.security_group_rule_create(admin_ctxt,
+ {'parent_group_id': secgroup['id'],
+ 'group_id': src_secgroup['id']})
+
db.instance_add_security_group(admin_ctxt, instance_ref['uuid'],
secgroup['id'])
db.instance_add_security_group(admin_ctxt, src_instance_ref['uuid'],
@@ -1951,6 +1955,9 @@ class IptablesFirewallTestCase(test.TestCase):
'--dports 80:81 -s %s' % ip['address'])
self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
"TCP port 80/81 acceptance rule wasn't added")
+ regex = re.compile('-A .* -j ACCEPT -s %s' % ip['address'])
+ self.assertTrue(len(filter(regex.match, self.out_rules)) > 0,
+ "Protocol/port-less acceptance rule wasn't added")
regex = re.compile('-A .* -j ACCEPT -p tcp '
'-m multiport --dports 80:81 -s 192.168.10.0/24')
diff --git a/nova/virt/firewall.py b/nova/virt/firewall.py
index be6a0f7c9..89559a829 100644
--- a/nova/virt/firewall.py
+++ b/nova/virt/firewall.py
@@ -331,7 +331,11 @@ class IptablesFirewallDriver(FirewallDriver):
else:
fw_rules = ipv6_rules
- protocol = rule.protocol.lower()
+ protocol = rule.protocol
+
+ if protocol:
+ protocol = rule.protocol.lower()
+
if version == 6 and protocol == 'icmp':
protocol = 'icmpv6'