I need a small billing report for the usage of the VMs inside openstack after it is stopped, so far I already find the way to get flavor information (vCPU, disk, memory) from instance name.
And I want to know the VM's startup time to calculate now.
Are there any good ways to fetch it from openstack python API ?
It will be nice if you can paste the code as well.
Why not just use metadata :
At creation you can save a date time, then when it starts up you can calculate a difference.
I just wanted to retrieve server's uptime. I mean real uptime for the time the server has been UP, not since its creation.
Request to the os-simple-tenant-usage extension (after obtaining an auth. token):
GET http://rdo:8774/v2/4e1900cf21924a098709c23480e157c0/os-simple-tenant-usage/4e1900cf21924a098709c23480e157c0
(with the correct tenant ID)Response (notice the machine is stopped and uptime is a non-zero value):
So despite its name uptime it is just time since the server creation.
(I got the answer from china-openstack community, and shared here)
In the novaclient usage module, all the instance (active or terminated) can be fetched by
list
API, the detail information is fetched viaget
API, it is not clear what information are exposed via this python document.Fortunately the openstack api : os-simple-tenant-usage tells the data structure, the
uptime
is what I want.openstack dashboard (at least Folsom version) use this API as well.