Beispiel #1
0
def _deactivate_storage_domains(api, sds):
    if not sds:
        LOGGER.info('No storages to deactivate')
        return

    for sd in sds:
        if sd.status.get_state() != 'maintenance':
            sd.deactivate()
            LOGGER.info('Started deactivation of storage domain %s', sd.name)
        else:
            LOGGER.info('Storage domain %s already inactive', sd.name)

    with LogTask('Waiting for the domains to get into maintenance'):
        for sd in sds:
            dc = api.datacenters.get(id=sd.get_data_center().get_id())
            with LogTask(
                'Waiting for storage domain %s to become inactive' % sd.name,
                level='debug'
            ):
                testlib.assert_true_within_long(
                    lambda: (
                        dc.storagedomains.get(sd.name).status.state
                        == 'maintenance'
                    ),
                )
Beispiel #2
0
def _activate_storage_domains(api, sds):
    for sd in sds:
        sd.activate()

    for sd in sds:
        dc = api.datacenters.get(id=sd.get_data_center().get_id(), )
        testlib.assert_true_within_long(
            lambda: dc.storagedomains.get(sd.name).status.state == 'active',
        )
def _deactivate_storage_domains(api, sds):
    for sd in sds:
        sd.deactivate()

    for sd in sds:
        dc = api.datacenters.get(id=sd.get_data_center().get_id())
        testlib.assert_true_within_long(
            lambda:
            dc.storagedomains.get(sd.name).status.state == 'maintenance',
        )
Beispiel #4
0
    def _get_api(self, wait):
        if wait:
            self.wait_for_ssh()
            try:
                testlib.assert_true_within_long(
                    lambda: self.service('ovirt-engine').alive())

                api = []
                testlib.assert_true_within_short(
                    lambda: api.append(self._create_api()) or True)
            except AssertionError:
                raise RuntimeError('Failed to connect to the engine')
        return api.pop()
    def _get_api(self, wait):
        if wait:
            self.wait_for_ssh()
            try:
                testlib.assert_true_within_long(
                    lambda: self.service('ovirt-engine').alive()
                )

                api = []
                testlib.assert_true_within_short(
                    lambda: api.append(self._create_api()) or True
                )
            except AssertionError:
                raise RuntimeError('Failed to connect to the engine')
        return api.pop()
Beispiel #6
0
    def _activate(self):
        with LogTask('Wait for ssh connectivity'):
            for vm in self.virt_env.get_vms().values():
                vm.wait_for_ssh()

        with LogTask('Wait for engine to go online'):
            testlib.assert_true_within_long(
                lambda: self.virt_env.engine_vm().get_api() or True,
                allowed_exceptions=[RequestError, ConnectionError],
            )

        api = self.virt_env.engine_vm().get_api()
        with LogTask('Activate hosts'):
            _activate_all_hosts(api)
        with LogTask('Activate storage domains'):
            _activate_all_storage_domains(api)