On 07/15/2014 11:45 PM, shaohef(a)linux.vnet.ibm.com wrote:
+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}
Here, when ticket expire, I report an
error to user.
Tell him, he should reset the password.
Now I will change the API as follow:
GET /vms/<my-vm>
{
"name": my-vm,
"cpu": 1,
"memory": 512,
"passwd": "abcd"
}
data = GET /vms/<my-vm>
data.passwd
when when ticket expire, what should I do?
still an error report.
Or
GET /vms/<my-vm>
{
"name": my-vm,
"cpu": 1,
"memory": 512,
"passwd": None
}
But this will be confused with a VM that has no password.
so
{
"name": my-vm,
"cpu": 1,
"memory": 512,
"passwd": None,
...
}
means ticket expire.
{
"name": my-vm,
"cpu": 1,
"memory": 512,
...
}
means no passwd is set?
or
{
"name": my-vm,
"cpu": 1,
"memory": 512,
"ticket": {"passwd": None, "expire": True},
...
}
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center