On 07/18/2014 01:13 AM, Aline Manera wrote:
On 07/17/2014 12:10 PM, Sheldon wrote:
> 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},
> ...
>
> }
>
I think this last one can solve the problems
But set "expire" to None when "passwd" is None
OK. Will change it in next version.
but we should remember, the ticket in vm info may make no sense in most
time,
so we must get the whole vm info when connection.
For UI, when connection, after get the vm info, it should check the
expire of passwd
data = GET /vms/my-vm
data.ticket.expire == True
By the way, IMHO, an prompt of error message is friendly for whoever
using the Kimchi REST API.
> --
> Thanks and best regards!
>
> Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
> IBM Linux Technology Center
--
Thanks and best regards!
Sheldon Feng(冯少合)<shaohef(a)linux.vnet.ibm.com>
IBM Linux Technology Center