diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index d54064f4e9f..751255dfe2b 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -628,6 +628,18 @@ class VolumeTestCase(base.BaseVolumeTestCase): 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() diff --git a/cinder/volume/api.py b/cinder/volume/api.py index 04ea5c32c83..bc0fe43f815 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -349,7 +349,8 @@ class API(base.Base): # 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)