def main():
    _monkey_patch()

    cli_opts = [
        cfg.StrOpt('timestamp', default=None,
                   help='Will delete data older than ' +
                   'this timestamp. (default 48 hours). ' +
                   'Example value: 2015-03-13T19:01:27.255542Z'),
        cfg.StrOpt('action-ref', default='',
                   help='action-ref to delete executions for.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    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

    # Connect to db.
    db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port,
             username=username, password=password)

    if not timestamp:
        now = datetime.now()
        timestamp = now - timedelta(days=DEFAULT_TIMEDELTA_DAYS)
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')

    # Purge models.
    _purge_executions(timestamp=timestamp, action_ref=action_ref)

    # Disconnect from db.
    db_teardown()
Beispiel #2
0
    def _drop_db(cls):
        cls._drop_collections()

        if cls.db_connection is not None:
            cls.db_connection.drop_database(cfg.CONF.database.db_name)

        db_teardown()
        cls.db_connection = None
Beispiel #3
0
    def _drop_db(cls):
        cls._drop_collections()

        if cls.db_connection is not None:
            cls.db_connection.drop_database(cfg.CONF.database.db_name)

        db_teardown()
        cls.db_connection = None
Beispiel #4
0
def main():
    _parse_config()
    if CONF.verbose:
        _setup_logging()
        output = logging.getLogger(__name__).info
    else:
        output = pprint.pprint
    _setup_db()
    _refire_trigger_instance(trigger_instance_id=CONF.trigger_instance_id,
                             log_=logging.getLogger(__name__))
    output('Trigger re-fired')
    db_teardown()
Beispiel #5
0
def main():
    _parse_config()
    if CONF.verbose:
        _setup_logging()
        output = logging.getLogger(__name__).info
    else:
        output = pprint.pprint
    _setup_db()
    _refire_trigger_instance(trigger_instance_id=CONF.trigger_instance_id,
                             log_=logging.getLogger(__name__))
    output('Trigger re-fired')
    db_teardown()
def main():
    config.parse_args()

    # Connect to db.
    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)

    # Migrate rules.
    migrate_rules()

    # Disconnect from db.
    db_teardown()
Beispiel #7
0
def main():
    _monkey_patch()

    cli_opts = [
        cfg.BoolOpt("sensors", default=False, help="diff sensor alone."),
        cfg.BoolOpt("actions", default=False, help="diff actions alone."),
        cfg.BoolOpt("rules", default=False, help="diff rules alone."),
        cfg.BoolOpt("all", default=False, help="diff sensors, actions and rules."),
        cfg.BoolOpt("verbose", default=False),
        cfg.BoolOpt(
            "simple",
            default=False,
            help="In simple mode, tool only tells you if content is missing."
            + "It doesn't show you content diff between disk and db.",
        ),
        cfg.StrOpt("pack-dir", default=None, help="Path to specific pack to diff."),
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    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

    # Connect to db.
    db_setup(
        cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port, username=username, password=password
    )

    # Diff content
    pack_dir = cfg.CONF.pack_dir or None
    content_diff = not cfg.CONF.simple

    if cfg.CONF.all:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        return

    if cfg.CONF.sensors:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.actions:
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.rules:
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    # Disconnect from db.
    db_teardown()
Beispiel #8
0
def main():
    monkey_patch()

    cli_opts = [
        cfg.BoolOpt('sensors', default=False,
                    help='diff sensor alone.'),
        cfg.BoolOpt('actions', default=False,
                    help='diff actions alone.'),
        cfg.BoolOpt('rules', default=False,
                    help='diff rules alone.'),
        cfg.BoolOpt('all', default=False,
                    help='diff sensors, actions and rules.'),
        cfg.BoolOpt('verbose', default=False),
        cfg.BoolOpt('simple', default=False,
                    help='In simple mode, tool only tells you if content is missing.' +
                         'It doesn\'t show you content diff between disk and db.'),
        cfg.StrOpt('pack-dir', default=None, help='Path to specific pack to diff.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    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

    # Connect to db.
    db_setup(cfg.CONF.database.db_name, cfg.CONF.database.host, cfg.CONF.database.port,
             username=username, password=password)

    # Diff content
    pack_dir = cfg.CONF.pack_dir or None
    content_diff = not cfg.CONF.simple

    if cfg.CONF.all:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)
        return

    if cfg.CONF.sensors:
        _diff_sensors(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.actions:
        _diff_actions(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    if cfg.CONF.rules:
        _diff_rules(pack_dir=pack_dir, verbose=cfg.CONF.verbose, content_diff=content_diff)

    # Disconnect from db.
    db_teardown()
Beispiel #9
0
def main():
    _monkey_patch()

    cli_opts = [
        cfg.StrOpt('timestamp',
                   default=None,
                   help='Will delete data older than ' +
                   'this timestamp. (default 48 hours). ' +
                   'Example value: 2015-03-13T19:01:27.255542Z'),
        cfg.StrOpt('action-ref',
                   default='',
                   help='action-ref to delete executions for.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    # Get config values
    timestamp = cfg.CONF.timestamp
    action_ref = cfg.CONF.action_ref
    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

    # Connect to db.
    db_setup(cfg.CONF.database.db_name,
             cfg.CONF.database.host,
             cfg.CONF.database.port,
             username=username,
             password=password)

    if not timestamp:
        now = datetime.now()
        timestamp = now - timedelta(days=DEFAULT_TIMEDELTA_DAYS)
    else:
        timestamp = datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ')

    # Purge models.
    _purge_executions(timestamp=timestamp, action_ref=action_ref)

    # Disconnect from db.
    db_teardown()
Beispiel #10
0
def _teardown():
    db_teardown()
Beispiel #11
0
def db_teardown():
    return db.db_teardown()
Beispiel #12
0
def db_teardown():
    """
    Disconnects from the database.
    """
    return db.db_teardown()
Beispiel #13
0
 def tearDownClass(cls):
     cls.drop_collections()
     if DbTestCase.db_connection is not None:
         DbTestCase.db_connection.drop_database(cfg.CONF.database.db_name)
     db_teardown()
     DbTestCase.db_connection = None
Beispiel #14
0
def db_teardown():
    """
    Disconnects from the database.
    """
    return db.db_teardown()
Beispiel #15
0
def main():
    monkey_patch()

    cli_opts = [
        cfg.BoolOpt('sensors', default=False, help='diff sensor alone.'),
        cfg.BoolOpt('actions', default=False, help='diff actions alone.'),
        cfg.BoolOpt('rules', default=False, help='diff rules alone.'),
        cfg.BoolOpt('all',
                    default=False,
                    help='diff sensors, actions and rules.'),
        cfg.BoolOpt('verbose', default=False),
        cfg.BoolOpt(
            'simple',
            default=False,
            help='In simple mode, tool only tells you if content is missing.' +
            'It doesn\'t show you content diff between disk and db.'),
        cfg.StrOpt('pack-dir',
                   default=None,
                   help='Path to specific pack to diff.')
    ]
    do_register_cli_opts(cli_opts)
    config.parse_args()

    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

    # Connect to db.
    db_setup(cfg.CONF.database.db_name,
             cfg.CONF.database.host,
             cfg.CONF.database.port,
             username=username,
             password=password)

    # Diff content
    pack_dir = cfg.CONF.pack_dir or None
    content_diff = not cfg.CONF.simple

    if cfg.CONF.all:
        _diff_sensors(pack_dir=pack_dir,
                      verbose=cfg.CONF.verbose,
                      content_diff=content_diff)
        _diff_actions(pack_dir=pack_dir,
                      verbose=cfg.CONF.verbose,
                      content_diff=content_diff)
        _diff_rules(pack_dir=pack_dir,
                    verbose=cfg.CONF.verbose,
                    content_diff=content_diff)
        return

    if cfg.CONF.sensors:
        _diff_sensors(pack_dir=pack_dir,
                      verbose=cfg.CONF.verbose,
                      content_diff=content_diff)

    if cfg.CONF.actions:
        _diff_actions(pack_dir=pack_dir,
                      verbose=cfg.CONF.verbose,
                      content_diff=content_diff)

    if cfg.CONF.rules:
        _diff_rules(pack_dir=pack_dir,
                    verbose=cfg.CONF.verbose,
                    content_diff=content_diff)

    # Disconnect from db.
    db_teardown()
Beispiel #16
0
def _teardown():
    db_teardown()
Beispiel #17
0
def db_teardown():
    return db.db_teardown()
Beispiel #18
0
 def tearDownClass(cls):
     cls.drop_collections()
     if DbTestCase.db_connection is not None:
         DbTestCase.db_connection.drop_database(cfg.CONF.database.db_name)
     db_teardown()
     DbTestCase.db_connection = None