def do_upgrade(options):
    check_upgrade_options(options)
    setup_defaults(options)

    if not os.path.exists(admin_conf_dir(options.vo)):
        logger.error("The VOMS Admin service for VO %s is not configured on this host.", options.vo)
    else:
        logger.info("Upgrading database for VO %s to the latest version.",
                    options.vo)
        upgrade_database(options)
        logger.info("Upgrade completed successfully.")
def do_remove(options):
    check_remove_options(options)
    setup_defaults(options)

    if not options.skip_voms_admin:
        if not os.path.exists(admin_conf_dir(options.vo)):
            logger.error("The VOMS Admin service for VO %s is not configured on this host.", options.vo)
        else:
            if options.undeploy_database:
                if not options.skip_database:
                    undeploy_database(options)
                else:
                    logger.warning("Database will not be dropped since --skip-database option is set.")

            logger.info("Removing VOMS Admin service configuration")
            remove_dir_and_contents(admin_conf_dir(options.vo))

    if not options.skip_voms_core:
        if not os.path.exists(core_conf_dir(options.vo)):
            logger.error("The VOMS core service for VO %s is not configured on this host.", options.vo)
        else:
            logger.info("Removing VOMS core service configuration")
            remove_dir_and_contents(core_conf_dir(options.vo))
def create_admin_configuration(options):
    if os.path.exists(admin_conf_dir(options.vo)):
        logger.info("VOMS Admin service configuration for VO %s exists.", options.vo)
        if not options.dry_run and options.enable_conf_backup:
            backup_dir_contents(admin_conf_dir(options.vo))
    else:
        ## Set the deploy database option if the VO is
        ## installed for the first time on this host and this
        ## is not meant as a replica
        if not options.skip_database:
            options.deploy_database = True
            # options.createdb = True

        ## FIXME: set permissions
        if not options.dry_run:
            os.makedirs(admin_conf_dir(options.vo))

    create_admin_db_properties(options)
    create_admin_service_properties(options)
    create_endpoint_info(options)
    create_vomses(options)
    create_lsc(options)
    create_aup(options)
    create_logging_configuration(options)