openstack-nova源码分析(七)host aggregates 主机组

本文详细探讨了openstack-nova中主机组(host aggregates)的概念,包括其作为compute节点集合的用途,以及如何通过RESTful API和命令进行操作。源码分析涵盖了从创建、更新、查询到删除主机组的流程,强调了对象层的操作以及调度器的数据刷新机制。
摘要由CSDN通过智能技术生成

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及命令
  1. url
    标准的restful api
    /os-aggregates
    /os-aggregates/{aggregate_id}

  2. 命令

[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

  1. 列表功能映射到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.get_all(context)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值