virttest.utils_test: Add load_python_module method

The get method in virttest.libvirt_xml.devices.librarian is
for load python module in certain path with given name, the name
is restricted in pre-defined type list. When adding network filter
rule protocol xml modules, also need to use this method to load
specific protocol xml module. So extract the get method and put it
into utils_test as load_python_module for common use.

Update get method in virttest.libvirt_xml.devices.librarian to
use the new load_python_module method, which will not broken exist
modules and tests.

Add librarian module for network filter protocols, which only have
one get method to use the load_python_module for load specific
network filter protocol xml module.

Signed-off-by: Wayne Sun <gsun@redhat.com>
virttest.libvirt_xml.devices: Add network filter rule protocol modules

Add 24 libvirt nwfilter protocols modules for supported types.

This is for cover nwfilter rule protocols in page:
http://libvirt.org/formatnwfilter.html#nwfelemsRulesProto

Note:
Total number of libvirt supported protocols is 25, only igmp-ipv6
(fail for define, need confirm bug) is not included in this commit.

Signed-off-by: Wayne Sun <gsun@redhat.com>
virttest.libvirt_xml: Add nwfilter xml module

Module simplifying manipulation of XML described at
http://libvirt.org/formatnwfilter.html

Signed-off-by: Wayne Sun <gsun@redhat.com>
libvirt.tests: Add virsh nwfilter define case

- Add virsh nwfilter define case
  The case support process multiple rules for define one filter xml.

  Only check whether the filter config xml exist or not after define
  and check the filter is in nwfilter-list command output.

  Why not strict check each attribue in xml:
    1. each attribute in xml might have default value if not set.
    2. if the attribute value is out of boundary (not valid value),
       define action will omit the attribute.
    3. protocols have different attributes which is a super big
       matrix to check each detail one

- Add virsh nwfilter define cfg
  25 positive cases including 1 update define case and 24 protocol
  type xml test.
  include 3 negative cases.

  The rule parameter in cfg should be like:
  for only 1 rule:
    rule = "rule_action=accept rule_direction=out protocol=mac EOL"
  each rule should end with string 'EOL' for split.

  Test Data:
    TESTS: 28
    CLEANUP: PASS (0.00 s)
    TOTAL TIME: 26.68 s
    TESTS PASSED: 28
    TESTS FAILED: 0
    SUCCESS RATE: 100.00 %

Signed-off-by: Wayne Sun <gsun@redhat.com>
libvirt.tests: Add virsh nwfilter-dumpxml test

v1:
Simply dump network filter xml with normal and error test.

v2:
Only accept filter name from cfg as filter uuid may differ on
different host.
For check the dumpxml result, extract uuid and name from output
and compare with nwfilter-list to confirm.

v3:
Add nwfilter dumpxml using filter uuid after using filter name
Only given filter name in cfg, run 2 time dumpxml to cover both
name and uuid option.

Signed-off-by: Wayne Sun <gsun@redhat.com>

add uuid test in dumpxml
libvirt.tests: add virsh nwfilter list test

The test simply list filters and check the filter cfg file exist
under network filter config path

Signed-off-by: Wayne Sun <gsun@redhat.com>
libvirt.tests: Add nwfilter-undefine test case

Undefine network filter using given filter name or uuid in cfg.
If the filter is valid, backup filter xml before undefine and
define the filter back after undefine succeed.

Signed-off-by: Wayne Sun <gsun@redhat.com>
libvirt.tests: Add nwfilter-edit test case

Add the case and cfg file for nwfilter-edit.
In the cfg file, 4 scenarios included, 2 for positive and 2 for
negative testing.

TODO: Cover test with readonly mode and update invalid value in xml
This two scenarios need shell interactive session to return false
when "Failed. Try again? [y,n,f,?]:" prompt.

Signed-off-by: Wayne Sun <gsun@redhat.com>