查询当前 tenants 方法
mysql> select name from keystone.project; +----------------+ | name | +----------------+ | admin | | DEV | | DMZ1 | | DMZ2 | | DMZ3 | | DMZ4 | | DMZ5 | | DMZ6 | | MGMT | | MOBILE | | OPS | | QA | | QATOOL | | services | | unlimit_tenant | +----------------+ 15 rows in set (0.00 sec)直接通过 sql 语法调用, 连接 openstack 数据库 (mariadb)
mysql> select b.name instances, count(a.vcpus) instances, sum(a.vcpus) cpus, sum( a.memory_mb ) memory_MB from nova.instances a, keystone.project b where a.deleted=0 and a.project_id = b.id and b.name in ('DEV', 'MOBILE','OPS') and a.vm_state in ( 'active', 'building', 'stopped') group by project_id; +-----------+-----------+------+-----------+ | instances | instances | cpus | memory_MB | +-----------+-----------+------+-----------+ | DEV | 2003 | 8890 | 11540480 | | MOBILE | 470 | 2830 | 4521984 | | OPS | 231 | 1037 | 1955840 | +-----------+-----------+------+-----------+ 3 rows in set (0.08 sec)…….. (待续)
相关资源:python入门教程(PDF版)