コード例 #1
0
def remove(archive):
    """Remove a backup tarball from the server.
    archive: name of the archive to remove.

    """
    server = pantheon.PantheonServer()
    path = os.path.join(server.ftproot, archive)
    if os.path.exists(path):
        local('rm -f %s' % path)
コード例 #2
0
ファイル: drupaltools.py プロジェクト: KyleAMathews/mercury
def get_drupal_update_status(project):
    """Return dictionary of Drupal/Pressflow version/update information.
    project: Name of project.

    """
    repo_path = os.path.join('/var/git/projects', project)
    project_path = os.path.join(pantheon.PantheonServer().webroot, project)
    environments = pantheon.get_environments()
    status = dict()

    with cd(repo_path):
        # Get upstream updates.
        local('git fetch origin')
        # Determine latest upstream version.
        latest_drupal_version = _get_latest_drupal_version()

    for env in environments:
        env_path = os.path.join(project_path, env)

        with cd(env_path):
            local('git fetch origin')

            platform = get_drupal_platform(env_path)
            drupal_version = get_drupal_version(env_path)

            # python -> json -> php boolean disagreements. Just use int.
            drupal_update = int(latest_drupal_version != drupal_version)

            # Pantheon log only makes sense if already using Pressflow/Pantheon
            # If using Drupal, the log would show every pressflow commit ever.
            if platform == 'PANTHEON' or platform == 'PRESSFLOW':
                pantheon_log = local('git log refs/heads/%s' % project + \
                                     '..refs/remotes/origin/master'
                                    ).rstrip('\n')
            else:
                pantheon_log = 'Upgrade to Pressflow/Pantheon'

            # NOTE: Removed reporting back with log entries, so using logs
            # to determine if there is an update is a little silly. However,
            # we may want to send back logs someday, so leaving for now.

            # If log is impty, no updates.
            pantheon_update = int(bool(pantheon_log))

            status[env] = {
                'drupal_update': drupal_update,
                'pantheon_update': pantheon_update,
                'current': {
                    'platform': platform,
                    'drupal_version': drupal_version
                },
                'available': {
                    'drupal_version': latest_drupal_version,
                }
            }
    return status
コード例 #3
0
    def __init__(self, name, project):
        """Initialize Backup Object.
        name: name of backup (resulting file: name.tar.gz)
        project: name of project to backup.

        """
        self.server = pantheon.PantheonServer()
        self.project = project
        self.working_dir = tempfile.mkdtemp()
        self.backup_dir = os.path.join(self.working_dir, self.project)
        self.name = name + '.tar.gz'
コード例 #4
0
    def __init__(self, name, project):
        """Initialize Backup Object.
        name: name of backup (resulting file: name.tar.gz)
        project: name of project to backup.

        """
        self.server = pantheon.PantheonServer()
        self.project = project
        self.environments = pantheon.get_environments()
        self.working_dir = tempfile.mkdtemp()
        self.backup_dir = os.path.join(self.working_dir, self.project)
        self.name = name + '.tar.gz'
        self.log = logger.logging.getLogger('pantheon.backup.PantheonBackup')
        self.log = logger.logging.LoggerAdapter(self.log, {"project": project})
コード例 #5
0
    def __init__(self):
        """ Initialize generic project installation object & helper functions.
        project: the name of the project to be built.

        """
        config = ygg.get_config()
        self.server = pantheon.PantheonServer()

        self.project = config.keys()[0]
        self.config = config[self.project]
        self.environments = set(self.config['environments'].keys())
        self.project_path = os.path.join(self.server.webroot, self.project)
        self.db_password = self.config\
                ['environments']['live']['mysql']['db_password']
コード例 #6
0
def remove(archive):
    """Remove a backup tarball from the server.
    archive: name of the archive to remove.

    """
    log = logger.logging.getLogger('pantheon.backup.remove')
    try:
        server = pantheon.PantheonServer()
        path = os.path.join(server.ftproot, archive)
        if os.path.exists(path):
            local('rm -f %s' % path)
    except:
        log.exception('Removal of local backup archive was unsuccessful.')
        raise
    else:
        log.debug('Removal of local backup archive successful.')
コード例 #7
0
ファイル: gittools.py プロジェクト: KyleAMathews/mercury
def post_receive_hook(params):
    """Perform post-receive actions when changes are made to git repo.
    params: hook params from git stdin.

    NOTE: we use 'env -i' to clear environmental variables git has set when
    running hook operations.

    """
    (project, old_rev, new_rev) = _parse_hook_params(params)
    webroot = pantheon.PantheonServer().webroot
    dest = os.path.join(webroot, project, 'dev')

    # Check for development environment.
    if not os.path.exists(dest):
        print "\n\nWARNING: No development environment for " + \
              "'%s' was found.\n" % (project)
    # Development environment exists.
    else:
        with cd(dest):
            # Hide output from showing on git's report back to user.
            with settings(hide('running', 'warnings'), warn_only=True):
                dev_update = local('env -i git pull')
            # Output status to the git push initiator.
            if dev_update.failed:
                print "\n\nWARNING: The development environment could" + \
                "not be updated. Please review any error messages, and " + \
                "resolve any conflicts in /var/www/%s/dev\n" % project
                print "ERROR:"
                print dev_update.stderr + "\n\n"
            else:
                print "\nDevelopment environment updated.\n"

        with hide('running'):
            # If not inside a jenkins job, send back data about repo and drupal.
            # Otherwise, we assume the job we are inside of will do this.
            if not os.environ.get('BUILD_TAG'):
                local('curl http://127.0.0.1:8090/job/post_hook_status/' + \
                      'buildWithParameters?project=%s' % project)
コード例 #8
0
ファイル: gittools.py プロジェクト: KyleAMathews/mercury
 def __init__(self, project):
     self.project = project
     self.repo = os.path.join('/var/git/projects', self.project)
     self.server = pantheon.PantheonServer()
     self.project_path = os.path.join(self.server.webroot, self.project)