def needs_restart(params):
    restarted = params['restarted']
    if (restarted is True):
        return ModuleRes(success=True, changed=True)
    if (restarted is False):
        return ModuleRes(success=True, changed=False)
    stateboard = params['stateboard']
    control_sock = params['control_sock']
    appname = params['appname']
    new_default_conf = params['cartridge_defaults']
    new_instance_conf = params['config']
    cluster_cookie = params['cluster_cookie']
    instance_conf_file = params['instance_conf_file']
    conf_section_name = params['conf_section_name']
    default_conf_path = '/etc/tarantool/conf.d/{}.yml'.format(appname)
    app_code_path = '/usr/share/tarantool/{}'.format(appname)
    if (not os.path.exists(control_sock)):
        return ModuleRes(success=True, changed=True)
    try:
        control_console = get_control_console(control_sock)
    except CartridgeException as e:
        allowed_errcodes = [cartridge_errcodes.SOCKET_NOT_FOUND, cartridge_errcodes.FAILED_TO_CONNECT_TO_SOCKET, cartridge_errcodes.INSTANCE_IS_NOT_STARTED_YET]
        if (e.code in allowed_errcodes):
            return ModuleRes(success=True, changed=True)
    last_restart_time = os.path.getmtime(control_sock)
    package_update_time = os.path.getmtime(app_code_path)
    if (last_restart_time < package_update_time):
        return ModuleRes(success=True, changed=True)
    current_instance_conf = read_yaml_file_section(instance_conf_file, control_console, conf_section_name)
    if check_conf_updated(new_instance_conf, current_instance_conf, dynamic_box_cfg_params):
        return ModuleRes(success=True, changed=True)
    if (not stateboard):
        current_default_conf = read_yaml_file_section(default_conf_path, control_console, appname)
        new_default_conf.update({'cluster_cookie': cluster_cookie})
        if check_conf_updated(new_default_conf, current_default_conf, dynamic_box_cfg_params):
            return ModuleRes(success=True, changed=True)
    current_cfg = get_current_cfg(control_console)
    for param_name in dynamic_box_cfg_params:
        new_value = None
        if (param_name in new_instance_conf):
            new_value = new_instance_conf[param_name]
        elif ((not stateboard) and (param_name in new_default_conf)):
            new_value = new_default_conf[param_name]
        if (new_value is not None):
            if (current_cfg[param_name] != new_value):
                return ModuleRes(success=True, changed=True)
    return ModuleRes(success=True, changed=False)
def needs_restart(params):
    restarted = params['restarted']
    if (restarted is True):
        return ModuleRes(success=True, changed=True)
    if (restarted is False):
        return ModuleRes(success=True, changed=False)
    stateboard = params['stateboard']
    control_sock = params['control_sock']
    appname = params['appname']
    new_default_conf = params['cartridge_defaults']
    new_instance_conf = params['config']
    cluster_cookie = params['cluster_cookie']
    instance_conf_file = params['instance_conf_file']
    conf_section_name = params['conf_section_name']
    default_conf_path = '/etc/tarantool/conf.d/{}.yml'.format(appname)
    app_code_path = '/usr/share/tarantool/{}'.format(appname)
    if (not os.path.exists(control_sock)):
        return ModuleRes(success=True, changed=True)
    try:
        control_console = get_control_console(control_sock)
    except CartridgeException as e:
        allowed_errcodes = [cartridge_errcodes.SOCKET_NOT_FOUND, cartridge_errcodes.FAILED_TO_CONNECT_TO_SOCKET, cartridge_errcodes.INSTANCE_IS_NOT_STARTED_YET]
        if (e.code in allowed_errcodes):
            return ModuleRes(success=True, changed=True)
    last_restart_time = os.path.getmtime(control_sock)
    package_update_time = os.path.getmtime(app_code_path)
    if (last_restart_time < package_update_time):
        return ModuleRes(success=True, changed=True)
    current_instance_conf = read_yaml_file_section(instance_conf_file, control_console, conf_section_name)
    if check_conf_updated(new_instance_conf, current_instance_conf, dynamic_box_cfg_params):
        return ModuleRes(success=True, changed=True)
    if (not stateboard):
        current_default_conf = read_yaml_file_section(default_conf_path, control_console, appname)
        new_default_conf.update({'cluster_cookie': cluster_cookie})
        if check_conf_updated(new_default_conf, current_default_conf, dynamic_box_cfg_params):
            return ModuleRes(success=True, changed=True)
    current_cfg = get_current_cfg(control_console)
    for param_name in dynamic_box_cfg_params:
        new_value = None
        if (param_name in new_instance_conf):
            new_value = new_instance_conf[param_name]
        elif ((not stateboard) and (param_name in new_default_conf)):
            new_value = new_default_conf[param_name]
        if (new_value is not None):
            if (current_cfg[param_name] != new_value):
                return ModuleRes(success=True, changed=True)
    return ModuleRes(success=True, changed=False)