Am 27-02-2014 11:37, schrieb Rodrigo Trujillo:
I was wondering whether would be better to store the user id in vm
xml
instead of the user name (login).
Yes, that is also an option. But as you said
below, the user ID can also
be changed, so we can never make sure that what we store in the VM
metadata will hold true forever. In any case, the user can always be
deleted and we will have invalid information. While none of the
approaches are perfect, I chose to store user names as they are more
easily readable.
But we can store user IDs as well, if there is any advantage.
+ try:
> + users = _get_vm_metadata(xml, "users")
> + except:
You could log the error here. I think its good for debugging and
general information.
> + # Wrong XML tree structure, wrong array syntax, or empty
> value:
> + # ignore error and build an empty list
> + users = []
I decided not to log an error message because, in most
of the times (at
least for now), there will no VM metadata, so we would see two errors
for each VM fetched. E.g.: if you have 10 VMs and you click on the tab
"Guests", you will see a flood of at least 20 error messages. Not having
user and groups metadata is not an error; if the user just creates a VM
and do not assign users or groups, I do not think their VM info is wrong.
I can rewrite that snippet to log only actual error messages (e.g. if
someone edits the XML manually and puts wrong metadata info), but not
empty metadata info.