Return the results of init attachment request
Methods ``openstack.block_storage.v3.volume.Volume.init_attachment`` and ``block_storage.init_volume_attachment`` now return the results of the POST request instead of None. This replicates the behaviour of cinderclient; the returned data is used by nova and ironic for managing volume attachments. Change-Id: I55ad94c872e807668b85125b32f142c3a8cf40bf
This commit is contained in:
parent
911cf7ddb1
commit
a03396d347
@ -948,9 +948,9 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
||||
:class:`~openstack.block_storage.v3.volume.Volume` instance.
|
||||
:param dict connector: The connector object.
|
||||
|
||||
:returns: None"""
|
||||
:returns: Dictionary containing the modified connector object"""
|
||||
volume = self._get_resource(_volume.Volume, volume)
|
||||
volume.init_attachment(self, connector)
|
||||
return volume.init_attachment(self, connector)
|
||||
|
||||
def terminate_volume_attachment(self, volume, connector):
|
||||
"""Update volume status to 'in-use'.
|
||||
|
@ -290,7 +290,8 @@ class Volume(resource.Resource, metadata.MetadataMixin):
|
||||
"""Initialize volume attachment"""
|
||||
body = {'os-initialize_connection': {'connector': connector}}
|
||||
|
||||
self._action(session, body)
|
||||
resp = self._action(session, body).json()
|
||||
return resp['connection_info']
|
||||
|
||||
def terminate_attachment(self, session, connector):
|
||||
"""Terminate volume attachment"""
|
||||
|
@ -545,7 +545,14 @@ class TestVolumeActions(TestVolume):
|
||||
def test_init_attachment(self):
|
||||
sot = volume.Volume(**VOLUME)
|
||||
|
||||
self.assertIsNone(sot.init_attachment(self.sess, {'a': 'b'}))
|
||||
self.resp = mock.Mock()
|
||||
self.resp.body = {'connection_info': {'c': 'd'}}
|
||||
self.resp.status_code = 200
|
||||
self.resp.json = mock.Mock(return_value=self.resp.body)
|
||||
self.sess.post = mock.Mock(return_value=self.resp)
|
||||
self.assertEqual(
|
||||
{'c': 'd'}, sot.init_attachment(self.sess, {'a': 'b'})
|
||||
)
|
||||
|
||||
url = 'volumes/%s/action' % FAKE_ID
|
||||
body = {'os-initialize_connection': {'connector': {'a': 'b'}}}
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Methods ``openstack.block_storage.v3.volume.Volume.init_attachment`` and
|
||||
``block_storage.init_volume_attachment`` now return the results of the POST
|
||||
request instead of None. This replicates the behaviour of cinderclient; the
|
||||
returned data is used by nova and ironic for managing volume attachments.
|
Loading…
Reference in New Issue
Block a user