Exemple #1
0
 def do_GET(self):
     #p = self.path[1:]
     if self.path[1:] == "ip_default":
         self.send_response(200)
         self.send_header('Content-type','text/html')
         self.end_headers()
         self.wfile.write(str(theIP("eth0"))) #call sample function here
         return
     elif self.path[1:11] == "test_query":
         parsed_path = urlparse.urlparse(self.path)
         message_parts = [
             'CLIENT VALUES:',
             'client_address=%s (%s)' % (self.client_address,
                                         self.address_string()),
             'command=%s' % self.command,
             'path=%s' % self.path,
             'real path=%s' % parsed_path.path,
             'query=%s' % parsed_path.query,
             'request_version=%s' % self.request_version,
             '',
             'SERVER VALUES:',
             'server_version=%s' % self.server_version,
             'sys_version=%s' % self.sys_version,
             'protocol_version=%s' % self.protocol_version,
             '',
             'HEADERS RECEIVED:',
             ]
         for name, value in sorted(self.headers.items()):
             message_parts.append('%s=%s' % (name, value.rstrip()))
         message_parts.append('')
         message = '\r\n'.join(message_parts)
         self.send_response(200)
         self.end_headers()
         self.wfile.write(message)
     elif self.path[1:9] == "ip_query":
         parsed_path = urlparse.urlparse(self.path)
         self.send_response(200)
         self.send_header('Content-type','text/html')
         self.end_headers()
         if "i=" in parsed_path.query:
             iface= parsed_path.query.replace("i=","")
         self.wfile.write(str(theIP(iface))) #call sample function here
     else:
         #print super
         SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
Exemple #2
0
def createrc(d):
    if not d:
        d = {}
    tmpstr = d.get("SSD_PATH","")
    if tmpstr:
        tmpc = open("/home/xeven/x7env","w")
        tmpc.write("SSDDEV={0}\n".format(tmpstr))
        tmpc.close()
    print d
    c = open("/home/xeven/localrc_server_template","w")
    
    tmpstr = d.get("FLAT_INTERFACE","eth0")
    ip = theIP(tmpstr)
    c.write("HOST_IP={0}\n".format(ip.ipaddr))
    c.write("FLAT_INTERFACE={0}\n".format(tmpstr))

    tmpstr = d.get("FIXED_RANGE",r"10.10.10.0/24")
    c.write("FIXED_RANGE={0}\n".format(tmpstr))

    tmpstr = d.get("FIXED_NETWORK_SIZE",r"256")
    c.write("FIXED_NETWORK_SIZE={0}\n".format(tmpstr))

    tmpstr = d.get("FLOATING_RANGE", "{0}/25".format(ip.brdcast))
    c.write("FLOATING_RANGE={0}\n".format(tmpstr))
    c.write("MULTI_HOST=1\n")
    c.write("SERVICE_TOKEN=xyzpdqlazydog\n")

    tmpstr = d.get("MYSQL_PASSWORD","gadmei")
    c.write("MYSQL_PASSWORD={0}\n".format(tmpstr))

    tmpstr = d.get("RABBIT_PASSWORD","gadmei")
    c.write("RABBIT_PASSWORD={0}\n".format(tmpstr))

    tmpstr = d.get("ADMIN_PASSWORD","gadmei")
    c.write("ADMIN_PASSWORD={0}\n".format(tmpstr))

    tmpstr = d.get("SERVICE_PASSWORD","gadmei")
    c.write("SERVICE_PASSWORD={0}\n".format(tmpstr))

    tmpstr = d.get("VOLUMN_SELECTED",None)
    if tmpstr == "File":
        tmpstr = d.get("VOLUMN_SELECTED_RESULT","10G")
        c.write("VOLUME_BACKING_FILE_SIZE={0}\n".format(tmpstr))
    elif tmpstr == "Device":
        tmpstr = d.get("VOLUMN_SELECTED_RESULT","")
        if tmpstr:
            c.write("VOLUMDEV={0}\n".format(tmpstr))
            pass
    else:
        pass

    servertype = d.get("Select_x7","server")
    if servertype == "server":
        c.write("ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-net,n-vol,n-sch,n-cauth,horizon,mysql,rabbit\n")
    elif servertype == "all":
        c.write("ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-net,n-vol,n-sch,n-cauth,horizon,mysql,rabbit,n-cpu,n-vol,n-novnc,n-xvnc\n")
        c.write("MYSQL_HOST={0}\n".format(ip.ipaddr))
        c.write("RABBIT_HOST={0}\n".format(ip.ipaddr))
        c.write("GLANCE_HOSTPORT={0}:9292\n".format(ip.ipaddr))
        c.write("SERVICE_HOST={0}\n".format(ip.ipaddr))
        c.write("NOVNCPROXY_URL=http://{0}:6080/vnc_auto.html\n".format(ip.ipaddr))
        c.write("XVPVNCPROXY_URL=http://{0}:6081/console\n".format(ip.ipaddr))
    else:
        print servertype
        raise
    c.close()