0

在官方文档https://developer.openstack.org/api-ref/block-storage/v2/index.html中,将卷附加到服务器只有一个步骤:

POST /v2/{tenant_id}/volumes/{volume_id}/action
{
    "os-attach": {
        "instance_uuid": "95D9EF50-507D-11E5-B970-0800200C9A66",
        "mountpoint": "/dev/vdc"
    }
}

但是如果我只调用这个 API 来附加一个卷到服务器,附加会失败,因为服务器并没有真正附加卷。

于是我通过Horizo​​n/CLI对附件进行了测试,发现在附件之前还有两个步骤需要完成:

POST http://172.21.128.196:8776/v2/1237920e0dff49e380c03db9eb5dac7a/volumes/68a66368-4ec3-46cc-b65c-6fbc30fa1c15/action
Action body: {"os-reserve": null} from (pid=1986) get_method /opt/stack/cinder/cinder/api/openstack/wsgi.py:985

POST http://172.21.128.196:8776/v2/1237920e0dff49e380c03db9eb5dac7a/volumes/68a66368-4ec3-46cc-b65c-6fbc30fa1c15/action
Action body: {"os-initialize_connection": {"connector": {"platform": "x86_64", "host": "bogon", "do_local_attach": false, "ip": "172.21.128.196", "os_type": "linux2", "multipath": false, "initiator": "iqn.1993-08.org.debian:01:8144b0ddeab"}}} from (pid=1986) get_method /opt/stack/cinder/cinder/api/openstack/wsgi.py:985

POST http://172.21.128.196:8776/v2/1237920e0dff49e380c03db9eb5dac7a/volumes/68a66368-4ec3-46cc-b65c-6fbc30fa1c15/action
Action body: {"os-attach": {"instance_uuid": "a68806a6-b67d-4c48-9bc1-7af018d8f81b", "mountpoint": "/dev/vdb", "mode": "rw"}} from (pid=1986) get_method /opt/stack/cinder/cinder/api/openstack/wsgi.py:985

我找不到关于 POST 的文档os-initialize_connection,那么如何构建这个 POST 呢?

任何帮助表示赞赏!

4

1 回答 1

0

好的,我自己回答这个问题。
上面询问的 Cinder API 是针对 Nova 的。Horizo​​n/CLI 可以调用的附加卷端点来自 Nova:

POST nova/os-volume_attachments

在此处输入图像描述

于 2017-03-22T11:49:21.567 回答