VirtualMemballon: Convert to new style XML props

This commit is contained in:
Cole Robinson 2013-07-15 16:55:32 -04:00
parent e3abd6496d
commit e6e1036c59
2 changed files with 3 additions and 31 deletions

View File

@ -22,36 +22,9 @@ from virtinst.xmlbuilder import XMLProperty
class VirtualMemballoon(VirtualDevice):
_virtual_device_type = VirtualDevice.VIRTUAL_DEV_MEMBALLOON
MODEL_DEFAULT = "virtio"
MODELS = ["xen", "none", MODEL_DEFAULT]
def __init__(self, conn=None, model=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
model = XMLProperty(xpath="./@model", default_cb=lambda s: s.MODEL_DEFAULT)

View File

@ -1791,11 +1791,10 @@ def parse_memballoon(guest, optstring, dev=None):
# Peel the mode off the front
opts = parse_optstr(optstring, remove_first="model")
model = get_opt_param(opts, "model")
if not dev:
dev = virtinst.VirtualMemballoon(model=model,
conn=guest.conn)
dev = virtinst.VirtualMemballoon(conn=guest.conn)
dev.model = get_opt_param(opts, "model")
if opts:
raise ValueError(_("Unknown options %s") % opts.keys())