Пример #1
0
def _revert_go_online(repo,
                      branch,
                      build,
                      buildtype,
                      site,
                      drupal_version=None):
    print "===> Bringing the %s site back online." % site

    drush_runtime_location = "/var/www/live.%s.%s/www/sites/%s" % (
        repo, branch, site)

    with settings(warn_only=True):
        if drupal_version is None:
            # Use "sync" method here so the check uses the live symlink to get the Drupal version rather than the new build, which just failed
            drupal_version = int(
                DrupalUtils.determine_drupal_version(None, repo, branch, build,
                                                     None, "sync"))

        if drupal_version > 7:
            online_command = "state-set system.maintenance_mode 0"
        else:
            online_command = "vset site_offline 0"

        DrupalUtils.drush_command(online_command, site, drush_runtime_location)
        Drupal.drush_clear_cache(repo, branch, build, site, drupal_version)
Пример #2
0
def initial_db_and_config(repo, branch, build, site, import_config,
                          drupal_version):
    with settings(warn_only=True):
        # Run database updates
        drush_runtime_location = "/var/www/%s_%s_%s/www/sites/default" % (
            repo, branch, build)
        if DrupalUtils.drush_command("updatedb", site, drush_runtime_location,
                                     True, None, None, True).failed:
            raise SystemExit(
                "###### Could not run database updates! Everything else has been done, but failing the build to alert to the fact database updates could not be run."
            )
        else:
            Drupal.drush_clear_cache(repo, branch, build, "default",
                                     drupal_version)

        # Run entity updates
        if drupal_version > 7:
            if DrupalUtils.drush_command("entity-updates", site,
                                         drush_runtime_location, True, None,
                                         None, True).failed:
                print "###### Could not carry out entity updates! Continuing anyway, as this probably isn't a major issue."

        # Import config
        if drupal_version > 7 and import_config:
            print "===> Importing configuration for Drupal 8 site..."
            if DrupalUtils.drush_command("cim", site, drush_runtime_location,
                                         True, None, None, True).failed:
                raise SystemExit(
                    "###### Could not import configuration! Failing build.")
            else:
                print "===> Configuration imported. Running a cache rebuild..."
                Drupal.drush_clear_cache(repo, branch, build, "default",
                                         drupal_version)
Пример #3
0
def _revert_db(repo, branch, build, buildtype, site):
    print "===> Reverting the database for %s site..." % site
    drush_runtime_location = "/var/www/live.%s.%s/www/sites/%s" % (
        repo, branch, site)
    drush_output = Drupal.drush_status(repo, branch, build, buildtype, site,
                                       drush_runtime_location)
    db_name = Drupal.get_db_name(repo, branch, build, buildtype, site,
                                 drush_output)

    # Get Drupal version to pass to cache clear and _revert_go_online()
    drupal_version = run(
        "echo \"%s\" | grep \"drupal-version\" | cut -d\: -f2 | cut -d. -f1" %
        drush_output)
    drupal_version = drupal_version.strip()
    # Older versions of Drupal put version in single quotes
    drupal_version = drupal_version.strip("'")
    drupal_version = int(drupal_version)

    common.MySQL.mysql_revert_db(db_name, build)
    Drupal.drush_clear_cache(repo, branch, build, site, drupal_version)
    _revert_go_online(repo, branch, build, buildtype, site, drupal_version)