提交 992ff20e 编写于 作者: Y yalzhang

Adding nwfilter with parameters

Add nwfilter with parameters with update-device and check the rules in
host. Also add check point for delete network filter, we should not only
check the xml, but also ensure the rules are deleted.
Signed-off-by: Nyalzhang <yalzhang@redhat.com>
上级 58424429
......@@ -26,6 +26,10 @@
net_name = "net7"
- add_filter:
new_iface_filter = "clean-traffic"
- add_filter_with_paramters:
new_iface_filter = "clean-traffic"
new_iface_filter_parameters = "[{'name': 'IP', 'value': '1.2.3.4'}, {'name': 'MAC', 'value': '52:54:00:7b:35:93'}]"
rules = ["-s 52:54:00:7b:35:93 -j RETURN", "-p IPv4 --ip-src 1.2.3.4 -j RETURN", "-p ARP --arp-mac-src 52:54:00:7b:35:93 -j RETURN", "-p ARP --arp-ip-src 1.2.3.4 -j RETURN"]
- update_filter:
iface_filter = "no-mac-spoofing"
new_iface_filter = "clean-traffic"
......
import os
import re
import logging
import time
from avocado.utils import process
......@@ -192,9 +193,17 @@ def run(test, params, env):
if rule not in ebtables_outputs:
test.fail("Can not find the corresponding rule after update filter with parameters!")
if del_filter:
# if the filter is deleted, it should not exists in the xml and the rules should be deleted as well
iface_filter_value = iface_aft.find('filterref')
if iface_filter_value is not None:
test.fail("After delete, the filter still exists: %s" % iface_filter_value)
ebtables_outputs = process.run("ebtables -t nat -L", shell=True).stdout_text
logging.debug("after nwfilter deleted, ebtables rules are %s" % ebtables_outputs)
time.sleep(5)
entries_num = re.findall(r'entries:\s+(\d)', ebtables_outputs)
for i in entries_num:
if i != '0':
test.fail("After delete, the rules are still exists!")
if new_iface_alias:
iface_alias_value = iface_aft.find('alias').get('name')
if iface_alias_value == eval(new_iface_alias)['name']:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册