Problem with calculating server usage for given tenant/project
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
python-novaclient |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I'm trying to calculate servers usage for given project within a certain period of time. We have a special policy requiring calculating half of the resource usage between stop/start actions and none between shelve/unshelve so I have to calculate everything by hand and cannot fully rely on existing calculation methods.
I'm developed a simple script in python for this reason.
The thing/problem is:
1/ Firstly I'm trying to get a list of servers usage using nova.usage.get method for given period of time (let-s assume 2017-09-05 00:00:00 - 2017-09-09 23:59:59). The returned list isn't equivalent to nova.servers.list which seem to be ok at first glance. But it's not.
For given period of time from usage class I get a server with following info.
{ 'ended_at': '2017-09-
'flavor': '...',
'hours': 1.3166666666666667,
'instance_id': '...',
'local_gb': 40,
'memory_mb': ...,
'name': 'SERVERNAME',
'started_at': '2017-09-
'state': 'terminated',
'tenant_id': '...',
'uptime': 4740,
'vcpus': 24}
It can be noticed this server ran for about 1 hour. For this reason I would like to check details and actions which are matching this server. So I ran nova.instance_
ERROR (CommandError): No server with a name or ID of 'SERVERNAME' exists.
2/ Secondly, nova.servers.list returns me server which is not listed by nova.usage.get but it should have been. instance-
+------
| Action | Request_ID | Message | Start_Time |
+------
| create | ... | - | 2017-08-
| reboot | .... | - | 2017-08-
| shelve | ... | - | 2017-09-
| unshelve | ... | - | 2017-09-
| shelve | ... | - | 2017-09-
+------
Why is this server not reported by usage.get method in provided period of time?It shoud return some info regarding this server but it's not. Isn't it a bug?
Alternatively - what am I doing wrong.....
Best,
Damian
One comment: action- list (I will get error saying server with this name or id doesn't exist) to calculate shelve/unshelve and stop/start periods for further cost calculations. I hope I made myself clear and you see my point... action- list on DELETED servers......
One of the questions is: Should I get list of servers for given project and period of time relying on what I get from nova.usage.get or nova.servers.list ? It may happend that in given period of time one of the servers will be shut down and will not appear on servers.list and thus I will not be able to check its instance-
I think (maybe I'm missing that) there is lack of functionality allowing to ask for instance-