Host aggregates 主机组
主机组是一组主机compute节点的集合,默认只开放给管理员的功能,可以通过策略配置修改访问权限
官方api介绍:
Creates and manages host aggregates. An aggregate assigns metadata to groups of compute nodes.
Policy defaults enable only users with the administrative role to perform operations with aggregates.
Cloud providers can change these permissions through policy file configuration.
一. url及命令
-
url
标准的restful api
/os-aggregates
/os-aggregates/{aggregate_id} -
命令
[root@nova ~]# nova help | grep aggregate
aggregate-create Create a new aggregate with the specified
aggregate-delete Delete the aggregate.
aggregate-list Print a list of all aggregates.
aggregate-show Show details of the specified aggregate.
aggregate-update Update the aggregate's name and optionally
二. 源码分析:
在setup.cfg中定义如下:
aggregates = nova.api.openstack.compute.aggregates:Aggregates
Aggregates定义如下:
class Aggregates(extensions.V21APIExtensionBase):
"""Admin-only aggregate administration."""
name = "Aggregates"
alias = ALIAS
version = 1
def get_resources(self):
resources = [extensions.ResourceExtension(
ALIAS,
AggregateController(),
member_actions={'action': 'POST'})]
return resources
映射到AggregateController并增加了POST 方法映射到action
- 列表功能映射到index, 定义如下:
@extensions.expected_errors(())
def index(self, req):
"""Returns a list a host aggregate's id, name, availability_zone."""
context = _get_context(req)
context.can(aggr_policies.POLICY_ROOT % 'index')
aggregates = self.api.get_aggregate_list(context)
return {'aggregates': [self._marshall_aggregate(req, a)['aggregate']
for a in aggregates]}
self.api.get_aggregate_list(context) 获取列表
实际调用如下:
def get_aggregate_list(self, context):
"""Get all the aggregates."""
return objects.AggregateList.ge
深入解析openstack-nova主机组实现

本文详细探讨了openstack-nova中主机组(host aggregates)的概念,包括其作为compute节点集合的用途,以及如何通过RESTful API和命令进行操作。源码分析涵盖了从创建、更新、查询到删除主机组的流程,强调了对象层的操作以及调度器的数据刷新机制。
最低0.47元/天 解锁文章
4008

被折叠的 条评论
为什么被折叠?



