Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

attach volume, how to post `os-initialize_connection`

In the Official Document https://developer.openstack.org/api-ref/block-storage/v2/index.html , there is only one step to attach a volume to server:

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

But if I only call this API to attach a volume to server, the attachment will be failed, cause the server does not really attach the volume.

So I test the attachment via Horizon/CLI, find that there are two more steps need to be done before attachment:

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

I can't find document about the POST os-initialize_connection, so how to construct this POST?

Any help appreciated!