blob: 409f14de16ddc9b78a3560deb6026dce60837e6b [file] [log] [blame]
magnussonl2b0e2d72020-02-04 10:52:46 +01001# -*- coding: utf-8 -*-
2
3# Copyright 2020 ArctosLabs Scandinavia AB
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14# implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17import argparse
18import asyncio
19import logging
20import sys
21
22from osm_pla.config.config import Config
23from osm_pla.server.server import Server
24
25
26def main():
garciadeblas20fc3b72022-11-14 00:48:32 +010027 parser = argparse.ArgumentParser(prog="osm-policy-agent")
28 parser.add_argument("--config-file", nargs="?", help="PLA configuration file")
magnussonl2b0e2d72020-02-04 10:52:46 +010029 args = parser.parse_args()
30 cfg = Config(args.config_file)
31
32 root = logging.getLogger()
garciadeblas20fc3b72022-11-14 00:48:32 +010033 root.setLevel(logging.getLevelName(cfg.get("global", "loglevel")))
magnussonl2b0e2d72020-02-04 10:52:46 +010034 ch = logging.StreamHandler(sys.stdout)
garciadeblas20fc3b72022-11-14 00:48:32 +010035 ch.setLevel(logging.getLevelName(cfg.get("global", "loglevel")))
36 formatter = logging.Formatter(
37 "%(asctime)s - %(name)s - %(levelname)s - %(message)s", "%m/%d/%Y %I:%M:%S %p"
38 )
magnussonl2b0e2d72020-02-04 10:52:46 +010039 ch.setFormatter(formatter)
40 root.addHandler(ch)
41
42 log = logging.getLogger(__name__)
43 log.info("Starting PLA Server...")
44
45 loop = asyncio.get_event_loop()
46 server = Server(cfg, loop)
47 server.run()
48
49
garciadeblas20fc3b72022-11-14 00:48:32 +010050if __name__ == "__main__":
magnussonl2b0e2d72020-02-04 10:52:46 +010051 main()