Esempio n. 1
0
def destroy_db(vo, dbusername=None):
    """Destroy the VOMS database for the VO. If given, also remove the VO user from the database"""
    dbname = 'voms_' + vo

    mysql.execute('DROP DATABASE IF EXISTS `%s`;' % dbname)
    if dbusername:
        mysql.execute("DROP USER '%s'@'localhost';" % dbusername)
Esempio n. 2
0
def destroy_db(vo, dbusername=None):
    """Destroy the VOMS database for the VO. If given, also remove the VO user from the database"""
    dbname = 'voms_' + vo

    mysql.execute('DROP DATABASE IF EXISTS `%s`;' % dbname)
    if dbusername:
        mysql.execute("DROP USER '%s'@'localhost';" % dbusername)
Esempio n. 3
0
def create_vo(vo,
              dbusername='******',
              dbpassword='******',
              vomscert='/etc/grid-security/voms/vomscert.pem',
              vomskey='/etc/grid-security/voms/vomskey.pem',
              use_voms_admin=False):
    """Create the given VO using either voms-admin or the voms_install_db script that comes with voms-server. A new
    database user with the given username/password is created with access to the VO database.
    """
    if use_voms_admin:
        command = ('voms-admin-configure', 'install', '--vo', vo, '--dbtype',
                   'mysql', '--createdb', '--deploy-database', '--dbauser',
                   'root', '--dbapwd', '', '--dbport', '3306', '--dbusername',
                   dbusername, '--dbpassword', dbpassword, '--port', '15151',
                   '--sqlloc', _get_sqlloc(), '--mail-from', 'root@localhost',
                   '--smtp-host', 'localhost', '--cert', vomscert, '--key',
                   vomskey, '--read-access-for-authenticated-clients')

        stdout, _, fail = core.check_system(command, 'Configure VOMS Admin')
        good_message = 'VO %s installation finished' % vo
        assert good_message in stdout, fail

    else:

        mysql.execute("CREATE USER '%(dbusername)s'@'localhost';" % locals())

        command = [
            '/usr/share/voms/voms_install_db',
            '--voms-vo=' + vo,
            '--port=15151',
            '--db-type=mysql',
            '--db-admin=root',
            '--voms-name=' + dbusername,
            '--voms-pwd=' + dbpassword,
            '--sqlloc=' + _get_sqlloc(),
            '--vomscert=' + vomscert,
            '--vomskey=' + vomskey,
        ]

        core.check_system(command, 'Create VO')
Esempio n. 4
0
def create_vo(vo, dbusername='******', dbpassword='******', vomscert='/etc/grid-security/voms/vomscert.pem', vomskey='/etc/grid-security/voms/vomskey.pem', use_voms_admin=False):
    """Create the given VO using either voms-admin or the voms_install_db script that comes with voms-server. A new
    database user with the given username/password is created with access to the VO database.
    """
    if use_voms_admin:
        command = ('voms-admin-configure', 'install',
                   '--vo', vo,
                   '--dbtype', 'mysql', '--createdb', '--deploy-database',
                   '--dbauser', 'root', '--dbapwd', '', '--dbport', '3306',
                   '--dbusername', dbusername, '--dbpassword', dbpassword,
                   '--port', '15151', '--sqlloc', _get_sqlloc(),
                   '--mail-from', 'root@localhost', '--smtp-host', 'localhost',
                   '--cert', vomscert,
                   '--key', vomskey,
                   '--read-access-for-authenticated-clients')

        stdout, _, fail = core.check_system(command, 'Configure VOMS Admin')
        good_message = 'VO %s installation finished' % vo
        assert good_message in stdout, fail

    else:

        mysql.execute("CREATE USER '%(dbusername)s'@'localhost';" % locals())

        command = ['/usr/share/voms/voms_install_db',
                   '--voms-vo=' + vo,
                   '--port=15151',
                   '--db-type=mysql',
                   '--db-admin=root',
                   '--voms-name=' + dbusername,
                   '--voms-pwd=' + dbpassword,
                   '--sqlloc=' + _get_sqlloc(),
                   '--vomscert=' + vomscert,
                   '--vomskey=' + vomskey,
                   ]

        core.check_system(command, 'Create VO')
Esempio n. 5
0
def create_vo(vo,
              dbusername='******',
              dbpassword='******',
              vomscert='/etc/grid-security/voms/vomscert.pem',
              vomskey='/etc/grid-security/voms/vomskey.pem'):
    """Create the given VO using the voms_install_db script that comes with voms-server. A new
    database user with the given username/password is created with access to the VO database.
    """
    mysql.execute("CREATE USER '%(dbusername)s'@'localhost';" % locals())

    command = [
        '/usr/share/voms/voms_install_db',
        '--voms-vo=' + vo,
        '--port=' + str(VOPORT),
        '--db-type=mysql',
        '--db-admin=root',
        '--voms-name=' + dbusername,
        '--voms-pwd=' + dbpassword,
        '--sqlloc=' + _get_sqlloc(),
        '--vomscert=' + vomscert,
        '--vomskey=' + vomskey,
    ]

    core.check_system(command, 'Create VO')