mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-09-01 21:49:28 +03:00
VirtualMemballon: Convert to new style XML props
This commit is contained in:
@ -22,36 +22,9 @@ from virtinst.xmlbuilder import XMLProperty
|
|||||||
|
|
||||||
|
|
||||||
class VirtualMemballoon(VirtualDevice):
|
class VirtualMemballoon(VirtualDevice):
|
||||||
|
|
||||||
_virtual_device_type = VirtualDevice.VIRTUAL_DEV_MEMBALLOON
|
_virtual_device_type = VirtualDevice.VIRTUAL_DEV_MEMBALLOON
|
||||||
|
|
||||||
MODEL_DEFAULT = "virtio"
|
MODEL_DEFAULT = "virtio"
|
||||||
MODELS = ["xen", "none", MODEL_DEFAULT]
|
MODELS = ["xen", "none", MODEL_DEFAULT]
|
||||||
|
|
||||||
def __init__(self, conn=None, model=MODEL_DEFAULT,
|
model = XMLProperty(xpath="./@model", default_cb=lambda s: s.MODEL_DEFAULT)
|
||||||
parsexml=None, parsexmlnode=None):
|
|
||||||
VirtualDevice.__init__(self, conn, parsexml, parsexmlnode)
|
|
||||||
|
|
||||||
self._model = None
|
|
||||||
|
|
||||||
if self._is_parse():
|
|
||||||
return
|
|
||||||
|
|
||||||
self.model = model
|
|
||||||
|
|
||||||
def get_model(self):
|
|
||||||
return self._model
|
|
||||||
def set_model(self, new_model):
|
|
||||||
if type(new_model) != str:
|
|
||||||
raise ValueError(_("'model' must be a string, "
|
|
||||||
" was '%s'." % type(new_model)))
|
|
||||||
if not self.MODELS.count(new_model):
|
|
||||||
raise ValueError(_("Unsupported memballoon model '%s'" % new_model))
|
|
||||||
self._model = new_model
|
|
||||||
model = XMLProperty(get_model, set_model,
|
|
||||||
xpath="./@model")
|
|
||||||
|
|
||||||
def _get_xml_config(self):
|
|
||||||
xml = " <memballoon model='%s'" % self.model
|
|
||||||
xml += "/>"
|
|
||||||
return xml
|
|
||||||
|
@ -1791,11 +1791,10 @@ def parse_memballoon(guest, optstring, dev=None):
|
|||||||
|
|
||||||
# Peel the mode off the front
|
# Peel the mode off the front
|
||||||
opts = parse_optstr(optstring, remove_first="model")
|
opts = parse_optstr(optstring, remove_first="model")
|
||||||
model = get_opt_param(opts, "model")
|
|
||||||
|
|
||||||
if not dev:
|
if not dev:
|
||||||
dev = virtinst.VirtualMemballoon(model=model,
|
dev = virtinst.VirtualMemballoon(conn=guest.conn)
|
||||||
conn=guest.conn)
|
dev.model = get_opt_param(opts, "model")
|
||||||
|
|
||||||
if opts:
|
if opts:
|
||||||
raise ValueError(_("Unknown options %s") % opts.keys())
|
raise ValueError(_("Unknown options %s") % opts.keys())
|
||||||
|
Reference in New Issue
Block a user