[英]python api show aggregates hypervisors in openstack
I can't get information about availability_zone(aggregate) hypervisors in OpenStack API. 我无法在OpenStack API中获取有关availability_zone(聚合)虚拟机监控程序的信息。 I try to list all hypervisors on the same AZ.
我尝试在同一个AZ上列出所有虚拟机管理程序。
CLI
openstack aggregate list
+----+----------------+-------------------+
| ID | Name | Availability Zone |
+----+----------------+-------------------+
| 3 | zone19 | zone1 |
| 4 | zone20 | zone2 |
| 6 | zone22 | zone3 |
+----+----------------+-------------------+
openstack aggregate show zone19
+-------------------+----------------------------------------------------------------------+
| Field | Value |
+-------------------+----------------------------------------------------------------------+
| availability_zone | zone1 |
| created_at | 2017-06-22T14:14:55.000000 |
| deleted | False |
| deleted_at | None |
| hosts | [u'compute101', u'compute102'] |
| id | 3 |
| name | zone19 |
| properties | |
| updated_at | None |
+-------------------+----------------------------------------------------------------------+
servers = nova.aggregates.list()
print("servers", servers)
('servers', [<Aggregate: 3>, <Aggregate: 4>, <Aggregate: 6>])
Ok, i found solution for my case. 好的,我为我的案子找到了解决方案。 It's not really hard but first what i found was how to take JSON from API with information with AZ.
这并不是很难,但我首先发现的是如何从API中获取带有AZ信息的JSON。
First in openstack CLI: 首先在openstack CLI中:
-f json -f json
$ openstack aggregate show -f json zone19
then response is: 然后回应是:
{
"name": "zone19",
"availability_zone": "zone1",
"deleted": false,
"created_at": "2017-06-22T14:14:55.000000",
"updated_at": null,
"properties": "",
"hosts": [
"compute101",
"compute102"
],
"deleted_at": null,
"id": 3
}
and in python: 并在python中:
aggregates = nova.aggregates.list()
if aggregates:
for aggregate in aggregates:
print("aggregate_name", aggregate.name, aggregate.hosts)
('aggregate_name', u'zone19', [u'compute101',u'compute102'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.