Exemple #1
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)
Exemple #2
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)