Ejemplo n.º 1
0
 def __init__(self, username, password, tenant_name, auth_url, num_threads=5,
              log_level=LOG_INFO):
     """
     @param username: String; the Openstack user name
     @param password: String; the Openstack password for username
     @param tenant_name: String, the Openstack tenant's name
     @param auth_url: String; the Openstack authentication URL. This will
         authenticate the username/password to allow them to perform the
         resource provisioning tasks.
     @keyword num_threads: Optional. Integer, default 5. The number of threads
         to spawn to handle parallel provisioning tasks
     @keyword log_level: Optional; default LOG_INFO. One of the logging values
         from actuator: LOG_CRIT, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG.
     """
     self.os_creds = OpenstackCredentials(username, password, tenant_name, auth_url)
     self.agent = None
     self.num_threads = num_threads
     root_logger.setLevel(log_level)
     self.logger = root_logger.getChild(self.LOG_SUFFIX)
Ejemplo n.º 2
0
    def __init__(
        self,
        exec_model_instance=None,
        config_model_instance=None,
        namespace_model_instance=None,
        infra_model_instance=None,
        num_threads=5,
        do_log=False,
        no_delay=False,
        log_level=LOG_INFO,
    ):
        """
        Make a new ExecutionAgent
        
        @keyword exec_model_instance: Reserved for latter use
        @keyword config_model_instance: an instance of a derived class of
            ConfigModel
        @keyword namespace_model_instance: an instance of a derived class of
            NamespaceModel
        @keyword infra_model_instance: UNUSED; an instance of a derived class of
            InfraModel
        @keyword num_threads: Integer, default 5. The number of worker threads
            to spin up to perform tasks.
        @keyword do_log: boolean, default False. If True, creates a log file
            that contains more detailed logs of the activities carried out.
            Independent of log_level (see below).
        @keyword no_delay: booleand, default False. The default causes a short
            pause of up to 2.5 seconds to be taken before a task is started.
            This keeps a single host from being bombarded with too many ssh
            requests at the same time in the case where a number of different
            tasks can all start in parallel on the same Role's host.
        @keyword log_level: Any of the symbolic log levels in the actuator root
            package, LOG_CRIT, LOG_DEBUG, LOG_ERROR, LOG_INFO, or LOG_WARN
        """
        # @TODO: need to add a test for the type of the exec_model_instance
        self.exec_mi = exec_model_instance
        if config_model_instance is not None and not isinstance(config_model_instance, ConfigModel):
            raise ExecutionException("config_model_instance argument isn't an instance of ConfigModel")
        self.config_mi = config_model_instance

        if namespace_model_instance is not None and not isinstance(namespace_model_instance, NamespaceModel):
            raise ExecutionException("namespace_model_instance isn't an instance of NamespaceModel")
        self.namespace_mi = namespace_model_instance

        if self.config_mi is not None:
            self.config_mi.set_namespace(self.namespace_mi)

        if infra_model_instance is not None and not isinstance(infra_model_instance, InfraModel):
            raise ExecutionException("infra_model_instance isn't an instance of InfraModel")
        self.infra_mi = infra_model_instance

        root_logger.setLevel(log_level)
        self.task_queue = Queue.Queue()
        self.node_lock = threading.Lock()
        self.stop = False
        self.aborted_tasks = []
        self.num_tasks_to_perform = None
        self.config_record = None
        self.num_threads = num_threads
        self.do_log = do_log
        self.no_delay = no_delay