Beispiel #1
0
def convert_to_mvo(new_vo, description, email, create_super_root=False, commit_changes=False, skip_history=False, echo=True):
    """
    Converts a single-VO database to a multi-VO one with the specified VO details.

    :param new_vo:            The 3 character string for the new VO.
    :param description:       Full description of the new VO.
    :param email:             Admin email for the new VO.
    :param create_super_root: If True and the renaming was successful, then create a super_root account at VO def.
    :param commit_changes:    If True then changes are made against the database directly.
                              If False, then nothing is commited and the commands needed are dumped to be run later.
    :param skip_history:      If True then tables without FKC containing historical data will not be converted to save time.
    """
    if not config_get_bool('common', 'multi_vo', False, False):
        print('Multi-VO mode is not enabled in the config file, aborting conversion.')
        return

    s = session.get_session()
    vos = [vo['vo'] for vo in list_vos(session=s)]
    if new_vo not in vos:
        insert_new_vo = True
    else:
        insert_new_vo = False

    success = rename_vo('def', new_vo, insert_new_vo=insert_new_vo, description=description, email=email,
                        commit_changes=commit_changes, skip_history=skip_history)
    if create_super_root and success:
        create_root_account(create_counters=False)
    s.close()
Beispiel #2
0
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Run this once to set up the database.
#   PYTHONPATH=/opt/rucio/.venv/lib/python2.7/site-packages/rucio python tools/bootstrap.py
#
# Verify for default SQLite:
#   for i in `sqlite3 /tmp/rucio.db ".tables"`; do echo $i:; sqlite3 /tmp/rucio.db "select * from $i"; echo; done

import sys
import os.path
base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(base_path)
os.chdir(base_path)

from rucio.db.sqla.util import (build_database, create_base_vo,
                                create_root_account)  # noqa: E402

if __name__ == '__main__':
    build_database()
    create_base_vo()
    create_root_account()