def test_guard_connection_manual_scan_unsupported_hared(self, mock_lock): utils.ISCSI_SUPPORTS_MANUAL_SCAN = False with utils.guard_connection({ 'service_uuid': mock.sentinel.uuid, 'shared_targets': True }): mock_lock.assert_called_once_with(mock.sentinel.uuid, 'os-brick-')
def detach(self, context, instance, volume_api, virt_driver, attachment_id=None, destroy_bdm=False): volume = self._get_volume(context, volume_api, self.volume_id) # Let OS-Brick handle high level locking that covers the local os-brick # detach and the Cinder call to call unmap the volume. Not all volume # backends or hosts require locking. with brick_utils.guard_connection(volume): self._do_detach(context, instance, volume_api, virt_driver, attachment_id, destroy_bdm)
def attach(self, context, instance, volume_api, virt_driver, do_driver_attach=False, **kwargs): volume = self._get_volume(context, volume_api, self.volume_id) volume_api.check_availability_zone(context, volume, instance=instance) # Let OS-Brick handle high level locking that covers the call to # Cinder that exports & maps the volume, and for the local os-brick # attach. Not all volume backends or hosts require locking. with brick_utils.guard_connection(volume): self._do_attach(context, instance, volume, volume_api, virt_driver, do_driver_attach)
def test_guard_connection_manual_scan_unsupported_not_shared( self, mock_lock): utils.ISCSI_SUPPORTS_MANUAL_SCAN = False with utils.guard_connection({'shared_targets': False}): mock_lock.assert_not_called()
def test_guard_connection_manual_scan_support(self, mock_lock): utils.ISCSI_SUPPORTS_MANUAL_SCAN = True # We confirm that shared_targets is ignored with utils.guard_connection({'shared_targets': True}): mock_lock.assert_not_called()