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