Exemplo n.º 1
0
    def _connect_hypervisor_to_volume(self, sr_ref, connection_data):
        LOG.debug("Connect volume to hypervisor: %s", connection_data)
        if 'vdi_uuid' in connection_data:
            vdi_ref = volume_utils.introduce_vdi(
                self._session, sr_ref, vdi_uuid=connection_data['vdi_uuid'])

        elif 'target_lun' in connection_data:
            vdi_ref = volume_utils.introduce_vdi(
                self._session,
                sr_ref,
                target_lun=connection_data['target_lun'])

        else:
            # NOTE(sirp): This will introduce the first VDI in the SR
            vdi_ref = volume_utils.introduce_vdi(self._session, sr_ref)

        return vdi_ref
Exemplo n.º 2
0
    def _connect_hypervisor_to_volume(self, sr_ref, connection_data):
        LOG.debug("Connect volume to hypervisor: %s", connection_data)
        if 'vdi_uuid' in connection_data:
            vdi_ref = volume_utils.introduce_vdi(
                    self._session, sr_ref,
                    vdi_uuid=connection_data['vdi_uuid'])

        elif 'target_lun' in connection_data:
            vdi_ref = volume_utils.introduce_vdi(
                    self._session, sr_ref,
                    target_lun=connection_data['target_lun'])

        else:
            # NOTE(sirp): This will introduce the first VDI in the SR
            vdi_ref = volume_utils.introduce_vdi(self._session, sr_ref)

        return vdi_ref
Exemplo n.º 3
0
    def test_introduce_vdi_retry(self, mock_sleep, mock_get_vdi_ref):
        def fake_get_vdi_ref(session, sr_ref, vdi_uuid, target_lun):
            fake_get_vdi_ref.call_count += 1
            if fake_get_vdi_ref.call_count == 2:
                return 'vdi_ref'

        def fake_call_xenapi(method, *args):
            if method == 'SR.scan':
                return
            elif method == 'VDI.get_record':
                return {'managed': 'true'}

        session = mock.Mock()
        session.call_xenapi.side_effect = fake_call_xenapi

        mock_get_vdi_ref.side_effect = fake_get_vdi_ref
        fake_get_vdi_ref.call_count = 0

        self.assertEqual(volume_utils.introduce_vdi(session, 'sr_ref'),
                         'vdi_ref')
        mock_sleep.assert_called_once_with(20)