[virt-tools-list] [PATCH] graphics: add passwdValidTo attribute

Marc-André Lureau marcandre.lureau at redhat.com
Fri Jan 7 19:52:30 UTC 2011


# HG changeset patch
# User Marc-André Lureau <marcandre.lureau at redhat.com>
# Date 1294424777 -3600
# Node ID 3fc485aa19224b1f29586b546a7508747c1714dc
# Parent  1b630fe29b72b2fc7a41f884a55f1132b19132d4
graphics: add passwdValidTo attribute

diff -r 1b630fe29b72 -r 3fc485aa1922 tests/xmlparse-xml/change-graphics-in.xml
--- a/tests/xmlparse-xml/change-graphics-in.xml	Fri Jan 07 18:33:38 2011 +0100
+++ b/tests/xmlparse-xml/change-graphics-in.xml	Fri Jan 07 19:26:17 2011 +0100
@@ -27,7 +27,7 @@
     <graphics type="sdl" xauth="/tmp/.Xauthority" display="1:2"/>
     <graphics type="rdp"/>
     <graphics type="vnc" port="-1"/>
-    <graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0">
+    <graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0" passwdValidTo="2010-04-09T15:51:00">
       <channel name='inputs' mode='insecure'/>
       <channel name='main' mode='secure'/>
       <channel name='record' mode='any'/>
diff -r 1b630fe29b72 -r 3fc485aa1922 tests/xmlparse-xml/change-graphics-out.xml
--- a/tests/xmlparse-xml/change-graphics-out.xml	Fri Jan 07 18:33:38 2011 +0100
+++ b/tests/xmlparse-xml/change-graphics-out.xml	Fri Jan 07 19:26:17 2011 +0100
@@ -27,7 +27,7 @@
     <graphics type="sdl" xauth="fooauth" display="6:1"/>
     <graphics type="rdp"/>
     <graphics type="vnc" port="-1"/>
-    <graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4">
+    <graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4" passwdValidTo="2011-01-07T19:08:00">
       <channel name="inputs" mode="secure"/>
       <channel name="main" mode="any"/>
       <channel name="record" mode="insecure"/>
diff -r 1b630fe29b72 -r 3fc485aa1922 tests/xmlparse.py
--- a/tests/xmlparse.py	Fri Jan 07 18:33:38 2011 +0100
+++ b/tests/xmlparse.py	Fri Jan 07 19:26:17 2011 +0100
@@ -444,6 +444,7 @@
         check("channel_inputs_mode", "insecure", "secure")
         check("channel_main_mode", "secure", "any")
         check("channel_record_mode", "any", "insecure")
+        check("passwdValidTo", "2010-04-09T15:51:00", "2011-01-07T19:08:00")
 
         self._alter_compare(guest.get_config_xml(), outfile)
 
diff -r 1b630fe29b72 -r 3fc485aa1922 virtinst/VirtualGraphics.py
--- a/virtinst/VirtualGraphics.py	Fri Jan 07 18:33:38 2011 +0100
+++ b/virtinst/VirtualGraphics.py	Fri Jan 07 19:26:17 2011 +0100
@@ -84,7 +84,7 @@
     def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
                  keymap=KEYMAP_DEFAULT, conn=None, parsexml=None,
                  parsexmlnode=None, tlsPort=-1, channels=None,
-                 caps=None):
+                 caps=None, passwdValidTo=None):
 
         VirtualDevice.VirtualDevice.__init__(self, conn,
                                              parsexml, parsexmlnode, caps)
@@ -94,6 +94,7 @@
         self._tlsPort = None
         self._listen = None
         self._passwd = None
+        self._passwdValidTo = None
         self._keymap = None
         self._xauth = None
         self._display = None
@@ -108,6 +109,7 @@
         self.keymap = keymap
         self.listen = listen
         self.passwd = passwd
+        self.passwdValidTo = passwdValidTo
         if channels:
             self.channels = channels
 
@@ -208,6 +210,13 @@
     passwd = _xml_property(get_passwd, set_passwd,
                            xpath="./@passwd")
 
+    def get_passwdValidTo(self):
+        return self._passwdValidTo
+    def set_passwdValidTo(self, val):
+        self._passwdValidTo = val
+    passwdValidTo = _xml_property(get_passwdValidTo, set_passwdValidTo,
+                                  xpath="./@passwdValidTo")
+
     def get_tlsPort(self):
         return self._tlsPort
     def set_tlsPort(self, val):
@@ -245,53 +254,39 @@
         return """    <graphics type='sdl' display='%s' xauth='%s'/>""" % \
                (disp, xauth)
 
-    def _spice_config(self):
+    def _get_xml_config(self):
+        if self._type == self.TYPE_SDL:
+            return self._sdl_config()
+
+        if self._type not in [self.TYPE_VNC, self.TYPE_SPICE]:
+            raise ValueError(_("Unknown graphics type %r" % self._type))
+
+        tlsportxml = ""
         autoportxml = ""
         keymapxml = ""
         listenxml = ""
         passwdxml = ""
-        if self._port == -1 or self._tlsPort == -1:
-            autoportxml = "autoport='yes'"
+        passwdValidToxml = ""
+        if self._type == self.TYPE_SPICE:
+            if self._port == -1 or self._tlsPort == -1:
+                autoportxml = "autoport='yes'"
+            tlsportxml = " tlsPort='%(tlsPort)d' " % { "tlsPort" : self._tlsPort }
         if self.keymap:
             keymapxml = " keymap='%s'" % self.keymap
         if self.listen:
             listenxml = " listen='%s'" % self._listen
         if self.passwd:
             passwdxml = " passwd='%s'" % self._passwd
+        if self.passwdValidTo:
+            passwdValidToxml = " passwdValidTo='%s'" % self._passwd
 
-        xml = "    <graphics type='spice' " + \
-                   "port='%(port)d' " % { "port" : self._port } + \
-                   "tlsPort='%(tlsPort)d' " % { "tlsPort" : self._tlsPort } + \
+        xml = "    <graphics type='%(type)s' " % { "type" : self._type } + \
+                   "port='%(port)d'" % { "port" : self._port } + \
+                   "%(tlsport)s" % { "tlsport" : tlsportxml } + \
                    "%(autoport)s" % { "autoport" : autoportxml } + \
                    "%(keymapxml)s" % { "keymapxml" : keymapxml } + \
                    "%(listenxml)s" % { "listenxml" : listenxml } + \
-                   "%(passwdxml)s/>" % { "passwdxml" : passwdxml }
-        return xml
-
-    def _vnc_config(self):
-        keymapxml = ""
-        listenxml = ""
-        passwdxml = ""
-        if self.keymap:
-            keymapxml = " keymap='%s'" % self.keymap
-        if self.listen:
-            listenxml = " listen='%s'" % self._listen
-        if self.passwd:
-            passwdxml = " passwd='%s'" % self._passwd
-        xml = "    <graphics type='vnc' " + \
-                   "port='%(port)d'" % { "port" : self._port } + \
-                   "%(keymapxml)s"   % { "keymapxml" : keymapxml } + \
-                   "%(listenxml)s"   % { "listenxml" : listenxml } + \
-                   "%(passwdxml)s"   % { "passwdxml" : passwdxml } + \
+                   "%(passwdxml)s" % { "passwdxml" : passwdxml } + \
+                   "%(passwdValidToxml)s" % { "passwdValidToxml" : passwdValidToxml } + \
                    "/>"
         return xml
-
-    def _get_xml_config(self):
-        if self._type == self.TYPE_SDL:
-            return self._sdl_config()
-        if self._type == self.TYPE_SPICE:
-            return self._spice_config()
-        if self._type == self.TYPE_VNC:
-            return self._vnc_config()
-        else:
-            raise ValueError(_("Unknown graphics type"))
diff -r 1b630fe29b72 -r 3fc485aa1922 virtinst/cli.py
--- a/virtinst/cli.py	Fri Jan 07 18:33:38 2011 +0100
+++ b/virtinst/cli.py	Fri Jan 07 19:26:17 2011 +0100
@@ -1001,6 +1001,7 @@
     set_param("listen", "listen")
     set_param("keymap", "keymap")
     set_param("passwd", "password")
+    set_param("passwdValidTo", "passwordvalidto")
 
     if opts:
         raise ValueError(_("Unknown options %s") % opts.keys())




More information about the virt-tools-list mailing list