Пример #1
0
def setup_cinder_database_on_controller():

    mysql_commands = createDatabaseScript("cinder", passwd['CINDER_DBPASS'])
    msg = 'Create the database'
    runCheck(
        msg, 'echo "%s" | mysql -u root -p%s' %
        (mysql_commands, env_config.passwd['ROOT_SECRET']))
Пример #2
0
def setup_nova_database_on_controller():

    NOVA_DBPASS = passwd['NOVA_DBPASS']

    mysql_commands = createDatabaseScript('nova',NOVA_DBPASS)
    
    msg = "Create database for Nova"
    runCheck(msg, 'echo "' + mysql_commands + '" | mysql -u root -p' + env_config.passwd['ROOT_SECRET'])
Пример #3
0
def setup_heat_database(HEAT_DBPASS):

    mysql_commands = createDatabaseScript('heat', HEAT_DBPASS)

    msg = 'Create database for heat'
    runCheck(
        msg, 'echo "{}" | mysql -u root -p{}'.format(
            mysql_commands, env_config.passwd['ROOT_SECRET']))
Пример #4
0
def setup_glance_database():

    GLANCE_DBPASS=passwd['GLANCE_DBPASS']

    mysql_commands = createDatabaseScript('glance',GLANCE_DBPASS)
    
    msg = "Create database for keystone"
    runCheck(msg, 'echo "' + mysql_commands + '" | mysql -u root -p"%s" ' % env_config.passwd['ROOT_SECRET'])
    run(' mysql -u root -p"%s" -e  "select host, user, password from user where user=\'glance\'" mysql' % env_config.passwd['ROOT_SECRET'])
Пример #5
0
def setup_nova_database_on_controller():

    NOVA_DBPASS = passwd['NOVA_DBPASS']

    mysql_commands = createDatabaseScript('nova', NOVA_DBPASS)

    msg = "Create database for Nova"
    runCheck(
        msg, 'echo "' + mysql_commands + '" | mysql -u root -p' +
        env_config.passwd['ROOT_SECRET'])
Пример #6
0
def setup_glance_database():

    GLANCE_DBPASS = passwd['GLANCE_DBPASS']

    mysql_commands = createDatabaseScript('glance', GLANCE_DBPASS)

    msg = "Create database for keystone"
    runCheck(
        msg, 'echo "' + mysql_commands +
        '" | mysql -u root -p"%s" ' % env_config.passwd['ROOT_SECRET'])
    run(' mysql -u root -p"%s" -e  "select host, user, password from user where user=\'glance\'" mysql'
        % env_config.passwd['ROOT_SECRET'])
Пример #7
0
def restoreDB():
    """
    Delete the database and repopulate it
    """

    database_script = createDatabaseScript('neutron',passwd['NEUTRON_DBPASS'])
    msg = "Recreate MySQL database for neutron"
    runCheck(msg, '''echo "{}" | mysql -u root -p{}'''.format(
        database_script, env_config.passwd['ROOT_SECRET']))

    msg = "Populate the database for neutron"
    runCheck(msg, 'su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf ' + \
              '--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron')
Пример #8
0
def restoreDB():
    """
    Delete the database and repopulate it
    """

    database_script = createDatabaseScript('neutron', passwd['NEUTRON_DBPASS'])
    msg = "Recreate MySQL database for neutron"
    runCheck(
        msg, '''echo "{}" | mysql -u root -p{}'''.format(
            database_script, env_config.passwd['ROOT_SECRET']))

    msg = "Populate the database for neutron"
    runCheck(msg, 'su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf ' + \
              '--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron')
Пример #9
0
def setupKeystone():

    msg = "Checking MariaDB service"
    out = runCheck(msg, "systemctl is-enabled mariadb")
    if out.return_code != 0:
        # we need mariadb working in order to proceed
        sys.exit("mariadb is not enabled")

    # get Keystone database creation scripts
    databaseCreation = createDatabaseScript('keystone',
                                            passwd['KEYSTONE_DBPASS'])

    msg = "Create database for keystone"
    runCheck(
        msg, 'echo "' + databaseCreation +
        '" | mysql -u root -p"%s" ' % env_config.passwd['ROOT_SECRET'])
    run(' mysql -u root -p"%s" -e  "select host, user, password from user where user=\'keystone\'" mysql'
        % env_config.passwd['ROOT_SECRET'])
    execute(installPackages)

    msg = "Generate an admin token"
    admin_token = runCheck(msg, 'openssl rand -hex 10')

    setKeystoneConfigFile(admin_token, passwd['KEYSTONE_DBPASS'])

    createGenericCertificatesAndKeys()

    msg = 'Populate the Identity service database'
    runCheck(msg, "su -s /bin/sh -c 'keystone-manage db_sync' keystone")
    run('mysql -u root -p%s -e "SHOW DATABASES"' %
        env_config.passwd['ROOT_SECRET'])

    # start the Identity service and configure it to start when the system boots
    msg = "Enable keystone service"
    runCheck(msg, "systemctl enable openstack-keystone.service")
    msg = "Start keystone service"
    runCheck(msg, "systemctl start openstack-keystone.service")

    configureCronToPurgeExpiredTokens()

    createUsersRolesAndTenants(admin_token)
Пример #10
0
def setupKeystone():

    msg = "Checking MariaDB service"
    out = runCheck(msg, "systemctl is-enabled mariadb")
    if out.return_code != 0:
        # we need mariadb working in order to proceed
        sys.exit("mariadb is not enabled")

    # get Keystone database creation scripts
    databaseCreation = createDatabaseScript('keystone',passwd['KEYSTONE_DBPASS'])

    msg = "Create database for keystone"
    runCheck(msg, 'echo "' + databaseCreation + '" | mysql -u root -p"%s" ' % env_config.passwd['ROOT_SECRET'])
    run(' mysql -u root -p"%s" -e  "select host, user, password from user where user=\'keystone\'" mysql' % env_config.passwd['ROOT_SECRET'])
    execute(installPackages)
  
    msg = "Generate an admin token"
    admin_token = runCheck(msg, 'openssl rand -hex 10')

    setKeystoneConfigFile(admin_token,passwd['KEYSTONE_DBPASS'])
    
    createGenericCertificatesAndKeys()

    msg = 'Populate the Identity service database'
    runCheck(msg, "su -s /bin/sh -c 'keystone-manage db_sync' keystone")
    run('mysql -u root -p%s -e "SHOW DATABASES"'% env_config.passwd['ROOT_SECRET'])

    # start the Identity service and configure it to start when the system boots
    msg = "Enable keystone service"
    runCheck(msg, "systemctl enable openstack-keystone.service")
    msg = "Start keystone service"
    runCheck(msg, "systemctl start openstack-keystone.service")

    configureCronToPurgeExpiredTokens()

    createUsersRolesAndTenants(admin_token)
Пример #11
0
def create_neutron_database():
    database_script = createDatabaseScript('neutron',passwd['NEUTRON_DBPASS'])
    msg = "Create MySQL database for neutron"
    runCheck(msg, '''echo "{}" | mysql -u root -p{}'''.format(
        database_script, env_config.passwd['ROOT_SECRET']))
Пример #12
0
def setup_heat_database(HEAT_DBPASS):

    mysql_commands = createDatabaseScript('heat',HEAT_DBPASS)
    
    msg = 'Create database for heat'
    runCheck(msg, 'echo "{}" | mysql -u root -p{}'.format(mysql_commands, env_config.passwd['ROOT_SECRET']))
Пример #13
0
def create_neutron_database():
    database_script = createDatabaseScript('neutron', passwd['NEUTRON_DBPASS'])
    msg = "Create MySQL database for neutron"
    runCheck(
        msg, '''echo "{}" | mysql -u root -p{}'''.format(
            database_script, env_config.passwd['ROOT_SECRET']))
Пример #14
0
def setup_cinder_database_on_controller():

    mysql_commands = createDatabaseScript("cinder", passwd["CINDER_DBPASS"])
    msg = "Create the database"
    runCheck(msg, 'echo "%s" | mysql -u root -p%s' % (mysql_commands, env_config.passwd["ROOT_SECRET"]))