libvirt-cim-bounces@redhat.com wrote on 2009-05-08 01:28:09:

>
> > +def dump_netxml(server, netname):
> > +    cmd = "virsh net-dumpxml %s | awk '/ip address/ {print}' | \
> > +           cut -d ' ' -f 4 | sed 's/address=//'" % netname
> > +    s, addr = run_remote(server, cmd)
> > +    addr = addr.strip("'")
> > +    
> > +    return addr
>
> This only checks the IP, it doesn't check the - the netmask, ip start,
> ip end, etc.
>
> I would try to leverage the NetXML class here.  You can have a function
> similar to dumpxml.  You can also have functions similar to
> xml_get_net_mac(), xml_get_vcpus() etc.  This will allow you to verify
> all the values of the XML, not just the IP.


  I discussed this in detail with Deepti. We'd like to define several functions
  for parsing net pool values in NetXML class. But on the tc, we can only get
  NetXML string instead of NetXML class, so we can not call the parsing functions.
  Do you know how to fix this?
  Now, the only options is to use dump function outside of NetXML, and then
  parse the values in the str...

 
>
> > +def verify_pool(server, pooltype, poolid, address):
> > +    status = FAIL
> > +    pool_list = EnumInstances(server, pooltype)
> > +    if len(pool_list) < 1:
> > +        logger.error("Return %i instances, expected at least one instance",
> > +                     len(pool_list))
> > +        return FAIL
> > +    
> > +    for i in range(0, len(pool_list)):
> > +        ret_pool = pool_list[i].InstanceID
> > +        ret_pool_name = ret_pool.split("/")[1]
>
> You can use the parse_instance_id() function for this.
>
> --
> Kaitlin Rupert
> IBM Linux Technology Center
> kaitlin@linux.vnet.ibm.com
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim@redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim