Example #1
0
def test_devices_assimilated(
    get_data_contents: Callable[[str, str], str],
    mocker: MockerFixture,
    gstate: GlobalState,
) -> None:
    def device_ls_gen():
        raw = json.loads(
            get_data_contents(DATA_DIR, "device_ls_not_available.json"))
        devicels = parse_obj_as(List[OrchDevicesPerHostModel], raw)
        yield devicels
        devicels[0].devices[1].available = True
        yield devicels

    from gravel.controllers.orch.orchestrator import Orchestrator

    orch = Orchestrator(gstate.ceph_mgr)

    devicegen = device_ls_gen()
    orch.devices_ls = mocker.MagicMock(return_value=next(devicegen))
    assert orch.devices_assimilated("asd", ["/dev/vdb", "/dev/vdc"])

    orch.devices_ls = mocker.MagicMock(return_value=next(devicegen))
    assert not orch.devices_assimilated("asd", ["/dev/vdc"])
Example #2
0
    async def _assimilate_devices(self, hostname: str,
                                  devices: List[str]) -> None:
        try:
            orch = Orchestrator(self._gstate.ceph_mgr)
            if not orch.host_exists(hostname):
                raise DeploymentError("Host not part of cluster.")
            orch.assimilate_devices(hostname, devices)

            # wait a few seconds so the orchestrator settles down
            while not orch.devices_assimilated(hostname, devices):
                await asyncio.sleep(1.0)

        except Exception as e:
            raise DeploymentError(str(e))