Esempio n. 1
0
 def build_application(self, cr, uid, vals, context):
     super(saas_application_version,
           self).build_application(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'wordpress':
         ssh, sftp = execute.connect('localhost', 22, 'saas-conductor',
                                     context)
         execute.execute(ssh, [
             'wget', '-q', 'https://wordpress.org/latest.tar.gz',
             'latest.tar.gz'
         ],
                         context,
                         path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['tar', '-xzf', 'latest.tar.gz'],
                         context,
                         path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['mv', 'wordpress/*', './'],
                         context,
                         path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', './*.tar.gz'],
                         context,
                         path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', 'wordpress/'],
                         context,
                         path=vals['app_version_full_archivepath'])
         ssh.close()
         sftp.close()
     return
Esempio n. 2
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version,
              self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor',
                                        context)
            execute.execute(ssh, [
                'wget', '-q',
                'https://bitbucket.org/haiwen/seafile/downloads/seafile-server_'
                + vals['app_current_version'] + '_x86-64.tar.gz'
            ],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['tar', '-xzf', 'seafile-server_*'],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(ssh, [
                'mv', 'seafile-server-' + vals['app_current_version'] + '/*',
                './'
            ],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['rm', '-rf', './*.tar.gz'],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(
                ssh,
                ['rm', '-rf', 'seafile-server_' + vals['app_current_version']],
                context,
                path=vals['app_version_full_archivepath'])
            ssh.close()
            sftp.close()

        return
Esempio n. 3
0
 def deploy_build(self, cr, uid, vals, context=None):
     res = super(saas_base, self).deploy_build(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['app_code'] == 'gitlab':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     username='******',
                                     context=context)
         database_file = vals[
             'service_full_localpath_files'] + '/config/database.yml'
         execute.execute(ssh, [
             'cp', vals['service_full_localpath_files'] +
             '/config/database.yml.postgresql', database_file
         ], context)
         execute.execute(ssh, [
             'sed', '-i', 's/gitlabhq_production/' +
             vals['base_unique_name_'] + '/g', database_file
         ], context)
         execute.execute(ssh, [
             'sed', '-i', 's/#\ username:\ git/username:\ ' +
             vals['service_db_user'] + '/g', database_file
         ], context)
         execute.execute(ssh, [
             'sed', '-i', 's/#\ password:/password:\ ' +
             vals['service_db_password'] + '/g', database_file
         ], context)
         execute.execute(ssh, [
             'sed', '-i', 's/#\ host:\ localhost/host:\ ' +
             vals['database_server'] + '/g', database_file
         ], context)
         ssh.close()
         sftp.close()
     return res
Esempio n. 4
0
    def deploy_create_database(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_create_database(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['mkdir', '-p', '/opt/odoo/' + vals['service_name'] + '/filestore/' + vals['base_unique_name_']], context)
            ssh.close()
            sftp.close()
            if vals['base_build'] == 'build':

#I had to go in /usr/local/lib/python2.7/dist-packages/erppeek.py and replace def create_database line 610. More specifically, db.create and db.get_progress used here aren't working anymore, see why in odoo/services/db.py, check dispatch function.
#    def create_database(self, passwd, database, demo=False, lang='en_US',
#                        user_password='******'):
#        thread_id = self.db.create_database(passwd, database, demo, lang, user_password)
#        self.login('admin', user_password,
#                       database=database)

                execute.log("client = erppeek.Client('http://" + vals['server_domain'] + ":" + vals['service_options']['port']['hostport'] + "')", context)
                client = erppeek.Client('http://' + vals['server_domain'] + ':' + vals['service_options']['port']['hostport'])
                execute.log("client.create_database('" + vals['service_db_password'] + "','" + vals['base_unique_name_'] + "'," + "demo=" + str(vals['base_test']) + "," + "lang='" + vals['base_lang'] + "'," + "user_password='******'base_admin_passwd'] + "')", context)
                client.create_database(vals['service_db_password'], vals['base_unique_name_'], demo=vals['base_test'], lang=vals['base_lang'], user_password=vals['base_admin_passwd'])
#                cmd = ['/usr/local/bin/erppeek', '--server', 'http://' + vals['server_domain'] + ':' + vals['service_options']['port']['hostport']]
#                stdin = ["client.create_database('" + vals['service_db_password'] + "', '" + vals['base_unique_name_'] + "', demo=" + str(vals['base_test']) + ", lang='fr_FR', user_password='******'base_admin_passwd'] + "')"]
#                execute.execute_local(cmd, context, stdin_arg=stdin)
                return True
        return res
Esempio n. 5
0
 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'postgres':
         ssh, sftp = execute.connect(vals['container_fullname'], context=context)
         execute.execute(ssh, ['echo "host all  all    ' + vals['container_options']['network']['value'] + ' md5" >> /etc/postgresql/' + vals['app_current_version'] + '/main/pg_hba.conf'], context)
         execute.execute(ssh, ['echo "listen_addresses=\'' + vals['container_options']['listen']['value'] + '\'" >> /etc/postgresql/' + vals['app_current_version'] + '/main/postgresql.conf'], context)
Esempio n. 6
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'bind':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.execute(ssh, ['sed', '-i', '"/' + vals['base_name'] + '\sIN\sCNAME/d"', vals['domain_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/bind9', 'restart'], context)
         ssh.close()
         sftp.close()
Esempio n. 7
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'shinken':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.execute(ssh, ['rm', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/shinken', 'reload'], context)
         ssh.close()
         sftp.close()
 def deploy_post(self, cr, uid, vals, context=None):
     res = super(saas_base, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'drupal':
         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
         execute.execute(ssh, ['drush', 'vset', '--yes', '--exact', 'site_name', vals['base_title']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         ssh.close()
         sftp.close()
Esempio n. 9
0
 def purge_post(self, cr, uid, vals, context):
     super(saas_base, self).purge_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'odoo':
         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
         execute.execute(ssh, ['rm', '-rf', '/opt/odoo/' + vals['service_name'] + '/filestore/' + vals['base_unique_name_']], context)
         ssh.close()
         sftp.close()
Esempio n. 10
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'shinken':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'],
                                     context=context)
         execute.execute(ssh, ['rm', vals['base_shinken_configfile']],
                         context)
         execute.execute(ssh, ['/etc/init.d/shinken', 'reload'], context)
         ssh.close()
         sftp.close()
    def deploy_post_service(self, cr, uid, vals, context):
        super(saas_service, self).deploy_post_service(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['cp', '-R', vals['service_full_localpath_files'] + '/sites-template', vals['service_full_localpath'] + '/sites'], context)
            ssh.close()
            sftp.close()

        return
Esempio n. 12
0
 def restore_base(self, cr, uid, vals, context=None):
     res = super(saas_save_save, self).restore_base(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'odoo':
         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
         execute.execute(ssh, ['rm', '-rf', '/opt/odoo/' + vals['service_name'] + '/filestore/' + vals['base_unique_name_']], context)
         execute.execute(ssh, ['cp', '-R', '/base-backup/' + vals['saverepo_name'] + '/filestore', '/opt/odoo/' + vals['service_name'] + '/filestore/' + vals['base_unique_name_']], context)
         ssh.close()
         sftp.close()
     return
    def deploy_base(self, cr, uid, vals, context=None):
        res = super(saas_save_save, self).deploy_base(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
#            execute.execute(ssh, ['drush', 'archive-dump', vals['base_unique_name_'], '--destination=/base-backup/' + vals['saverepo_name'] + 'tar.gz'], context)
            execute.execute(ssh, ['cp', '-R', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'], '/base-backup/' + vals['saverepo_name'] + '/site'], context)
            ssh.close()
            sftp.close()
        return
 def restore_base(self, cr, uid, vals, context=None):
     res = super(saas_save_save, self).restore_base(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'drupal':
         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
         execute.execute(ssh, ['rm', '-rf', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain']], context)
         execute.execute(ssh, ['cp', '-R', '/base-backup/' + vals['saverepo_name'] + '/site', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain']], context)
         ssh.close()
         sftp.close()
     return
Esempio n. 15
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'proxy':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.execute(ssh, ['rm', '/etc/nginx/sites-enabled/' + vals['base_unique_name']], context)
         execute.execute(ssh, ['rm', vals['base_nginx_configfile']], context)
         execute.execute(ssh, ['rm', '/etc/ssl/certs/' + vals['base_name'] + '.' + vals['domain_name'] + '.*'], context)
         execute.execute(ssh, ['rm', '/etc/ssl/private/' + vals['base_name'] + '.' + vals['domain_name'] + '.*'], context)
         execute.execute(ssh, ['/etc/init.d/nginx', 'reload'], context)
         ssh.close()
         sftp.close()
Esempio n. 16
0
    def purge_pre_service(self, cr, uid, vals, context):
        super(saas_service, self).purge_pre_service(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['sed', '-i', '"/program:' + vals['service_name'] + '/d"', '/opt/odoo/supervisor.conf'], context)
            execute.execute(ssh, ['sed', '-i', '"/command=su odoo -c \'\/opt\/odoo\/' + vals['service_name'] + '/d"', '/opt/odoo/supervisor.conf'], context)
            ssh.close()
            sftp.close()

        return
    def post_reset(self, cr, uid, vals, context=None):
        res = super(saas_base, self).post_reset(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':

            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['cp', '-R', vals['service_parent_full_localpath'] + '/sites/' + vals['base_parent_fulldomain'], vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain']], context)
            ssh.close()
            sftp.close()

        return res
    def deploy_create_poweruser(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_create_poweruser(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':

            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['drush', 'user-create',  vals['base_poweruser_name'],  '--password='******'base_poweruser_password'], '--mail=' + vals['base_poweruser_email']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
            if vals['app_options']['poweruser_group']['value']:
                execute.execute(ssh, ['drush', 'user-add-role', vals['app_options']['poweruser_group']['value'], vals['base_poweruser_name']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
            ssh.close()
            sftp.close()

        return res
Esempio n. 19
0
 def build_application(self, cr, uid, vals, context):
     super(saas_application_version, self).build_application(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'wordpress':
         ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
         execute.execute(ssh, ['wget', '-q', 'https://wordpress.org/latest.tar.gz', 'latest.tar.gz'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['tar', '-xzf', 'latest.tar.gz'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['mv', 'wordpress/*', './'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', './*.tar.gz'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', 'wordpress/'], context, path=vals['app_version_full_archivepath'])
         ssh.close()
         sftp.close()
     return
Esempio n. 20
0
 def purge_post(self, cr, uid, vals, context):
     super(saas_base, self).purge_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'odoo':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     username=vals['apptype_system_user'],
                                     context=context)
         execute.execute(ssh, [
             'rm', '-rf', '/opt/odoo/' + vals['service_name'] +
             '/filestore/' + vals['base_unique_name_']
         ], context)
         ssh.close()
         sftp.close()
Esempio n. 21
0
 def build_application(self, cr, uid, vals, context):
     super(saas_application_version, self).build_application(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'piwik':
         ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
         execute.execute(ssh, ['wget', '-q', 'http://builds.piwik.org/piwik.zip', 'piwik.zip'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['unzip', '-q', 'piwik.zip'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['mv', 'piwik/*', './'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', './*.zip'], context, path=vals['app_version_full_archivepath'])
         execute.execute(ssh, ['rm', '-rf', 'piwik/'], context, path=vals['app_version_full_archivepath'])
         ssh.close()
         sftp.close()
     return
Esempio n. 22
0
    def deploy_post(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_post(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect(vals['container_fullname'],
                                        username=vals['apptype_system_user'],
                                        context=context)
            execute.execute(ssh, [
                'echo "[program:' + vals['base_unique_name'] +
                '-seafile]" >> /opt/seafile/supervisor.conf'
            ], context)
            execute.execute(ssh, [
                'echo "command=su seafile -c \'' +
                vals['service_full_localpath_files'] +
                '/seafile.sh start\'" >> /opt/seafile/supervisor.conf'
            ], context)
            execute.execute(ssh, [
                'echo "[program:' + vals['base_unique_name'] +
                '-seahub]" >> /opt/seafile/supervisor.conf'
            ], context)
            execute.execute(ssh, [
                'echo "command=su seafile -c \'rm ' +
                vals['service_full_localpath_files'] +
                '/runtime/seahub.pid; ' +
                vals['service_full_localpath_files'] +
                '/seahub.sh start\'" >> /opt/seafile/supervisor.conf'
            ], context)

            ssh.close()
            sftp.close()
        return res
Esempio n. 23
0
 def purge_post(self, cr, uid, vals, context):
     super(saas_base, self).purge_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'seafile':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     username=vals['apptype_system_user'],
                                     context=context)
         execute.execute(ssh, [
             'sed', '-i', '"/program:' + vals['base_unique_name'] +
             '-seafile/d"', '/opt/seafile/supervisor.conf'
         ], context)
         execute.execute(ssh, [
             'sed', '-i', '"/' +
             vals['service_full_localpath_files'].replace('/', '\/') +
             '\/seafile.sh/d"', '/opt/seafile/supervisor.conf'
         ], context)
         execute.execute(ssh, [
             'sed', '-i', '"/program:' + vals['base_unique_name'] +
             '-seahub/d"', '/opt/seafile/supervisor.conf'
         ], context)
         execute.execute(ssh, [
             'sed', '-i', '"/' +
             vals['service_full_localpath_files'].replace('/', '\/') +
             '\/seahub.sh/d"', '/opt/seafile/supervisor.conf'
         ], context)
         ssh.close()
         sftp.close()
Esempio n. 24
0
 def deploy_build(self, cr, uid, vals, context=None):
     res = super(saas_base, self).deploy_build(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['app_code'] == 'gitlab':
         ssh, sftp = execute.connect(vals['container_fullname'], username='******', context=context)
         database_file = vals['service_full_localpath_files'] + '/config/database.yml'
         execute.execute(ssh, ['cp', vals['service_full_localpath_files'] + '/config/database.yml.postgresql', database_file], context)
         execute.execute(ssh, ['sed', '-i', 's/gitlabhq_production/' + vals['base_unique_name_'] + '/g', database_file], context)
         execute.execute(ssh, ['sed', '-i', 's/#\ username:\ git/username:\ ' + vals['service_db_user'] + '/g', database_file], context)
         execute.execute(ssh, ['sed', '-i', 's/#\ password:/password:\ ' + vals['service_db_password'] + '/g', database_file], context)
         execute.execute(ssh, ['sed', '-i', 's/#\ host:\ localhost/host:\ ' + vals['database_server'] + '/g', database_file], context)
         ssh.close()
         sftp.close()
     return res
    def post_reset(self, cr, uid, vals, context=None):
        res = super(saas_base, self).post_reset(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            execute.log(
                "client = erppeek.Client('http://" + vals['server_domain'] +
                ":" + vals['service_options']['port']['hostport'] + "," +
                "db=" + vals['base_unique_name_'] + "," + "user="******", password="******")", context)
            client = erppeek.Client(
                'http://' + vals['server_domain'] + ':' +
                vals['service_options']['port']['hostport'],
                db=vals['base_unique_name_'],
                user=vals['apptype_admin_name'],
                password=vals['base_admin_passwd'])
            execute.log(
                "server_id = client.model('ir.model.data').get_object_reference('base', 'ir_mail_server_localhost0')[1]",
                context)
            server_id = client.model('ir.model.data').get_object_reference(
                'base', 'ir_mail_server_localhost0')[1]
            execute.log(
                "client.model('ir.mail_server').write([" + str(server_id) +
                "], {'smtp_host': 'mail.disabled.lol'})", context)
            client.model('ir.mail_server').write(
                [server_id], {'smtp_host': 'mail.disabled.lol'})

            execute.log(
                "cron_ids = client.model('ir.cron').search(['|',('active','=',True),('active','=',False)])",
                context)
            cron_ids = client.model('ir.cron').search(
                ['|', ('active', '=', True), ('active', '=', False)])
            execute.log(
                "client.model('ir.cron').write(" + str(cron_ids) +
                ", {'active': False})", context)
            client.model('ir.cron').write(cron_ids, {'active': False})

            ssh, sftp = execute.connect(vals['container_fullname'],
                                        username=vals['apptype_system_user'],
                                        context=context)
            execute.execute(ssh, [
                'cp', '-R', '/opt/odoo/' + vals['service_parent_name'] +
                '/filestore/' + vals['base_parent_unique_name_'],
                '/opt/odoo/' + vals['service_name'] + '/filestore/' +
                vals['base_unique_name_']
            ], context)
            ssh.close()
            sftp.close()

        return res
Esempio n. 26
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version, self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
            execute.execute(ssh,['wget', '-q', 'https://bitbucket.org/haiwen/seafile/downloads/seafile-server_' + vals['app_current_version'] + '_x86-64.tar.gz'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['tar', '-xzf', 'seafile-server_*'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['mv', 'seafile-server-' + vals['app_current_version'] + '/*', './'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['rm', '-rf', './*.tar.gz'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['rm', '-rf', 'seafile-server_' + vals['app_current_version']], context, path=vals['app_version_full_archivepath'])
            ssh.close()
            sftp.close()

        return
 def deploy_base(self, cr, uid, vals, context=None):
     res = super(saas_save_save, self).deploy_base(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'odoo':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     username=vals['apptype_system_user'],
                                     context=context)
         #            execute.execute(ssh, ['mkdir', '-p', '/base-backup/' + vals['saverepo_name'] + '/filestore'], context)
         execute.execute(ssh, [
             'cp', '-R', '/opt/odoo/' + vals['service_name'] +
             '/filestore/' + vals['base_unique_name_'],
             '/base-backup/' + vals['saverepo_name'] + '/filestore'
         ], context)
         ssh.close()
         sftp.close()
     return
    def deploy_create_database(self, cr, uid, vals, context=None):
        res = super(saas_base,
                    self).deploy_create_database(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            ssh, sftp = execute.connect(vals['container_fullname'],
                                        username=vals['apptype_system_user'],
                                        context=context)
            execute.execute(ssh, [
                'mkdir', '-p', '/opt/odoo/' + vals['service_name'] +
                '/filestore/' + vals['base_unique_name_']
            ], context)
            ssh.close()
            sftp.close()
            if vals['base_build'] == 'build':

                #I had to go in /usr/local/lib/python2.7/dist-packages/erppeek.py and replace def create_database line 610. More specifically, db.create and db.get_progress used here aren't working anymore, see why in odoo/services/db.py, check dispatch function.
                #    def create_database(self, passwd, database, demo=False, lang='en_US',
                #                        user_password='******'):
                #        thread_id = self.db.create_database(passwd, database, demo, lang, user_password)
                #        self.login('admin', user_password,
                #                       database=database)

                execute.log(
                    "client = erppeek.Client('http://" +
                    vals['server_domain'] + ":" +
                    vals['service_options']['port']['hostport'] + "')",
                    context)
                client = erppeek.Client(
                    'http://' + vals['server_domain'] + ':' +
                    vals['service_options']['port']['hostport'])
                execute.log(
                    "client.create_database('" + vals['service_db_password'] +
                    "','" + vals['base_unique_name_'] + "'," + "demo=" +
                    str(vals['base_test']) + "," + "lang='" +
                    vals['base_lang'] + "'," + "user_password='******'base_admin_passwd'] + "')", context)
                client.create_database(vals['service_db_password'],
                                       vals['base_unique_name_'],
                                       demo=vals['base_test'],
                                       lang=vals['base_lang'],
                                       user_password=vals['base_admin_passwd'])
                #                cmd = ['/usr/local/bin/erppeek', '--server', 'http://' + vals['server_domain'] + ':' + vals['service_options']['port']['hostport']]
                #                stdin = ["client.create_database('" + vals['service_db_password'] + "', '" + vals['base_unique_name_'] + "', demo=" + str(vals['base_test']) + ", lang='fr_FR', user_password='******'base_admin_passwd'] + "')"]
                #                execute.execute_local(cmd, context, stdin_arg=stdin)
                return True
        return res
Esempio n. 29
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version,
              self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':
            execute.execute_write_file(
                vals['app_version_full_archivepath'] + '/drush.make',
                vals['app_buildfile'], context)
            execute.execute_local([
                'drush', 'make',
                vals['app_version_full_archivepath'] + '/drush.make', './'
            ],
                                  context,
                                  path=vals['app_version_full_archivepath'])
            execute.execute_local([
                'cp', vals['config_conductor_path'] +
                '/saas/saas_drupal/res/wikicompare.script',
                vals['app_version_full_archivepath']
            ], context)
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor',
                                        context)
            execute.execute(ssh, [
                'patch', '-p0', '-d', vals['app_version_full_archivepath'] +
                '/sites/all/modules/revisioning/', '<',
                vals['config_conductor_path'] +
                '/saas/saas_drupal/res/patch/revisioning_postgres.patch'
            ], context)
            ssh.close()
            sftp.close()
            execute.execute_local([
                'mv', vals['app_version_full_archivepath'] + '/sites',
                vals['app_version_full_archivepath'] + '/sites-template'
            ], context)
            execute.execute_local([
                'ln', '-s', '../sites',
                vals['app_version_full_archivepath'] + '/sites'
            ], context)

    #
    # if [[ $name == 'dev' ]]
    # then
    # patch -p0 -d $archive_path/$app/${app}-${name}/archive/sites/all/themes/wikicompare_theme/ < $openerp_path/saas/saas/apps/drupal/patch/dev_zen_rebuild_registry.patch
    # fi

        return
 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'postgres':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     context=context)
         execute.execute(ssh, [
             'echo "host all  all    ' +
             vals['container_options']['network']['value'] +
             ' md5" >> /etc/postgresql/' + vals['app_current_version'] +
             '/main/pg_hba.conf'
         ], context)
         execute.execute(ssh, [
             'echo "listen_addresses=\'' +
             vals['container_options']['listen']['value'] +
             '\'" >> /etc/postgresql/' + vals['app_current_version'] +
             '/main/postgresql.conf'
         ], context)
Esempio n. 31
0
    def deploy_link(self, cr, uid, vals, context={}):
        super(saas_base_link, self).deploy_link(cr, uid, vals, context=context)
        if vals['link_target_app_code'] == 'piwik':
            ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
            piwik_id = execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
                '"select idsite from piwik_site WHERE name = \'' + vals['base_fulldomain'] + '\' LIMIT 1;"'], context)
            if not piwik_id:
                execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
                    '"INSERT INTO piwik_site (name, main_url, ts_created, timezone, currency) VALUES (\'' + vals['base_fulldomain'] + '\', \'http://' + vals['base_fulldomain'] + '\', NOW(), \'Europe/Paris\', \'EUR\');"'], context)
                piwik_id = execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
                    '"select idsite from piwik_site WHERE name = \'' + vals['base_fulldomain'] + '\' LIMIT 1;"'], context)
#            execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
#                '"INSERT INTO piwik_access (login, idsite, access) VALUES (\'anonymous\', ' + piwik_id + ', \'view\');"'], context)

            ssh.close()
            sftp.close()

            self.deploy_piwik(cr, uid, vals, piwik_id, context=context)
Esempio n. 32
0
 def deploy_piwik(self, cr, uid, vals, piwik_id, context={}):
     super(saas_base_link, self).deploy_piwik(cr, uid, vals, piwik_id, context=context)
     if vals['link_target_app_code'] == 'piwik' and vals['apptype_name'] == 'drupal':
         ssh, sftp = execute.connect(vals['container_fullname'], context=context)
         execute.execute(ssh, ['drush', 'variable-set', 'piwik_site_id', piwik_id], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         execute.execute(ssh, ['drush', 'variable-set', 'piwik_url_http', 'http://' +  vals['link_target_base_fulldomain'] + '/'], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         execute.execute(ssh, ['drush', 'variable-set', 'piwik_url_https', 'https://' +  vals['link_target_base_fulldomain'] + '/'], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         execute.execute(ssh, ['drush', 'variable-set', 'piwik_privacy_donottrack', '0'], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         ssh.close()
         sftp.close()
     return
Esempio n. 33
0
    def purge_post(self, cr, uid, vals, context):
        super(saas_base, self).purge_post(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':

            ssh, sftp = execute.connect(vals['container_fullname'], context=context)
            execute.execute(ssh, ['rm', '-rf', vals['service_full_localpath'] + '/sites/' + vals['base_fulldomain']], context)
            execute.execute(ssh, ['rm', '-rf', '/etc/nginx/sites-enabled/' + vals['base_fullname']], context)
            execute.execute(ssh, ['rm', '-rf', '/etc/nginx/sites-available/' + vals['base_fullname']], context)
            execute.execute(ssh, ['/etc/init.d/nginx','reload'], context)
            ssh.close()
            sftp.close()
Esempio n. 34
0
    def purge_pre_service(self, cr, uid, vals, context):
        super(saas_service, self).purge_pre_service(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            ssh, sftp = execute.connect(vals['container_fullname'],
                                        username=vals['apptype_system_user'],
                                        context=context)
            execute.execute(ssh, [
                'sed', '-i', '"/program:' + vals['service_name'] + '/d"',
                '/opt/odoo/supervisor.conf'
            ], context)
            execute.execute(ssh, [
                'sed', '-i', '"/command=su odoo -c \'\/opt\/odoo\/' +
                vals['service_name'] + '/d"', '/opt/odoo/supervisor.conf'
            ], context)
            ssh.close()
            sftp.close()

        return
Esempio n. 35
0
    def deploy_post(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_post(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['echo "[program:' + vals['base_unique_name'] + '-seafile]" >> /opt/seafile/supervisor.conf'], context)
            execute.execute(ssh, ['echo "command=su seafile -c \'' + vals['service_full_localpath_files'] + '/seafile.sh start\'" >> /opt/seafile/supervisor.conf'], context)
            execute.execute(ssh, ['echo "[program:' + vals['base_unique_name'] + '-seahub]" >> /opt/seafile/supervisor.conf'], context)
            execute.execute(ssh, ['echo "command=su seafile -c \'rm ' + vals['service_full_localpath_files'] + '/runtime/seahub.pid; ' + vals['service_full_localpath_files'] + '/seahub.sh start\'" >> /opt/seafile/supervisor.conf'], context)

            ssh.close()
            sftp.close()
        return res
Esempio n. 36
0
 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'mysql':
         ssh, sftp = execute.connect(vals['container_fullname'], context=context)
         execute.execute(ssh, ['sed', '-i', '"/bind-address/d"', '/etc/mysql/my.cnf'], context)
         if vals['container_options']['root_password']['value']:
             password =vals ['container_options']['root_password']['value']
         else:
             password = execute.generate_random_password(20)
             option_obj = self.pool.get('saas.container.option')
             option_ids = option_obj.search(cr, uid, [('container_id','=',vals['container_id']),('name','=','root_password')])
             if option_ids:
                 option_obj.write(cr, uid, option_ids, {'value': password}, context=context)
             else:
                 type_obj = self.pool.get('saas.application.type.option')
                 type_ids = type_obj.search(cr, uid, [('apptype_id.name','=','mysql'),('name','=','root_password')])
                 if type_ids:
                     option_obj.create(cr, uid, {'container_id': vals['container_id'], 'name': type_ids[0], 'value': password}, context=context)
         execute.execute(ssh, ['mysqladmin', '-u', 'root', 'password', password], context)
Esempio n. 37
0
    def purge_link(self, cr, uid, vals, context={}):
        super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
        if vals['link_target_app_code'] == 'piwik':
            ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
            piwik_id = execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
                '"select idsite from piwik_site WHERE name = \'' + vals['base_fulldomain'] + '\' LIMIT 1;"'], context)
            # if piwik_id:
            #     execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
            #         '"DELETE FROM piwik_access WHERE idsite = ' + piwik_id + ';"'], context)

            ssh.close()
            sftp.close()
 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'mysql':
         ssh, sftp = execute.connect(vals['container_fullname'],
                                     context=context)
         execute.execute(
             ssh, ['sed', '-i', '"/bind-address/d"', '/etc/mysql/my.cnf'],
             context)
         if vals['container_options']['root_password']['value']:
             password = vals['container_options']['root_password']['value']
         else:
             password = execute.generate_random_password(20)
             option_obj = self.pool.get('saas.container.option')
             option_ids = option_obj.search(
                 cr, uid, [('container_id', '=', vals['container_id']),
                           ('name', '=', 'root_password')])
             if option_ids:
                 option_obj.write(cr,
                                  uid,
                                  option_ids, {'value': password},
                                  context=context)
             else:
                 type_obj = self.pool.get('saas.application.type.option')
                 type_ids = type_obj.search(
                     cr, uid, [('apptype_id.name', '=', 'mysql'),
                               ('name', '=', 'root_password')])
                 if type_ids:
                     option_obj.create(
                         cr,
                         uid, {
                             'container_id': vals['container_id'],
                             'name': type_ids[0],
                             'value': password
                         },
                         context=context)
         execute.execute(ssh,
                         ['mysqladmin', '-u', 'root', 'password', password],
                         context)
Esempio n. 39
0
    def post_reset(self, cr, uid, vals, context=None):
        res = super(saas_base, self).post_reset(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            execute.log("client = erppeek.Client('http://" + vals['server_domain'] + ":" + vals['service_options']['port']['hostport'] + "," + "db=" + vals['base_unique_name_'] + "," + "user="******", password="******")", context)
            client = erppeek.Client('http://' + vals['server_domain'] + ':' + vals['service_options']['port']['hostport'], db=vals['base_unique_name_'], user=vals['apptype_admin_name'], password=vals['base_admin_passwd'])
            execute.log("server_id = client.model('ir.model.data').get_object_reference('base', 'ir_mail_server_localhost0')[1]", context)
            server_id = client.model('ir.model.data').get_object_reference('base', 'ir_mail_server_localhost0')[1]
            execute.log("client.model('ir.mail_server').write([" + str(server_id) + "], {'smtp_host': 'mail.disabled.lol'})", context)
            client.model('ir.mail_server').write([server_id], {'smtp_host': 'mail.disabled.lol'})

            execute.log("cron_ids = client.model('ir.cron').search(['|',('active','=',True),('active','=',False)])", context)
            cron_ids = client.model('ir.cron').search(['|',('active','=',True),('active','=',False)])
            execute.log("client.model('ir.cron').write(" + str(cron_ids) +", {'active': False})", context)
            client.model('ir.cron').write(cron_ids, {'active': False})

            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            execute.execute(ssh, ['cp', '-R', '/opt/odoo/' + vals['service_parent_name'] + '/filestore/' + vals['base_parent_unique_name_'], '/opt/odoo/' + vals['service_name'] + '/filestore/' + vals['base_unique_name_']], context)
            ssh.close()
            sftp.close()

        return res
Esempio n. 40
0
    def deploy_link(self, cr, uid, vals, context={}):
        super(saas_base_link, self).deploy_link(cr, uid, vals, context=context)
        if vals['link_target_app_code'] == 'piwik':
            ssh, sftp = execute.connect(vals['link_target_container_fullname'],
                                        context=context)
            piwik_id = execute.execute(ssh, [
                'mysql', vals['link_target_base_unique_name_'],
                '-h ' + vals['link_target_database_server'],
                '-u ' + vals['link_target_service_db_user'],
                '-p' + vals['link_target_service_db_password'], '-se',
                '"select idsite from piwik_site WHERE name = \'' +
                vals['base_fulldomain'] + '\' LIMIT 1;"'
            ], context)
            if not piwik_id:
                execute.execute(ssh, [
                    'mysql', vals['link_target_base_unique_name_'],
                    '-h ' + vals['link_target_database_server'],
                    '-u ' + vals['link_target_service_db_user'],
                    '-p' + vals['link_target_service_db_password'], '-se',
                    '"INSERT INTO piwik_site (name, main_url, ts_created, timezone, currency) VALUES (\''
                    + vals['base_fulldomain'] + '\', \'http://' +
                    vals['base_fulldomain'] +
                    '\', NOW(), \'Europe/Paris\', \'EUR\');"'
                ], context)
                piwik_id = execute.execute(ssh, [
                    'mysql', vals['link_target_base_unique_name_'],
                    '-h ' + vals['link_target_database_server'],
                    '-u ' + vals['link_target_service_db_user'],
                    '-p' + vals['link_target_service_db_password'], '-se',
                    '"select idsite from piwik_site WHERE name = \'' +
                    vals['base_fulldomain'] + '\' LIMIT 1;"'
                ], context)
#            execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
#                '"INSERT INTO piwik_access (login, idsite, access) VALUES (\'anonymous\', ' + piwik_id + ', \'view\');"'], context)

            ssh.close()
            sftp.close()

            self.deploy_piwik(cr, uid, vals, piwik_id, context=context)
Esempio n. 41
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'proxy':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'],
                                     context=context)
         execute.execute(
             ssh,
             ['rm', '/etc/nginx/sites-enabled/' + vals['base_unique_name']],
             context)
         execute.execute(ssh, ['rm', vals['base_nginx_configfile']],
                         context)
         execute.execute(ssh, [
             'rm', '/etc/ssl/certs/' + vals['base_name'] + '.' +
             vals['domain_name'] + '.*'
         ], context)
         execute.execute(ssh, [
             'rm', '/etc/ssl/private/' + vals['base_name'] + '.' +
             vals['domain_name'] + '.*'
         ], context)
         execute.execute(ssh, ['/etc/init.d/nginx', 'reload'], context)
         ssh.close()
         sftp.close()
 def deploy_test(self, cr, uid, vals, context=None):
     res = super(saas_base, self).deploy_test(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'drupal':
         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
         execute.execute(ssh, ['drush', 'vset', '--yes', '--exact', 'wikicompare_test_platform', '1'],context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         if vals['app_options']['test_install_modules']['value']:
             modules = vals['app_options']['test_install_modules']['value'].split(',')
             for module in modules:
                 execute.execute(ssh, ['drush', '-y', 'en', module], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
                 execute.execute(ssh, ['drush', '-y', 'en', module],context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
                 if vals['base_poweruser_name'] and vals['base_poweruser_email']:
                     execute.execute(ssh, ['drush', vals['service_full_localpath_files'] + '/wikicompare.script', '--user='******'base_poweruser_name'], 'deploy_demo'],context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
         ssh.close()
         sftp.close()
     return
Esempio n. 43
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version, self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'drupal':
            execute.execute_write_file(vals['app_version_full_archivepath'] + '/drush.make', vals['app_buildfile'], context)
            execute.execute_local(['drush', 'make', vals['app_version_full_archivepath'] + '/drush.make', './'], context, path=vals['app_version_full_archivepath'])
            execute.execute_local(['cp', vals['config_conductor_path'] + '/saas/saas_drupal/res/wikicompare.script', vals['app_version_full_archivepath']], context)
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
            execute.execute(ssh, ['patch', '-p0', '-d', vals['app_version_full_archivepath'] + '/sites/all/modules/revisioning/', '<', vals['config_conductor_path'] + '/saas/saas_drupal/res/patch/revisioning_postgres.patch'], context)
            ssh.close()
            sftp.close()
            execute.execute_local(['mv', vals['app_version_full_archivepath'] + '/sites', vals['app_version_full_archivepath'] + '/sites-template'], context)
            execute.execute_local(['ln', '-s', '../sites', vals['app_version_full_archivepath'] + '/sites'], context)


    #
    # if [[ $name == 'dev' ]]
    # then
    # patch -p0 -d $archive_path/$app/${app}-${name}/archive/sites/all/themes/wikicompare_theme/ < $openerp_path/saas/saas/apps/drupal/patch/dev_zen_rebuild_registry.patch
    # fi


        return
Esempio n. 44
0
 def deploy_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).deploy_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'bind':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.execute(ssh, ['echo "' + vals['base_name'] + ' IN CNAME ' + ('proxy' in vals['base_links'] and vals['base_links']['proxy']['target']['link_server_domain'] or vals['server_domain']) + '." >> ' + vals['domain_configfile']], context)
         if 'postfix' in vals['base_links']:
             execute.execute(ssh, ['echo "IN MX 1 ' + vals['base_links']['postfix']['target']['link_server_domain'] + '. ;' + vals['base_name'] + ' IN CNAME" >> ' + vals['domain_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/bind9', 'restart'], context)
         ssh.close()
         sftp.close()
Esempio n. 45
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version,
              self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            execute.execute_local([
                'mkdir', '-p', vals['app_version_full_archivepath'] + '/extra'
            ], context)
            execute.execute_write_file(
                vals['app_version_full_archivepath'] + '/buildout.cfg',
                vals['app_buildfile'], context)
            execute.execute_local([
                'wget',
                'https://raw.github.com/buildout/buildout/master/bootstrap/bootstrap.py'
            ],
                                  context,
                                  path=vals['app_version_full_archivepath'])
            execute.execute_local(['virtualenv', 'sandbox'], context,
                                  vals['app_version_full_archivepath'])
            execute.execute_local(
                ['yes | sandbox/bin/pip uninstall setuptools pip'],
                context,
                path=vals['app_version_full_archivepath'],
                shell=True)
            execute.execute_local(['sandbox/bin/python', 'bootstrap.py'],
                                  context,
                                  vals['app_version_full_archivepath'])
            execute.execute_local(['bin/buildout'], context,
                                  vals['app_version_full_archivepath'])

            #Can't make sed work on local
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor',
                                        context)
            execute.execute(ssh, [
                'patch', vals['app_version_full_archivepath'] +
                '/parts/odoo/openerp/http.py', '<',
                vals['config_conductor_path'] +
                '/saas/saas_odoo/res/http.patch'
            ], context)
            execute.execute(ssh, [
                'sed', '-i',
                '"s/' + vals['config_archive_path'].replace('/', '\/') + '/' +
                vals['apptype_localpath'].replace('/', '\/') + '/g"',
                vals['app_version_full_archivepath'] + '/bin/start_odoo'
            ], context)
            execute.execute(ssh, [
                'sed', '-i',
                '"s/' + vals['config_archive_path'].replace('/', '\/') + '/' +
                vals['apptype_localpath'].replace('/', '\/') + '/g"',
                vals['app_version_full_archivepath'] + '/bin/buildout'
            ], context)
            ssh.close()
            sftp.close()
        return
Esempio n. 46
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version, self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['app_code'] == 'gitlab':
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
            execute.execute(ssh,['git', 'clone', 'https://gitlab.com/gitlab-org/gitlab-ce.git', '-b', '7-5-stable', 'gitlab'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh,['mv', 'gitlab/*', './'], context, path=vals['app_version_full_archivepath'])
            execute.execute(ssh,['rm', '-r', 'gitlab'], context, path=vals['app_version_full_archivepath'])
            ssh.close()
            sftp.close()

        return
Esempio n. 47
0
    def purge_link(self, cr, uid, vals, context={}):
        super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
        if vals['link_target_app_code'] == 'piwik':
            ssh, sftp = execute.connect(vals['link_target_container_fullname'],
                                        context=context)
            piwik_id = execute.execute(ssh, [
                'mysql', vals['link_target_base_unique_name_'],
                '-h ' + vals['link_target_database_server'],
                '-u ' + vals['link_target_service_db_user'],
                '-p' + vals['link_target_service_db_password'], '-se',
                '"select idsite from piwik_site WHERE name = \'' +
                vals['base_fulldomain'] + '\' LIMIT 1;"'
            ], context)
            # if piwik_id:
            #     execute.execute(ssh, ['mysql', vals['link_target_base_unique_name_'], '-h ' + vals['link_target_database_server'], '-u ' + vals['link_target_service_db_user'], '-p' + vals['link_target_service_db_password'], '-se',
            #         '"DELETE FROM piwik_access WHERE idsite = ' + piwik_id + ';"'], context)

            ssh.close()
            sftp.close()
Esempio n. 48
0
    def deploy_build(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_build(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect(vals['container_fullname'],
                                        username=vals['apptype_system_user'],
                                        context=context)
            install_args = [
                '\n', vals['base_title'] + '\n',
                vals['base_fulldomain'] + '\n', '\n', '\n', '\n', '\n', '2\n',
                'mysql\n', '\n', vals['service_db_user'] + '\n',
                vals['service_db_password'] + '\n',
                vals['base_databases']['ccnet'] + '\n',
                vals['base_databases']['seafile'] + '\n',
                vals['base_databases']['seahub'] + '\n', '\n'
            ]
            seahub_args = [
                vals['apptype_admin_email'] + '\n',
                vals['base_admin_passwd'] + '\n',
                vals['base_admin_passwd'] + '\n'
            ]
            if not vals['base_options']['manual_install']['value']:
                #Be cautious, the install may crash because of the server name (title). Use only alphanumeric, less than 15 letter without space
                execute.execute(ssh, ['./setup-seafile-mysql.sh'],
                                context,
                                stdin_arg=install_args,
                                path=vals['service_full_localpath_files'])

                execute.execute(ssh, [
                    vals['service_full_localpath_files'] + '/seafile.sh',
                    'start'
                ], context)

                execute.execute(ssh, [
                    vals['service_full_localpath_files'] + '/seahub.sh',
                    'start'
                ],
                                context,
                                stdin_arg=seahub_args)
            else:
                for arg in install_args:
                    execute.log(arg, context)
                for arg in seahub_args:
                    execute.log(arg, context)

        return res
Esempio n. 49
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version, self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            execute.execute_local(['mkdir', '-p', vals['app_version_full_archivepath'] + '/extra'], context)
            execute.execute_write_file(vals['app_version_full_archivepath'] + '/buildout.cfg', vals['app_buildfile'], context)
            execute.execute_local(['wget', 'https://raw.github.com/buildout/buildout/master/bootstrap/bootstrap.py'], context, path=vals['app_version_full_archivepath'])
            execute.execute_local(['virtualenv', 'sandbox'], context, vals['app_version_full_archivepath'])
            execute.execute_local(['yes | sandbox/bin/pip uninstall setuptools pip'], context, path=vals['app_version_full_archivepath'], shell=True)
            execute.execute_local(['sandbox/bin/python', 'bootstrap.py'], context, vals['app_version_full_archivepath'])
            execute.execute_local(['bin/buildout'], context, vals['app_version_full_archivepath'])

            #Can't make sed work on local
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor', context)
            execute.execute(ssh, ['patch', vals['app_version_full_archivepath'] + '/parts/odoo/openerp/http.py', '<', vals['config_conductor_path'] + '/saas/saas_odoo/res/http.patch'], context)
            execute.execute(ssh, ['sed', '-i', '"s/' + vals['config_archive_path'].replace('/','\/') + '/' + vals['apptype_localpath'].replace('/','\/') + '/g"', vals['app_version_full_archivepath'] + '/bin/start_odoo'], context)
            execute.execute(ssh, ['sed', '-i', '"s/' + vals['config_archive_path'].replace('/','\/') + '/' + vals['apptype_localpath'].replace('/','\/') + '/g"', vals['app_version_full_archivepath'] + '/bin/buildout'], context)
            ssh.close()
            sftp.close()
        return
Esempio n. 50
0
    def build_application(self, cr, uid, vals, context):
        super(saas_application_version,
              self).build_application(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['app_code'] == 'gitlab':
            ssh, sftp = execute.connect('localhost', 22, 'saas-conductor',
                                        context)
            execute.execute(ssh, [
                'git', 'clone', 'https://gitlab.com/gitlab-org/gitlab-ce.git',
                '-b', '7-5-stable', 'gitlab'
            ],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['mv', 'gitlab/*', './'],
                            context,
                            path=vals['app_version_full_archivepath'])
            execute.execute(ssh, ['rm', '-r', 'gitlab'],
                            context,
                            path=vals['app_version_full_archivepath'])
            ssh.close()
            sftp.close()

        return
Esempio n. 51
0
    def deploy_build(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_build(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'seafile':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            install_args = ['\n',
                     vals['base_title'] + '\n',
                     vals['base_fulldomain'] + '\n',
                     '\n','\n','\n','\n',
                     '2\n',
                     'mysql\n',
                     '\n',
                     vals['service_db_user'] + '\n',
                     vals['service_db_password'] + '\n',
                     vals['base_databases']['ccnet'] + '\n',
                     vals['base_databases']['seafile'] + '\n',
                     vals['base_databases']['seahub'] + '\n',
                     '\n']
            seahub_args = [vals['apptype_admin_email'] + '\n',
                          vals['base_admin_passwd'] + '\n',
                          vals['base_admin_passwd'] + '\n']
            if not vals['base_options']['manual_install']['value']:
                #Be cautious, the install may crash because of the server name (title). Use only alphanumeric, less than 15 letter without space
                execute.execute(ssh, ['./setup-seafile-mysql.sh'],context, stdin_arg=install_args, path=vals['service_full_localpath_files'])

                execute.execute(ssh, [vals['service_full_localpath_files'] + '/seafile.sh', 'start'], context)

                execute.execute(ssh, [vals['service_full_localpath_files'] + '/seahub.sh', 'start'], context, stdin_arg=seahub_args)
            else:
                for arg in install_args:
                    execute.log(arg, context)
                for arg in seahub_args:
                    execute.log(arg, context)


        return res
Esempio n. 52
0
    def deploy_post_service(self, cr, uid, vals, context):
        super(saas_service, self).deploy_post_service(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'odoo':
            ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            # execute.execute(ssh, ['ln', '-s', vals['app_version_full_localpath'], '/opt/odoo/services/' + vals['service_name']], context)
            # execute.execute(ssh, ['mkdir', '/opt/odoo/' + vals['service_name'] + '/extra'], context)

            config_file = '/opt/odoo/' + vals['service_name'] + '/etc/config'
            execute.execute(ssh, ['mkdir', '-p', '/opt/odoo/' + vals['service_name'] + '/etc'], context)
            sftp.put(vals['config_conductor_path'] + '/saas/saas_odoo/res/openerp.config', config_file)
            addons_path = '/opt/odoo/' + vals['service_name'] + '/files/parts/odoo/addons,'
            for dir in  sftp.listdir('/opt/odoo/' + vals['service_name'] + '/files/extra'):
                addons_path += '/opt/odoo/' + vals['service_name'] + '/files/extra/' + dir + ','
            execute.execute(ssh, ['sed', '-i', '"s/ADDONS_PATH/' + addons_path.replace('/','\/') + '/g"', config_file], context)
            execute.execute(ssh, ['sed', '-i', '"s/APPLICATION/' + vals['app_code'] + '/g"', config_file], context)
            execute.execute(ssh, ['sed', '-i', 's/SERVICE/' + vals['service_name'] + '/g', config_file], context)
            execute.execute(ssh, ['sed', '-i', 's/DATABASE_SERVER/' + vals['database_server'] + '/g', config_file], context)
            execute.execute(ssh, ['sed', '-i', 's/DBUSER/' + vals['service_db_user'] + '/g', config_file], context)
            execute.execute(ssh, ['sed', '-i', 's/DATABASE_PASSWORD/' + vals['service_db_password'] + '/g', config_file], context)
            execute.execute(ssh, ['sed', '-i', 's/PORT/' + vals['service_options']['port']['localport'] + '/g', config_file], context)
            execute.execute(ssh, ['mkdir', '-p', '/opt/odoo/' + vals['service_name'] + '/filestore'], context)

            execute.execute(ssh, ['echo "[program:' + vals['service_name'] + ']" >> /opt/odoo/supervisor.conf'], context)
            execute.execute(ssh, ['echo "command=su odoo -c \'/opt/odoo/' + vals['service_name'] + '/files/parts/odoo/odoo.py -c ' + config_file  + '\'" >> /opt/odoo/supervisor.conf'], context)


            ssh.close()
            sftp.close()

        return
Esempio n. 53
0
 def deploy_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).deploy_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'shinken':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         file = 'base-shinken'
         if vals['base_nosave']:
             file = 'base-shinken-nosave'
         sftp.put(vals['config_conductor_path'] + '/saas/saas_shinken/res/' + file + '.config', vals['base_shinken_configfile'])
         execute.execute(ssh, ['sed', '-i', '"s/TYPE/base/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/UNIQUE_NAME/' + vals['base_unique_name_'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/DATABASES/' + vals['base_databases_comma'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/BASE/' + vals['base_name'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/DOMAIN/' + vals['domain_name'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/METHOD/' + vals['config_restore_method'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/CONTAINER/' + vals['backup_fullname'] + '/g"', vals['base_shinken_configfile']], context)
         execute.execute(ssh, ['/etc/init.d/shinken', 'reload'], context)
         ssh.close()
         sftp.close()
Esempio n. 54
0
    def deploy_post_service(self, cr, uid, vals, context):
        super(saas_service, self).deploy_post_service(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['app_code'] == 'gitlab':
            ssh, sftp = execute.connect(vals['container_fullname'], username='******', context=context)
            execute.execute(ssh, ['cp', vals['service_full_localpath_files'] + '/config/gitlab.yml.example', vals['service_full_localpath_files'] + '/config/gitlab.yml'], context)
            execute.execute(ssh, ['chown', '-R', 'git', vals['service_full_localpath_files'] + '/log'], context)
            execute.execute(ssh, ['chown', '-R', 'git', vals['service_full_localpath_files'] + '/tmp'], context)
            execute.execute(ssh, ['chmod', '-R', 'u+rwX,go-w', vals['service_full_localpath_files'] + '/log'], context)
            execute.execute(ssh, ['chmod', '-R', 'u+rwX,go-w', vals['service_full_localpath_files'] + '/tmp'], context)

            execute.execute(ssh, ['mkdir', vals['service_full_localpath'] + '/gitlab-satellites'], context)
            execute.execute(ssh, ['chmod', '-R', 'u+rwx,g=rx,o-rwx', vals['service_full_localpath'] + '/gitlab-satellites'], context)

            execute.execute(ssh, ['chmod', '-R', 'u+rwX', vals['service_full_localpath_files'] + '/tmp/pids'], context)
            execute.execute(ssh, ['chmod', '-R', 'u+rwX', vals['service_full_localpath_files'] + '/tmp/sockets'], context)
            execute.execute(ssh, ['chmod', '-R', 'u+rwX', vals['service_full_localpath_files'] + '/public/uploads'], context)

            execute.execute(ssh, ['cp', vals['service_full_localpath_files'] + '/config/unicorn.rb.example', vals['service_full_localpath_files'] + '/config/unicorn.rb'], context)
            execute.execute(ssh, ['cp', vals['service_full_localpath_files'] + '/config/initializers/rack_attack.rb.example', vals['service_full_localpath_files'] + '/config/initializers/rack_attack.rb'], context)
            execute.execute(ssh, ['cp', vals['service_full_localpath_files'] + '/config/resque.yml.example', vals['service_full_localpath_files'] + '/config/resque.yml'], context)
            execute.execute(ssh, ['chown', '-R', 'git', vals['service_full_localpath']], context)
            ssh.close()
            sftp.close()

        return
Esempio n. 55
0
 def deploy_post(self, cr, uid, vals, context):
     super(saas_container, self).deploy_post(cr, uid, vals, context)
     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
     if vals['apptype_name'] == 'postfix':
         ssh, sftp = execute.connect(vals['container_fullname'], context=context)
         execute.execute(ssh, ['echo "relayhost = [smtp.mandrillapp.com]" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "smtp_use_tls = yes" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "mynetworks = 127.0.0.0/8 172.17.0.0/16" >> /etc/postfix/main.cf'], context)
         execute.execute(ssh, ['echo "[smtp.mandrillapp.com]    ' + vals['config_mailchimp_username'] + ':' + vals['config_mailchimp_apikey'] + '" > /etc/postfix/sasl_passwd'], context)
         execute.execute(ssh, ['postmap /etc/postfix/sasl_passwd'], context)
         ssh.close()
         sftp.close()
Esempio n. 56
0
    def deploy_build(self, cr, uid, vals, context=None):
        res = super(saas_base, self).deploy_build(cr, uid, vals, context)
        context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
        if vals['apptype_name'] == 'piwik':

            ssh, sftp = execute.connect(vals['container_fullname'], context=context)
            config_file = '/etc/nginx/sites-available/' + vals['base_fullname']
            sftp.put(vals['config_conductor_path'] + '/saas/saas_piwik/res/nginx.config', config_file)
            execute.execute(ssh, ['sed', '-i', '"s/BASE/' + vals['base_name'] + '/g"', config_file], context)
            execute.execute(ssh, ['sed', '-i', '"s/DOMAIN/' + vals['domain_name'] + '/g"', config_file], context)
            execute.execute(ssh, ['sed', '-i', '"s/PATH/' + vals['service_full_localpath_files'].replace('/','\/') + '/g"', config_file], context)
            execute.execute(ssh, ['ln', '-s',  '/etc/nginx/sites-available/' + vals['base_fullname'],  '/etc/nginx/sites-enabled/' + vals['base_fullname']], context)
            execute.execute(ssh, ['/etc/init.d/nginx','reload'], context)
            ssh.close()
            sftp.close()
            #
            # ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
            # execute.execute(ssh, ['drush', '-y', 'si',
            #                       '--db-url=' + vals['app_bdd'] + '://' + vals['service_db_user'] + ':' + vals['service_db_password'] + '@' + vals['database_server'] + '/' + vals['base_unique_name_'],
            #                       '--account-mail=' + vals['apptype_admin_email'],
            #                       '--account-name=' + vals['apptype_admin_name'],
            #                       '--account-pass='******'base_admin_passwd'],
            #                       '--sites-subdir=' + vals['base_fulldomain'],
            #                       'minimal'], context, path=vals['service_full_localpath_files'])

            # if vals['app_options']['install_modules']['value']:
            #     modules = vals['app_options']['install_modules']['value'].split(',')
            #     for module in modules:
            #         execute.execute(ssh, ['drush', '-y', 'en', module], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
            # if vals['app_options']['theme']['value']:
            #     theme = vals['app_options']['theme']['value']
            #     execute.execute(ssh, ['drush', '-y', 'pm-enable', theme],context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
            #     execute.execute(ssh, ['drush', 'vset', '--yes', '--exact', 'theme_default', theme],context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
            # ssh.close()
            # sftp.close()


        return res



    # def deploy_post(self, cr, uid, vals, context=None):
    #     res = super(saas_base, self).deploy_post(cr, uid, vals, context)
    #     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
    #     if vals['apptype_name'] == 'drupal':
    #         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
    #         execute.execute(ssh, ['drush', 'vset', '--yes', '--exact', 'site_name', vals['base_title']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
    #         ssh.close()
    #         sftp.close()

    # def deploy_create_poweruser(self, cr, uid, vals, context=None):
    #     res = super(saas_base, self).deploy_create_poweruser(cr, uid, vals, context)
    #     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
    #     if vals['apptype_name'] == 'drupal':
    #
    #         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
    #         execute.execute(ssh, ['drush', 'user-create',  vals['base_poweruser_name'],  '--password='******'base_poweruser_password'], '--mail=' + vals['base_poweruser_email']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
    #         if vals['app_options']['poweruser_group']['value']:
    #             execute.execute(ssh, ['drush', 'user-add-role', vals['app_options']['poweruser_group']['value'], vals['base_poweruser_name']], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
    #         ssh.close()
    #         sftp.close()
    #
    #     return res

    #
    #
    # def update_base(self, cr, uid, vals, context=None):
    #     res = super(saas_base, self).update_base(cr, uid, vals, context)
    #     context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
    #     if vals['apptype_name'] == 'drupal':
    #         ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
    #         execute.execute(ssh, ['drush', 'updatedb'], context, path=vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'])
    #         ssh.close()
    #         sftp.close()
    #
    #     return res

# class saas_save_save(osv.osv):
#     _inherit = 'saas.save.save'
#
#
#     def deploy_base(self, cr, uid, vals, context=None):
#         res = super(saas_save_save, self).deploy_base(cr, uid, vals, context)
#         context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
#         if vals['apptype_name'] == 'drupal':
#             ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
# #            execute.execute(ssh, ['drush', 'archive-dump', vals['base_unique_name_'], '--destination=/base-backup/' + vals['saverepo_name'] + 'tar.gz'], context)
#             execute.execute(ssh, ['cp', '-R', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain'], '/base-backup/' + vals['saverepo_name'] + '/site'], context)
#             ssh.close()
#             sftp.close()
#         return
#
#
#     def restore_base(self, cr, uid, vals, context=None):
#         res = super(saas_save_save, self).restore_base(cr, uid, vals, context)
#         context.update({'saas-self': self, 'saas-cr': cr, 'saas-uid': uid})
#         if vals['apptype_name'] == 'drupal':
#             ssh, sftp = execute.connect(vals['container_fullname'], username=vals['apptype_system_user'], context=context)
#             execute.execute(ssh, ['rm', '-rf', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain']], context)
#             execute.execute(ssh, ['cp', '-R', '/base-backup/' + vals['saverepo_name'] + '/site', vals['service_full_localpath_files'] + '/sites/' + vals['base_fulldomain']], context)
#             ssh.close()
#             sftp.close()
#         return
Esempio n. 57
0
 def purge_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).purge_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'postfix' and vals['apptype_name'] == 'odoo':
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.execute(ssh, ['sed', '-i', '"/^mydestination =/ s/, ' + vals['base_fulldomain'] + '//"', '/etc/postfix/main.cf'], context)
         execute.execute(ssh, ['sed', '-i', '"/@' + vals['base_fulldomain'] + '/d"', '/etc/postfix/virtual_aliases'], context)
         execute.execute(ssh, ['postmap' , '/etc/postfix/virtual_aliases'], context)
         execute.execute(ssh, ['sed', '-i', '"/d\s' + vals['base_unique_name_'] + '/d"', '/etc/aliases'], context)
         execute.execute(ssh, ['newaliases'], context)
         execute.execute(ssh, ['/etc/init.d/postfix', 'reload'], context)
         ssh.close()
         sftp.close()
Esempio n. 58
0
 def deploy_link(self, cr, uid, vals, context={}):
     super(saas_base_link, self).deploy_link(cr, uid, vals, context=context)
     if vals['link_target_app_code'] == 'proxy':
         if not vals['base_sslonly']:
             file = 'proxy.config'
         else:
             file = 'proxy-sslonly.config'
         ssh, sftp = execute.connect(vals['link_target_container_fullname'], context=context)
         execute.send(sftp, vals['config_conductor_path'] + '/saas/saas_' + vals['apptype_name'] + '/res/' + file, vals['base_nginx_configfile'], context)
         execute.execute(ssh, ['sed', '-i', '"s/BASE/' + vals['base_name'] + '/g"', vals['base_nginx_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/DOMAIN/' + vals['domain_name'] + '/g"', vals['base_nginx_configfile']], context)
         execute.execute(ssh, ['sed', '-i', '"s/SERVER/' + vals['server_domain'] + '/g"', vals['base_nginx_configfile']], context)
         if 'port' in vals['service_options']:
             execute.execute(ssh, ['sed', '-i', '"s/PORT/' + vals['service_options']['port']['hostport'] + '/g"', vals['base_nginx_configfile']], context)
         # self.deploy_prepare_apache(cr, uid, vals, context)
         cert_file = '/etc/ssl/certs/' + vals['base_name'] + '.' + vals['domain_name'] + '.crt'
         key_file = '/etc/ssl/private/' + vals['base_name'] + '.' + vals['domain_name'] + '.key'
         if vals['base_certcert'] and vals['base_certkey']:
             execute.execute(ssh, ['echo', '"' + vals['base_certcert'] + '"', '>', cert_file], context)
             execute.execute(ssh, ['echo', '"' + vals['base_certkey'] + '"', '>', key_file], context)
         elif vals['domain_certcert'] and vals['domain_certkey']:
             execute.execute(ssh, ['echo', '"' + vals['domain_certcert'] + '"', '>', cert_file], context)
             execute.execute(ssh, ['echo', '"' + vals['domain_certkey'] + '"', '>', key_file], context)
         else:
             execute.execute(ssh, ['openssl', 'req', '-x509', '-nodes', '-days', '365', '-newkey', 'rsa:2048', '-out', cert_file, ' -keyout',  key_file, '-subj', '"/C=FR/L=Paris/O=' + vals['domain_organisation'] + '/CN=' + vals['base_name'] + '.' + vals['domain_name'] + '"'], context)
         execute.execute(ssh, ['ln', '-s', vals['base_nginx_configfile'], '/etc/nginx/sites-enabled/' + vals['base_unique_name']], context)
         execute.execute(ssh, ['/etc/init.d/nginx', 'reload'], context)
         ssh.close()
         sftp.close()