Make a cleaner log message and use [] instead of . to get database fields.
This commit is contained in:
@@ -884,10 +884,7 @@ class IptablesFirewallTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_provider_firewall_rules(self):
|
def test_provider_firewall_rules(self):
|
||||||
# setup basic instance data
|
# setup basic instance data
|
||||||
instance_ref = db.instance_create(self.context,
|
instance_ref = self._create_instance_ref()
|
||||||
{'user_id': 'fake',
|
|
||||||
'project_id': 'fake',
|
|
||||||
'mac_address': '56:12:12:12:12:12'})
|
|
||||||
ip = '10.11.12.13'
|
ip = '10.11.12.13'
|
||||||
network_ref = db.project_get_network(self.context, 'fake')
|
network_ref = db.project_get_network(self.context, 'fake')
|
||||||
admin_ctxt = context.get_admin_context()
|
admin_ctxt = context.get_admin_context()
|
||||||
|
|||||||
@@ -749,29 +749,29 @@ class IptablesFirewallDriver(FirewallDriver):
|
|||||||
ipv6_rules = []
|
ipv6_rules = []
|
||||||
rules = db.provider_fw_rule_get_all(ctxt)
|
rules = db.provider_fw_rule_get_all(ctxt)
|
||||||
for rule in rules:
|
for rule in rules:
|
||||||
LOG.debug(_('Adding prvider rule: %r'), rule)
|
LOG.debug(_('Adding provider rule: %s'), rule['cidr'])
|
||||||
version = netutils.get_ip_version(rule.cidr)
|
version = netutils.get_ip_version(rule['cidr'])
|
||||||
if version == 4:
|
if version == 4:
|
||||||
fw_rules = ipv4_rules
|
fw_rules = ipv4_rules
|
||||||
else:
|
else:
|
||||||
fw_rules = ipv6_rules
|
fw_rules = ipv6_rules
|
||||||
|
|
||||||
protocol = rule.protocol
|
protocol = rule['protocol']
|
||||||
if version == 6 and protocol == 'icmp':
|
if version == 6 and protocol == 'icmp':
|
||||||
protocol = 'icmpv6'
|
protocol = 'icmpv6'
|
||||||
|
|
||||||
args = ['-p', protocol, '-s', rule.cidr]
|
args = ['-p', protocol, '-s', rule['cidr']]
|
||||||
|
|
||||||
if protocol in ['udp', 'tcp']:
|
if protocol in ['udp', 'tcp']:
|
||||||
if rule.from_port == rule.to_port:
|
if rule['from_port'] == rule['to_port']:
|
||||||
args += ['--dport', '%s' % (rule.from_port,)]
|
args += ['--dport', '%s' % (rule['from_port'],)]
|
||||||
else:
|
else:
|
||||||
args += ['-m', 'multiport',
|
args += ['-m', 'multiport',
|
||||||
'--dports', '%s:%s' % (rule.from_port,
|
'--dports', '%s:%s' % (rule['from_port'],
|
||||||
rule.to_port)]
|
rule['to_port'])]
|
||||||
elif protocol == 'icmp':
|
elif protocol == 'icmp':
|
||||||
icmp_type = rule.from_port
|
icmp_type = rule['from_port']
|
||||||
icmp_code = rule.to_port
|
icmp_code = rule['to_port']
|
||||||
|
|
||||||
if icmp_type == -1:
|
if icmp_type == -1:
|
||||||
icmp_type_arg = None
|
icmp_type_arg = None
|
||||||
|
|||||||
Reference in New Issue
Block a user