Пример #1
0
def chgPwd(req,userid,pwd):
    ip_addr=req.META.get("REMOTE_ADDR",None)
    user=framework.getApiUserByToken(req)
    #user="******"
    if not user:
        return HttpResponse(RTN_500 % "Unknow auth token request." )
    print "chgPwd(ip:%s)---%s update password=%s where userid=%s" % (ip_addr,user,pwd,userid)
    password=passlib.hash.sha512_crypt.encrypt(pwd,rounds=40000)
    C2Keystone().chgPwd(userid,password)
    return HttpResponse(RTN_200 % "update password success")
Пример #2
0
Файл: eva.py Проект: hum1/mana
def controller(req,ip,region=settings.REGIONS):
    if not checker.IsIpAddr(ip):
	rtn="check ip(%s) address failed" % ip
    else:
	ip_addr=req.META.get("REMOTE_ADDR",None)
	user=framework.getApiUserByToken(req)
	if not user:
	    return HttpResponse(RTN_500 % "Unknow auth token request." )
	regions=[]
	if not region ==settings.REGIONS:
	    regions.append(region)
	else:
	    regions=region
	rtn=eva(ip,regions)
	EvaLog().addLog(user,ip,rtn,ip_addr)
    return HttpResponse(rtn)
Пример #3
0
def chgPwd(req,uuid,region,pwd):
    user=framework.getApiUserByToken(req)
    #if not user:
    #return HttpResponse(RTN_500 % "Unknow auth token request.")
    hostInfo=InstanceManager().getHostIp(NOVA_DB(region),uuid)
    if not hostInfo:
        return HttpResponse(RTN_500 % ("Can't find host ip by uuid(%s) in Region(%s)" % (uuid,region)))
    host_ip=hostInfo["host_ip"]

    #change private to public ip
    host_ip=getConnIp(host_ip)

    instid=int(hostInfo["id"])
    vir="instance-%s" % hex(instid)[2:].zfill(8)
    script_name=settings.C2_CHANGE_VIR_PWD_SCRIPT
    exe="%s %s %s" %(script_name,vir,pwd)
    print "runScript--->host_ip:%s,exe:%s" % (host_ip,exe)
    try:
        LOG=c2_ssh.conn(host_ip,exe)
    except Exception,ex:
        print Exception,":",ex
        LOG="SSH exception:%s" % str(ex)
Пример #4
0
def getUserNetwork2(req,region,tenant_id,networkname):
    user=framework.getApiUserByToken(req)
    if not user:
        return HttpResponse(RTN_500 % "Unknow auth token request." )
    return getUserNetwork(req,region,tenant_id,networkname)