Exemple #1
0
def try_add(core_device: Device, cache_id: int, core_id: int = None):
    output = TestRun.executor.run(
        script_try_add_cmd(str(cache_id), core_device.path,
                           str(core_id) if core_id is not None else None))
    if output.exit_code != 0:
        raise CmdException("Failed to execute try add script command.", output)
    return Core(core_device.path, cache_id)
def add_core(cache: Cache, core_dev: Device, core_id: int = None, shortcut: bool = False):
    _core_id = None if core_id is None else str(id)
    output = TestRun.executor.run(
        add_core_cmd(cache_id=str(cache.cache_id), core_dev=core_dev.system_path,
                     core_id=_core_id, shortcut=shortcut))
    if output.exit_code != 0:
        raise CmdException("Failed to add core.", output)
    return Core(core_dev.system_path, cache.cache_id)
Exemple #3
0
def get_cores(cache_id: int):
    from api.cas.core import Core, CoreStatus
    cores_list = []
    lines = casadm.list_caches(OutputFormat.csv).stdout.split('\n')
    is_proper_core_line = False
    for line in lines:
        args = line.split(',')
        if args[0] == "core" and is_proper_core_line:
            core_status_str = args[3].lower()
            is_valid_status = CoreStatus[core_status_str].value[0] <= 1
            if is_valid_status:
                cores_list.append(Core(args[2], cache_id))
        if args[0] == "cache":
            is_proper_core_line = True if int(args[1]) == cache_id else False
    return cores_list
Exemple #4
0
def add_core(cache: Cache,
             core_dev: Device,
             core_id: int = None,
             shortcut: bool = False):
    _core_id = None if core_id is None else str(id)
    output = TestProperties.executor.execute(
        add_core_cmd(cache_id=str(cache.cache_id),
                     core_dev=core_dev.system_path,
                     core_id=_core_id,
                     shortcut=shortcut))
    if output.exit_code != 0:
        raise Exception(
            f"Failed to add core. stdout: {output.stdout} \n stderr :{output.stderr}"
        )
    return Core(core_dev.system_path, cache.cache_id)
Exemple #5
0
def try_add(core_device: Device, cache_id: int):
    output = TestRun.executor.run(script_try_add_cmd(str(cache_id), core_device.system_path))
    if output.exit_code != 0:
        raise CmdException("Failed to execute try add script command.", output)
    return Core(core_device.system_path, cache_id)