[Libvirt-cim] [PATCH] [TEST] WIP: Update FilterList/03_create.py
Chip Vincent
cvincent at linux.vnet.ibm.com
Thu Jan 26 20:02:29 UTC 2012
Thanks. This helped me find the problem. Fix for NestedFilterList is in v4 patch.
BTW - On RHEL 6.2, I'm seeing the follow message periodically when I run with
this cimtest patch.
/home/cvincent/proj/cimtest/suites/libvirt-cim/cimtest/FilterList/helper.py:255:
FutureWarning: The behavior of this method will change in future versions. Use
specific 'len(elem)' or 'elem is not None' test instead.
if not root:
On 01/26/2012 02:16 PM, Eduardo Lima (Etrunko) wrote:
> From: "Eduardo Lima (Etrunko)"<eblima at br.ibm.com>
>
> According to recent changes in FilterList provider.
>
> Note that this is still work in progress. Sending only for testing purposes.
>
> Signed-off-by: Eduardo Lima (Etrunko)<eblima at br.ibm.com>
> ---
> suites/libvirt-cim/cimtest/FilterList/03_create.py | 36 ++++++++++++++++----
> suites/libvirt-cim/cimtest/FilterList/helper.py | 18 +++++++++-
> 2 files changed, 46 insertions(+), 8 deletions(-)
>
> diff --git a/suites/libvirt-cim/cimtest/FilterList/03_create.py b/suites/libvirt-cim/cimtest/FilterList/03_create.py
> index 157bd23..4a66f09 100644
> --- a/suites/libvirt-cim/cimtest/FilterList/03_create.py
> +++ b/suites/libvirt-cim/cimtest/FilterList/03_create.py
> @@ -37,6 +37,9 @@ from VirtLib.utils import run_remote
> sup_types = ["KVM",]
>
> domain = None
> +flist_name = None
> +nested_name = None
> +applied_name = None
>
> def get_filter_inst_and_inst_name(name):
> try:
> @@ -88,6 +91,7 @@ def create_filter_list(name):
>
> # A NestedFilterList instance will add the "clean-traffic" filter
> # as an entry of the newly created FilterList
> + global nested_name
> logger.info("Creating NestedFilterList instance")
> nested_name = test.CreateFilterListInstance(None, "KVM_NestedFilterList",
> {"Antecedent":flist_name,
> @@ -124,8 +128,12 @@ def get_nwport_inst_and_inst_name(domain_name):
>
> def cleanup():
> try:
> - # Destroy filter list
> - test.wbem.DeleteInstance(flist_name)
> + # Destroy filter list instances
> + for n in [applied_name, nested_name, flist_name]:
> + if n is not None:
> + logger.info("Deleting instance %s", n)
> + test.wbem.DeleteInstance(n)
> + logger.info("OK")
> except Exception, e:
> logger.error("Error deleting filter list: %s", e)
>
> @@ -164,15 +172,29 @@ def main():
>
> # An AppliedFilterList Instance will apply the filter to the network
> # port of the defined domain
> - test.CreateFilterListInstance(None, "KVM_AppliedFilterList",
> - {"Antecedent":nwport_name,
> - "Dependent":flist_name})
> + global applied_name
> + logger.info ("Creating AppliedFilterList instance")
> + applied_name = test.CreateFilterListInstance(None, "KVM_AppliedFilterList",
> + {"Antecedent":nwport_name,
> + "Dependent":flist_name})
> + logger.info("Got AppliedFilterList name '%s'", applied_name)
> + #applied = test.GetInstance(applied_name)
> + #logger.info("Got AppliedFilterList '%s'", applied)
> +
> + # Check results
> + filterref = test.libvirt_applied_filter_lists(domain_name)[0]
> + rule = helper.FilterRule(filterref)
> + if rule.filter != test_flist:
> + raise Exception("AppliedFilterList name '%s' does not match expected '%s'",
> + rule.filter, test_flist)
> +
> + test.cim_applied_filter_lists(domain_name)
> + logger.info("AppliedFilterList created succesfully")
> + result = PASS
> except Exception, e:
> logger.error("Caught exception: %s", e)
> result = FAIL
>
> - # Check results
> -
> # Cleanup
> cleanup()
>
> diff --git a/suites/libvirt-cim/cimtest/FilterList/helper.py b/suites/libvirt-cim/cimtest/FilterList/helper.py
> index 294ae8f..c7e8612 100644
> --- a/suites/libvirt-cim/cimtest/FilterList/helper.py
> +++ b/suites/libvirt-cim/cimtest/FilterList/helper.py
> @@ -307,6 +307,22 @@ class FilterListTest(BaseTestObject):
>
> return self.Associators(_inst_name, result_class="CIM_FilterEntryBase")
> # cim_entries_in_filter_list
> +
> + def libvirt_applied_filter_lists(self, dom_name):
> + cmd = "virsh -q -c %s dumpxml %s 2>/dev/null" % (self.uri, dom_name)
> + ret, dom_xml = run_remote(self.server, cmd)
> + if ret:
> + logger.error("Error retrieving domain xml for %s", dom_name)
> + return None
> +
> + xdoc = etree.fromstring(dom_xml)
> + filter_list = xdoc.xpath("/domain/devices/interface/filterref")
> + return filter_list
> + # libvirt_applied_filter_lists
> +
> + def cim_applied_filter_lists(self, dom_name):
> + pass
> + # cim_applied_filter_lists
> # FilterListTest
>
>
> @@ -394,7 +410,7 @@ class FilterRule(object):
>
> for e in element:
> self.__dict = dict(self.__dict, **e.attrib)
> - if not self.__type:
> + if self.__type is None:
> self.__type = e.tag
>
> try:
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list