Simplify XMLProperty declarations
This commit is contained in:
parent
1aaf41b201
commit
99a50de53e
|
@ -23,4 +23,4 @@ from virtinst.xmlbuilder import XMLBuilder, XMLProperty
|
|||
class Clock(XMLBuilder):
|
||||
_XML_ROOT_NAME = "clock"
|
||||
|
||||
offset = XMLProperty(xpath="./@offset")
|
||||
offset = XMLProperty("./@offset")
|
||||
|
|
|
@ -131,12 +131,12 @@ class CPU(XMLBuilder):
|
|||
if not self.match:
|
||||
self.match = "exact"
|
||||
return val
|
||||
model = XMLProperty(xpath="./model", set_converter=_set_model)
|
||||
model = XMLProperty("./model", set_converter=_set_model)
|
||||
|
||||
match = XMLProperty(xpath="./@match")
|
||||
vendor = XMLProperty(xpath="./vendor")
|
||||
mode = XMLProperty(xpath="./@mode")
|
||||
match = XMLProperty("./@match")
|
||||
vendor = XMLProperty("./vendor")
|
||||
mode = XMLProperty("./@mode")
|
||||
|
||||
sockets = XMLProperty(xpath="./topology/@sockets", is_int=True)
|
||||
cores = XMLProperty(xpath="./topology/@cores", is_int=True)
|
||||
threads = XMLProperty(xpath="./topology/@threads", is_int=True)
|
||||
sockets = XMLProperty("./topology/@sockets", is_int=True)
|
||||
cores = XMLProperty("./topology/@cores", is_int=True)
|
||||
threads = XMLProperty("./topology/@threads", is_int=True)
|
||||
|
|
|
@ -24,7 +24,7 @@ from virtinst.xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
|||
|
||||
class VirtualDeviceAlias(XMLBuilder):
|
||||
_XML_ROOT_NAME = "alias"
|
||||
name = XMLProperty(xpath="./@name")
|
||||
name = XMLProperty("./@name")
|
||||
|
||||
|
||||
class VirtualDeviceAddress(XMLBuilder):
|
||||
|
@ -68,16 +68,16 @@ class VirtualDeviceAddress(XMLBuilder):
|
|||
"format of '%s'") % addrstr)
|
||||
|
||||
|
||||
type = XMLProperty(xpath="./@type")
|
||||
domain = XMLProperty(xpath="./@domain", is_int=True)
|
||||
bus = XMLProperty(xpath="./@bus", is_int=True)
|
||||
slot = XMLProperty(xpath="./@slot", is_int=True)
|
||||
function = XMLProperty(xpath="./@function", is_int=True)
|
||||
controller = XMLProperty(xpath="./@controller", is_int=True)
|
||||
unit = XMLProperty(xpath="./@unit", is_int=True)
|
||||
port = XMLProperty(xpath="./@port", is_int=True)
|
||||
target = XMLProperty(xpath="./@target", is_int=True)
|
||||
multifunction = XMLProperty(xpath="./@multifunction", is_onoff=True)
|
||||
type = XMLProperty("./@type")
|
||||
domain = XMLProperty("./@domain", is_int=True)
|
||||
bus = XMLProperty("./@bus", is_int=True)
|
||||
slot = XMLProperty("./@slot", is_int=True)
|
||||
function = XMLProperty("./@function", is_int=True)
|
||||
controller = XMLProperty("./@controller", is_int=True)
|
||||
unit = XMLProperty("./@unit", is_int=True)
|
||||
port = XMLProperty("./@port", is_int=True)
|
||||
target = XMLProperty("./@target", is_int=True)
|
||||
multifunction = XMLProperty("./@multifunction", is_onoff=True)
|
||||
|
||||
|
||||
class VirtualDevice(XMLBuilder):
|
||||
|
|
|
@ -27,7 +27,7 @@ class VirtualAudio(VirtualDevice):
|
|||
MODEL_DEFAULT = "default"
|
||||
MODELS = ["es1370", "sb16", "pcspk", "ac97", "ich6", MODEL_DEFAULT]
|
||||
|
||||
model = XMLProperty(xpath="./@model",
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=lambda s: "es1370",
|
||||
default_name=MODEL_DEFAULT)
|
||||
|
||||
|
|
|
@ -208,8 +208,8 @@ class _VirtualCharDevice(VirtualDevice):
|
|||
make_setter_xpath_cb=_sourceport_xpath,
|
||||
set_converter=_set_source_validate, is_int=True)
|
||||
|
||||
_has_mode_connect = XMLProperty(xpath="./source[@mode='connect']/@mode")
|
||||
_has_mode_bind = XMLProperty(xpath="./source[@mode='bind']/@mode")
|
||||
_has_mode_connect = XMLProperty("./source[@mode='connect']/@mode")
|
||||
_has_mode_bind = XMLProperty("./source[@mode='bind']/@mode")
|
||||
|
||||
def _set_bind_validate(self, val):
|
||||
if val is None:
|
||||
|
@ -217,10 +217,10 @@ class _VirtualCharDevice(VirtualDevice):
|
|||
if not self._has_mode_bind:
|
||||
self._has_mode_bind = self.MODE_BIND
|
||||
return val
|
||||
bind_host = XMLProperty(xpath="./source[@mode='bind']/@host",
|
||||
bind_host = XMLProperty("./source[@mode='bind']/@host",
|
||||
doc=_("Host addresss to bind to."),
|
||||
set_converter=_set_bind_validate)
|
||||
bind_port = XMLProperty(xpath="./source[@mode='bind']/@service",
|
||||
bind_port = XMLProperty("./source[@mode='bind']/@service",
|
||||
doc=_("Host port to bind to."),
|
||||
set_converter=_set_bind_validate, is_int=True)
|
||||
|
||||
|
@ -228,7 +228,7 @@ class _VirtualCharDevice(VirtualDevice):
|
|||
if not self.supports_property("protocol"):
|
||||
return None
|
||||
return self.PROTOCOL_RAW
|
||||
protocol = XMLProperty(xpath="./protocol/@type",
|
||||
protocol = XMLProperty("./protocol/@type",
|
||||
doc=_("Format used when sending data."),
|
||||
default_cb=_get_default_protocol)
|
||||
|
||||
|
@ -236,21 +236,21 @@ class _VirtualCharDevice(VirtualDevice):
|
|||
if self.virtual_device_type == "channel":
|
||||
return self.CHANNEL_TARGET_VIRTIO
|
||||
return None
|
||||
target_type = XMLProperty(xpath="./target/@type",
|
||||
target_type = XMLProperty("./target/@type",
|
||||
doc=_("Channel type as exposed in the guest."),
|
||||
default_cb=_get_default_target_type)
|
||||
|
||||
target_address = XMLProperty(xpath="./target/@address",
|
||||
target_address = XMLProperty("./target/@address",
|
||||
doc=_("Guest forward channel address in the guest."))
|
||||
|
||||
target_port = XMLProperty(xpath="./target/@port", is_int=True,
|
||||
target_port = XMLProperty("./target/@port", is_int=True,
|
||||
doc=_("Guest forward channel port in the guest."))
|
||||
|
||||
def _default_target_name(self):
|
||||
if self.type == self.TYPE_SPICEVMC:
|
||||
return "com.redhat.spice.0"
|
||||
return None
|
||||
target_name = XMLProperty(xpath="./target/@name",
|
||||
target_name = XMLProperty("./target/@name",
|
||||
doc=_("Sysfs name of virtio port in the guest"),
|
||||
default_cb=_default_target_name)
|
||||
|
||||
|
|
|
@ -84,12 +84,12 @@ class VirtualController(VirtualDevice):
|
|||
|
||||
_XML_PROP_ORDER = ["type", "index", "model", "master_startport"]
|
||||
|
||||
type = XMLProperty(xpath="./@type")
|
||||
model = XMLProperty(xpath="./@model")
|
||||
vectors = XMLProperty(xpath="./@vectors", is_int=True)
|
||||
ports = XMLProperty(xpath="./@ports", is_int=True)
|
||||
master_startport = XMLProperty(xpath="./master/@startport", is_int=True)
|
||||
type = XMLProperty("./@type")
|
||||
model = XMLProperty("./@model")
|
||||
vectors = XMLProperty("./@vectors", is_int=True)
|
||||
ports = XMLProperty("./@ports", is_int=True)
|
||||
master_startport = XMLProperty("./master/@startport", is_int=True)
|
||||
|
||||
index = XMLProperty(xpath="./@index", is_int=True, default_cb=lambda s: 0)
|
||||
index = XMLProperty("./@index", is_int=True, default_cb=lambda s: 0)
|
||||
|
||||
VirtualController.register_type()
|
||||
|
|
|
@ -500,32 +500,32 @@ class VirtualDisk(VirtualDevice):
|
|||
clear_first=["./source/@" + target for target in
|
||||
_TARGET_PROPS])
|
||||
|
||||
device = XMLProperty(xpath="./@device",
|
||||
device = XMLProperty("./@device",
|
||||
default_cb=lambda s: s.DEVICE_DISK)
|
||||
type = XMLProperty(xpath="./@type", default_cb=_get_default_type)
|
||||
driver_name = XMLProperty(xpath="./driver/@name",
|
||||
type = XMLProperty("./@type", default_cb=_get_default_type)
|
||||
driver_name = XMLProperty("./driver/@name",
|
||||
default_cb=_get_default_driver_name)
|
||||
driver_type = XMLProperty(xpath="./driver/@type",
|
||||
driver_type = XMLProperty("./driver/@type",
|
||||
default_cb=_get_default_driver_type)
|
||||
|
||||
|
||||
bus = XMLProperty(xpath="./target/@bus")
|
||||
target = XMLProperty(xpath="./target/@dev")
|
||||
bus = XMLProperty("./target/@bus")
|
||||
target = XMLProperty("./target/@dev")
|
||||
|
||||
read_only = XMLProperty(xpath="./readonly", is_bool=True)
|
||||
shareable = XMLProperty(xpath="./shareable", is_bool=True)
|
||||
driver_cache = XMLProperty(xpath="./driver/@cache")
|
||||
driver_io = XMLProperty(xpath="./driver/@io")
|
||||
read_only = XMLProperty("./readonly", is_bool=True)
|
||||
shareable = XMLProperty("./shareable", is_bool=True)
|
||||
driver_cache = XMLProperty("./driver/@cache")
|
||||
driver_io = XMLProperty("./driver/@io")
|
||||
|
||||
error_policy = XMLProperty(xpath="./driver/@error_policy")
|
||||
serial = XMLProperty(xpath="./serial")
|
||||
error_policy = XMLProperty("./driver/@error_policy")
|
||||
serial = XMLProperty("./serial")
|
||||
|
||||
iotune_rbs = XMLProperty(xpath="./iotune/read_bytes_sec", is_int=True)
|
||||
iotune_ris = XMLProperty(xpath="./iotune/read_iops_sec", is_int=True)
|
||||
iotune_tbs = XMLProperty(xpath="./iotune/total_bytes_sec", is_int=True)
|
||||
iotune_tis = XMLProperty(xpath="./iotune/total_iops_sec", is_int=True)
|
||||
iotune_wbs = XMLProperty(xpath="./iotune/write_bytes_sec", is_int=True)
|
||||
iotune_wis = XMLProperty(xpath="./iotune/write_iops_sec", is_int=True)
|
||||
iotune_rbs = XMLProperty("./iotune/read_bytes_sec", is_int=True)
|
||||
iotune_ris = XMLProperty("./iotune/read_iops_sec", is_int=True)
|
||||
iotune_tbs = XMLProperty("./iotune/total_bytes_sec", is_int=True)
|
||||
iotune_tis = XMLProperty("./iotune/total_iops_sec", is_int=True)
|
||||
iotune_wbs = XMLProperty("./iotune/write_bytes_sec", is_int=True)
|
||||
iotune_wis = XMLProperty("./iotune/write_iops_sec", is_int=True)
|
||||
|
||||
|
||||
#################################
|
||||
|
|
|
@ -70,20 +70,20 @@ class VirtualFilesystem(VirtualDevice):
|
|||
return "dir"
|
||||
|
||||
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=lambda s: None,
|
||||
default_name=TYPE_DEFAULT)
|
||||
mode = XMLProperty(xpath="./@accessmode",
|
||||
mode = XMLProperty("./@accessmode",
|
||||
default_cb=lambda s: None,
|
||||
default_name=MODE_DEFAULT)
|
||||
wrpolicy = XMLProperty(xpath="./driver/@wrpolicy",
|
||||
wrpolicy = XMLProperty("./driver/@wrpolicy",
|
||||
default_cb=lambda s: None,
|
||||
default_name=WRPOLICY_DEFAULT)
|
||||
driver = XMLProperty(xpath="./driver/@type",
|
||||
driver = XMLProperty("./driver/@type",
|
||||
default_cb=lambda s: None,
|
||||
default_name=DRIVER_DEFAULT)
|
||||
|
||||
readonly = XMLProperty(xpath="./readonly", is_bool=True)
|
||||
readonly = XMLProperty("./readonly", is_bool=True)
|
||||
|
||||
|
||||
def _xml_get_source_xpath(self):
|
||||
|
@ -114,7 +114,7 @@ class VirtualFilesystem(VirtualDevice):
|
|||
raise ValueError(_("Filesystem target '%s' must be an absolute "
|
||||
"path") % val)
|
||||
return val
|
||||
target = XMLProperty(xpath="./target/@dir",
|
||||
target = XMLProperty("./target/@dir",
|
||||
set_converter=_validate_set_target)
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ from virtinst.xmlbuilder import XMLProperty
|
|||
|
||||
def _get_mode_prop(channel_type):
|
||||
xpath = "./channel[@name='%s']/@mode" % channel_type
|
||||
return XMLProperty(xpath=xpath)
|
||||
return XMLProperty(xpath)
|
||||
|
||||
|
||||
def _validate_port(name, val):
|
||||
|
@ -124,7 +124,7 @@ class VirtualGraphics(VirtualDevice):
|
|||
if val == self.KEYMAP_LOCAL:
|
||||
return self._default_keymap(force_local=True)
|
||||
return val
|
||||
keymap = XMLProperty(xpath="./@keymap",
|
||||
keymap = XMLProperty("./@keymap",
|
||||
default_cb=_default_keymap,
|
||||
set_converter=_set_keymap_converter)
|
||||
|
||||
|
@ -144,13 +144,13 @@ class VirtualGraphics(VirtualDevice):
|
|||
if (self.port == -1 or self.tlsPort == -1):
|
||||
return True
|
||||
return None
|
||||
port = XMLProperty(xpath="./@port", is_int=True,
|
||||
port = XMLProperty("./@port", is_int=True,
|
||||
set_converter=lambda s, v: _validate_port("Port", v),
|
||||
default_cb=_get_default_port)
|
||||
tlsPort = XMLProperty(xpath="./@tlsPort", is_int=True,
|
||||
tlsPort = XMLProperty("./@tlsPort", is_int=True,
|
||||
set_converter=lambda s, v: _validate_port("TLS port", v),
|
||||
default_cb=_get_default_tlsport)
|
||||
autoport = XMLProperty(xpath="./@autoport", is_yesno=True,
|
||||
autoport = XMLProperty("./@autoport", is_yesno=True,
|
||||
default_cb=_get_default_autoport)
|
||||
|
||||
channel_main_mode = _get_mode_prop(CHANNEL_TYPE_MAIN)
|
||||
|
@ -171,17 +171,17 @@ class VirtualGraphics(VirtualDevice):
|
|||
if self.type != "sdl":
|
||||
return None
|
||||
return os.path.expanduser("~/.Xauthority")
|
||||
xauth = XMLProperty(xpath="./@xauth",
|
||||
xauth = XMLProperty("./@xauth",
|
||||
default_cb=_get_default_xauth)
|
||||
display = XMLProperty(xpath="./@display",
|
||||
display = XMLProperty("./@display",
|
||||
default_cb=_get_default_display)
|
||||
|
||||
|
||||
type = XMLProperty(xpath="./@type", default_cb=lambda s: "vnc")
|
||||
listen = XMLProperty(xpath="./@listen")
|
||||
passwd = XMLProperty(xpath="./@passwd")
|
||||
passwdValidTo = XMLProperty(xpath="./@passwdValidTo")
|
||||
socket = XMLProperty(xpath="./@socket")
|
||||
type = XMLProperty("./@type", default_cb=lambda s: "vnc")
|
||||
listen = XMLProperty("./@listen")
|
||||
passwd = XMLProperty("./@passwd")
|
||||
passwdValidTo = XMLProperty("./@passwdValidTo")
|
||||
socket = XMLProperty("./@socket")
|
||||
|
||||
|
||||
VirtualGraphics.register_type()
|
||||
|
|
|
@ -83,28 +83,28 @@ class VirtualHostDevice(VirtualDevice):
|
|||
_XML_PROP_ORDER = ["mode", "type", "managed", "vendor", "product",
|
||||
"domain", "bus", "slot", "function"]
|
||||
|
||||
mode = XMLProperty(xpath="./@mode", default_cb=lambda s: "subsystem")
|
||||
type = XMLProperty(xpath="./@type")
|
||||
mode = XMLProperty("./@mode", default_cb=lambda s: "subsystem")
|
||||
type = XMLProperty("./@type")
|
||||
|
||||
def _get_default_managed(self):
|
||||
return self.conn.is_xen() and "no" or "yes"
|
||||
managed = XMLProperty(xpath="./@managed", is_yesno=True,
|
||||
managed = XMLProperty("./@managed", is_yesno=True,
|
||||
default_cb=_get_default_managed)
|
||||
|
||||
vendor = XMLProperty(xpath="./source/vendor/@id")
|
||||
product = XMLProperty(xpath="./source/product/@id")
|
||||
vendor = XMLProperty("./source/vendor/@id")
|
||||
product = XMLProperty("./source/product/@id")
|
||||
|
||||
device = XMLProperty(xpath="./source/address/@device")
|
||||
bus = XMLProperty(xpath="./source/address/@bus")
|
||||
device = XMLProperty("./source/address/@device")
|
||||
bus = XMLProperty("./source/address/@bus")
|
||||
|
||||
def _get_default_domain(self):
|
||||
if self.type == "pci":
|
||||
return "0x0"
|
||||
return None
|
||||
domain = XMLProperty(xpath="./source/address/@domain",
|
||||
domain = XMLProperty("./source/address/@domain",
|
||||
default_cb=_get_default_domain)
|
||||
function = XMLProperty(xpath="./source/address/@function")
|
||||
slot = XMLProperty(xpath="./source/address/@slot")
|
||||
function = XMLProperty("./source/address/@function")
|
||||
slot = XMLProperty("./source/address/@slot")
|
||||
|
||||
|
||||
VirtualHostDevice.register_type()
|
||||
|
|
|
@ -35,10 +35,10 @@ class VirtualInputDevice(VirtualDevice):
|
|||
BUS_DEFAULT = "default"
|
||||
BUSES = [BUS_PS2, BUS_USB, BUS_XEN, BUS_DEFAULT]
|
||||
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=lambda s: s.TYPE_MOUSE,
|
||||
default_name=TYPE_DEFAULT)
|
||||
bus = XMLProperty(xpath="./@bus",
|
||||
bus = XMLProperty("./@bus",
|
||||
default_cb=lambda s: s.BUS_XEN,
|
||||
default_name=BUS_DEFAULT)
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ class VirtualNetworkInterface(VirtualDevice):
|
|||
"filterref"]
|
||||
|
||||
virtualport = XMLChildProperty(VirtualPort, is_single=True)
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=lambda s: s.TYPE_BRIDGE)
|
||||
|
||||
def _get_default_mac(self):
|
||||
|
@ -207,7 +207,7 @@ class VirtualNetworkInterface(VirtualDevice):
|
|||
def _validate_mac(self, val):
|
||||
util.validate_macaddr(val)
|
||||
return val
|
||||
macaddr = XMLProperty(xpath="./mac/@address",
|
||||
macaddr = XMLProperty("./mac/@address",
|
||||
set_converter=_validate_mac,
|
||||
default_cb=_get_default_mac)
|
||||
|
||||
|
@ -215,10 +215,10 @@ class VirtualNetworkInterface(VirtualDevice):
|
|||
if self.type == self.TYPE_BRIDGE:
|
||||
return self._generate_default_bridge()
|
||||
return None
|
||||
bridge = XMLProperty(xpath="./source/@bridge",
|
||||
bridge = XMLProperty("./source/@bridge",
|
||||
default_cb=_get_default_bridge)
|
||||
network = XMLProperty(xpath="./source/@network")
|
||||
source_dev = XMLProperty(xpath="./source/@dev")
|
||||
network = XMLProperty("./source/@network")
|
||||
source_dev = XMLProperty("./source/@dev")
|
||||
|
||||
|
||||
|
||||
|
@ -226,11 +226,11 @@ class VirtualNetworkInterface(VirtualDevice):
|
|||
if self.type == self.TYPE_DIRECT:
|
||||
return "vepa"
|
||||
return None
|
||||
source_mode = XMLProperty(xpath="./source/@mode",
|
||||
source_mode = XMLProperty("./source/@mode",
|
||||
default_cb=_default_source_mode)
|
||||
model = XMLProperty(xpath="./model/@type")
|
||||
target_dev = XMLProperty(xpath="./target/@dev")
|
||||
filterref = XMLProperty(xpath="./filterref/@filter")
|
||||
model = XMLProperty("./model/@type")
|
||||
target_dev = XMLProperty("./target/@dev")
|
||||
filterref = XMLProperty("./filterref/@filter")
|
||||
|
||||
|
||||
VirtualNetworkInterface.register_type()
|
||||
|
|
|
@ -27,7 +27,7 @@ class VirtualMemballoon(VirtualDevice):
|
|||
MODEL_DEFAULT = "virtio"
|
||||
MODELS = ["xen", "none", MODEL_DEFAULT]
|
||||
|
||||
model = XMLProperty(xpath="./@model", default_cb=lambda s: s.MODEL_DEFAULT)
|
||||
model = XMLProperty("./@model", default_cb=lambda s: s.MODEL_DEFAULT)
|
||||
|
||||
|
||||
VirtualMemballoon.register_type()
|
||||
|
|
|
@ -42,15 +42,15 @@ class VirtualRedirDevice(VirtualDevice):
|
|||
|
||||
_XML_PROP_ORDER = ["bus", "type"]
|
||||
|
||||
bus = XMLProperty(xpath="./@bus",
|
||||
bus = XMLProperty("./@bus",
|
||||
default_cb=lambda s: "usb",
|
||||
default_name=BUS_DEFAULT)
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=lambda s: "spicevmc",
|
||||
default_name=TYPE_DEFAULT)
|
||||
|
||||
host = XMLProperty(xpath="./source/@host")
|
||||
service = XMLProperty(xpath="./source/@service", is_int=True)
|
||||
host = XMLProperty("./source/@host")
|
||||
service = XMLProperty("./source/@service", is_int=True)
|
||||
|
||||
|
||||
VirtualRedirDevice.register_type()
|
||||
|
|
|
@ -37,7 +37,7 @@ class VirtualSmartCardDevice(VirtualDevice):
|
|||
|
||||
_XML_PROP_ORDER = ["mode", "type"]
|
||||
|
||||
mode = XMLProperty(xpath="./@mode",
|
||||
mode = XMLProperty("./@mode",
|
||||
default_cb=lambda s: "passthrough",
|
||||
default_name=MODE_DEFAULT)
|
||||
|
||||
|
@ -45,7 +45,7 @@ class VirtualSmartCardDevice(VirtualDevice):
|
|||
if self.mode == self.MODE_DEFAULT or self.mode == "passthrough":
|
||||
return "spicevmc"
|
||||
return "tcp"
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=_default_type,
|
||||
default_name=TYPE_DEFAULT)
|
||||
|
||||
|
|
|
@ -57,11 +57,11 @@ class VirtualTPMDevice(VirtualDevice):
|
|||
|
||||
return hasattr(self, propname)
|
||||
|
||||
type = XMLProperty(xpath="./backend/@type",
|
||||
type = XMLProperty("./backend/@type",
|
||||
default_cb=lambda s: s.TYPE_PASSTHROUGH)
|
||||
model = XMLProperty(xpath="./@model",
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=lambda s: s.MODEL_TIS)
|
||||
device_path = XMLProperty(xpath="./backend/device/@path",
|
||||
device_path = XMLProperty("./backend/device/@path",
|
||||
default_cb=lambda s: "/dev/tpm0")
|
||||
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ class VirtualVideoDevice(VirtualDevice):
|
|||
|
||||
|
||||
_XML_PROP_ORDER = ["model", "vram", "heads"]
|
||||
model = XMLProperty(xpath="./model/@type",
|
||||
model = XMLProperty("./model/@type",
|
||||
default_cb=lambda s: "cirrus",
|
||||
default_name=MODEL_DEFAULT)
|
||||
vram = XMLProperty(xpath="./model/@vram", is_int=True)
|
||||
ram = XMLProperty(xpath="./model/@ram", is_int=True)
|
||||
heads = XMLProperty(xpath="./model/@heads", is_int=True)
|
||||
vram = XMLProperty("./model/@vram", is_int=True)
|
||||
ram = XMLProperty("./model/@ram", is_int=True)
|
||||
heads = XMLProperty("./model/@heads", is_int=True)
|
||||
|
||||
|
||||
VirtualVideoDevice.register_type()
|
||||
|
|
|
@ -59,10 +59,10 @@ class VirtualWatchdog(VirtualDevice):
|
|||
return action
|
||||
|
||||
_XML_PROP_ORDER = ["model", "action"]
|
||||
model = XMLProperty(xpath="./@model",
|
||||
model = XMLProperty("./@model",
|
||||
default_name=MODEL_DEFAULT,
|
||||
default_cb=lambda s: s.MODEL_I6300)
|
||||
action = XMLProperty(xpath="./@action",
|
||||
action = XMLProperty("./@action",
|
||||
default_name=ACTION_DEFAULT,
|
||||
default_cb=lambda s: s.ACTION_RESET)
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@ class DomainFeatures(XMLBuilder):
|
|||
_XML_ROOT_NAME = "features"
|
||||
_XML_PROP_ORDER = ["acpi", "apic", "pae"]
|
||||
|
||||
acpi = XMLProperty(xpath="./acpi", is_bool=True,
|
||||
acpi = XMLProperty("./acpi", is_bool=True,
|
||||
default_name="default",
|
||||
default_cb=lambda s: False)
|
||||
apic = XMLProperty(xpath="./apic", is_bool=True,
|
||||
apic = XMLProperty("./apic", is_bool=True,
|
||||
default_name="default",
|
||||
default_cb=lambda s: False)
|
||||
pae = XMLProperty(xpath="./pae", is_bool=True,
|
||||
pae = XMLProperty("./pae", is_bool=True,
|
||||
default_name="default",
|
||||
default_cb=lambda s: False)
|
||||
|
||||
|
|
|
@ -149,5 +149,5 @@ class DomainNumatune(XMLBuilder):
|
|||
_XML_ROOT_NAME = "numatune"
|
||||
_XML_PROP_ORDER = ["memory_mode", "memory_nodeset"]
|
||||
|
||||
memory_nodeset = XMLProperty(xpath="./memory/@nodeset")
|
||||
memory_mode = XMLProperty(xpath="./memory/@mode")
|
||||
memory_nodeset = XMLProperty("./memory/@nodeset")
|
||||
memory_mode = XMLProperty("./memory/@mode")
|
||||
|
|
|
@ -116,7 +116,7 @@ class Guest(XMLBuilder):
|
|||
if val == self.name:
|
||||
return
|
||||
self.validate_name(self.conn, val, check_collision=not self.replace)
|
||||
name = XMLProperty(xpath="./name", validate_cb=_validate_name)
|
||||
name = XMLProperty("./name", validate_cb=_validate_name)
|
||||
|
||||
def _set_memory(self, val):
|
||||
if val is None:
|
||||
|
@ -125,10 +125,10 @@ class Guest(XMLBuilder):
|
|||
if self.maxmemory is None or self.maxmemory < val:
|
||||
self.maxmemory = val
|
||||
return val
|
||||
memory = XMLProperty(xpath="./currentMemory", is_int=True,
|
||||
memory = XMLProperty("./currentMemory", is_int=True,
|
||||
default_cb=lambda s: 1,
|
||||
set_converter=_set_memory)
|
||||
maxmemory = XMLProperty(xpath="./memory", is_int=True)
|
||||
maxmemory = XMLProperty("./memory", is_int=True)
|
||||
|
||||
def _set_vcpus(self, val):
|
||||
if val is None:
|
||||
|
@ -138,34 +138,34 @@ class Guest(XMLBuilder):
|
|||
if self.curvcpus is not None and self.curvcpus > val:
|
||||
self.curvcpus = val
|
||||
return val
|
||||
vcpus = XMLProperty(xpath="./vcpu", is_int=True,
|
||||
vcpus = XMLProperty("./vcpu", is_int=True,
|
||||
set_converter=_set_vcpus,
|
||||
default_cb=lambda s: 1)
|
||||
curvcpus = XMLProperty(xpath="./vcpu/@current", is_int=True)
|
||||
curvcpus = XMLProperty("./vcpu/@current", is_int=True)
|
||||
|
||||
def _validate_cpuset(self, val):
|
||||
DomainNumatune.validate_cpuset(self.conn, val)
|
||||
cpuset = XMLProperty(xpath="./vcpu/@cpuset",
|
||||
cpuset = XMLProperty("./vcpu/@cpuset",
|
||||
validate_cb=_validate_cpuset)
|
||||
|
||||
def _get_default_uuid(self):
|
||||
if self._random_uuid is None:
|
||||
self._random_uuid = util.generate_uuid(self.conn)
|
||||
return self._random_uuid
|
||||
uuid = XMLProperty(xpath="./uuid",
|
||||
uuid = XMLProperty("./uuid",
|
||||
validate_cb=lambda s, v: util.validate_uuid(v),
|
||||
default_cb=_get_default_uuid)
|
||||
|
||||
type = XMLProperty(xpath="./@type", default_cb=lambda s: "xen")
|
||||
hugepage = XMLProperty(xpath="./memoryBacking/hugepages", is_bool=True)
|
||||
bootloader = XMLProperty(xpath="./bootloader")
|
||||
description = XMLProperty(xpath="./description")
|
||||
emulator = XMLProperty(xpath="./devices/emulator")
|
||||
type = XMLProperty("./@type", default_cb=lambda s: "xen")
|
||||
hugepage = XMLProperty("./memoryBacking/hugepages", is_bool=True)
|
||||
bootloader = XMLProperty("./bootloader")
|
||||
description = XMLProperty("./description")
|
||||
emulator = XMLProperty("./devices/emulator")
|
||||
|
||||
on_poweroff = XMLProperty(xpath="./on_poweroff",
|
||||
on_poweroff = XMLProperty("./on_poweroff",
|
||||
default_cb=lambda s: "destroy")
|
||||
on_reboot = XMLProperty(xpath="./on_reboot")
|
||||
on_crash = XMLProperty(xpath="./on_crash")
|
||||
on_reboot = XMLProperty("./on_reboot")
|
||||
on_crash = XMLProperty("./on_crash")
|
||||
|
||||
os = XMLChildProperty(OSXML, is_single=True)
|
||||
features = XMLChildProperty(DomainFeatures, is_single=True)
|
||||
|
|
|
@ -72,17 +72,17 @@ class OSXML(XMLBuilder):
|
|||
_bootdevs = XMLChildProperty(_BootDevice)
|
||||
bootorder = property(_get_bootorder, _set_bootorder)
|
||||
|
||||
enable_bootmenu = XMLProperty(xpath="./bootmenu/@enable", is_yesno=True)
|
||||
useserial = XMLProperty(xpath="./bios/@useserial", is_yesno=True)
|
||||
enable_bootmenu = XMLProperty("./bootmenu/@enable", is_yesno=True)
|
||||
useserial = XMLProperty("./bios/@useserial", is_yesno=True)
|
||||
|
||||
kernel = XMLProperty(xpath="./kernel")
|
||||
initrd = XMLProperty(xpath="./initrd")
|
||||
kernel_args = XMLProperty(xpath="./cmdline")
|
||||
dtb = XMLProperty(xpath="./dtb")
|
||||
kernel = XMLProperty("./kernel")
|
||||
initrd = XMLProperty("./initrd")
|
||||
kernel_args = XMLProperty("./cmdline")
|
||||
dtb = XMLProperty("./dtb")
|
||||
|
||||
init = XMLProperty(xpath="./init")
|
||||
loader = XMLProperty(xpath="./loader")
|
||||
arch = XMLProperty(xpath="./type/@arch",
|
||||
init = XMLProperty("./init")
|
||||
loader = XMLProperty("./loader")
|
||||
arch = XMLProperty("./type/@arch",
|
||||
default_cb=lambda s: s.conn.caps.host.arch)
|
||||
machine = XMLProperty(xpath="./type/@machine")
|
||||
os_type = XMLProperty(xpath="./type", default_cb=lambda s: "xen")
|
||||
machine = XMLProperty("./type/@machine")
|
||||
os_type = XMLProperty("./type", default_cb=lambda s: "xen")
|
||||
|
|
|
@ -75,7 +75,7 @@ class Seclabel(XMLBuilder):
|
|||
if self.type is None or self.type == self.TYPE_DEFAULT:
|
||||
return None
|
||||
return self._guess_secmodel()
|
||||
model = XMLProperty(xpath="./@model",
|
||||
model = XMLProperty("./@model",
|
||||
default_cb=_get_default_model,
|
||||
default_name=MODEL_DEFAULT)
|
||||
|
||||
|
@ -83,10 +83,10 @@ class Seclabel(XMLBuilder):
|
|||
if self.model is None or self.model == self.MODEL_DEFAULT:
|
||||
return None
|
||||
return self.TYPE_DYNAMIC
|
||||
type = XMLProperty(xpath="./@type",
|
||||
type = XMLProperty("./@type",
|
||||
default_cb=_get_default_type,
|
||||
default_name=TYPE_DEFAULT)
|
||||
|
||||
label = XMLProperty(xpath="./label")
|
||||
imagelabel = XMLProperty(xpath="./imagelabel")
|
||||
relabel = XMLProperty(xpath="./@relabel", is_yesno=True)
|
||||
label = XMLProperty("./label")
|
||||
imagelabel = XMLProperty("./imagelabel")
|
||||
relabel = XMLProperty("./@relabel", is_yesno=True)
|
||||
|
|
|
@ -24,11 +24,11 @@ class DomainSnapshot(XMLBuilder):
|
|||
_XML_ROOT_NAME = "domainsnapshot"
|
||||
_XML_PROP_ORDER = ["name", "description", "creationTime"]
|
||||
|
||||
name = XMLProperty(xpath="./name")
|
||||
description = XMLProperty(xpath="./description")
|
||||
state = XMLProperty(xpath="./state")
|
||||
creationTime = XMLProperty(xpath="./creationTime", is_int=True)
|
||||
parent = XMLProperty(xpath="./parent/name")
|
||||
name = XMLProperty("./name")
|
||||
description = XMLProperty("./description")
|
||||
state = XMLProperty("./state")
|
||||
creationTime = XMLProperty("./creationTime", is_int=True)
|
||||
parent = XMLProperty("./parent/name")
|
||||
|
||||
# Missing bits:
|
||||
# <memory> @type and @file
|
||||
|
|
Loading…
Reference in New Issue