Beispiel #1
0
def esxiInstalled():
    mac = request.args.get('mac')
    print(request.remote_addr)
    print(mac)
    host = findByMac(mac) 
    host['status'] = 2
    write(host)
    p = Popen(["ssh", "-oStrictHostKeyChecking=no", "-oUserKnownHostsFile=/dev/null", "-o", "LogLevel=quiet", "root@" + request.remote_addr, "esxcli hardware platform get"], stdout=PIPE, stderr=PIPE)
    out, error = p.communicate()
    print(out)
    now = datetime.now()
    print(now.isoformat())
    return now.isoformat()
Beispiel #2
0
def addHosts():
    if request.method == 'GET':
        with open('hosts.json', 'r+') as file:
            hostSet = json.load(file)
        
        hosts = [hostSet[x] for x in sorted(hostSet.keys())] 
        
        data = {"data": hosts}

        print data
        return Response(json.dumps(data), mimetype='application/json', headers={'Cache-Control': 'no-cache'}) 
    if request.method == 'POST':
        host = request.form.to_dict()
        write(host)        
        return 'Ok'