def _legacy_detach(self, volume_id, attachment_uuid=None, multipath=False, enforce_multipath=False, device_info=None, nic=None): """The original/legacy detach workflow.""" with actions.BeginDetach(self.volumes_client, volume_id) as cmd: cmd.reserve() with actions.InitializeConnectionForDetach(self.volumes_client, volume_id) as cmd: connection = cmd.initialize(self, multipath, enforce_multipath, nic) brick_connector = self._brick_get_connector( connection['driver_volume_type'], do_local_attach=True, use_multipath=multipath, ) with actions.DisconnectVolume(self.volumes_client, volume_id) as cmd: cmd.disconnect(brick_connector, connection['data'], device_info) with actions.DetachVolume(self.volumes_client, volume_id) as cmd: cmd.detach(self, attachment_uuid, multipath, enforce_multipath)
def test_detach(self): brick_client = mock.Mock() brick_client.get_connector.return_value = 'connector' with volume_actions.DetachVolume(*self.command_args) as cmd: cmd.detach(brick_client, 'attachment_uuid', 'multipath', 'enforce_multipath') brick_client.get_connector.assert_called_once_with( 'multipath', 'enforce_multipath') self.v_client.volumes.terminate_connection.assert_called_once_with( self.volume_id, 'connector') self.v_client.volumes.detach.assert_called_once_with( self.volume_id, 'attachment_uuid')
def detach(self, volume_id, attachment_uuid=None, multipath=False, enforce_multipath=False, device_info=None): with actions.BeginDetach(self.volumes_client, volume_id) as cmd: cmd.reserve() with actions.InitializeConnectionForDetach(self.volumes_client, volume_id) as cmd: connection = cmd.initialize(self, multipath, enforce_multipath) brick_connector = self._brick_get_connector( connection['driver_volume_type'], do_local_attach=True) with actions.DisconnectVolume(self.volumes_client, volume_id) as cmd: cmd.disconnect(brick_connector, connection['data'], device_info) with actions.DetachVolume(self.volumes_client, volume_id) as cmd: cmd.detach(self, attachment_uuid, multipath, enforce_multipath)