GAE是否需要某种WSGI(https://cloud.google.com/appengine/docs/python/tools/webapp/running)?这就像HTTPD的CGI配置吗? 即,在
app.yaml
我必须有script.app
和参考app
到一个wsgi/webapp对象?GAE运行Python脚本和GCE权限试图使用
AppAssertionCredentials
从GAE到GCE进行身份验证。 我做了另一个脚本,该片段在工作:
credentials = AppAssertionCredentials( scope='https://www.googleapis.com/auth/compute') auth_http = credentials.authorize(httplib2.Http()) compute = discovery.build('compute', 'v1', http=auth_http)
我试图现在要做的就是创建一个使用REST API从GAE GCE快照。 我不明白如何引用我的POST
的compute
对象,以便获得auth的工作(现在获得未授权)。
这是我的脚本(太多import
原因可能会测试):
import requests
import urllib2
import logging
import sys
import argparse
import httplib2
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client import tools
from oauth2client.tools import run_flow
from oauth2client.appengine import AppAssertionCredentials
from google.appengine.api import memcache
import datetime
import httplib2
import json
import logging
from pprint import pformat
from apiclient import discovery
from google.appengine.api import memcache
from oauth2client.appengine import AppAssertionCredentials
import cgi
from google.appengine.api import users
import urllib
from google.appengine.api import users
from google.appengine.ext import ndb
import time
PROJECT = "testprojgce"
ZONE = "europe-west1-b"
### OAuth2
credentials = AppAssertionCredentials(
scope='https://www.googleapis.com/auth/compute')
auth_http = credentials.authorize(httplib2.Http())
compute = discovery.build('compute', 'v1', http=auth_http)
# Create snapshot
createsnapurl= "https://www.googleapis.com/compute/v1/projects/"+PROJECT+"/zones/"+ZONE+"/disks/testdisk1/createSnapshot"
req=requests.post(createsnapurl)
请坚持“每个问题一个问题” - 这是非常基本的StackOverflow礼仪。仅关注问题1,是的:GAE的Web服务器的2.7 Python运行时通过您的WSGI应用程序(应用程序)连接到您的代码。yaml可以派发给其中的一个或多个),就像任何其他web服务器一样 - 任何您选择的任何Python框架都可以轻松实现这些(我建议您的用例是一个轻量级框架,例如猎鹰,烧瓶,瓶子,或webapp2,而不是像django或web2py这样的丰富而重的完整版本 - 当然,这是您的选择)。 –
怀疑是否打开“这是一个2部分问题”或类似的东西。对不起,因为违反了礼仪。 – PyGAE