Exemple #1
0
    def __init__(self,
                 dry_run=False,
                 concurrent_workers=1,
                 project_sema=None,
                 max_running_operations=0):
        """Initialize.

        Args:
          dry_run: If True, will simply log what action would have been taken
              without actually applying any modifications.
          concurrent_workers: The number of parallel enforcement threads to
              execute.
          project_sema: An optional semaphore object, used to limit the number
              of concurrent projects getting written to.
          max_running_operations: Used to limit the number of concurrent write
              operations on a single project's firewall rules. Set to 0 to
              allow unlimited in flight asynchronous operations.
        """
        self.enforcement_log = enforcer_log_pb2.EnforcerLog()
        self._dry_run = dry_run
        self._concurrent_workers = concurrent_workers

        self._project_sema = project_sema
        self._max_running_operations = max_running_operations

        self.compute = compute.ComputeClient()
Exemple #2
0
    def __init__(self,
                 global_configs=None,
                 dry_run=False,
                 concurrent_workers=1,
                 project_sema=None,
                 max_running_operations=0):
        """Initialize.

        Args:
          global_configs (dict): Global configurations.
          dry_run (bool): If True, will simply log what action would have been
              taken without actually applying any modifications.
          concurrent_workers (int): The number of parallel enforcement threads
              to execute.
          project_sema (threading.BoundedSemaphore): An optional semaphore
              object, used to limit the number of concurrent projects getting
              written to.
          max_running_operations (int): Used to limit the number of concurrent
              write operations on a single project's firewall rules. Set to 0 to
              allow unlimited in flight asynchronous operations.
        """
        self.global_configs = global_configs
        self.enforcement_log = enforcer_log_pb2.EnforcerLog()
        self._dry_run = dry_run
        self._concurrent_workers = concurrent_workers

        self._project_sema = project_sema
        self._max_running_operations = max_running_operations
        self._local = LOCAL_THREAD