About Using App Engine to start a Compute Engine VM problem

163 views
Skip to first unread message

育峰吳

unread,
Sep 14, 2017, 10:46:36 PM9/14/17
to Google App Engine
Hi,
I want to build an app engine task runing using corn service to start and stop the VM instance.
I find some example file on github :https://github.com/fivunlm/app-engine-start-vm.
And I modify the code to test, I use google cloud shell to deploy the app engine application("gcloud app depoly app.yaml" to deploy )
but I got the "Internal Server Error" , when I go to https://projectname.appspot.com/vm/start.
Then,I try to test then add the code in main.py file
'''
@app.route('/vm')
def vm():
    credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/compute')
    result = credentials
    return json.dumps(result, indent=4)
'''
The I got the same result "Internal Server Error".
Does anyone have an idea about this problem?

育峰吳

unread,
Sep 15, 2017, 9:04:45 AM9/15/17
to Google App Engine
I get the answer.
The  API about discover got the error ,because the result is too large to memcache.
 ValueError: Values may not be more than 1000000 bytes in length; received 1014315 bytes.

So  I modify the code in main.py file
'''
@app.route('/vm/start')
def start_vm():

    credentials = AppAssertionCredentials(scope='https://www.googleapis.com/auth/compute')
    http = credentials.authorize(httplib2.Http(memcache))
    api_start_uri = 'https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{instance}/start'
    api_start_uri = api_start_uri.format(project=PROJECT, zone=INSTANCE_ZONE, instance=INSTANCE_NAME)
    response, result = http.request(
        uri=api_start_uri,
        method='POST'
        )
return result, 200, {'Content-Type': 'application/json'}
''''

George (Cloud Platform Support)

unread,
Sep 15, 2017, 10:35:15 AM9/15/17
to Google App Engine
Did this modification solve your issue? 

For strictly code-related issues you are encouraged to rather post to stackoverflow or similar forums, where programming experts are ready to help. Groups are meant for general discussion and opinions.
Reply all
Reply to author
Forward
0 new messages