Merge "Return the results of init attachment request"
This commit is contained in:
commit
d0165fc742
@ -961,9 +961,9 @@ class Proxy(_base_proxy.BaseBlockStorageProxy):
|
|||||||
:class:`~openstack.block_storage.v3.volume.Volume` instance.
|
:class:`~openstack.block_storage.v3.volume.Volume` instance.
|
||||||
:param dict connector: The connector object.
|
:param dict connector: The connector object.
|
||||||
|
|
||||||
:returns: None"""
|
:returns: Dictionary containing the modified connector object"""
|
||||||
volume = self._get_resource(_volume.Volume, volume)
|
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):
|
def terminate_volume_attachment(self, volume, connector):
|
||||||
"""Update volume status to 'in-use'.
|
"""Update volume status to 'in-use'.
|
||||||
|
@ -330,7 +330,8 @@ class Volume(resource.Resource, metadata.MetadataMixin):
|
|||||||
"""Initialize volume attachment"""
|
"""Initialize volume attachment"""
|
||||||
body = {'os-initialize_connection': {'connector': connector}}
|
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):
|
def terminate_attachment(self, session, connector):
|
||||||
"""Terminate volume attachment"""
|
"""Terminate volume attachment"""
|
||||||
|
@ -546,7 +546,14 @@ class TestVolumeActions(TestVolume):
|
|||||||
def test_init_attachment(self):
|
def test_init_attachment(self):
|
||||||
sot = volume.Volume(**VOLUME)
|
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
|
url = 'volumes/%s/action' % FAKE_ID
|
||||||
body = {'os-initialize_connection': {'connector': {'a': 'b'}}}
|
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