virttest.libvirt_xml package

Subpackages

Submodules

virttest.libvirt_xml.accessors module

Specializations of base.AccessorBase for particular XML manipulation types

class virttest.libvirt_xml.accessors.AccessorBase(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.propcan.PropCanBase

Base class for a callable operating on a LibvirtXMLBase subclass instance

element_by_parent(parent_xpath, tag_name, create=True)[source]

Retrieve/create an element instance at parent_xpath/tag_name

Parameters:
  • parent_xpath – xpath of parent element
  • tag_name – name of element under parent to retrieve/create
  • create – True to create new element if not exist
Returns:

ElementTree.Element instance

Raise:

LibvirtXMLError: If element not exist & create=False

libvirtxml
operation
property_name
xmltreefile()[source]

Retrieve xmltreefile instance from libvirtxml instance

class virttest.libvirt_xml.accessors.AccessorGeneratorBase(property_name, libvirtxml, forbidden=None, **dargs)[source]

Bases: object

Accessor method/class generator for specific property name

accessor_name(operation)[source]

Return instance name for operation, defined by subclass (i.e. ‘get_foo’)

assign_callable(operation, callable_inst)[source]

Set reference on objectified libvirtxml instance to callable_inst

static callable_name(operation)[source]

Return class name for operation (i.e. ‘Getter’), defined by subclass.

make_callable(operation)[source]

Return an callable instance for operation

make_forbidden(operation)[source]

Return a forbidden callable instance for operation

set_if_not_defined(operation)[source]

Setup a callable instance for operation only if not already defined

class virttest.libvirt_xml.accessors.AllForbidden(property_name, libvirtxml)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of forbidden accessor classes for those undefined on libvirtxml

class virttest.libvirt_xml.accessors.ForbiddenBase(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Raise LibvirtXMLAccessorError when called w/ or w/o a value arg.

class virttest.libvirt_xml.accessors.XMLAttribute(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None, attribute=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating on an attribute of an element

class Delter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove attribute

attribute
libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLAttribute.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Get attribute value

attribute
libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLAttribute.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set attribute value

attribute
libvirtxml
operation
parent_xpath
property_name
tag_name
class virttest.libvirt_xml.accessors.XMLElementBool(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating purely element existence

class Delter(operation, property_name, libvirtxml, **dargs)

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove element and ignore if it doesn’t exist (same as False)

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementBool.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve text on element

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementBool.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Create element when True, delete when false

libvirtxml
operation
parent_xpath
property_name
tag_name
XMLElementBool.required_dargs = ('parent_xpath', 'tag_name')
class virttest.libvirt_xml.accessors.XMLElementDict(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating as a dictionary of attributes

class Delter(operation, property_name, libvirtxml, **dargs)

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove element and ignore if it doesn’t exist (same as False)

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementDict.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve attributes on element

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementDict.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set attributes to value on element

libvirtxml
operation
parent_xpath
property_name
tag_name
class virttest.libvirt_xml.accessors.XMLElementInt(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None, radix=10)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating on element.text as an integer

class Delter(operation, property_name, libvirtxml, **dargs)

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove element and ignore if it doesn’t exist (same as False)

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementInt.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve text on element and convert to int

libvirtxml
operation
parent_xpath
property_name
radix
tag_name
class XMLElementInt.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set text on element after converting to int then to str

libvirtxml
operation
parent_xpath
property_name
radix
tag_name
XMLElementInt.required_dargs = ('parent_xpath', 'tag_name', 'radix')
class virttest.libvirt_xml.accessors.XMLElementList(property_name, libvirtxml, forbidden=None, parent_xpath=None, marshal_from=None, marshal_to=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating on a list of child elements

Other generators here have a hard-time dealing with XML that has multiple child-elements with the same tag. This class allows treating these structures as lists of arbitrary user-defined objects. User-defined marshal functions are called to perform the conversion to/from the format described in __init__.

class Delter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove ALL child elements for which marshal_to does NOT return None

libvirtxml
marshal_to
operation
parent_xpath
property_name
class XMLElementList.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve list of values as returned by the marshal_to callable

libvirtxml
marshal_to
operation
parent_xpath
property_name
class XMLElementList.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set child elements as returned by the marshal_to callable

libvirtxml
marshal_from
operation
parent_xpath
property_name
XMLElementList.required_dargs = ('parent_xpath', 'tag_name', 'marshal_from', 'marshal_to')
class virttest.libvirt_xml.accessors.XMLElementNest(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None, subclass=None, subclass_dargs=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating on a LibvirtXMLBase subclass

class Delter(operation, property_name, libvirtxml, **dargs)

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove element and ignore if it doesn’t exist (same as False)

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementNest.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve instance of subclass with it’s xml set to rerooted xpath/tag

libvirtxml
operation
parent_xpath
property_name
subclass
subclass_dargs
tag_name
class XMLElementNest.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set attributes to value on element

libvirtxml
operation
parent_xpath
property_name
subclass
tag_name
XMLElementNest.required_dargs = ('parent_xpath', 'tag_name', 'subclass', 'subclass_dargs')
class virttest.libvirt_xml.accessors.XMLElementText(property_name, libvirtxml, forbidden=None, parent_xpath=None, tag_name=None)[source]

Bases: virttest.libvirt_xml.accessors.AccessorGeneratorBase

Class of accessor classes operating on element.text

class Delter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Remove element and ignore if it doesn’t exist (same as False)

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementText.Getter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Retrieve text on element

libvirtxml
operation
parent_xpath
property_name
tag_name
class XMLElementText.Setter(operation, property_name, libvirtxml, **dargs)[source]

Bases: virttest.libvirt_xml.accessors.AccessorBase

Set text to value on element

libvirtxml
operation
parent_xpath
property_name
tag_name
XMLElementText.required_dargs = ('parent_xpath', 'tag_name')
virttest.libvirt_xml.accessors.add_to_slots(*args)[source]

Return list of AccessorBase.__all_slots__ + args

virttest.libvirt_xml.accessors.type_check(name, thing, expected)[source]

Check that thing is expected subclass or instance, raise ValueError if not

virttest.libvirt_xml.base module

class virttest.libvirt_xml.base.LibvirtXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.propcan.PropCanBase

Base class for common attributes/methods applying to all sub-classes

Properties:
xml:
virtual XMLTreeFile instance
get:
xml filename string
set:
create new XMLTreeFile instance from string or filename
del:
deletes property, closes & unlinks any temp. files
xmltreefile:
XMLTreeFile instance
virsh:
virsh module or Virsh class instance
set:
validates and sets value
get:
returns value
del:
removes value
validates:
virtual boolean, read-only, True/False from virt-xml-validate
copy()[source]

Returns a copy of instance not sharing any references or modifications

del_validates()[source]

Raises LibvirtXMLError

del_xmltreefile()[source]

Remove all backing XML

get_section_string(xpath)[source]

Returns the content of section in xml.

get_validates()[source]

Accessor method for ‘validates’ property returns virt-xml-validate T/F

get_xml()[source]

Accessor method for ‘xml’ property returns xmlTreeFile backup filename

get_xmltreefile()[source]

Return the xmltreefile object backing this instance

restore()[source]

Restore current xml content to original source content

set_validates(value)[source]

Raises LibvirtXMLError

set_virsh(value)[source]

Accessor method for virsh property, make sure it’s right type

set_xml(value)[source]

Accessor method for ‘xml’ property to load using xml_utils.XMLTreeFile

set_xmltreefile(value)[source]

Point instance directly at an already initialized XMLTreeFile instance

validates
virsh
static virt_xml_validate(filename, schema_name=None)[source]

Return CmdResult from running virt-xml-validate on backing XML

xml
xmltreefile
virttest.libvirt_xml.base.load_xml_module(path, name, type_list)[source]

Returns named xml element’s handler class

Parameters:
  • path – the xml module path
  • name – the xml module name
  • type_list – the supported type list of xml module names
Returns:

the named xml element’s handler class

virttest.libvirt_xml.capability_xml module

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

class virttest.libvirt_xml.capability_xml.CapabilityXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Handler of libvirt capabilities and nonspecific item operations.

Properties:
uuid:
string of host uuid
guest_capabilities:
dict, read-only
get:
dict map from os type names to dict map from arch names
add_feature(value)[source]

Add a feature Element to xml

Parameters:value – The added feature name
arch
cells_topology
check_feature_name(name)[source]

Check feature name valid or not.

Parameters:name – The checked feature name
Returns:True if check pass
cpu_count
cpu_topology
feature_list
get_cpu_count()[source]

Accessor method for cpu_count property (in __slots__)

get_feature(num)[source]

Get a feature element from feature list by number

Returns:Feature element
get_feature_list()[source]

Accessor method for feature_list property (in __slots__)

get_feature_name(num)[source]

Get assigned feature name

Parameters:num – Assigned feature number
Returns:Assigned feature name
get_guest_capabilities()[source]

Accessor method for guest_capabilities property (in __slots__). Return a guest capabilities dict in following schema: {<os_type>: {<arch name>: {‘wordsize’: ‘’, ‘emulator’: ‘’, ‘machine’: [<machine name>, ...], ‘domaini_<type>’: {‘emulator’: ‘’}}}}

get_power_management_list()[source]

Accessor method for power_management_list property (in __slots__)

guest_capabilities
model
power_management_list
remove_feature(num)[source]

Remove a assigned feature from xml

Parameters:num – Assigned feature number
set_feature(num, value)[source]

Set a assigned feature value to xml

Parameters:
  • num – Assigned feature number
  • value – The feature name modified to
uuid
vendor
class virttest.libvirt_xml.capability_xml.CellXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Handler of cell element in libvirt capabilities.

Properties:
cell_id:
string of node cell number id
memory:
int, memory size
mem_unit:
string of memory unit
pages:
list of pages dict
sibling:
list of sibling dict
cpus_num:
string of cpus number
cpu:
list of cpu dict
cell_id
cpu
cpus_num
static marshal_from_cpu(item, index, libvirtxml)[source]

Convert a dict to cpu tag and attributes.

static marshal_from_pages(item, index, libvirtxml)[source]

Convert a dict to pages tag and attributes.

static marshal_from_sibling(item, index, libvirtxml)[source]

Convert a dict to sibling tag and attributes.

static marshal_to_cpu(tag, attr_dict, index, libvirtxml)[source]

Convert a cpu tag and attributes to a dict.

static marshal_to_pages(tag, attr_dict, index, libvirtxml, text)[source]

Convert a pages tag and attributes to a dict.

static marshal_to_sibling(tag, attr_dict, index, libvirtxml)[source]

Convert a sibling tag and attributes to a dict.

mem_unit
memory
pages
sibling
class virttest.libvirt_xml.capability_xml.TopologyXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Handler of cells topology element in libvirt capabilities.

Properties:
num:
string of node cell numbers
cell:
list of cpu dict
cell
get_cell()[source]

Return CellXML instances list

num

virttest.libvirt_xml.network_xml module

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

class virttest.libvirt_xml.network_xml.DNSXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

IP address block, optionally containing DHCP range information

Properties:
txt:
Dict. keys: name, value
forwarder:
List
srv:
Dict. keys: service, protocol, domain, tartget, port, priority, weight
hosts:
List of host name
class HostXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Hostname element of dns

host_ip
hostnames
static marshal_from_hostname(item, index, libvirtxml)[source]

Convert a HostnameXML instance into a tag + attributes

static marshal_to_hostname(tag, attr, index, libvirtxml, text)[source]

Convert a tag + attributes into a HostnameXML instance

class DNSXML.HostnameXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Hostname element of dns

hostname
DNSXML.dns_forward
DNSXML.forwarders
DNSXML.host
static DNSXML.marshal_from_forwarder(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static DNSXML.marshal_to_forwarder(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

DNSXML.new_host(**dargs)[source]

Return a new disk IOTune instance and set properties from dargs

DNSXML.srv
DNSXML.txt
class virttest.libvirt_xml.network_xml.IPXML(address='192.168.122.1', netmask='255.255.255.0', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

IP address block, optionally containing DHCP range information

Properties:
dhcp_ranges: Dict. keys: start, end host_attr: host mac, name and ip information address: string IP address netmask: string IP’s netmask
address
dhcp_bootp
dhcp_ranges
family
hosts
static marshal_from_host(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static marshal_to_host(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

netmask
prefix
tftp_root
class virttest.libvirt_xml.network_xml.NetworkXML(network_name='default', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.network_xml.NetworkXMLBase

Manipulators of a Virtual Network through it’s XML definition.

create()[source]

Adds non-persistant / transient network to libvirt with net-create

debug_xml()[source]

Dump contents of XML file for debugging

define()[source]

Define network from self.xml.

exists()[source]

Return True if network already exists.

static get_uuid_by_name(network_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return Network’s uuid by Network’s name.

Parameters:network_name – Network’s name
Returns:Network’s uuid
static new_all_networks_dict(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return a dictionary of names to NetworkXML instances for all networks

Parameters:virsh – virsh module or instance to use
Returns:Dictionary of network name to NetworkXML instance
static new_from_net_dumpxml(network_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>, extra='')[source]

Return new NetworkXML instance from virsh net-dumpxml command

Parameters:
  • network_name – Name of network to net-dumpxml
  • virsh_instance – virsh module or instance to use
Returns:

New initialized NetworkXML instance

orbital_nuclear_strike()[source]

It’s the only way to really be sure. Remove all libvirt state

start()[source]

Start network with self.virsh.

state_dict()[source]

Return a dict containing states of active/autostart/persistent

Returns:A dict contains active/autostart/persistent as keys and boolean as values or None if network doesn’t exist.
sync(state=None)[source]

Make the change of “self” take effect on network. Recover network to designated state if option state is set.

Parameters:state – a boolean dict contains active/persistent/autostart as keys
undefine()[source]

Undefine network witch name is self.name.

class virttest.libvirt_xml.network_xml.NetworkXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for NetworkXML class.

Properties:
name:
string, operates on XML name tag
uuid:
string, operates on uuid tag
mac:
string, operates on address attribute of mac tag
ip:
string operate on ip/dhcp ranges as IPXML instances
forward:
dict, operates on forward tag
forward_interface:
list, operates on forward/interface tag
nat_port:
dict, operates on nat tag
bridge:
dict, operates on bridge attributes
routes:
list, operates on route tag.
virtualport_type:
string, operates on ‘type’ attribute of virtualport tag.
bandwidth_inbound:
dict, operates on inbound under bandwidth.
bandwidth_outbound:
dict, operates on outbound under bandwidth.
portgroup:
PortgroupXML instance to access portgroup tag.
domain_name:
string, operates on name attribute of domain tag
dns:
DNSXML instance to access dns tag.
defined:
virtual boolean, callout to virsh methods
get:
True if libvirt knows network name
set:
True defines network, False undefines to libvirt
del:
Undefines network to libvirt
active:
virtual boolean, callout to virsh methods
get:
True if network is active to libvirt
set:
True activates network, False deactivates to libvirt
del:
Deactivates network to libvirt
autostart:
virtual boolean, callout to virsh methods
get:
True if libvirt autostarts network with same name
set:
True to set autostart, False to unset to libvirt
del:
Unset autostart to libvirt
persistent:
virtual boolean, callout to virsh methods
get:
True if network was defined, False if only created.
set:
Same as defined property
del:
Same as defined property
active
autostart
bandwidth_inbound
bandwidth_outbound
bridge
defined
del_active()[source]

Accessor method for ‘active’ property, stops network

del_autostart()[source]

Accessor method for ‘autostart’ property, unsets autostart

del_defined()[source]

Accessor method for ‘define’ property, undefines network

del_ip()[source]
del_persistent()

Accessor method for ‘define’ property, undefines network

del_portgroup()[source]
dns
domain_name
forward
forward_interface
get_active()[source]

Accessor method for ‘active’ property (True/False)

get_autostart()[source]

Accessor method for ‘autostart’ property, True if set

get_defined()[source]

Accessor for ‘define’ property - does this name exist in network list

get_ip()[source]
get_persistent()[source]

Accessor method for ‘persistent’ property

get_portgroup()[source]
ip
mac
static marshal_from_forward_iface(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static marshal_from_route(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static marshal_to_forward_iface(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

static marshal_to_route(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

name
nat_port
new_dns(**dargs)[source]

Return a new dns instance and set properties from dargs

persistent
portgroup
routes
set_active(value)[source]

Accessor method for ‘active’ property, sets network active

set_autostart(value)[source]

Accessor method for ‘autostart’ property, sets/unsets autostart

set_defined(value)[source]

Accessor method for ‘define’ property, set True to define.

set_ip(value)[source]
set_persistent(value)

Accessor method for ‘define’ property, set True to define.

set_portgroup(value)[source]
uuid
virtualport_type
class virttest.libvirt_xml.network_xml.PortgroupXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for PortgroupXML class in NetworkXML.

Properties:
name:
string, operates on ‘name’ attribute of portgroup tag
default:
string of yes or no, operates on ‘default’ attribute of portgroup tag
virtualport_type:
string, operates on ‘type’ attribute of virtualport tag in portgroup.
bandwidth_inbound:
dict, operates on inbound tag in bandwidth which is child of portgroup.
bandwidth_outbound:
dict, operates on outbound tag in bandwidth which is child of portgroup.
vlan_tag:
dict, operates on vlan tag of portgroup
bandwidth_inbound
bandwidth_outbound
default
name
virtualport_type
vlan_tag
class virttest.libvirt_xml.network_xml.RangeList(iterable=None)[source]

Bases: list

A list of start & end address tuples

append_to_element(element)[source]

Adds range described by instance to ElementTree.element

virttest.libvirt_xml.nodedev_xml module

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

class virttest.libvirt_xml.nodedev_xml.CAPXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

The base class for capability.

static get_key2filename_dict()[source]

Return a dict which contain the key and the name of info file.

get_key2value_dict()[source]

Reutn a dict which contain the key and the value in capability xml.

get_sysfs_sub_path()[source]

return the sub path store the info of capibility.

class virttest.libvirt_xml.nodedev_xml.NetXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nodedev_xml.CAPXML

class for capability whose type is net.

address
interface
class virttest.libvirt_xml.nodedev_xml.NodedevXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nodedev_xml.NodedevXMLBase

class for Node device XML.

get_key2syspath_dict()[source]

Get the dict which contains key and path. key: keys in nodedev xml need to check. syspath: the abs path for the file stores info for the key.

get_key2value_dict()[source]

Get the dict which contain key and value in xml. key: keys in nodedev xml need to check. value: value in xml for the key.

static new_from_dumpxml(dev_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get a instance of NodedevXML by dumpxml dev_name.

class virttest.libvirt_xml.nodedev_xml.NodedevXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for NodedevXML class.

cap
cap_type
del_cap()[source]

Delete the capability from nodedev xml.

fabric_wwn
fc_type
get_cap()[source]

Return the capability of nodedev_xml.

static get_cap_by_type(cap_type)[source]

Init a cap class for a specific type.

Parameters:cap_type – the type of capability.
Returns:instanse of the cap.
get_sysfs_path()[source]

Get the abs path of the capability info.

get_sysfs_sub_path()[source]

Get the sub sysfs path of the capability.

host
name
parent
set_cap(value)[source]

Set the capability by value.

sysfs_main_path
wwnn
wwpn
class virttest.libvirt_xml.nodedev_xml.PCIXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nodedev_xml.CAPXML

class for capability whose type is pci.

class Address(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Address of Virtual Function device.

bus
domain
function
slot
PCIXML.bus
PCIXML.domain
PCIXML.function
PCIXML.get_address_dict()[source]

Return a dict contain the address.

static PCIXML.get_key2filename_dict()[source]

return the dict key2filename. key: the keys in pcixml need to check. filename: the name of file stored info for this key.

PCIXML.get_key2value_dict()[source]

return the dict key2value

key: the key in xml need to check. value: value in xml for this key.

PCIXML.get_sysfs_sub_path()[source]

Return the sysfs_subdir in .

Example:
pci_bus/0000:00/device/0000:00:00.0/
static PCIXML.make_sysfs_sub_path(domain, bus, slot, function)[source]

Make sysfs_sub_path for pci by domain,bus,slot and function.

static PCIXML.marshal_from_address(item, index, libvirtxml)[source]

Convert an Address instance into tag + attributes

static PCIXML.marshal_to_address(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into an Address instance

PCIXML.numa_node
PCIXML.product_id
PCIXML.slot
PCIXML.vendor_id
PCIXML.virt_functions
class virttest.libvirt_xml.nodedev_xml.StorageXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nodedev_xml.CAPXML

class for capability whose type is storage.

block
bus
driver_type
class virttest.libvirt_xml.nodedev_xml.SystemXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nodedev_xml.CAPXML

class for capability which type is system.

firm_release_date
firmversion
firmware_vendor
static get_key2filename_dict()[source]

Return a dict which contain the key and the name of info file for System node device.

get_key2value_dict()[source]

return the dict key2value

key: the key in xml need to check. value: value in xml for this key.

get_sysfs_sub_path()[source]

Return the sysfs_subdir.

hdware_serial
hdware_uuid
hdware_vendor
static make_sysfs_sub_path()[source]

return __sysfs_sub_path__ immediately.

product

virttest.libvirt_xml.nwfilter_xml module

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

class virttest.libvirt_xml.nwfilter_xml.NwfilterRulesProtocol[source]

Bases: list

List of protocol instances from classes handed out by librarian.get

append(value)[source]
by_device_tag(tag)[source]
extend(iterable)[source]
class virttest.libvirt_xml.nwfilter_xml.NwfilterXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.nwfilter_xml.NwfilterXMLBase

Manipulators of a nwfilter through it’s XML definition.

filter_chain
filter_name
filter_priority
filterrefs
get_all_protocols(protocol=None)[source]

Put all type of protocol into a NwfilterRulesProtocol instance. Return all protocols class list if protocol as None, else return specific protocol type class list.

Parameters:protocol – specific protocol type in rules
Returns:NwfilterRulesProtocol instance list
get_all_rules()[source]

Return all rules dict with protocol attribute.

Returns:all rules dict with key as rule index number
get_rules_dict(filter_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return all rules dict with protocol attribute for given filter

Parameters:
  • filter_name – name or uuid of filter
  • options – extra options
Returns:

all rules dictionary with index as key

static new_from_filter_dumpxml(uuid, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new NwfilterXML instance from virsh filter-dumpxml command

Parameters:
  • uuid – filter’s uuid
  • virsh_instance – virsh module or instance to use
Returns:

New initialized NwfilterXML instance

uuid
validates
virsh
xml
xmltreefile
class virttest.libvirt_xml.nwfilter_xml.NwfilterXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for NwfilterXML class.

Properties:
filter_name: string, filter name filter_chain: string, filter name filter_priority: string, filter priority uuid: string, operates on uuid tag filterrefs: list, list of dictionaries describing filterref properties
add_rule(value)[source]

Add new rule into filter

Parameters:value – NwfilterXMLRules instance
del_rule(rule_index=0)[source]

Delete rule with specific index

Parameters:rule_index – rule’s index number
filter_chain
filter_name
filter_priority
filterrefs
get_protocol_attr(rule_index=0, protocol=None)[source]

Return protocol dict of specific rule index and protocol type

Parameters:
  • rule_index – rule’s index number
  • protocol – the specific protocol type in rules
Returns:

protocol attribute dict

get_rule(rule_index=0, rule_protocol=None)[source]

Return NwfilterXMLRules instance for specific protocol and index

Parameters:
  • rule_index – rule’s index number
  • rule_protocol – the specific protocol type in rules
Returns:

New initialized NwfilterXMLRules instance

get_rule_index(rule_protocol=None)[source]

Return rule index list for specific protocol

Parameters:rule_protocol – the specific protocol type in rules
Returns:rule index list
static marshal_from_filterref(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static marshal_to_filterref(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

set_rule(value, rule_index=0)[source]

Delete rule with specific index and add new given value

Parameters:
  • rule_index – rule’s index number
  • value – NwfilterXMLRules instance
uuid
validates
virsh
xml
xmltreefile
class virttest.libvirt_xml.nwfilter_xml.NwfilterXMLRules(protocol=None, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Create new NwfilterXMLRules instance.

Properties:
rule_action: string, rule action rule_direction: string, rule direction priority: string, rule priority statematch: string, rule statematch
backup_rule()[source]

Return backup rule instance

Returns:the backup of rule instance
del_protocol()[source]

Delete protocol in rule xml

get_protocol(protocol=None)[source]

Return None if protocol is None, else return specific class instance

Parameters:protocol – specific protocol type in rules
Returns:specific protocol class instance from librarian.get
new_protocol(**dargs)[source]

Return a new rule protocol instance and set properties from dargs

rule_action
rule_direction
rule_priority
rule_statematch

virttest.libvirt_xml.pool_xml module

Module simplifying manipulation of XML described at http://libvirt.org/formatstorage.html#StoragePool

class virttest.libvirt_xml.pool_xml.PoolXML(pool_type='dir', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.pool_xml.PoolXMLBase

Manipulators of a libvirt Pool through it’s XML definition.

static backup_xml(name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Backup the pool xml file.

debug_xml()[source]

Dump contents of XML file for debugging

static get_pool_details(name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return pool details by pool name.

Parameters:name – pool name
Returns:a dict which include a series of pool details
static get_type(name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return pool type by pool name

Parameters:name – pool name
Returns:pool type
static new_from_dumpxml(name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new PoolXML instance from virsh pool-dumpxml command

Parameters:
  • name – Name of pool to pool-dumpxml
  • virsh_instance – Virsh module or instance to use
Returns:

new initialized PoolXML instance

pool_define()[source]

Define pool with virsh from this instance

static pool_rename(name, new_name, uuid=None, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Rename a pool from pool XML. :param name: Original pool name. :param new_name: new name of pool. :param uuid: new pool uuid, if None libvirt will generate automatically. :return: True/False or raise LibvirtXMLError

pool_undefine()[source]

Undefine pool with libvirt retaining XML in instance

class virttest.libvirt_xml.pool_xml.PoolXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for PoolXML class.

Properties:
pool_type:
string, pool type
name:
string, pool name
uuid:
string, pool uuid
capacity:
integer, pool total capacity
allocation:
integer, pool allocated capacity
available:
integer, pool available capacity
source:
PoolSourceXML instanc
target:
string, target path of pool
allocation
available
capacity
del_source()[source]
get_source()[source]
group
mode
name
owner
pool_type
set_source(value)[source]
source
target_path
uuid
class virttest.libvirt_xml.pool_xml.SourceXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Source block in pool xml, optionally containing different elements and attributes which dependent on pool type.

adp_name
adp_parent
adp_type
adp_wwnn
adp_wwpn
auth_type
auth_username
device_path
dir_path
format_type
host_name
hosts
static marshal_from_host(item, index, libvirtxml)[source]

Convert a dictionary into a tag + attributes

static marshal_to_host(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes into a dictionary

secret_usage
secret_uuid
vg_name

virttest.libvirt_xml.secret_xml module

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

class virttest.libvirt_xml.secret_xml.SecretXML(ephemeral='yes', private='no', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.secret_xml.SecretXMLBase

Manipulators of a secret through it’s XML definition.

static get_secret_details_by_uuid(uuid, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return secret XML by secret’s uuid

Parameters:uuid – secret’s uuid
Returns:secret XML dictionary
static new_from_secret_dumpxml(uuid, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new SecretXML instance from virsh secret-dumpxml command

Parameters:
  • uuid – secret’s uuid
  • virsh_instance – virsh module or instance to use
Returns:

New initialized SecretXML instance

class virttest.libvirt_xml.secret_xml.SecretXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for SecretXML class.

Properties:
secret_ephemeral:
yes or no, operates on XML secret tag
secret_private:
yes or no, operates on XML secret tag
description:
string, operates on description tag
uuid:
string, operates on uuid tag
auth_type:
string, sercet authentication type, operates on auth tag
auth_username:
string, secret authentication username, operates on auth tag
usage:
string, operates on usage tag
target:
string, sub-tag of the usage tag, operates on target tag
volume:
the volume file path, sub-tag of the usage tag, operates on volume tag
auth_type
auth_username
description
secret_ephemeral
secret_private
target
usage
usage_name
uuid
volume

virttest.libvirt_xml.snapshot_xml module

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

class virttest.libvirt_xml.snapshot_xml.SnapshotXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.snapshot_xml.SnapshotXMLBase

Manipulators of a snapshot through it’s XML definition.

class SnapDiskXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.devices.disk.Disk

Manipulators disk xml in snapshot xml definition. Most properties are inherit from parent class Disk.

Properties:
disk_name:
string, operates on disk name under disk tag
address
auth
blockio
boot
device
disk_name
driver
encryption
geometry
iotune
mirror
product
rawio
readonly
ready
serial
sgio
share
snapshot
source
target
transient
vendor
wwn
SnapshotXML.del_disks()[source]

Remove all disks

static SnapshotXML.new_from_snapshot_dumpxml(name, snap_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new SnapshotXML instance from virsh snapshot-dumpxml command

Parameters:
  • name – vm’s name
  • snap_name – snapshot name
  • uuid – snapshot’s uuid
  • virsh_instance – virsh module or instance to use
Returns:

New initialized SnapshotXML instance

SnapshotXML.set_disks(value_list)[source]

Define disks based on contents of SnapDiskXML instance list

Parameters:value_list – SnapDiskXML instance list
class virttest.libvirt_xml.snapshot_xml.SnapshotXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for SnapshotXML class.

Properties:
snap_name:
string, operates on snapshot name tag
description:
string, operates on snapshot description tag
mem_snap_type:
string, operates snapshot type under memory tag, ‘internal’, ‘external’ or ‘no’
mem_file:
string, operates snapshot file path under memory tag
creation_time:
string, operates on creationTime tag
state:
string, operates snapshot state tag
parent_name:
string, parent snapshot name tag under parent tag
creation_time
description
mem_file
mem_snap_type
parent_name
snap_name
state

virttest.libvirt_xml.sysinfo_xml module

Module simplifying manipulation of sysinfo XML

class virttest.libvirt_xml.sysinfo_xml.SysinfoXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Handler of libvirt sysinfo xml.

get_all_processors()[source]

Get all processors dict with entry name as key.

Returns:all processors dict with entry name as key

virttest.libvirt_xml.vm_xml module

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

class virttest.libvirt_xml.vm_xml.VMCPUTuneXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

CPU tuning tag XML class

Elements:
vcpupins: list of dict - vcpu, cpuset emulatorpin: attribute - cpuset shares: int period: int quota: int emulator_period: int emulator_quota: int
emulator_period
emulator_quota
emulatorpin
static marshal_from_vcpupins(item, index, libvirtxml)[source]

Convert a dict to vcpupin tag and attributes.

static marshal_to_vcpupins(tag, attr_dict, index, libvirtxml)[source]

Convert a vcpupin tag and attributes to a dict.

period
quota
shares
vcpupins
class virttest.libvirt_xml.vm_xml.VMCPUXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Higher-level manipulations related to VM’s XML(CPU)

add_feature(name, policy='')[source]

Add a feature element to xml

Parameters:
  • name – New feature name
  • policy – New feature policy
static check_feature_name(value)[source]

Check feature name valid or not.

Parameters:value – Feature name
Returns:True if check pass
fallback
feature_list
get_feature(num)[source]

Get a feature element from feature list by number

Returns:Feature element
get_feature_list()[source]

Accessor method for feature_list property (in __slots__)

get_feature_name(num)[source]

Get feature name

Parameters:num – Number in feature list
Returns:Feature name
get_feature_policy(num)[source]

Get feature policy

Parameters:num – Number in feature list
Returns:Feature policy
static marshal_from_cell(item, index, libvirtxml)[source]

Convert a dict to cell tag and attributes.

static marshal_to_cell(tag, attr_dict, index, libvirtxml)[source]

Convert a cell tag and attributes to a dict.

match
mode
model
numa_cell
remove_feature(num)[source]

Remove a feature from xml

Parameters:num – Number in feature list
set_feature(num, name='', policy='')[source]

Set feature name (and policy) to xml

Parameters:
  • num – Number in feature list
  • name – New feature name
  • policy – New feature policy
topology
vendor
class virttest.libvirt_xml.vm_xml.VMClockXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>, offset='utc')[source]

Bases: virttest.libvirt_xml.vm_xml.VMXML

Higher-level manipulations related to VM’s XML(Clock)

class TimerXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>, timer_name='tsc')[source]

Bases: virttest.libvirt_xml.vm_xml.VMXML

Timer element of clock

catchup_limit
catchup_slew
catchup_threshold
frequency
mode
name
present
tickpolicy
track
update(attr_dict)[source]
VMClockXML.adjustment
VMClockXML.from_dumpxml(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Helper to load xml from domain.

static VMClockXML.marshal_from_timer(item, index, libvirtxml)[source]

Convert a TimerXML instance into tag + attributes

static VMClockXML.marshal_to_timer(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes to a TimerXML instance

VMClockXML.offset
VMClockXML.timers
VMClockXML.timezone
class virttest.libvirt_xml.vm_xml.VMFeaturesXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Class to access <features> tag of domain XML.

Elements:
feature_list list of top level element hyperv_relaxed: attribute - state hyperv_vapic: attribute - state hyperv_spinlocks: attributes - state, retries kvm_hidden: attribute - state pvspinlock: attribute - state
add_feature(name, attr_name='', attr_value='')[source]

Add a feature element to xml

Params name:Feature name
feature_list
get_feature_list()[source]

Return all features(top level elements) in xml

has_feature(name)[source]

Return true if the given feature exist in xml

hyperv_relaxed_state
hyperv_spinlocks_retries
hyperv_spinlocks_state
hyperv_vapic_state
kvm_hidden_state
pvspinlock_state
remove_feature(name)[source]

Remove a feature element from xml

Params name:Feature name
class virttest.libvirt_xml.vm_xml.VMHugepagesXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.vm_xml.VMXML

hugepages element

class PageXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.vm_xml.VMXML

Page element of hugepages

nodeset
size
unit
update(attr_dict)[source]
static VMHugepagesXML.marshal_from_page(item, index, libvirtxml)[source]

Convert a PageXML instance into tag + attributes

static VMHugepagesXML.marshal_to_page(tag, attr_dict, index, libvirtxml)[source]

Convert a tag + attributes to a PageXML instance

VMHugepagesXML.pages
class virttest.libvirt_xml.vm_xml.VMMemBackingXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.vm_xml.VMXML

memoryBacking tag XML class

Elements:
hugepages nosharepages locked
hugepages
locked
nosharepages
class virttest.libvirt_xml.vm_xml.VMMemTuneXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Memory Tuning tag XML class

Element:
hard_limit: int hard_limit_unit: attribute soft_limit: int soft_limit_unit: attribute swap_hard_limit: int swap_limit_unit: attribute min_guarantee: int min_guarantee_unit: attribute
hard_limit
hard_limit_unit
min_guarantee
min_guarantee_unit
soft_limit
soft_limit_unit
swap_hard_limit
swap_limit_unit
class virttest.libvirt_xml.vm_xml.VMOSXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Class to access <os> tag of domain XML.

Elements:
type: text attributes - arch, machine loader: path boots: list attributes - dev bootmenu: attributes - enable smbios: attributes - mode bios: attributes - useserial, rebootTimeout init: text bootloader: text bootloader_args: text kernel: text initrd: text cmdline: text dtb: text
TODO:
initargs: list
arch
bios_reboot_timeout
bios_useserial
bootloader
bootloader_args
bootmenu_enable
boots
cmdline
dtb
init
initargs
initrd
kernel
loader
machine
static marshal_from_boots(item, index, libvirtxml)[source]

Convert a string to boot tag and attributes.

static marshal_to_boots(tag, attr_dict, index, libvirtxml)[source]

Convert a boot tag and attributes to a string.

smbios_mode
type
class virttest.libvirt_xml.vm_xml.VMPMXML(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

VM power management tag XML class

Elements:
suspend-to-disk: attribute - enabled suspend-to-mem: attribute - enabled
disk_enabled
mem_enabled
class virttest.libvirt_xml.vm_xml.VMXML(hypervisor_type='kvm', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.vm_xml.VMXMLBase

Higher-level manipulations related to VM’s XML or guest/host state

add_device(value)[source]

Add a device into VMXML.

Parameters:value – instance of device in libvirt_xml/devices/
add_hostdev(source_address, mode='subsystem', hostdev_type='pci', managed='yes', boot_order=None)[source]

Add a hostdev device to guest.

Parameters:source_address – A dict include slot, function, bus, domain
static add_security_info(vmxml, passwd)[source]

Add passwd for graphic

Parameters:
  • vmxml – instance of VMXML
  • passwd – Password you want to set
static check_cpu_mode(mode)[source]

Check input cpu mode invalid or not.

Parameters:mode – the mode of cpu:’host-model’...
static check_disk_exist(vm_name, disk_src, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Check if given disk exist in VM.

Parameters:
  • vm_name – Domain name.
  • disk_src – Domian disk source path or darget dev.
Returns:

True/False

static check_disk_type(vm_name, disk_src, disk_type, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Check if disk type is correct in VM

Parameters:
  • vm_name – Domain name.
  • disk_src – Domain disk source path
  • disk_type – Domain disk type
Returns:

True/False

define()[source]

Define VM with virsh from this instance

del_device(value, by_tag=False)[source]

Remove a device from VMXML

Parameters:
  • value – instance of device in libvirt_xml/devices/ or device tag
  • by_tag – Boolean value. True for delete device by tag name
static del_memoryBacking_tag(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Remove the memoryBacking tag from a domain

get_agent_channels()[source]

Get all qemu guest agent channels

static get_blkdevio_params(vm_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s block I/O tuning setting from XML definition

static get_blkio_params(vm_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s block I/O setting from XML definition

static get_device_class(type_name)[source]

Return class that handles type_name devices, or raise exception.

static get_disk_address(vm_name, disk_target, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get disk address in VM

Parameters:
  • vm_name – Domain name.
  • disk_target – Domain disk target
Returns:

disk address

get_disk_all()[source]

Return VM’s disk from XML definition, None if not set

static get_disk_attr(vm_name, target, tag, attr, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get value of disk tag attribute for a given target dev.

static get_disk_blk(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get block device of a defined VM’s disks.

Parameters:vm_name – Name of defined vm.
static get_disk_count(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get count of VM’s disks.

Parameters:vm_name – Name of defined vm.
static get_disk_serial(vm_name, disk_target, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get disk serial in VM

Parameters:
  • vm_name – Domain name.
  • disk_target – Domain disk target
Returns:

disk serial

static get_disk_source(vm_name, option='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get block device of a defined VM’s disks.

Parameters:
  • vm_name – Name of defined vm.
  • option – extra option.
static get_first_mac_by_name(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Convenience method for getting first mac of a defined VM

Param:vm_name: Name of defined vm to get mac
get_graphics_devices(type_name='')[source]

Get all graphics devices or desired type graphics devices

Parameters:type_name – graphic type, vnc or spice
get_iface_all()[source]

Get a dict with interface’s mac and node.

static get_iface_by_mac(vm_name, mac, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Get the interface if mac is matched.

Parameters:
  • vm_name – Name of defined vm.
  • mac – a mac address.
Returns:

return a dict include main interface’s features

static get_iface_dev(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s interface device from XML definition, None if not set

static get_iftune_params(vm_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s interface tuning setting from XML definition

get_net_all()[source]

Return VM’s net from XML definition, None if not set

static get_net_dev(vm_name)[source]

Get net device of a defined VM’s nets.

Parameters:vm_name – Name of defined vm.
static get_numa_memnode_params(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s numa memnode setting from XML definition

static get_numa_memory_params(vm_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return VM’s numa memory setting from XML definition

get_primary_serial()[source]

Get a dict with primary serial features.

static new_from_dumpxml(vm_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new VMXML instance from virsh dumpxml command

Parameters:
  • vm_name – Name of VM to dumpxml
  • virsh_instance – virsh module or instance to use
Returns:

New initialized VMXML instance

static new_from_inactive_dumpxml(vm_name, options='', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new VMXML instance of inactive domain from virsh dumpxml command

Parameters:
  • vm_name – Name of VM to dumpxml
  • options – virsh dumpxml command’s options
  • virsh_instance – virsh module or instance to use
Returns:

New initialized VMXML instance

remove_agent_channels()[source]

Delete all channels for guest agent

remove_all_boots()[source]

Remove all OS boots

remove_all_device_by_type(device_type)[source]

Remove all devices of a given type.

Parameters:type – Type name for devices should be removed.
remove_all_graphics()[source]

Remove all graphics devices.

set_agent_channel(src_path=None, tgt_name='org.qemu.guest_agent.0', ignore_exist=False)[source]

Add a channel for guest agent if non exists.

Parameters:
  • src_path – Source path of the channel
  • tgt_name – Target name of the channel
  • ignore_exist – Whether add a channel even if another already exists.
static set_cpu_mode(vm_name, mode='host-model')[source]

Set cpu’s mode of VM.

Parameters:
  • vm_name – Name of defined vm to set cpu mode.
  • mode – the mode of cpu:’host-model’...
static set_memoryBacking_tag(vm_name, hpgs=True, nosp=False, locked=False, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

let the guest using hugepages.

static set_multiqueues(vm_name, queues, index=0)[source]

Set multiqueues for interface.

Parameters:
  • queues – the count of queues for interface
  • index – the index of interface
static set_pm_suspend(vm_name, mem='yes', disk='yes', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Add/set pm suspend Support

Params vm_name:Name of defined vm
Params mem:Enable suspend to memory
Params disk:Enable suspend to disk
static set_primary_serial(vm_name, dev_type, port, path=None, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Set primary serial’s features of vm_name.

Parameters:
  • vm_name – Name of defined vm to set primary serial.
  • dev_type – the type of serial:pty,file...
  • port – the port of serial
  • path – the path of serial, it is not necessary for pty
static set_vm_vcpus(vm_name, value, current=None, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Convenience method for updating ‘vcpu’ and ‘current’ attribute property of a defined VM

Parameters:
  • vm_name – Name of defined vm to change vcpu elemnet data
  • value – New data value, None to delete.
  • current – New current value, None will not change current value
sync(options=None)[source]

Rebuild VM with the config file.

undefine(options=None)[source]

Undefine this VM with libvirt retaining XML in instance

static vm_rename(vm, new_name, uuid=None, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Rename a vm from its XML.

Parameters:
  • vm – VM class type instance
  • new_name – new name of vm
  • uuid – new_vm’s uuid, if None libvirt will generate.
Returns:

a new VM instance

class virttest.libvirt_xml.vm_xml.VMXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for VMXML class properties (items in __slots__)

Properties:
hypervisor_type: string, hypervisor type name
get: return domain’s type attribute value set: change domain type attribute value del: raise xcepts.LibvirtXMLError
vm_name: string, name of the vm
get: return text value of name tag set: set text value of name tag del: raise xcepts.LibvirtXMLError
uuid: string, uuid string for vm
get: return text value of uuid tag set: set text value for (new) uuid tag (unvalidated) del: remove uuid tag
vcpu, max_mem, current_mem, iothreads: integers
get: returns integer set: set integer del: removes tag
dumpcore: string, control guest OS memory dump
get: return text value set: set ‘on’ or ‘off’ for guest OS memory dump del: removes tag
numa_memory: dictionary
get: return dictionary of numatune/memory attributes set: set numatune/memory attributes from dictionary del: remove numatune/memory tag
numa_memnode: list dict of memnode attributes cellid, mode and nodeset
get: return list of dictionary with numatune/memnode attributes set: set multiple numatune/memnode attributes from dictionary list del: remove numatune/memnode tag
on_poweroff: string, action to take when the guest requests a poweroff
get: returns text value of on_poweroff tag set: set test of on_poweroff tag del: remove on_poweroff tag
on_reboot: string, action to take when the guest requests a reboot
get: returns text value of on_reboot tag set: set test of on_reboot tag del: remove on_reboot tag
on_crash: string, action to take when the guest crashes
get: returns text value of on_crash tag set: set test of on_crash tag del: remove on_crash tag
devices: VMXMLDevices (list-like)
get: returns VMXMLDevices instance for all devices set: Define all devices from VMXMLDevices instance del: remove all devices
cputune: VMCPUTuneXML
get: return VMCPUTuneXML instance for the domain. set: Define cputune tag from a VMCPUTuneXML instance. del: remove cputune tag
cpu: VMCPUXML
get: return VMCPUXML instance for the domain. set: Define cpu tag from a VMCPUXML instance. del: remove cpu tag
current_vcpu: string, ‘current’ attribute of vcpu tag
get: return a string for ‘current’ attribute of vcpu set: change ‘current’ attribute of vcpu del: remove ‘current’ attribute of vcpu
placement: string, ‘placement’ attribute of vcpu tag
get: return a string for ‘placement’ attribute of vcpu set: change ‘placement’ attribute of vcpu del: remove ‘placement’ attribute of vcpu
cpuset: string, ‘cpuset’ attribute of vcpu tag
get: return a string for ‘cpuset’ attribute of vcpu set: change ‘cpuset’ attribute of vcpu del: remove ‘cpuset’ attribute of vcpu
emulatorpin: string, cpuset value (see man virsh: cpulist)
get: return text value of cputune/emulatorpin attributes set: set cputune/emulatorpin attributes from string del: remove cputune/emulatorpin tag
features: VMFeaturesXML
get: return VMFeaturesXML instances for the domain. set: define features tag from a VMFeaturesXML instances. del: remove features tag
mem_backing: VMMemBackingXML
get: return VMMemBackingXML instances for the domain. set: define memoryBacking tag from a VMMemBackingXML instances. del: remove memoryBacking tag
max_mem_unit: string, ‘unit’ attribute of memory
get: return text value of memory unit attribute set: set memory unit attribute del: remove memory unit attribute
current_mem_unit: string, ‘unit’ attribute of memory
get: return text value of current_memory unit attribute set: set current_memory unit attribute del: remove current_memory unit attribute
memtune: VMMemTuneXML
get: return VMMemTuneXML instance for the domain. set: Define memtune tag from a VMCPUTuneXML instance. del: remove memtune tag
cpu
cpuset
cputune
current_mem
current_mem_unit
current_vcpu
del_controller(controller_type=None)[source]

Delete controllers according controller type

Returns:None if deleting all controllers
del_devices()[source]

Remove all devices

del_seclabel()[source]

Remove the seclabel tag from a domain

devices
dumpcore
features
get_devices(device_type=None)[source]

Put all nodes of devices into a VMXMLDevices instance.

get_seclabel()[source]

Return seclabel + child attribute dict list or raise LibvirtXML error

Returns:None if no seclabel in xml, list contains dict of seclabel’s attributs and children.
hypervisor_type
iothreads
static marshal_from_memnode(item, index, libvirtxml)[source]

Convert a dict to memnode tag and attributes.

static marshal_to_memnode(tag, attr_dict, index, libvirtxml)[source]

Convert a memnode tag and attributes to a dict.

max_mem
max_mem_rt
max_mem_rt_slots
max_mem_rt_unit
max_mem_unit
mb
memtune
numa_memnode
numa_memory
on_crash
on_poweroff
on_reboot
os
placement
pm
seclabel
set_controller(controller_list)[source]

Set controller of vm. Create new controllers use xmltreefile from given controller_list.

set_devices(value)[source]

Define devices based on contents of VMXMLDevices instance

set_seclabel(seclabel_dict_list)[source]

Set seclabel of vm. Delete all seclabels if seclabel exists, create new seclabels use dict values from given seclabel_dict_list in xmltreefile.

uuid
vcpu
vm_name
class virttest.libvirt_xml.vm_xml.VMXMLDevices[source]

Bases: list

List of device instances from classes handed out by librarian.get()

append(value)[source]
by_device_tag(tag)[source]
extend(iterable)[source]

virttest.libvirt_xml.vol_xml module

Module simplifying manipulation of XML described at http://libvirt.org/formatstorage.html#StorageVol

class virttest.libvirt_xml.vol_xml.VolXML(vol_name='default', virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.vol_xml.VolXMLBase

Manipulators of a Virtual Vol through it’s XML definition.

class Encryption(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Encryption volume XML class

Properties:

format:
string.
secret:
dict, keys: type, uuid
format
secret
VolXML.create(pool_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Create volume with virsh from this instance

static VolXML.get_vol_details_by_name(vol_name, pool_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return volume xml dictionary by Vol’s uuid or name.

Parameters:vol_name – Vol’s name
Returns:volume xml dictionary
VolXML.new_encryption(**dargs)[source]

Return a new volume encryption instance and set properties from dargs

static VolXML.new_from_vol_dumpxml(vol_name, pool_name, virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Return new VolXML instance from virsh vol-dumpxml command

Parameters:
  • vol_name – Name of vol to vol-dumpxml
  • virsh_instance – virsh module or instance to use
Returns:

New initialized VolXML instance

static VolXML.new_vol(**dargs)[source]

Return a new VolXML instance and set properties from dargs

Parameters:dargs – param dictionary
Returns:new VolXML instance
class virttest.libvirt_xml.vol_xml.VolXMLBase(virsh_instance=<module 'virttest.virsh' from '/home/docs/checkouts/readthedocs.org/user_builds/virt-test/checkouts/latest/virttest/virsh.py'>)[source]

Bases: virttest.libvirt_xml.base.LibvirtXMLBase

Accessor methods for VolXML class.

Properties:
name: string, operates on XML name tag key: string, operates on key tag capacity: integer, operates on capacity attribute of capacity tag allocation: integer, operates on allocation attribute of allocation format: string, operates on type attribute of format tag path: string, operates on path attribute of path tag owner, integer, operates on owner attribute of owner tag group, integer, operates on group attribute of group tag mode: string, operates on mode attribute of mode tag label: string, operates on label attribute of label tag compat: string, operates on compat attribute of label tag lazy_refcounts: bool, True/False encryption: VolXMLBase.Encryption instance. capacity_unit: string, operates on unit attribute of capacity tag
allocation
capacity
capacity_unit
compat
encryption
format
group
key
label
lazy_refcounts
mode
name
owner
path

virttest.libvirt_xml.xcepts module

Module of common exceptions used in libvirt_xml package

exception virttest.libvirt_xml.xcepts.LibvirtXMLAccessorError(details='')[source]

Bases: virttest.libvirt_xml.xcepts.LibvirtXMLError

LibvirtXMLError related to an accessor generator class/method

exception virttest.libvirt_xml.xcepts.LibvirtXMLError(details='')[source]

Bases: exceptions.Exception

Error originating within libvirt_xml module

exception virttest.libvirt_xml.xcepts.LibvirtXMLForbiddenError(details='')[source]

Bases: virttest.libvirt_xml.xcepts.LibvirtXMLError

LibvirtXMLError raised when operating on a property is prohibited

exception virttest.libvirt_xml.xcepts.LibvirtXMLNotFoundError(details='')[source]

Bases: virttest.libvirt_xml.xcepts.LibvirtXMLError

LibvirtXMLError related when an element cannot be found

Module contents

Intermediate module for working with XML-related virsh functions/methods.

The intention of this module is to hide the details of working with XML from test module code. Helper methods are all high-level and not condusive to direct use in error-testing. However, access to a virsh instance is available.

All classes defined here should inherit from LibvirtXMLBase and utilize the property-like interface provided by utils_misc.PropCanBase to manipulate XML from the ‘xml’ property. Please refer to the xml_utils module documentation for more information on working with XMLTreeFile instances. Please see the virsh and utils_misc modules for information on working with Virsh and PropCanBase classes.

All properties defined in __slots__ are intended for test-module manipulation. External calling of accessor methods isn’t forbidden, but discouraged. Instead, test modules should use normal reference, assignment, and delete operations on instance properties as if they were attributes. It’s up to the test if it uses the dict-like or instance-attribute interface.

Internally, accessor methods (get_*(), set_*(), & del_*()) should always use __dict_get__(), __dict_set__(), and/or __dict_del__() to manipulate properties (otherwise infinite recursion can occur). In some cases, where class or instance attributes are needed (ousdie of __slots__) they must be accessed via the __super_set__(), __super_get__(), and/or __super_del__() methods. None of the __super_*() or the __dict_*() methods are intended for use by test-modules.

Errors originating beneath this module (e.g. w/in virsh or libvirt_vm) should not be caught (so caller can test for them). Errors detected within this module should raise LibvirtXMLError or a subclass.