def __init__(self, pack, file_path, parameters=None, parent_args=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` :param parent_args: Command line arguments passed to the parent process. :type parse_args: ``list`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} self._parent_args = parent_args or [] self._class_name = None self._logger = logging.getLogger('PythonActionWrapper') try: config.parse_args(args=self._parent_args) except Exception: pass else: db_setup()
def _setup(): # Set up logger which logs everything which happens during and before config # parsing to sys.stdout logging.setup(DEFAULT_LOGGING_CONF_PATH) # 1. parse args to setup config. config.parse_args() # 2. setup logging. logging.setup(cfg.CONF.actionrunner.logging) # 3. all other setup which requires config to be parsed and logging to # be correctly setup. username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password) register_exchanges() # 4. Register internal triggers # Note: We need to do import here because of a messed up configuration # situation (this module depends on configuration being parsed) from st2common.triggers import register_internal_trigger_types register_internal_trigger_types()
def _setup(): # Set up logger which logs everything which happens during and before config # parsing to sys.stdout logging.setup(DEFAULT_LOGGING_CONF_PATH) # 1. parse args to setup config. config.parse_args() # 2. setup logging. logging.setup(cfg.CONF.actionrunner.logging) # 3. all other setup which requires config to be parsed and logging to # be correctly setup. username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password) register_exchanges() register_common_signal_handlers() # 4. Register internal triggers register_internal_trigger_types()
def _setup(): # Set up logger which logs everything which happens during and before config # parsing to sys.stdout logging.setup(DEFAULT_LOGGING_CONF_PATH) # 1. parse args to setup config. config.parse_args() # 2. setup logging. logging.setup(cfg.CONF.resultstracker.logging) # 3. all other setup which requires config to be parsed and logging to # be correctly setup. username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password)
def _setup(): # Set up logger which logs everything which happens during and before config # parsing to sys.stdout logging.setup(DEFAULT_LOGGING_CONF_PATH) # 1. parse args to setup config. config.parse_args() # 2. setup logging. logging.setup(cfg.CONF.notifier.logging) # 3. all other setup which requires config to be parsed and logging to # be correctly setup. username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password) register_exchanges()
def _setup(): # 1. parse args to setup config. config.parse_args() # 2. setup logging. logging.setup(cfg.CONF.actionrunner.logging) # 3. all other setup which requires config to be parsed and logging to # be correctly setup. username = cfg.CONF.database.username if hasattr(cfg.CONF.database, 'username') else None password = cfg.CONF.database.password if hasattr(cfg.CONF.database, 'password') else None db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password)
def __init__(self, pack, file_path, parameters=None, user=None, parent_args=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` :param user: Name of the user who triggered this action execution. :type user: ``str`` :param parent_args: Command line arguments passed to the parent process. :type parse_args: ``list`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} self._user = user self._parent_args = parent_args or [] self._class_name = None self._logger = logging.getLogger('PythonActionWrapper') try: config.parse_args(args=self._parent_args) except Exception as e: LOG.debug( 'Failed to parse config using parent args (parent_args=%s): %s' % (str(self._parent_args), str(e))) # We don't need to ensure indexes every subprocess because they should already be created # and ensured by other services db_setup(ensure_indexes=False) # Note: We can only set a default user value if one is not provided after parsing the # config if not self._user: self._user = cfg.CONF.system_user.user
def __init__(self, pack, file_path, parameters=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} try: config.parse_args(args=[]) except Exception: pass
def __init__(self, pack, file_path, parameters=None, user=None, parent_args=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` :param user: Name of the user who triggered this action execution. :type user: ``str`` :param parent_args: Command line arguments passed to the parent process. :type parse_args: ``list`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} self._user = user self._parent_args = parent_args or [] self._class_name = None self._logger = logging.getLogger('PythonActionWrapper') try: config.parse_args(args=self._parent_args) except Exception: pass db_setup() # Note: We can only set a default user value if one is not provided after parsing the # config if not self._user: self._user = cfg.CONF.system_user.user
def __init__(self, pack, file_path, parameters=None, user=None, parent_args=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` :param user: Name of the user who triggered this action execution. :type user: ``str`` :param parent_args: Command line arguments passed to the parent process. :type parse_args: ``list`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} self._user = user self._parent_args = parent_args or [] self._class_name = None self._logger = logging.getLogger('PythonActionWrapper') try: config.parse_args(args=self._parent_args) except Exception as e: LOG.debug('Failed to parse config using parent args (parent_args=%s): %s' % (str(self._parent_args), str(e))) # We don't need to ensure indexes every subprocess because they should already be created # and ensured by other services db_setup(ensure_indexes=False) # Note: We can only set a default user value if one is not provided after parsing the # config if not self._user: self._user = cfg.CONF.system_user.user
def __init__(self, pack, file_path, parameters=None, parent_args=None): """ :param pack: Name of the pack this action belongs to. :type pack: ``str`` :param file_path: Path to the action module. :type file_path: ``str`` :param parameters: action parameters. :type parameters: ``dict`` or ``None`` :param parent_args: Command line arguments passed to the parent process. :type parse_args: ``list`` """ self._pack = pack self._file_path = file_path self._parameters = parameters or {} self._parent_args = parent_args or [] try: config.parse_args(args=self._parent_args) except Exception: pass