<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/15/2014 11:45 PM,
<a 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() <= 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/<my-vm><br>
{<br>
<blockquote>"name": my-vm,<br>
"cpu": 1,<br>
"memory": 512,<br>
"passwd": "abcd"<br>
</blockquote>
}<br>
<br>
data = GET /vms/<my-vm><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/<my-vm><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>
or <br>
{<br>
<blockquote>"name": my-vm,<br>
"cpu": 1,<br>
"memory": 512,<br>
"ticket": {"passwd": None, "expire": True},<br>
...<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"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
</body>
</html>