executing python-heatclient CLI from Apache python cgi-bin

asked 2015-03-14 12:51:51 -0500

bbb gravatar image

I have this following code as get_status.py

#!/usr/bin/env python
from cgi import escape
from flup.server.fcgi import WSGIServer
import commands
import subprocess

def do_get_status():
    cmd = """/usr/bin/heat --os-username admin --os-password admin --os-tenant-name admin --os-auth-url stack-show demo_stack"""
    status, out = commands.getstatusoutput(cmd)
    return "<pre>" + str(out) + "</pre>"

def app(environ, start_response):

    # initialise and login to the website
    #test = testpost.cookie(target_url,username, password)
    qs = environ['QUERY_STRING']
    result = do_get_status()

    start_response('200 OK', [('Content-Type', 'text/html')])
    return result


but when I do ( the output I am getting is

Unable to establish connection to

That python script is running in apache cgi-bin. It was perfectly working fine 2 days back, but after updating the openstack stack setup now it stopped working all of a sudden. If I take command and run it on command line I get the expected result. I even tried running same piece of code with python get_status.py and I get the expected results. I am not able to understand what could be the prob.

edit retag flag offensive close merge delete