Esempio n. 1
0
    def _check_healthpolicy(self):
        """Check if version 1.0 health policies exists

        Stein introduces health policy version 1.1 which is incompatible with
        health policy version 1.0.  Users are required to delete version 1.0
        health policies before upgrade and recreate them in version 1.1 format
        after upgrading.
        """

        engine = api.get_engine()
        metadata = MetaData(bind=engine)
        policy = Table('policy', metadata, autoload=True)

        healthpolicy_select = (select(
            [column('name')]).select_from(policy).where(
                column('type') == 'senlin.policy.health-1.0'))
        healthpolicy_rows = engine.execute(healthpolicy_select).fetchall()

        if not healthpolicy_rows:
            return upgradecheck.Result(upgradecheck.Code.SUCCESS)

        healthpolicy_names = [row[0] for row in healthpolicy_rows]
        error_msg = _('The following version 1.0 health policies must be '
                      'deleted before upgrade: \'{}\'. After upgrading, the '
                      'health policies can be recreated in version 1.1 '
                      'format.').format(', '.join(healthpolicy_names))
        return upgradecheck.Result(upgradecheck.Code.FAILURE, error_msg)
Esempio n. 2
0
def do_event_purge():
    """Purge the specified event records in senlin's database."""
    if CONF.command.age < 0:
        print(_("age must be a positive integer."))
        return
    api.event_purge(api.get_engine(), CONF.command.project_id,
                    CONF.command.granularity, CONF.command.age)
Esempio n. 3
0
def do_event_purge():
    '''Purge the specified event records in senlin's database.'''
    if CONF.command.age < 0:
        print("age should be a positive integer!")
        return
    api.event_purge(api.get_engine(), CONF.command.project_id,
                    CONF.command.granularity, CONF.command.age)
Esempio n. 4
0
def setup_dummy_db():
    options.cfg.set_defaults(options.database_opts, sqlite_synchronous=False)
    options.set_defaults(cfg.CONF,
                         connection="sqlite://",
                         sqlite_db='senlin.db')
    engine = db_api.get_engine()
    db_api.db_sync(engine)
    engine.connect()
Esempio n. 5
0
def setup_dummy_db():
    options.cfg.set_defaults(options.database_opts, sqlite_synchronous=False)
    options.set_defaults(cfg.CONF,
                         connection="sqlite://",
                         sqlite_db='senlin.db')
    engine = db_api.get_engine()
    db_api.db_sync(engine)
    engine.connect()
Esempio n. 6
0
def reset_dummy_db():
    engine = db_api.get_engine()
    meta = sqlalchemy.MetaData()
    meta.reflect(bind=engine)

    for table in reversed(meta.sorted_tables):
        if table.name == 'migrate_version':
            continue
        engine.execute(table.delete())
Esempio n. 7
0
def reset_dummy_db():
    engine = db_api.get_engine()
    meta = sqlalchemy.MetaData()
    meta.reflect(bind=engine)

    for table in reversed(meta.sorted_tables):
        if table.name == 'migrate_version':
            continue
        engine.execute(table.delete())
Esempio n. 8
0
def do_action_purge():
    """Purge the specified action records in senlin's database."""
    age = CONF.command.age

    if age < 0:
        print(_("Age must be a positive integer."))
        return

    if CONF.command.granularity == 'days':
        age = age * 86400
    elif CONF.command.granularity == 'hours':
        age = age * 3600
    elif CONF.command.granularity == 'minutes':
        age = age * 60

    if age < CONF.default_action_timeout:
        print(_("Age must be greater than the default action timeout."))
        return
    api.action_purge(api.get_engine(), CONF.command.project_id,
                     CONF.command.granularity, CONF.command.age)
Esempio n. 9
0
def do_db_sync():
    """Place a database under migration control and upgrade.

    DB is created first if necessary.
    """
    api.db_sync(api.get_engine(), CONF.command.version)
Esempio n. 10
0
def do_db_version():
    """Print database's current migration level."""
    print(api.db_version(api.get_engine()))
Esempio n. 11
0
def do_db_sync():
    """Place a database under migration control and upgrade,
    creating first if necessary.
    """
    api.db_sync(api.get_engine(), CONF.command.version)
Esempio n. 12
0
def do_db_version():
    """Print database's current migration level."""
    print(api.db_version(api.get_engine()))
Esempio n. 13
0
def do_db_sync():
    '''Place a database under migration control and upgrade.

    DB is created first if necessary.
    '''
    api.db_sync(api.get_engine(), CONF.command.version)