Skip to content

Commit

Permalink
Add back support for the multiattach flag for volume create
Browse files Browse the repository at this point in the history
As the 'multiattach' request parameter in volume create is
not formally deprecated out of the REST API via microversion,
we need to keep the functionality working.

Currently the 'multiattach' attribute on the volume is set by
the volume_type only, which means that we cannot create a
multi-attach volume the old way, the volume gets created with
'multiattach': false.

This patch fixes that.

Closes-Bug: #1745219

Change-Id: Iac67f112b0dc9353c6a66e6fbc81cc8324a2b37c
  • Loading branch information
ildikov authored and mriedem committed Jan 24, 2018
1 parent 2a5f80f commit a32e24f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions cinder/tests/unit/volume/test_volume.py
Expand Up @@ -628,6 +628,18 @@ def test_create_volume_with_multiattach_volume_type(self):
self.assertEqual(foo['id'], vol['volume_type_id'])
self.assertTrue(vol['multiattach'])

def test_create_volume_with_multiattach_no_volume_type(self):
"""Tests creating a volume with multiattach=True but no special type.
This tests the pre 3.50 microversion behavior of being able to create
a volume with the multiattach request parameter regardless of a
multiattach-capable volume type.
"""
volume_api = cinder.volume.api.API()
volume = volume_api.create(
self.context, 1, 'name', 'description', multiattach=True)
self.assertTrue(volume.multiattach)

@mock.patch.object(key_manager, 'API', fake_keymgr.fake_api)
def test_create_volume_with_encrypted_volume_type_aes(self):
ctxt = context.get_admin_context()
Expand Down
3 changes: 2 additions & 1 deletion cinder/volume/api.py
Expand Up @@ -349,7 +349,8 @@ def create(self, context, size, name, description, snapshot=None,
# Refresh the object here, otherwise things ain't right
vref = objects.Volume.get_by_id(
context, vref['id'])
vref.multiattach = self._is_multiattach(volume_type)
vref.multiattach = (self._is_multiattach(volume_type) or
multiattach)
vref.save()
LOG.info("Create volume request issued successfully.",
resource=vref)
Expand Down

0 comments on commit a32e24f

Please sign in to comment.