示例#1
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    purge_incomplete = cfg.CONF.purge_incomplete

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    try:
        purge_executions(logger=LOG,
                         timestamp=timestamp,
                         action_ref=action_ref,
                         purge_incomplete=purge_incomplete)
    except Exception as e:
        LOG.exception(str(e))
        return FAILURE_EXIT_CODE
    finally:
        common_teardown()

    return SUCCESS_EXIT_CODE
示例#2
0
文件: cleanup.py 项目: st2sandbox/st2
def setup(argv):
    common_setup(
        config=config,
        setup_db=False,
        register_mq_exchanges=False,
        register_internal_trigger_types=False,
    )
示例#3
0
def main(argv):
    _register_cli_opts()

    # Parse CLI args, set up logging
    common_setup(config=config, setup_db=False, register_mq_exchanges=False,
                 register_internal_trigger_types=False)

    packs = cfg.CONF.pack
    verify_ssl = cfg.CONF.verify_ssl
    force = cfg.CONF.force
    use_python3 = cfg.CONF.use_python3

    proxy_config = get_and_set_proxy_config()

    for pack in packs:
        LOG.info('Installing pack "%s"' % (pack))
        result = download_pack(pack=pack, verify_ssl=verify_ssl, force=force,
                               proxy_config=proxy_config, force_permissions=True,
                               use_python3=use_python3)

        # Raw pack name excluding the version
        pack_name = result[1]
        success = result[2][0]

        if success:
            LOG.info('Successfully installed pack "%s"' % (pack_name))
        else:
            error = result[2][1]
            LOG.error('Failed to installed pack "%s": %s' % (pack_name, error))
            sys.exit(2)

    return 0
示例#4
0
def main(argv):
    _register_cli_opts()

    # Parse CLI args, set up logging
    common_setup(config=config, setup_db=False, register_mq_exchanges=False,
                 register_internal_trigger_types=False)

    packs = cfg.CONF.pack
    verify_ssl = cfg.CONF.verify_ssl
    force = cfg.CONF.force

    proxy_config = get_and_set_proxy_config()

    for pack in packs:
        LOG.info('Installing pack "%s"' % (pack))
        result = download_pack(pack=pack, verify_ssl=verify_ssl, force=force,
                               proxy_config=proxy_config, force_permissions=True)

        # Raw pack name excluding the version
        pack_name = result[1]
        success = result[2][0]

        if success:
            LOG.info('Successfully installed pack "%s"' % (pack_name))
        else:
            error = result[2][1]
            LOG.error('Failed to installed pack "%s": %s' % (pack_name, error))
            sys.exit(2)

    return 0
示例#5
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    purge_incomplete = cfg.CONF.purge_incomplete

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    try:
        purge_executions(logger=LOG, timestamp=timestamp, action_ref=action_ref,
                         purge_incomplete=purge_incomplete)
    except Exception as e:
        LOG.exception(str(e))
        return FAILURE_EXIT_CODE
    finally:
        common_teardown()

    return SUCCESS_EXIT_CODE
示例#6
0
def main(argv):
    _register_cli_opts()

    # Parse CLI args, set up logging
    common_setup(config=config,
                 setup_db=False,
                 register_mq_exchanges=False,
                 register_internal_trigger_types=False)

    packs = cfg.CONF.pack
    update = cfg.CONF.update
    use_python3 = cfg.CONF.python3

    proxy_config = get_and_set_proxy_config()

    for pack in packs:
        # Setup pack virtual environment
        LOG.info('Setting up virtualenv for pack "%s"' % (pack))
        setup_pack_virtualenv(pack_name=pack,
                              update=update,
                              logger=LOG,
                              proxy_config=proxy_config,
                              use_python3=use_python3,
                              no_download=True)
        LOG.info('Successfully set up virtualenv for pack "%s"' % (pack))

    return 0
示例#7
0
def setup(argv):
    common_setup(
        config=config,
        setup_db=True,
        register_mq_exchanges=True,
        register_internal_trigger_types=True,
        ignore_register_config_opts_errors=True,
    )
示例#8
0
def main(argv):
    _register_cli_opts()

    # Parse CLI args, set up logging
    common_setup(config=config,
                 setup_db=False,
                 register_mq_exchanges=False,
                 register_internal_trigger_types=False)

    packs = cfg.CONF.pack
    verify_ssl = cfg.CONF.verify_ssl
    force = cfg.CONF.force
    use_python3 = cfg.CONF.use_python3

    proxy_config = get_and_set_proxy_config()

    for pack in packs:
        # 1. Download the pack
        LOG.info('Installing pack "%s"' % (pack))
        result = download_pack(pack=pack,
                               verify_ssl=verify_ssl,
                               force=force,
                               proxy_config=proxy_config,
                               force_permissions=True,
                               use_python3=use_python3)

        # Raw pack name excluding the version
        pack_name = result[1]
        success = result[2][0]

        if success:
            LOG.info('Successfully installed pack "%s"' % (pack_name))
        else:
            error = result[2][1]
            LOG.error('Failed to install pack "%s": %s' % (pack_name, error))
            sys.exit(2)

        # 2. Setup pack virtual environment
        LOG.info('Setting up virtualenv for pack "%s"' % (pack_name))
        setup_pack_virtualenv(pack_name=pack_name,
                              update=False,
                              logger=LOG,
                              proxy_config=proxy_config,
                              use_python3=use_python3,
                              no_download=True)
        LOG.info('Successfully set up virtualenv for pack "%s"' % (pack_name))

    return 0
示例#9
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    # Purge models.
    purge_trigger_instances(timestamp=timestamp)

    common_teardown()
示例#10
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    # Purge models.
    purge_trigger_instances(timestamp=timestamp)

    common_teardown()
示例#11
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    try:
        tester = RuleTester(rule_file_path=cfg.CONF.rule,
                            rule_ref=cfg.CONF.rule_ref,
                            trigger_instance_file_path=cfg.CONF.trigger_instance,
                            trigger_instance_id=cfg.CONF.trigger_instance_id)
        matches = tester.evaluate()
    finally:
        common_teardown()

    if matches:
        LOG.info('=== RULE MATCHES ===')
        sys.exit(0)
    else:
        LOG.info('=== RULE DOES NOT MATCH ===')
        sys.exit(1)
示例#12
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    try:
        tester = RuleTester(rule_file_path=cfg.CONF.rule,
                            rule_ref=cfg.CONF.rule_ref,
                            trigger_instance_file_path=cfg.CONF.trigger_instance,
                            trigger_instance_id=cfg.CONF.trigger_instance_id)
        matches = tester.evaluate()
    finally:
        common_teardown()

    if matches:
        LOG.info('=== RULE MATCHES ===')
        sys.exit(0)
    else:
        LOG.info('=== RULE DOES NOT MATCH ===')
        sys.exit(1)
示例#13
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    purge_incomplete = cfg.CONF.purge_incomplete

    if not timestamp:
        LOG.error("Please supply a timestamp for purging models. Aborting.")
        return 1
    else:
        timestamp = datetime.strptime(timestamp, "%Y-%m-%dT%H:%M:%S.%fZ")
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    # Purge models.
    purge_executions(timestamp=timestamp, action_ref=action_ref, purge_incomplete=purge_incomplete)

    common_teardown()
示例#14
0
def main(argv):
    _register_cli_opts()

    # Parse CLI args, set up logging
    common_setup(config=config, setup_db=False, register_mq_exchanges=False,
                 register_internal_trigger_types=False)

    packs = cfg.CONF.pack
    update = cfg.CONF.update
    use_python3 = cfg.CONF.python3

    proxy_config = get_and_set_proxy_config()

    for pack in packs:
        # Setup pack virtual environment
        LOG.info('Setting up virtualenv for pack "%s"' % (pack))
        setup_pack_virtualenv(pack_name=pack, update=update, logger=LOG,
                              proxy_config=proxy_config, use_python3=use_python3,
                              no_download=True)
        LOG.info('Successfully set up virtualenv for pack "%s"' % (pack))

    return 0
示例#15
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    # Purge models.
    try:
        purge_trigger_instances(logger=LOG, timestamp=timestamp)
    except Exception as e:
        LOG.exception(six.text_type(e))
        return FAILURE_EXIT_CODE
    finally:
        common_teardown()

    return SUCCESS_EXIT_CODE
示例#16
0
def main():
    _register_cli_opts()
    common_setup(config=config, setup_db=True, register_mq_exchanges=False)

    # Get config values
    timestamp = cfg.CONF.timestamp

    if not timestamp:
        LOG.error('Please supply a timestamp for purging models. Aborting.')
        return 1
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')
        timestamp = timestamp.replace(tzinfo=pytz.UTC)

    # Purge models.
    try:
        purge_trigger_instances(logger=LOG, timestamp=timestamp)
    except Exception as e:
        LOG.exception(six.text_type(e))
        return FAILURE_EXIT_CODE
    finally:
        common_teardown()

    return SUCCESS_EXIT_CODE
示例#17
0
def setup(argv):
    common_setup(config=config, setup_db=True, register_mq_exchanges=True)
def main():
    common_setup(config=config, setup_db=False, register_mq_exchanges=False)
    setup_pack_virtualenv(cfg.CONF.pack, logger=LOG)
    common_teardown()
示例#19
0
文件: bootstrap.py 项目: lyandut/st2
def setup(argv):
    common_setup(config=config, setup_db=True, register_mq_exchanges=True,
                 register_internal_trigger_types=True)
示例#20
0
def setup(argv):
    common_setup(config=config, setup_db=True, register_mq_exchanges=True)
示例#21
0
def setup():
    common_setup(config=config, setup_db=False, register_mq_exchanges=False)
示例#22
0
def setup():
    common_setup(config=config, setup_db=False, register_mq_exchanges=False)