Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 886e70a

Browse files
committed
graphics: add passwdValidTo attribute
1 parent b77e638 commit 886e70a

5 files changed

Lines changed: 34 additions & 37 deletions

File tree

tests/xmlparse-xml/change-graphics-in.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<graphics type="sdl" xauth="/tmp/.Xauthority" display="1:2"/>
2828
<graphics type="rdp"/>
2929
<graphics type="vnc" port="-1"/>
30-
<graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0">
30+
<graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0" passwdValidTo="2010-04-09T15:51:00">
3131
<channel name='inputs' mode='insecure'/>
3232
<channel name='main' mode='secure'/>
3333
<channel name='record' mode='any'/>

tests/xmlparse-xml/change-graphics-out.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<graphics type="sdl" xauth="fooauth" display="6:1"/>
2828
<graphics type="rdp"/>
2929
<graphics type="vnc" port="-1"/>
30-
<graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4">
30+
<graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4" passwdValidTo="2011-01-07T19:08:00">
3131
<channel name="inputs" mode="secure"/>
3232
<channel name="main" mode="any"/>
3333
<channel name="record" mode="insecure"/>

tests/xmlparse.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ def testAlterGraphics(self):
444444
check("channel_inputs_mode", "insecure", "secure")
445445
check("channel_main_mode", "secure", "any")
446446
check("channel_record_mode", "any", "insecure")
447+
check("passwdValidTo", "2010-04-09T15:51:00", "2011-01-07T19:08:00")
447448

448449
self._alter_compare(guest.get_config_xml(), outfile)
449450

virtinst/VirtualGraphics.py

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def valid_keymaps():
8484
def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
8585
keymap=KEYMAP_DEFAULT, conn=None, parsexml=None,
8686
parsexmlnode=None, tlsPort=-1, channels=None,
87-
caps=None):
87+
caps=None, passwdValidTo=None):
8888

8989
VirtualDevice.VirtualDevice.__init__(self, conn,
9090
parsexml, parsexmlnode, caps)
@@ -94,6 +94,7 @@ def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
9494
self._tlsPort = None
9595
self._listen = None
9696
self._passwd = None
97+
self._passwdValidTo = None
9798
self._keymap = None
9899
self._xauth = None
99100
self._display = None
@@ -108,6 +109,7 @@ def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
108109
self.keymap = keymap
109110
self.listen = listen
110111
self.passwd = passwd
112+
self.passwdValidTo = passwdValidTo
111113
if channels:
112114
self.channels = channels
113115

@@ -208,6 +210,13 @@ def set_passwd(self, val):
208210
passwd = _xml_property(get_passwd, set_passwd,
209211
xpath="./@passwd")
210212

213+
def get_passwdValidTo(self):
214+
return self._passwdValidTo
215+
def set_passwdValidTo(self, val):
216+
self._passwdValidTo = val
217+
passwdValidTo = _xml_property(get_passwdValidTo, set_passwdValidTo,
218+
xpath="./@passwdValidTo")
219+
211220
def get_tlsPort(self):
212221
return self._tlsPort
213222
def set_tlsPort(self, val):
@@ -245,53 +254,39 @@ def _sdl_config(self):
245254
return """ <graphics type='sdl' display='%s' xauth='%s'/>""" % \
246255
(disp, xauth)
247256

248-
def _spice_config(self):
257+
def _get_xml_config(self):
258+
if self._type == self.TYPE_SDL:
259+
return self._sdl_config()
260+
261+
if self._type not in [self.TYPE_VNC, self.TYPE_SPICE]:
262+
raise ValueError(_("Unknown graphics type %r" % self._type))
263+
264+
tlsportxml = ""
249265
autoportxml = ""
250266
keymapxml = ""
251267
listenxml = ""
252268
passwdxml = ""
253-
if self._port == -1 or self._tlsPort == -1:
254-
autoportxml = "autoport='yes'"
269+
passwdValidToxml = ""
270+
if self._type == self.TYPE_SPICE:
271+
if self._port == -1 or self._tlsPort == -1:
272+
autoportxml = "autoport='yes'"
273+
tlsportxml = " tlsPort='%(tlsPort)d' " % { "tlsPort" : self._tlsPort }
255274
if self.keymap:
256275
keymapxml = " keymap='%s'" % self.keymap
257276
if self.listen:
258277
listenxml = " listen='%s'" % self._listen
259278
if self.passwd:
260279
passwdxml = " passwd='%s'" % self._passwd
280+
if self.passwdValidTo:
281+
passwdValidToxml = " passwdValidTo='%s'" % self._passwd
261282

262-
xml = " <graphics type='spice' " + \
263-
"port='%(port)d' " % { "port" : self._port } + \
264-
"tlsPort='%(tlsPort)d' " % { "tlsPort" : self._tlsPort } + \
283+
xml = " <graphics type='%(type)s' " % { "type" : self._type } + \
284+
"port='%(port)d'" % { "port" : self._port } + \
285+
"%(tlsport)s" % { "tlsport" : tlsportxml } + \
265286
"%(autoport)s" % { "autoport" : autoportxml } + \
266287
"%(keymapxml)s" % { "keymapxml" : keymapxml } + \
267288
"%(listenxml)s" % { "listenxml" : listenxml } + \
268-
"%(passwdxml)s/>" % { "passwdxml" : passwdxml }
269-
return xml
270-
271-
def _vnc_config(self):
272-
keymapxml = ""
273-
listenxml = ""
274-
passwdxml = ""
275-
if self.keymap:
276-
keymapxml = " keymap='%s'" % self.keymap
277-
if self.listen:
278-
listenxml = " listen='%s'" % self._listen
279-
if self.passwd:
280-
passwdxml = " passwd='%s'" % self._passwd
281-
xml = " <graphics type='vnc' " + \
282-
"port='%(port)d'" % { "port" : self._port } + \
283-
"%(keymapxml)s" % { "keymapxml" : keymapxml } + \
284-
"%(listenxml)s" % { "listenxml" : listenxml } + \
285-
"%(passwdxml)s" % { "passwdxml" : passwdxml } + \
289+
"%(passwdxml)s" % { "passwdxml" : passwdxml } + \
290+
"%(passwdValidToxml)s" % { "passwdValidToxml" : passwdValidToxml } + \
286291
"/>"
287292
return xml
288-
289-
def _get_xml_config(self):
290-
if self._type == self.TYPE_SDL:
291-
return self._sdl_config()
292-
if self._type == self.TYPE_SPICE:
293-
return self._spice_config()
294-
if self._type == self.TYPE_VNC:
295-
return self._vnc_config()
296-
else:
297-
raise ValueError(_("Unknown graphics type"))

virtinst/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,7 @@ def set_param(paramname, dictname, val=None):
10011001
set_param("listen", "listen")
10021002
set_param("keymap", "keymap")
10031003
set_param("passwd", "password")
1004+
set_param("passwdValidTo", "passwordvalidto")
10041005

10051006
if opts:
10061007
raise ValueError(_("Unknown options %s") % opts.keys())

0 commit comments

Comments
 (0)