We are trying to solve two issues in one report as they are dependent.
Issue 1:
On the current master the update_volume_attachment through compute fails to update volume attachment because of update method is not supported and shows the below error while updating the volume attcahment as "allow_update" is set to "False" [1].
Error:
File "/opt/stack/python-openstacksdk/openstack/compute/v2/_proxy.py", line 1176, in update_volume_attachment
server_id=server_id)
File "/opt/stack/python-openstacksdk/openstack/proxy2.py", line 37, in check
return method(self, expected, actual, *args, **kwargs)
File "/opt/stack/python-openstacksdk/openstack/proxy2.py", line 174, in _update
return res.update(self._session)
File "/opt/stack/python-openstacksdk/openstack/resource2.py", line 747, in update
raise exceptions.MethodNotSupported(self, "update")
openstack.exceptions.MethodNotSupported: The update method is not supported for openstack.compute.v2.volume_attachment.VolumeAttachment
Issue 2:
But after changing "allow_update" flag to True at [1](alloew the update_volume_attachment) then it raises HTTP 400 Bad Request.
Error:
Traceback (most recent call last):
File "test_openstacksdk_compute.py", line 264, in <module>
update_volume_attachment = conn.compute.update_volume_attachment('13f57218-813d-4db6-b574-e493ad0cf19c', '539bfa7f-3ae7-4b51-b036-1316396aa2cf', volumeId='45a8659c-9abd-460a-887d-fd8f3248f801')
File "/opt/stack/python-openstacksdk/openstack/compute/v2/_proxy.py", line 1176, in update_volume_attachment
server_id=server_id)
File "/opt/stack/python-openstacksdk/openstack/proxy2.py", line 37, in check
return method(self, expected, actual, *args, **kwargs)
File "/opt/stack/python-openstacksdk/openstack/proxy2.py", line 174, in _update
return res.update(self._session)
File "/opt/stack/python-openstacksdk/openstack/resource2.py", line 757, in update
json=request.body, headers=request.headers)
File "/usr/local/lib/python2.7/dist-packages/keystoneauth1/session.py", line 774, in put
return self.request(url, 'PUT', **kwargs)
File "/opt/stack/python-openstacksdk/openstack/session.py", line 66, in map_exceptions_wrapper
raise exceptions.from_exception(e)
openstack.exceptions.HttpException: HttpException: Bad Request (HTTP 400) (Request-ID: req-1f487dc3-78f2-4fcb-86af-cf2ef58a5555), Invalid input for field/attribute volumeAttachment. Value: {u'attachment_id': u'13f57218-813d-4db6-b574-e493ad0cf19c'}. Additional properties are not allowed (u'attachment_id' was unexpected)
The reason behind above error is nova accepts only new volume-id in the body and old volume-id is a part of url (see below curl command for reference) where as from openstacksdk both old and new volume ids are sent as input through body.
Nova's curl command:
curl -g -i -X PUT http://10.232.48.200:8774/v2.1/servers/539bfa7f-3ae7-4b51-b036-1316396aa2cf/os-volume_attachments/13f57218-813d-4db6-b574-e493ad0cf19c -H "Accept: application/json" -H "User-Agent: python-novaclient" -H "OpenStack-API-Version: compute 2.41" -H "X-OpenStack-Nova-API-Version: 2.41" -H "X-Auth-Token: {SHA1}e15607b1cb7fd902b7d0ee52a8e5000714c99ff2" -H "Content-Type: application/json" -d '{"volumeAttachment": {"volumeId": "45a8659c-9abd-460a-887d-fd8f3248f801"}}'
[1] https://github.com/openstack/python-openstacksdk/blame/master/openstack/compute/v2/volume_attachment.py#L26