简体   繁体   English

Openstack API-Nova与Ceilometer了解实例状态

[英]Openstack API - Nova vs Ceilometer to Know Instance State

Does anyone knows a way to ask to openstack, through API, if a instance is running or not? 有谁知道一种通过API询问openstack的方法,无论实例是否正在运行? I don't even know if I have to ask to Ceilometer or Nova. 我什至不知道我是否要问Ceilometer或Nova。

Thanks in advance 提前致谢

Normally you would ask Nova to get current state, and Ceilometer to get historical states (eg for billing). 通常,您会要求Nova获取当前状态,并要求Ceilometer获取历史状态(例如,用于计费)。 Assuming you've got a valid nova client: 假设您有一个有效的nova客户:

 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, eg extended status power state (you need to use getattr vs . because of the illegal identifier characters in the name): 有迹象表明,可以给您根据您的设置更详细的信息,如扩展状态电源状态(你需要使用潜在的其他属性getattr VS .因为在名称中非法标识字符):

 print(getattr(s, "os-extended-status:power_state"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM