diff --git a/virtinst/clock.py b/virtinst/clock.py index 465716808..8b4065829 100644 --- a/virtinst/clock.py +++ b/virtinst/clock.py @@ -23,4 +23,4 @@ from virtinst.xmlbuilder import XMLBuilder, XMLProperty class Clock(XMLBuilder): _XML_ROOT_NAME = "clock" - offset = XMLProperty(xpath="./@offset") + offset = XMLProperty("./@offset") diff --git a/virtinst/cpu.py b/virtinst/cpu.py index d651d7b5f..90bf9dada 100644 --- a/virtinst/cpu.py +++ b/virtinst/cpu.py @@ -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) diff --git a/virtinst/device.py b/virtinst/device.py index 110048538..887da8a05 100644 --- a/virtinst/device.py +++ b/virtinst/device.py @@ -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): diff --git a/virtinst/deviceaudio.py b/virtinst/deviceaudio.py index 6d8e1997c..610c9c664 100644 --- a/virtinst/deviceaudio.py +++ b/virtinst/deviceaudio.py @@ -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) diff --git a/virtinst/devicechar.py b/virtinst/devicechar.py index a6942744e..4ac7f84bc 100644 --- a/virtinst/devicechar.py +++ b/virtinst/devicechar.py @@ -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) diff --git a/virtinst/devicecontroller.py b/virtinst/devicecontroller.py index 91cc84f76..e643d57d1 100644 --- a/virtinst/devicecontroller.py +++ b/virtinst/devicecontroller.py @@ -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() diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index 4348dcfdd..1ea9961cb 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -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) ################################# diff --git a/virtinst/devicefilesystem.py b/virtinst/devicefilesystem.py index ef64f7944..32b553439 100644 --- a/virtinst/devicefilesystem.py +++ b/virtinst/devicefilesystem.py @@ -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) diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py index 781d97ddf..504747849 100644 --- a/virtinst/devicegraphics.py +++ b/virtinst/devicegraphics.py @@ -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() diff --git a/virtinst/devicehostdev.py b/virtinst/devicehostdev.py index 93f1f15f4..a1315a99f 100644 --- a/virtinst/devicehostdev.py +++ b/virtinst/devicehostdev.py @@ -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() diff --git a/virtinst/deviceinput.py b/virtinst/deviceinput.py index 46c9dca25..392e27daf 100644 --- a/virtinst/deviceinput.py +++ b/virtinst/deviceinput.py @@ -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) diff --git a/virtinst/deviceinterface.py b/virtinst/deviceinterface.py index 69016d748..7a1a05d7a 100644 --- a/virtinst/deviceinterface.py +++ b/virtinst/deviceinterface.py @@ -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() diff --git a/virtinst/devicememballoon.py b/virtinst/devicememballoon.py index 8f2f65d94..d301b9413 100644 --- a/virtinst/devicememballoon.py +++ b/virtinst/devicememballoon.py @@ -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() diff --git a/virtinst/deviceredirdev.py b/virtinst/deviceredirdev.py index 4b1d40c7c..2ffcbd662 100644 --- a/virtinst/deviceredirdev.py +++ b/virtinst/deviceredirdev.py @@ -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() diff --git a/virtinst/devicesmartcard.py b/virtinst/devicesmartcard.py index 111b0ea61..d50c9e2fb 100644 --- a/virtinst/devicesmartcard.py +++ b/virtinst/devicesmartcard.py @@ -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) diff --git a/virtinst/devicetpm.py b/virtinst/devicetpm.py index 5f28837c3..0800469c7 100644 --- a/virtinst/devicetpm.py +++ b/virtinst/devicetpm.py @@ -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") diff --git a/virtinst/devicevideo.py b/virtinst/devicevideo.py index efabdb5db..9a289665c 100644 --- a/virtinst/devicevideo.py +++ b/virtinst/devicevideo.py @@ -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() diff --git a/virtinst/devicewatchdog.py b/virtinst/devicewatchdog.py index 1a1290c23..e7c24f63f 100644 --- a/virtinst/devicewatchdog.py +++ b/virtinst/devicewatchdog.py @@ -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) diff --git a/virtinst/domainfeatures.py b/virtinst/domainfeatures.py index 8ca9c386b..3ebb3b2be 100644 --- a/virtinst/domainfeatures.py +++ b/virtinst/domainfeatures.py @@ -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) diff --git a/virtinst/domainnumatune.py b/virtinst/domainnumatune.py index cebdcc397..9a22bddfb 100644 --- a/virtinst/domainnumatune.py +++ b/virtinst/domainnumatune.py @@ -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") diff --git a/virtinst/guest.py b/virtinst/guest.py index 757330ecd..784402e2c 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -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) diff --git a/virtinst/osxml.py b/virtinst/osxml.py index 8d429ed53..b7eee73d5 100644 --- a/virtinst/osxml.py +++ b/virtinst/osxml.py @@ -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") diff --git a/virtinst/seclabel.py b/virtinst/seclabel.py index 2d4083fed..a9f478766 100644 --- a/virtinst/seclabel.py +++ b/virtinst/seclabel.py @@ -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) diff --git a/virtinst/snapshot.py b/virtinst/snapshot.py index be6b10e28..7577409b8 100644 --- a/virtinst/snapshot.py +++ b/virtinst/snapshot.py @@ -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: # @type and @file