def load_cache(device: Device, shortcut: bool = False):
    output = TestRun.executor.run(
        load_cmd(cache_dev=device.system_path, shortcut=shortcut))
    if output.exit_code != 0:
        raise Exception(
            f"Failed to load cache. stdout: {output.stdout} \n stderr :{output.stderr}")
    return Cache(device.system_path)
Example #2
0
def load_cache(device: Device, shortcut: bool = False):
    output = TestRun.executor.run(
        load_cmd(cache_dev=device.system_path, shortcut=shortcut))
    if output.exit_code != 0:
        raise CmdException("Failed to load cache.", output)

    return Cache(device)
Example #3
0
def start_cache(cache_dev: Device,
                cache_mode: CacheMode = None,
                cache_line_size: CacheLineSize = None,
                cache_id: int = None,
                force: bool = False,
                load: bool = False,
                shortcut: bool = False,
                kernel_params: KernelParameters = KernelParameters()):
    if kernel_params != KernelParameters.read_current_settings():
        reload_kernel_module("cas_cache",
                             kernel_params.get_parameter_dictionary())

    _cache_line_size = None if cache_line_size is None else str(
        int(cache_line_size.value.get_value(Unit.KibiByte)))
    _cache_id = None if cache_id is None else str(cache_id)
    _cache_mode = None if cache_mode is None else cache_mode.name.lower()
    output = TestRun.executor.run(
        start_cmd(cache_dev=cache_dev.path,
                  cache_mode=_cache_mode,
                  cache_line_size=_cache_line_size,
                  cache_id=_cache_id,
                  force=force,
                  load=load,
                  shortcut=shortcut))
    if output.exit_code != 0:
        raise CmdException("Failed to start cache.", output)
    return Cache(cache_dev)
Example #4
0
def get_caches():  # This method does not return inactive or detached CAS devices
    from api.cas.cache import Cache
    caches_list = []
    lines = casadm.list_caches(OutputFormat.csv).stdout.split('\n')
    for line in lines:
        args = line.split(',')
        if args[0] == "cache":
            current_cache = Cache(Device(args[2]))
            caches_list.append(current_cache)
    return caches_list
Example #5
0
def start_cache(cache_dev: Device, cache_mode: CacheMode = None,
                cache_line_size: CacheLineSize = None, cache_id: int = None,
                force: bool = False, load: bool = False, shortcut: bool = False):
    _cache_line_size = None if cache_line_size is None else str(
        CacheLineSize.get_value(Unit.KibiByte))
    _cache_id = None if cache_id is None else str(cache_id)
    _cache_mode = None if cache_mode is None else cache_mode.name.lower()
    output = TestRun.executor.run(start_cmd(
        cache_dev=cache_dev.system_path, cache_mode=_cache_mode, cache_line_size=_cache_line_size,
        cache_id=_cache_id, force=force, load=load, shortcut=shortcut))
    if output.exit_code != 0:
        raise CmdException("Failed to start cache.", output)
    return Cache(cache_dev.system_path)
Example #6
0
def standby_init(cache_dev: Device,
                 cache_id: int,
                 cache_line_size: CacheLineSize,
                 force: bool = False,
                 shortcut: bool = False,
                 kernel_params: KernelParameters = KernelParameters()):
    if kernel_params != KernelParameters.read_current_settings():
        reload_kernel_module("cas_cache",
                             kernel_params.get_parameter_dictionary())
    output = TestRun.executor.run(
        standby_init_cmd(
            cache_dev=cache_dev.path,
            cache_id=str(cache_id),
            cache_line_size=str(cache_line_size),
            force=force,
            shortcut=shortcut,
        ))
    if output.exit_code != 0:
        raise CmdException("Failed to init standby cache.", output)
    return Cache(cache_dev)
Example #7
0
def standby_load(cache_dev: Device, shortcut: bool = False):
    output = TestRun.executor.run(
        standby_load_cmd(cache_dev=cache_dev.path, shortcut=shortcut))
    if output.exit_code != 0:
        raise CmdException("Failed to load standby cache.", output)
    return Cache(cache_dev)