(转)openstack 资源查询常用 sql

直接通过查询 openstack 数据库, 获得相应的常见查询结果
查询用户使用中主机, 及其主机对应信息
查询用户使用中存储, 及其存储对应信息

查询用户对应主机

mysql> select a.display_name instnace from nova.instances a, keystone.user b where b.id=a.user_id and a.vm_state in ('active', 'building', 'stopped') and a.deleted = 0 and b.name='test';

利用主机名查询对应id, ip 地址等相关信息  -- uuid

mysql> select a.display_name instance, b.name user, a.vcpus cpu, a.memory_mb, a.node hypervisor, c.name tenant, e.ip_address, a.uuid from nova.instances a, keystone.user b, keystone.project c, neutron.ports d, neutron.ipallocations e where a.vm_state in ('active', 'building', 'stopped') and a.deleted = 0 and a.user_id = b.id and a.project_id = c.id and d.device_id = a.uuid and e.port_id = d.id and a.display_name='terry-elk-exquv.xxxxxxx.xxx';

参考:

https://blog.csdn.net/signmem/article/details/58608645

原文地址:https://www.cnblogs.com/hixiaowei/p/9133538.html