<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 07/18/2014 01:13 AM, Aline Manera
      wrote:<br>
    </div>
    <blockquote cite="mid:53C80434.3060207@linux.vnet.ibm.com"
      type="cite">
      <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
      <br>
      <div class="moz-cite-prefix">On 07/17/2014 12:10 PM, Sheldon
        wrote:<br>
      </div>
      <blockquote cite="mid:53C7E74A.7060901@linux.vnet.ibm.com"
        type="cite">
        <meta content="text/html; charset=UTF-8"
          http-equiv="Content-Type">
        <div class="moz-cite-prefix">On 07/15/2014 11:45 PM, <a
            moz-do-not-send="true" class="moz-txt-link-abbreviated"
            href="mailto:shaohef@linux.vnet.ibm.com">shaohef@linux.vnet.ibm.com</a>
          wrote:<br>
        </div>
        <blockquote
          cite="mid:1405439113-20997-4-git-send-email-shaohef@linux.vnet.ibm.com"
          type="cite">
          <pre wrap="">+class VMTicketModel(object):
+    def __init__(self, **kargs):
+        self.objstore = kargs['objstore']
+        self.conn = kargs['conn']
+
+    def lookup(self, name):
+        dom = VMModel.get_vm(name, self.conn)
+        xml = dom.XMLDesc(libvirt.VIR_DOMAIN_XML_SECURE)
+        root = objectify.fromstring(xml)
+        graphic = root.devices.find("graphics")
+        passwd = graphic.attrib.get('passwd')
+        valid_to = graphic.attrib.get('passwdValidTo')
+        if valid_to is not None:
+            to = time.mktime(time.strptime(valid_to, '%Y-%m-%dT%H:%M:%S'))
+            if to - time.time() &lt;= 0:
+                raise OperationFailed("KCHVM0031E", {'name': name})
+        return {"passwd": passwd}</pre>
        </blockquote>
        Here, when ticket expire, I report an error to user. <br>
        Tell him, he should reset the password. <br>
        <br>
        Now I will change the API as follow:<br>
        GET /vms/&lt;my-vm&gt;<br>
        {<br>
        <blockquote>"name": my-vm,<br>
          "cpu": 1,<br>
          "memory": 512,<br>
          "passwd": "abcd"<br>
        </blockquote>
        }<br>
        <br>
        data = GET /vms/&lt;my-vm&gt;<br>
        data.passwd<br>
        <br>
        <br>
        when when ticket expire, what should I do? <br>
        still an error report. <br>
        <br>
        Or <br>
        GET /vms/&lt;my-vm&gt;<br>
        {<br>
        <blockquote>"name": my-vm,<br>
          "cpu": 1,<br>
          "memory": 512,<br>
          "passwd": None<br>
        </blockquote>
        }<br>
        <br>
        But this will be confused with a VM that has no password.<br>
        <br>
        so  <br>
        {<br>
        <blockquote>"name": my-vm,<br>
          "cpu": 1,<br>
          "memory": 512,<br>
          "passwd": None,<br>
          ...<br>
        </blockquote>
        }<br>
        means ticket expire.<br>
        <br>
        {<br>
        <blockquote>"name": my-vm,<br>
          "cpu": 1,<br>
          "memory": 512,<br>
          ...<br>
        </blockquote>
        }<br>
        means no passwd is set?<br>
        <br>
        <br>
      </blockquote>
      <br>
      <blockquote cite="mid:53C7E74A.7060901@linux.vnet.ibm.com"
        type="cite"> or <br>
        {<br>
        <blockquote>"name": my-vm,<br>
          "cpu": 1,<br>
          "memory": 512,<br>
          "ticket": {"passwd": None, "expire": True},<br>
          ...<br>
        </blockquote>
        }<br>
        <br>
      </blockquote>
      <br>
      I think this last one can solve the problems<br>
      But set "expire" to None when "passwd" is None<br>
    </blockquote>
    <br>
    OK.  Will change it in next version.<br>
    <br>
    but we should remember, the ticket in vm info may make no sense in
    most time,  <br>
    so we must get the whole vm info when connection.<br>
    <br>
    For UI,  when connection,  after get the vm info, it should  check
    the expire of passwd<br>
    data  = GET /vms/my-vm <br>
    data.ticket.expire == True<br>
    <br>
    <br>
    By the way,  IMHO,  an prompt of error message is friendly for
    whoever using the Kimchi REST API.
    <br>
    <br>
    <br>
    <blockquote cite="mid:53C80434.3060207@linux.vnet.ibm.com"
      type="cite"> <br>
      <blockquote cite="mid:53C7E74A.7060901@linux.vnet.ibm.com"
        type="cite">
        <pre class="moz-signature" cols="72">-- 
Thanks and best regards!

Sheldon Feng(冯少合)<a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
      </blockquote>
      <br>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Thanks and best regards!

Sheldon Feng(冯少合)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com">&lt;shaohef@linux.vnet.ibm.com&gt;</a>
IBM Linux Technology Center</pre>
  </body>
</html>