self.assertRaises(exception.DateraAPIException,
self.driver.create_export, ctxt, self.volume)
+ def test_detach_volume_success(self):
+ self.mock_api.return_value = {}
+ ctxt = context.get_admin_context()
+ volume = _stub_volume(status='in-use')
+ self.assertIsNone(self.driver.detach_volume(ctxt, volume))
+
+ def test_detach_volume_fails(self):
+ self.mock_api.side_effect = exception.DateraAPIException
+ ctxt = context.get_admin_context()
+ volume = _stub_volume(status='in-use')
+ self.assertRaises(exception.DateraAPIException,
+ self.driver.detach_volume, ctxt, volume)
+
+ def test_detach_volume_not_found(self):
+ self.mock_api.side_effect = exception.NotFound
+ ctxt = context.get_admin_context()
+ volume = _stub_volume(status='in-use')
+ self.assertIsNone(self.driver.detach_volume(ctxt, volume))
+
def test_create_snapshot_success(self):
self.mock_api.return_value = {
u'uuid': u'0bb34f0c-fea4-48e0-bf96-591120ac7e3c',
try:
self._issue_api_request('volumes', 'delete', volume['id'])
except exception.NotFound:
- msg = _("Tried to delete volume %s, but was not found in Datera "
- "cluster. Continuing with delete.")
- LOG.info(msg)
+ msg = _("Tried to delete volume %s, but it was not found in the "
+ "Datera cluster. Continuing with delete.")
+ LOG.info(msg, volume['id'])
def _do_export(self, context, volume):
"""Gets the associated account, retrieves CHAP info and updates."""
def create_export(self, context, volume):
return self._do_export(context, volume)
+ def detach_volume(self, context, volume):
+ try:
+ self._issue_api_request('volumes', 'delete', resource=volume['id'],
+ action='export')
+ except exception.NotFound:
+ msg = _("Tried to delete export for volume %s, but it was not "
+ "found in the Datera cluster. Continuing with volume "
+ "detach")
+ LOG.info(msg, volume['id'])
+
def delete_snapshot(self, snapshot):
try:
self._issue_api_request('snapshots', 'delete', snapshot['id'])
except exception.NotFound:
msg = _("Tried to delete snapshot %s, but was not found in Datera "
"cluster. Continuing with delete.")
- LOG.info(msg)
+ LOG.info(msg, snapshot['id'])
def create_snapshot(self, snapshot):
data = {