Exemple #1
0
def create_server():
    configuration.init_logging()

    component_id = os.getenv("UUID")
    component_type = os.getenv("TYPE")
    tcp_port = os.getenv("PORT")
    pdp_id = os.getenv("PDP_ID")
    meta_rule_id = os.getenv("META_RULE_ID")
    keystone_project_id = os.getenv("KEYSTONE_PROJECT_ID")
    logger.info("component_type={}".format(component_type))
    conf = configuration.get_plugins()
    # conf = configuration.get_configuration("plugins/{}".format(component_type))
    # conf["plugins/{}".format(component_type)]['id'] = component_id
    if component_type not in conf:
        raise exceptions.ConsulComponentNotFound(
            "{} not found".format(component_type))
    hostname = conf[component_type].get('hostname', component_id)
    port = conf[component_type].get('port', tcp_port)
    bind = conf[component_type].get('bind', "0.0.0.0")

    logger.info("Starting server with IP {} on port {} bind to {}".format(
        hostname, port, bind))
    server = Server(host=bind,
                    port=int(port),
                    component_data={
                        'component_id': component_id,
                        'component_type': component_type,
                        'pdp_id': pdp_id,
                        'meta_rule_id': meta_rule_id,
                        'keystone_project_id': keystone_project_id,
                    })
    return server
Exemple #2
0
def main():
    configuration.init_logging()
    try:
        conf = configuration.get_configuration("components/wrapper")
        LOG.debug("wrapper.conf={}".format(conf))
        hostname = conf["components/wrapper"].get("hostname", "wrapper")
        port = conf["components/wrapper"].get("port", 80)
        bind = conf["components/wrapper"].get("bind", "127.0.0.1")
    except exceptions.ConsulComponentNotFound:
        hostname = "wrapper"
        bind = "127.0.0.1"
        port = 80
        configuration.add_component(uuid="wrapper", name=hostname, port=port, bind=bind)
    LOG.info("Starting server with IP {} on port {} bind to {}".format(hostname, port, bind))
    return HTTPServer(host=bind, port=port)
Exemple #3
0
def create_server():
    configuration.init_logging()
    try:
        conf = configuration.get_configuration("components/orchestrator")
        hostname = conf["components/orchestrator"].get("hostname",
                                                       "orchestrator")
        port = conf["components/orchestrator"].get("port", 80)
        bind = conf["components/orchestrator"].get("bind", "127.0.0.1")
    except exceptions.ConsulComponentNotFound:
        hostname = "orchestrator"
        bind = "127.0.0.1"
        port = 80
        configuration.add_component(uuid="orchestrator", name=hostname,
                                    port=port, bind=bind)
    logger.info("Starting server with IP {} on port {} bind to {}".format(
        hostname, port, bind))
    return HTTPServer(host=bind, port=port)