What's Nova Microversioning API ? (by quqi99)

作者:张华  发表于:2015-12-16
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

(http://blog.csdn.net/quqi99 )


Nova v2.1 API = v2 compatibility + Validition + Microversioning

Nova API v2的问题:

  • 输入验证匮乏
  • 难于增加新的API实现

Nova API v2.1用例:

  • 即使OpenStack升级之后,应用仍然需要使用老API。
  • 通过API实现OpenStack的新特性。
  • 应用运行在跨数据中心的多个OpenStack云上。

v2 compatibility

v2的endpoint是/v2,v2.1的endpoint是/v2.1, kilo默认使用/v2.1,但也可以使用/v2,故它对v2兼容。

允许通过request header(X-OpenStack-Nova-API-Version: 2.114)指定API版本。response中会带有版本信息:

GET /
{
     "versions": [
        {
            "id": "v2.1",
            "links": [
                  {
                    "href": "http://localhost:8774/v2/",
                    "rel": "self"
                }
            ],
            "status": "CURRENT",
            "version": "5.2"
            "min_version": "2.1"
        },
   ]
}

Validation

例如:v2对没定义的输入参数没有验证;向客户端返回的HTTP 500响应没有包括错误的原因。现在增加/nova/api/openstack/compute/schemas验证请求对象的API版本。
@api_version(min_version='2.1', max_version='2.9')

Microversioning

E.g. v2.2 = v2.1 + new change, up to V2.x. 

@api_version(min_version='2.1', max_version='2.9')
def show(self, req, id):
   pass
@api_version(min_version='3.0')
def show(self, req, id):
   pass
或者:
def show(self, req, id):
  .... stuff ....
  if req.ver_obj.matches(start_version, end_version):
    .... Do version specific stuff ....
  ....  stuff ....

nova-pythonclient目前不支持microversioning,需要更新代码支持X-OpenStack-Nova-API-Version参数。
* 2.1 – Initial version. Equivalent to v2.0 code
* 2.2 – Adds (keypair) type parameter for os-keypairs plugin
           Fixes success status code for create/delete a keypair method
* 2.3 – Exposes additional os-extended-server-attributes
           Exposes delete_on_termination for os-extended-volumes
* 2.4 – Exposes reserved field in os-fixed-ips.
* 2.5 – Allow server search option ip6 for non-admin
* 2.6 – Consolidate the APIs for getting remote consoles

Client

Client期望具有版本协商功能:
- Cloud A:
  - min_ver: 2.100
  - max_ver: 2.300
- Cloud B:
  - min_ver: 2.200
  - max_ver: 2.450

代码实现

通过简短的原型代码更容易理解代码全貌,https://github.com/cyeoh/microversions_poc

[1] http://specs.openstack.org/openstack/nova-specs/specs/kilo/implemented/api-microversions.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

quqi99

你的鼓励就是我创造的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值