Reputation: 43
Does anyone knows a way to ask to openstack, through API, if a instance is running or not? I don't even know if I have to ask to Ceilometer or Nova.
Thanks in advance
Upvotes: 0
Views: 255
Reputation: 30268
Normally you would ask Nova to get current state, and Ceilometer to get historical states (e.g. for billing). Assuming you've got a valid nova
client:
servers = nova.servers.list(detailed=True)
for s in servers:
print(s.status)
There are potentially other attributes that can give you more detailed information depending on your setup, e.g. extended status power state (you need to use getattr
vs .
because of the illegal identifier characters in the name):
print(getattr(s, "os-extended-status:power_state"))
Upvotes: 1