diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index 791cfd4cfb5..ef84c103012 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -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() diff --git a/cinder/volume/api.py b/cinder/volume/api.py index f9d11e5e501..a59bd2f5c70 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -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)