server is required in openstack volume attachment create while it is optional in cinder api

Bug #2083326 reported by Bence Romsics
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-openstackclient
New
Undecided
Unassigned

Bug Description

osc is needlessly restrictive in 'volume attachment create'. Supplying a 'server' is mandatory in the cli, while it is optional in the cinder api.

cinder api accepts instance=null:

$ source openrc admin admin
$ export TOKEN="$( openstack token issue -f value -c id )"
$ curl -s -H "X-Auth-Token: $TOKEN" -H "OpenStack-API-Version: volume 3.71" -H "Content-Type: application/json" -X POST "http://127.0.0.1/volume/v3/$( openstack project show admin -f value -c id )/attachments" -d "{\"attachment\": {\"mode\": \"ro\", \"connector\": {}, \"volume_uuid\": \"$( openstack volume show vol0 -f value -c id )\"}}" | json_pp
{
   "attachment" : {
      "attach_mode" : "ro",
      "attached_at" : "",
      "connection_info" : {},
      "detached_at" : "",
      "id" : "4e8dae68-ae72-4deb-8b12-11f0fbfabb0b",
      "instance" : null,
      "status" : "reserved",
      "volume_id" : "472a7656-653b-435c-8fd5-dcef7f400c18"
   }
}
$ openstack volume attachment delete ...

But osc does not:

$ openstack volume create --size 1 vol0
$ openstack volume attachment create --mode ro vol0
usage: openstack volume attachment create [-h] [-f {json,shell,table,value,yaml}] [-c COLUMN] [--noindent] [--prefix PREFIX] [--max-width <integer>] [--fit-width] [--print-empty] [--connect] [--no-connect] [--initiator <initiator>]
                                          [--ip <ip>] [--host <host>] [--platform <platform>] [--os-type <ostype>] [--multipath] [--no-multipath] [--mountpoint <mountpoint>] [--mode <mode>]
                                          <volume> <server>
openstack volume attachment create: error: the following arguments are required: <server>

However it does work as expected when both the volume and the server are given:

$ openstack server create --flavor cirros256 --image cirros-0.6.2-x86_64-disk --nic net-id=private --wait vm0
$ openstack volume attachment create --mode ro vol0 vm0
as expected
$ openstack volume attachment delete ...

See also:
cinder api-ref: https://docs.openstack.org/api-ref/block-storage/v3/index.html#id413
related code: https://opendev.org/openstack/python-openstackclient/src/commit/ac59673b5d75984a46b2e8fba911530c791dd4b2/openstackclient/volume/v3/volume_attachment.py#L91-L100

$ openstack --version
openstack 7.2.0

$ openstack --debug
[snip]
compute API version 2.1, cmd group openstack.compute.v2
identity API version 3, cmd group openstack.identity.v3
image API version 2, cmd group openstack.image.v2
network API version 2, cmd group openstack.network.v2
object_store API version 1, cmd group openstack.object_store.v1
volume API version 3, cmd group openstack.volume.v3
orchestration API version 1, cmd group openstack.orchestration.v1
alarming API version 2, cmd group openstack.alarming.v2
load_balancer API version 2.0, cmd group openstack.load_balancer.v2
baremetal API version 1.92, cmd group openstack.baremetal.v1
key_manager API version 1, cmd group openstack.key_manager.v1
database API version 1, cmd group openstack.database.v1
placement API version 1, cmd group openstack.placement.v1
rca API version 1, cmd group openstack.rca.v1
container_infra API version 1, cmd group openstack.container_infra.v1
workflow_engine API version 2, cmd group openstack.workflow_engine.v2
container API version 1, cmd group openstack.container.v1
dns API version 2, cmd group openstack.dns.v2
messaging API version 2, cmd group openstack.messaging.v2
share API version 2.84, cmd group openstack.share.v2
reservation API version 1, cmd group openstack.reservation.v1
neutronclient API version 2, cmd group openstack.neutronclient.v2
[snip]

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.