Exemplo n.º 1
0
 def solr_reindex(self):
     self.log.info("Initialized solr-reindex.")
     try:
         with settings(warn_only=True):
             result = local("drush @%s_%s -b solr-reindex" % (self.project, self.update_env))
     except:
         self.log.exception("Solr-reindex encountered a fatal error.")
         raise
     else:
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 2
0
 def run_cron(self):
     self.log.info("Initialized cron.")
     try:
         with settings(warn_only=True):
             result = local("drush @%s_%s -b cron" % (self.project, self.update_env))
     except:
         self.log.exception("Cron encountered a fatal error.")
         raise
     else:
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 3
0
 def drupal_updatedb(self):
     self.log.info('Initiated Updatedb.')
     try:
         alias = '@%s_%s' % (self.project, self.update_env)
         result = drupaltools.updatedb(alias)
     except:
         self.log.exception('Updatedb encountered a fatal error.')
         raise
     else:
         self.log.info('Updatedb complete.')
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 4
0
 def solr_reindex(self):
     self.log.info('Initialized solr-reindex.')
     try:
         with settings(warn_only=True):
             result = local("drush @%s_%s -b solr-reindex" %
                            (self.project, self.update_env))
     except:
         self.log.exception('Solr-reindex encountered a fatal error.')
         raise
     else:
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 5
0
 def run_cron(self):
     self.log.info('Initialized cron.')
     try:
         with settings(warn_only=True):
             result = local("drush @%s_%s -b cron" %
                            (self.project, self.update_env))
     except:
         self.log.exception('Cron encountered a fatal error.')
         raise
     else:
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 6
0
 def drupal_updatedb(self):
     self.log.info('Initiated Updatedb.')
     try:
         alias = '@%s_%s' % (self.project, self.update_env)
         result = drupaltools.updatedb(alias)
     except:
         self.log.exception('Updatedb encountered a fatal error.')
         raise
     else:
         self.log.info('Updatedb complete.')
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 7
0
 def drupal_updatedb(self):
     self.log.info('Initiated Updatedb.')
     try:
         alias = '@%s_%s' % (self.project, self.update_env)
         with settings(warn_only=True):
             result = local('drush %s -by updb' % alias)
     except:
         self.log.exception('Updatedb encountered a fatal error.')
         raise
     else:
         self.log.info('Updatedb complete.')
         pantheon.log_drush_backend(result, self.log)
Exemplo n.º 8
0
def _drush_download(modules, destination, version):
    """ Download list of modules using Drush.
    modules: list of module names.
    destination: where to move the module after download
    version: set the default major version

    """
    #TODO: temporary until integrated in pantheon repo
    temp_dir = tempfile.mkdtemp()
    with cd(temp_dir):
        for module in modules:
             with settings(warn_only=True):
                 result = local('drush -by --default-major=%s dl %s' % 
                                (version, module))
             pantheon.log_drush_backend(result)
        local('mv * %s' % destination)
    local('rm -rf %s' % temp_dir)
Exemplo n.º 9
0
    def setup_pantheon_modules(self):
        """Setup required Pantheon modules and libraries.

        """
        module_dir = os.path.join(self.working_dir, 'sites/all/modules')
        if not os.path.exists(module_dir):
            local('mkdir -p %s' % module_dir)

        # Download modules in temp dir so drush doesn't complain.
        temp_dir = tempfile.mkdtemp()
        if self.version == 6:
            modules = ['apachesolr','memcache','varnish']
        else:
            modules = ['apachesolr-7.x-1.0-beta6', 'memcache-7.x-1.0-beta3']
        with cd(temp_dir):
            with settings(warn_only=True):
                result = local("drush dl -by --default-major=%s %s" % 
                               (self.version, ' '.join(modules)))
            pantheon.log_drush_backend(result, self.log)
            local("cp -R * %s" % module_dir)
        local("rm -rf " + temp_dir)
Exemplo n.º 10
0
    def enable_pantheon_settings(self):
        """Enable required modules, and set Pantheon defaults.

        """
        if self.version == 6:
            required_modules = ['apachesolr',
                                'apachesolr_search',
                                'locale',
                                'pantheon_api',
                                'pantheon_login',
                                'syslog',
                                'varnish']
        elif self.version == 7:
            required_modules = ['apachesolr',
                                'apachesolr_search',
                                'syslog',
                                'pantheon_api',
                                'pantheon_login',
                                'pantheon_apachesolr']

        # Enable modules.
        with settings(hide('warnings'), warn_only=True):
            for module in required_modules:
                result = local('drush -by @working_dir en %s' % module)
                pantheon.log_drush_backend(result, self.log)
                if result.failed:
                    # If importing vanilla drupal, this module wont exist.
                    if module != 'cookie_cache_bypass':
                        message = 'Could not enable %s module.' % module
                        self.log.warning('%s\n%s' % (message, result.stderr))
                        postback.build_warning(message)
                        print message
                        print '\n%s module could not be enabled. ' % module + \
                              'Error Message:'
                        print '\n%s' % result.stderr
                else:
                    self.log.info('%s enabled.' % module)

        if self.version == 6:
            drupal_vars = {
                'apachesolr_search_make_default': 1,
                'apachesolr_search_spellcheck': 1,
                'cache': '3',
                'block_cache': '1',
                'page_cache_max_age': '900',
                'page_compression': '0',
                'preprocess_js': '1',
                'preprocess_css': '1'}

        elif self.version == 7:
            drupal_vars = {
                'cache': 1,
                'block_cache': 1,
                'cache_lifetime': "0",
                'page_cache_maximum_age': "900",
                'page_compression': 0,
                'preprocess_css': 1,
                'preprocess_js': 1,
                'search_active_modules': {
                    'apachesolr_search':'apachesolr_search',
                    'user': '******',
                    'node': 0},
                'search_default_module': 'apachesolr_search'}

        # Set variables.
        (db_username, db_password, db_name) = pantheon.get_database_vars(self, 'dev')
        db = dbtools.MySQLConn(database = db_name,
                               username = db_username,
                               password = db_password)
        for key, value in drupal_vars.iteritems():
            db.vset(key, value)

        # apachesolr module for drupal 7 stores config in db.
        # TODO: use drush/drupal api to do this work.
        try:
            if self.version == 7:
                db.execute('TRUNCATE apachesolr_environment')
                for env in self.environments:
                    config = self.config['environments'][env]['solr']

                    env_id = '%s_%s' % (self.project, env)
                    name = '%s %s' % (self.project, env)
                    url = 'http://%s:%s%s' % (config['solr_host'],
                                              config['solr_port'],
                                              config['solr_path'])

                    # Populate the solr environments
                    db.execute('INSERT INTO apachesolr_environment ' + \
                        '(env_id, name, url) VALUES ' + \
                        '("%s", "%s", "%s")' % (env_id, name, url))

                    # Populate the solr environment variables
                    db.execute('INSERT INTO apachesolr_environment_variable '+\
                               '(env_id, name, value) VALUES ' + \
                               "('%s','apachesolr_read_only','s:1:\"0\"')" % (
                                                                      env_id))
        except Exception as mysql_error:
             self.log.error('Auto-configuration of ApacheSolr module failed: %s' % mysql_error)
             pass

        db.close()

        # D7: apachesolr config link will not display until cache cleared?
        with settings(warn_only=True):
            result = local('drush @working_dir -y cc all')
            pantheon.log_drush_backend(result, self.log)

        # Run updatedb
        drupaltools.updatedb(alias='@working_dir')

        # Remove temporary working_dir drush alias.
        alias_file = '/opt/drush/aliases/working_dir.alias.drushrc.php'
        if os.path.exists(alias_file):
            local('rm -f %s' % alias_file)
Exemplo n.º 11
0
    def enable_pantheon_settings(self):
        """Enable required modules, and set Pantheon defaults.

        """
        if self.version == 6:
            required_modules = [
                'apachesolr', 'apachesolr_search', 'locale', 'pantheon_api',
                'pantheon_login', 'syslog', 'varnish'
            ]
        elif self.version == 7:
            required_modules = [
                'apachesolr', 'apachesolr_search', 'syslog', 'pantheon_api',
                'pantheon_login', 'pantheon_apachesolr'
            ]

        # Enable modules.
        with settings(hide('warnings'), warn_only=True):
            for module in required_modules:
                result = local('drush -by @working_dir en %s' % module)
                pantheon.log_drush_backend(result, self.log)
                if result.failed:
                    # If importing vanilla drupal, this module wont exist.
                    if module != 'cookie_cache_bypass':
                        message = 'Could not enable %s module.' % module
                        self.log.warning('%s\n%s' % (message, result.stderr))
                        postback.build_warning(message)
                        print message
                        print '\n%s module could not be enabled. ' % module + \
                              'Error Message:'
                        print '\n%s' % result.stderr
                else:
                    self.log.info('%s enabled.' % module)

        if self.version == 6:
            drupal_vars = {
                'apachesolr_search_make_default': 1,
                'apachesolr_search_spellcheck': 1,
                'cache': '3',
                'block_cache': '1',
                'page_cache_max_age': '900',
                'page_compression': '0',
                'preprocess_js': '1',
                'preprocess_css': '1'
            }

        elif self.version == 7:
            drupal_vars = {
                'cache': 1,
                'block_cache': 1,
                'cache_lifetime': "0",
                'page_cache_maximum_age': "900",
                'page_compression': 0,
                'preprocess_css': 1,
                'preprocess_js': 1,
                'search_active_modules': {
                    'apachesolr_search': 'apachesolr_search',
                    'user': '******',
                    'node': 0
                },
                'search_default_module': 'apachesolr_search'
            }

        # Set variables.
        (db_username, db_password,
         db_name) = pantheon.get_database_vars(self, 'dev')
        db = dbtools.MySQLConn(database=db_name,
                               username=db_username,
                               password=db_password)
        for key, value in drupal_vars.iteritems():
            db.vset(key, value)

        # apachesolr module for drupal 7 stores config in db.
        # TODO: use drush/drupal api to do this work.
        try:
            if self.version == 7:
                db.execute('TRUNCATE apachesolr_environment')
                for env in self.environments:
                    config = self.config['environments'][env]['solr']

                    env_id = '%s_%s' % (self.project, env)
                    name = '%s %s' % (self.project, env)
                    url = 'http://%s:%s%s' % (config['solr_host'],
                                              config['solr_port'],
                                              config['solr_path'])

                    # Populate the solr environments
                    db.execute('INSERT INTO apachesolr_environment ' + \
                        '(env_id, name, url) VALUES ' + \
                        '("%s", "%s", "%s")' % (env_id, name, url))

                    # Populate the solr environment variables
                    db.execute('INSERT INTO apachesolr_environment_variable '+\
                               '(env_id, name, value) VALUES ' + \
                               "('%s','apachesolr_read_only','s:1:\"0\"')" % (
                                                                      env_id))
        except Exception as mysql_error:
            self.log.error(
                'Auto-configuration of ApacheSolr module failed: %s' %
                mysql_error)
            pass

        db.close()

        # D7: apachesolr config link will not display until cache cleared?
        with settings(warn_only=True):
            result = local('drush @working_dir -y cc all')
            pantheon.log_drush_backend(result, self.log)

        # Run updatedb
        drupaltools.updatedb(alias='@working_dir')

        # Remove temporary working_dir drush alias.
        alias_file = '/opt/drush/aliases/working_dir.alias.drushrc.php'
        if os.path.exists(alias_file):
            local('rm -f %s' % alias_file)
Exemplo n.º 12
0
    def enable_pantheon_settings(self):
        """Enable required modules, and set Pantheon defaults.

        """
        if self.version == 6:
            required_modules = ['apachesolr',
                                'apachesolr_search',
                                'locale',
                                'pantheon',
                                'syslog',
                                'varnish']
        elif self.version == 7:
            required_modules = ['apachesolr',
                                'apachesolr_search',
                                'syslog']

        # Enable modules.
        with settings(hide('warnings'), warn_only=True):
            for module in required_modules:
                result = local('drush -by @working_dir en %s' % module)
                pantheon.log_drush_backend(result, self.log)
                if result.failed:
                    # If importing vanilla drupal, this module wont exist.
                    if module != 'cookie_cache_bypass':
                        message = 'Could not enable %s module.' % module
                        self.log.warning('%s\n%s' % (message, result.stderr))
                        postback.build_warning(message)
                        print message
                        print '\n%s module could not be enabled. ' % module + \
                              'Error Message:'
                        print '\n%s' % result.stderr
                else:
                    self.log.info('%s enabled.' % module)

        if self.version == 6:
            drupal_vars = {
                'apachesolr_search_make_default': 1,
                'apachesolr_search_spellcheck': 1,
                'cache': '3',
                'block_cache': '1',
                'page_cache_max_age': '900',
                'page_compression': '0',
                'preprocess_js': '1',
                'preprocess_css': '1'}

        elif self.version == 7:
            drupal_vars = {
                'cache': 1,
                'block_cache': 1,
                'cache_lifetime': "0",
                'page_cache_maximum_age': "900",
                'page_compression': 0,
                'preprocess_css': 1,
                'preprocess_js': 1,
                'search_active_modules': {
                    'apachesolr_search':'apachesolr_search',
                    'user': '******',
                    'node': 0},
                'search_default_module': 'apachesolr_search'}

        # Set variables.
        database = '%s_dev' % self.project
        db = dbtools.MySQLConn(database=database,
                               username = self.project,
                               password = self.db_password)
        for key, value in drupal_vars.iteritems():
            db.vset(key, value)

        # apachesolr module for drupal 7 stores config in db.
        # TODO: use drush/drupal api to do this work.
        if self.version == 7:
            db.execute('TRUNCATE apachesolr_server')
            for env in self.environments:
                config = self.config['environments'][env]['solr']
                host = config['solr_host']
                port = config['solr_port']
                sid = config['apachesolr_default_server']
                name = '%s %s' % (self.project, env)
                path = config['solr_path']

                db.execute('INSERT INTO apachesolr_server ' + \
                    '(host, port, server_id, name, path) VALUES ' + \
                    '("%s", "%s", "%s", "%s", "%s")' % \
                           (host, port, sid, name, path))
        db.close()

        # D7: apachesolr config link will not display until cache cleared?
        with settings(warn_only=True):
            result = local('drush @working_dir -y cc all')
            pantheon.log_drush_backend(result, self.log)

       # Remove temporary working_dir drush alias.
        alias_file = '/opt/drush/aliases/working_dir.alias.drushrc.php'
        if os.path.exists(alias_file):
            local('rm -f %s' % alias_file)