VirtualGraphics: Drop non-default __init__ params

This commit is contained in:
Cole Robinson 2013-07-15 20:43:41 -04:00
parent 75e34247f3
commit dc58d48a33
5 changed files with 35 additions and 47 deletions

View File

@ -174,7 +174,10 @@ def get_basic_paravirt_guest(installer=None):
g.memory = int(200 * 1024)
g.maxmemory = int(400 * 1024)
g.uuid = "12345678-1234-1234-1234-123456789012"
g.add_device(VirtualGraphics(_conn, "vnc", keymap="ja"))
gdev = VirtualGraphics(_conn)
gdev.type = "vnc"
gdev.keymap= "ja"
g.add_device(gdev)
g.vcpus = 5
if installer:
@ -195,7 +198,9 @@ def get_basic_fullyvirt_guest(typ="xen", installer=None):
g.maxmemory = int(400 * 1024)
g.uuid = "12345678-1234-1234-1234-123456789012"
g.cdrom = "/dev/loop0"
g.add_device(VirtualGraphics(_conn, "sdl"))
gdev = VirtualGraphics(_conn)
gdev.type = "sdl"
g.add_device(gdev)
g.features['pae'] = 0
g.vcpus = 5
if installer:

View File

@ -472,11 +472,13 @@ class TestXMLConfig(unittest.TestCase):
def testKVMKeymap(self):
conn = utils.open_plainkvm(connver=10000)
g = virtinst.VirtualGraphics(conn, type="vnc")
g = virtinst.VirtualGraphics(conn)
g.type = "vnc"
self.assertTrue(g.keymap is not None)
conn = utils.open_plainkvm(connver=11000)
g = virtinst.VirtualGraphics(conn, type="vnc")
g = virtinst.VirtualGraphics(conn)
g.type = "vnc"
self.assertTrue(g.keymap is None)
@ -836,19 +838,24 @@ class TestXMLConfig(unittest.TestCase):
g.add_device(mdev1)
# Check keymap autoconfig
gdev1 = virtinst.VirtualGraphics(g.conn, type="vnc")
gdev1 = virtinst.VirtualGraphics(g.conn)
gdev1.type = "vnc"
self.assertTrue(gdev1.keymap is not None)
gdev1.keymap = "en-us"
# Check keymap None
gdev2 = virtinst.VirtualGraphics(g.conn, type="vnc")
gdev2 = virtinst.VirtualGraphics(g.conn)
gdev2.type = "vnc"
gdev2.keymap = None
gdev3 = virtinst.VirtualGraphics(g.conn, type="sdl")
gdev4 = virtinst.VirtualGraphics(g.conn, type="spice")
gdev3 = virtinst.VirtualGraphics(g.conn)
gdev3.type = "sdl"
gdev4 = virtinst.VirtualGraphics(g.conn)
gdev4.type = "spice"
gdev4.passwdValidTo = "foobar"
gdev5 = virtinst.VirtualGraphics(g.conn, type="sdl")
gdev5 = virtinst.VirtualGraphics(g.conn)
gdev5.type = "sdl"
gdev5.xauth = "fooxauth"
gdev5.display = "foodisplay"
g.add_device(gdev1)

View File

@ -1415,19 +1415,18 @@ class vmmAddHardware(vmmGObjectUI):
self._dev = dev
def validate_page_graphics(self):
graphics = self.get_config_graphics()
_type = {"vnc": virtinst.VirtualGraphics.TYPE_VNC,
"spice": virtinst.VirtualGraphics.TYPE_SPICE,
"sdl": virtinst.VirtualGraphics.TYPE_SDL}[graphics]
gtype = self.get_config_graphics()
self._dev = virtinst.VirtualGraphics(self.conn.get_backend(),
type=_type)
try:
self._dev.port = self.get_config_graphics_port()
self._dev.tlsPort = self.get_config_graphics_tls_port()
self._dev.passwd = self.get_config_graphics_password()
self._dev.listen = self.get_config_graphics_address()
self._dev.keymap = self.get_config_keymap()
self._dev = virtinst.VirtualGraphics(self.conn.get_backend())
self._dev.type = gtype
if gtype != "sdl":
self._dev.port = self.get_config_graphics_port()
self._dev.passwd = self.get_config_graphics_password() or None
self._dev.listen = self.get_config_graphics_address()
self._dev.keymap = self.get_config_keymap()
if gtype == "spice":
self._dev.tlsPort = self.get_config_graphics_tls_port()
except ValueError, e:
self.err.val_err(_("Graphics device parameter error"), e)

View File

@ -1401,7 +1401,9 @@ class vmmCreate(vmmGObjectUI):
"Using VNC graphics.")
gtype = virtinst.VirtualGraphics.TYPE_VNC
return virtinst.VirtualGraphics(guest.conn, type=gtype)
gdev = virtinst.VirtualGraphics(guest.conn)
gdev.type = gtype
return gdev
def get_video_device(self, guest):
if guest.installer.is_container():

View File

@ -112,36 +112,11 @@ class VirtualGraphics(VirtualDevice):
return str(gtype).capitalize()
def __init__(self, conn, type=None, port=None, listen=None, passwd=None,
keymap=None, parsexml=None,
parsexmlnode=None, tlsPort=None, channels=None,
passwdValidTo=None):
# pylint: disable=W0622
# Redefining built-in 'type', but it matches the XML so keep it
def __init__(self, conn, parsexml=None, parsexmlnode=None):
VirtualDevice.__init__(self, conn, parsexml, parsexmlnode)
self._local_keymap = -1
if self._is_parse():
return
if type:
self.type = type
if port:
self.port = port
if tlsPort:
self.tlsPort = tlsPort
if keymap:
self.keymap = keymap
if listen:
self.listen = listen
if passwd:
self.passwd = passwd
if passwdValidTo:
self.passwdValidTo = passwdValidTo
if channels:
self.channels = channels
_XML_PROP_ORDER = ["type", "port", "tlsPort", "autoport",
"keymap", "listen",