diff options
author | Thomas Duval <thomas.duval@orange.com> | 2018-01-03 14:13:11 +0100 |
---|---|---|
committer | Thomas Duval <thomas.duval@orange.com> | 2018-01-03 14:13:11 +0100 |
commit | d023803536f069b4a69cfeeb744e56dfcd54103b (patch) | |
tree | 73747e82b064bfa49bbfa10d8db28264c15a8217 /moon_authz/moon_authz/server.py | |
parent | 52d037e757ac2189978e1129f469929fe73a9b7f (diff) |
Clean the code and fix some bugs
Change-Id: I3516d001cb0792ca6b01a40b9d9d13efc3ba30f9
Diffstat (limited to 'moon_authz/moon_authz/server.py')
-rw-r--r-- | moon_authz/moon_authz/server.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/moon_authz/moon_authz/server.py b/moon_authz/moon_authz/server.py index 1919ebe5..8715bd87 100644 --- a/moon_authz/moon_authz/server.py +++ b/moon_authz/moon_authz/server.py @@ -4,15 +4,14 @@ # or at 'http://www.apache.org/licenses/LICENSE-2.0'. import os -from oslo_log import log as logging +import logging from moon_authz.http_server import HTTPServer as Server from python_moonutilities import configuration -LOG = logging.getLogger("moon.authz.server") -DOMAIN = "moon_authz" +logger = logging.getLogger("moon.authz.server") -def main(): +def create_server(): configuration.init_logging() component_id = os.getenv("UUID") @@ -21,14 +20,16 @@ def main(): pdp_id = os.getenv("PDP_ID") meta_rule_id = os.getenv("META_RULE_ID") keystone_project_id = os.getenv("KEYSTONE_PROJECT_ID") - LOG.info("component_type={}".format(component_type)) + logger.info("component_type={}".format(component_type)) conf = configuration.get_configuration("plugins/{}".format(component_type)) conf["plugins/{}".format(component_type)]['id'] = component_id - hostname = conf["plugins/{}".format(component_type)].get('hostname', component_id) + hostname = conf["plugins/{}".format(component_type)].get('hostname', + component_id) port = conf["plugins/{}".format(component_type)].get('port', tcp_port) bind = conf["plugins/{}".format(component_type)].get('bind', "0.0.0.0") - LOG.info("Starting server with IP {} on port {} bind to {}".format(hostname, port, bind)) + logger.info("Starting server with IP {} on port {} bind to {}".format( + hostname, port, bind)) server = Server( host=bind, port=int(port), @@ -43,5 +44,10 @@ def main(): return server +def run(): + server = create_server() + server.run() + + if __name__ == '__main__': - main() + run() |