コード例 #1
0
def run_remote():
    remote = env.remote_map[env.host]

    root, dirname = CONF._repo_dir.rsplit('/', 1)
    storage_dir = os.path.join(dirname, CONF._storage_dir.rsplit('/', 1)[1])

    repo_tar = '{0}/fabrepo.tar.gz'.format(CONF._tmp_dir)
    remote_repo = '{0}/fabrepo'.format(CONF._remote_tmp_dir)
    remote_repo_tar = '{0}/fabrepo.tar.gz'.format(CONF._remote_tmp_dir)
    local('cd {0} && tar -zcf {1} {2} --exclude .git --exclude {3}'.format(
        root, repo_tar, dirname, storage_dir))
    scp(repo_tar, remote_repo_tar)
    run('rm -rf $HOME/fabric-repo')
    run('cd {0} && tar -xf fabrepo.tar.gz -C $HOME'.format(CONF._remote_tmp_dir, remote_repo))

    task_name = ''
    if env.is_setup:
        task_name = 'setup'
    elif env.is_check:
        task_name = 'check'
    elif env.is_manage:
        task_name = 'manage:{0}'.format(','.join(env.func_names))

    cluster_map = {}
    with api.shell_env(password=env.password):
        for cluster in remote['clusters']:
            run('cd $HOME/{0} && fab node:{1}/{2},yes {3} -u $USER -p $password'.format(
                dirname, cluster, remote['host_pattern'], task_name, env.password))
            with api.warn_only():
                yaml_str = run('cat $HOME/{0}/nodes/{1}/__cluster.yml'.format(dirname, cluster))
            cluster_map[cluster] = yaml.load(yaml_str)

    return cluster_map
コード例 #2
0
 def create_tar(self):
     if env.host == env.hosts[0]:
         local('rm -rf /tmp/fabfile && '
               'cp -r {0} /tmp/fabfile && '
               'find /tmp/fabfile -name .git | xargs rm -rf && '
               'cd /tmp/ && tar cfz fabfile.tar.gz fabfile'.format(
                   CONF._fabfile_dir))
コード例 #3
0
 def create_tar(self):
     if env.host == env.hosts[0]:
         local(
             'rm -rf /tmp/fabfile && '
             'cp -r {0} /tmp/fabfile && '
             'find /tmp/fabfile -name .git | xargs rm -rf && '
             'cd /tmp/ && tar cfz fabfile.tar.gz fabfile'.format(CONF._fabfile_dir)
         )
コード例 #4
0
def runserver(*args, **kwargs):
    len_args = len(args)
    certdir = os.path.join(CONF._storage_dir, 'cert')
    certfile = os.path.join(certdir, 'server.crt')
    csrfile = os.path.join(certdir, 'server.csr')
    keyfile_tmp = os.path.join(certdir, 'server.key.tmp')
    keyfile = os.path.join(certdir, 'server.key')

    if len_args > 0 and 'create_cert' in args:
        if not os.path.exists(certdir):
            os.mkdir(certdir)

        print '\nCreate private key: {0}'.format(keyfile_tmp)
        if not os.path.exists(keyfile_tmp):
            local('openssl genrsa -aes128 -out {0} 4096'.format(keyfile_tmp))
        else:
            print '{0} is already exists.'.format(keyfile_tmp)

        print '\nCreate CSR: {0}'.format(csrfile)
        if not os.path.exists(csrfile):
            local('openssl req -new -key {0} -sha256 -out {1}'.format(keyfile_tmp, csrfile))
        else:
            print '{0} is already exists.'.format(csrfile)

        print '\nCreate SSL certificate (public key): {0}'.format(certfile)
        if not os.path.exists(certfile):
            local('openssl x509 -in {0} -days 365 -req -signkey {1} -sha256 -out {2}'.format(
                csrfile, keyfile_tmp, certfile))
        else:
            print '{0} is already exists.'.format(certfile)

        print '\nCreate Decryption private key: {0}'.format(keyfile)
        if not os.path.exists(keyfile):
            local('openssl rsa -in {0} -out {1}'.format(keyfile_tmp, keyfile))
        else:
            print '{0} is already exists.'.format(keyfile)

        return

    from django.core.wsgi import get_wsgi_application
    import pymysql
    pymysql.install_as_MySQLdb()

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "web_conf.settings")
    application = get_wsgi_application()

    wsgi.server(eventlet.listen(('', 8080)), application)