mock_notify.assert_has_calls(calls)
self.assertEqual(3, mock_notify.call_count)
+ @mock.patch('cinder.volume.utils.notify_about_volume_usage')
+ def test_transfer_accept_volume_in_consistencygroup(self, mock_notify):
+ svc = self.start_service('volume', host='test_host')
+ self.addCleanup(svc.stop)
+ tx_api = transfer_api.API()
+ consistencygroup = utils.create_consistencygroup(self.ctxt)
+ volume = utils.create_volume(self.ctxt,
+ updated_at=self.updated_at,
+ consistencygroup_id=
+ consistencygroup.id)
+ transfer = tx_api.create(self.ctxt, volume.id, 'Description')
+
+ self.assertRaises(exception.InvalidVolume,
+ tx_api.accept,
+ self.ctxt, transfer['id'], transfer['auth_key'])
+
@mock.patch.object(QUOTAS, "reserve")
@mock.patch.object(QUOTAS, "add_volume_type_opts")
@mock.patch('cinder.volume.utils.notify_about_volume_usage')
volume_id = transfer['volume_id']
vol_ref = self.db.volume_get(context.elevated(), volume_id)
+ if vol_ref['consistencygroup_id']:
+ msg = _("Volume %s must not be part of a consistency "
+ "group.") % vol_ref['id']
+ LOG.error(msg)
+ raise exception.InvalidVolume(reason=msg)
+
volume_utils.notify_about_volume_usage(context, vol_ref,
"transfer.accept.start")