def set_server_conf(config, input, session):
    if os.path.exists(LIGHTTPD_CONF_TEMP_DIR) is False:
        os.mkdir(LIGHTTPD_CONF_TEMP_DIR)

    tmp_file_names = {}

    # port.conf
    try:
        port_conf_path = LIGHTTPD_CONF_TEMP_DIR + "/kss_port_" + uniq_filename()
        port_conf = LighttpdPortConf(port_conf_path)
        port_conf.write(input)
        tmp_file_names["port"] = port_conf_path
    except AttributeError:
        raise KaresansuiGadgetException(
            "Failed to write configuration value input.port=%s at %s" % (input.port, port_conf_path)
        )

    # access.conf
    try:
        access_conf_path = LIGHTTPD_CONF_TEMP_DIR + "/kss_access_" + uniq_filename()
        access_conf = LighttpdAccessConf(access_conf_path)
        access_conf.write(input)
        tmp_file_names["access"] = access_conf_path
    except AttributeError:
        raise KaresansuiGadgetException(
            "Failed to write configuration value input.access=%s, input.access_ipaddress=%s, input.ip_list=%s at %s"
            % (input.access, input.network, input.access_ipaddress, access_conf_path)
        )

    # ssl.conf
    try:
        ssl_conf_path = LIGHTTPD_CONF_TEMP_DIR + "/kss_ssl_" + uniq_filename()
        ssl_conf = LighttpdSslConf(ssl_conf_path)
        ssl_conf.write(input)
        tmp_file_names["ssl"] = ssl_conf_path
    except AttributeError:
        raise KaresansuiGadgetException(
            "Failed to write configuration value input.ssl_status=%s at %s" % (input.ssl_status, ssl_conf_path)
        )

    config["application.uniqkey"] = input.uniqkey

    # check temporary files
    for key in ("port", "access", "ssl"):
        if not tmp_file_names.has_key(key):
            raise KaresansuiGadgetException("Failed to make temporary file for %s", key)
        elif os.path.isfile(tmp_file_names[key]) is False:
            raise KaresansuiGadgetException("Not exist temporary file for %s", key)

    return tmp_file_names
def get_view_server_conf(config):
    try:
        conf_file = config["lighttpd.etc.dir"] + "/" + LIGHTTPD_PORT_CONFIG
        port_conf = LighttpdPortConf(conf_file)
        port_number = port_conf.read()

        conf_file = config["lighttpd.etc.dir"] + "/" + LIGHTTPD_ACCESS_CONFIG
        access_conf = LighttpdAccessConf(conf_file)
        access_list = access_conf.read()

        conf_file = config["lighttpd.etc.dir"] + "/" + LIGHTTPD_SSL_CONFIG
        ssl_conf = LighttpdSslConf(conf_file)
        ssl_status = ssl_conf.read()

    except IOError:
        raise KaresansuiGadgetException("Failed to read configuration file. - %s" % conf_file)

    uniqkey = config["application.uniqkey"]

    server_config = {"uniqkey": uniqkey, "port": port_number, "access": access_list, "ssl_status": ssl_status}

    return server_config