Ejemplo n.º 1
0
    def __init__(self, forseti_config_file_path, forseti_db_connect_string,
                 endpoint):
        """Initialize.

        Args:
            forseti_config_file_path (str): Path to Forseti configuration file
            forseti_db_connect_string (str): Forseti database string
            endpoint (str): server endpoint
        """

        super(ServiceConfig, self).__init__()
        self.thread_pool = ThreadPool()

        # Enable pool_pre_ping to ensure that disconnected or errored
        # connections are dropped and recreated before use.
        self.engine = create_engine(forseti_db_connect_string,
                                    pool_recycle=3600,
                                    pool_pre_ping=True)
        self.model_manager = ModelManager(self.engine)
        self.sessionmaker = db.create_scoped_sessionmaker(self.engine)
        self.endpoint = endpoint

        self.forseti_config_file_path = forseti_config_file_path

        self.inventory_config = None
        self.scanner_config = None
        self.notifier_config = None
        self.global_config = None
        self.forseti_config = None

        self.update_lock = threading.RLock()
Ejemplo n.º 2
0
 def __init__(self):
     self.engine = create_test_engine()
     self.model_manager = ModelManager(self.engine)
     self.sessionmaker = db.create_scoped_sessionmaker(self.engine)
     self.workers = ThreadPool(10)
     self.inventory_config = InventoryConfig(gcp_api_mocks.ORGANIZATION_ID,
                                             '', {}, '', {})
     self.inventory_config.set_service_config(self)
Ejemplo n.º 3
0
 def __init__(self, engine):
     self.engine = engine
     self.model_manager = ModelManager(self.engine)
     self.sessionmaker = db.create_scoped_sessionmaker(self.engine)
     self.workers = ThreadPool(1)
     self.inventory_config = InventoryConfig(
         None, '', {}, 0, {'enabled': False},
         ['folders/1032', 'projects/1041'])
     self.inventory_config.set_service_config(self)
Ejemplo n.º 4
0
 def __init__(self, engine):
     self.engine = engine
     self.model_manager = ModelManager(self.engine)
     self.sessionmaker = db.create_scoped_sessionmaker(self.engine)
     self.workers = ThreadPool(1)
     self.inventory_config = InventoryConfig(
         gcp_api_mocks.ORGANIZATION_ID, '', {}, 0, {
             'enabled': True,
             'gcs_path': 'gs://test-bucket'
         })
     self.inventory_config.set_service_config(self)
Ejemplo n.º 5
0
 def __init__(self):
     engine = create_test_engine()
     self.model_manager = ModelManager(engine)
Ejemplo n.º 6
0
 def __init__(self):
     self.engine = create_test_engine()
     self.model_manager = ModelManager(self.engine)
     self.inventory_config = (
         InventoryConfig(gcp_api_mocks.ORGANIZATION_ID, '', {}, '', {}))
Ejemplo n.º 7
0
 def __init__(self, db_connect_string):
     engine = create_engine(db_connect_string, echo=False)
     self.model_manager = ModelManager(engine)
 def __init__(self, inventory_config):
     self.engine = create_test_engine()
     self.model_manager = ModelManager(self.engine)
     self.inventory_config = inventory_config
Ejemplo n.º 9
0
 def setUp(self):
     self.engine, self.dbfile = create_test_engine_with_file()
     self.model_manager = ModelManager(self.engine)