fix(healthcheck): new flag implemented as a file for health checking in POL (it only...
[osm/POL.git] / osm_policy_module / cmd / policy_module_agent.py
index 050cf32..e6c0681 100644 (file)
@@ -25,6 +25,7 @@ import argparse
 import asyncio
 import logging
 import sys
+import os
 
 from osm_policy_module.core.agent import PolicyModuleAgent
 from osm_policy_module.core.config import Config
@@ -32,6 +33,10 @@ from osm_policy_module.core.database import DatabaseManager
 
 
 def main():
+    # Cleanup old temp health file
+    if os.path.exists('/tmp/osm_pol_agent_health_flag'):
+        os.remove('/tmp/osm_pol_agent_health_flag')
+
     parser = argparse.ArgumentParser(prog='osm-policy-agent')
     parser.add_argument('--config-file', nargs='?', help='POL configuration file')
     args = parser.parse_args()
@@ -48,8 +53,8 @@ def main():
     log = logging.getLogger(__name__)
     log.debug("Config: %s", cfg.conf)
     log.info("Initializing database...")
-    db_manager = DatabaseManager()
-    db_manager.init_db(cfg)
+    db_manager = DatabaseManager(cfg)
+    db_manager.create_tables()
     log.info("Database initialized correctly.")
     log.info("Starting policy module agent...")
     loop = asyncio.get_event_loop()