What's Nova Microversioning API ? (by quqi99)

来源:互联网 发布:python 爬取微信好友 编辑:程序博客网 时间:2024/06/04 18:15
作者:张华  发表于: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

1 0
原创粉丝点击