Example #1
0
def createpvcs():
    try:
        token = request.args.get('token')
        namespace = request.args.get('namespace')
        pvname = request.args.get('pvname')
        pvcname = request.args.get('pvcname')
        print("token: ", token)
        print("namespace: ", namespace)
        print("pvname: ", pvname)
        print("pvcname: ", pvcname)
        if hastoken(token):
            srv, path = getpvnfsinfo(token, pvname)
            if srv is not "none" and path is not "none":
                if checkpvrbac(token, srv, path):
                    createpvc = cpvc(namespace, pvcname, pvname)
                    return createpvc
                else:
                    return '"message": {"auth": "failed"}'
            else:
                return '"message": {"auth": "failed"}'
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked!"}"'
Example #2
0
def deletepvcs():
    try:
        token     = request.args.get('token')
        pvcname   = request.args.get('pvcname')
        namespace = request.args.get('namespace')
        clstr     = request.args.get('cluster')
        print("token: ", token)
        print("pvcname: ", pvcname)
        print("namespace: ", namespace)
        if hastoken(token):
            gpv = getpv(clstr, namespace, pvcname)
            srv, path = getpvnfsinfo(clstr, token, gpv)
            if srv is not "none" and path is not "none":
                if checkpvrbac(clstr, token, srv, path):
                    deletepvc = dpvc(clstr, namespace, pvcname)
                    return deletepvc
                else:
                   return '"message": {"auth": "failed"}'
            else:
                return '"message": {"auth": "failed"}'
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked!"}"'
Example #3
0
def gpvs():
    try:
        token = request.args.get('token')
        if hastoken(token):
            gtpvs = getpvs()
            return gtpvs
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked in getpvs"}"'
Example #4
0
def gassls():
    try:
        token = request.args.get('token')
        if hastoken(token):
            gta = getrbac(token)
            return gta
        else:
            return '"message": {"getauth": "dont seem to have any pvs authorized"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked in getauth"}"'
Example #5
0
def gpvcs():
    try: 
        token     = request.args.get('token')
        namespace = request.args.get('namespace')
        clstr = request.args.get('cluster')
        if hastoken(token):
            gtpvcs = getpvcs(clstr, namespace)
            return gtpvcs
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked in getpvs"}"'
Example #6
0
def deletepvs():
    try:
        token = request.args.get('token')
        pvname = request.args.get('pvname')
        print("token: ", token)
        print("pvname: ", pvname)
        if hastoken(token):
            server, mount = getpvnfsinfo(token, pvname)
            getrbac = checkpvrbac(token, server, mount)
            if getrbac:
                deletepv = dpv(pvname)
                return deletepv
            else:
                return '"message": {"auth": "failed"}'
            return '"message": {"auth": "failed"}'
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked!"}"'
Example #7
0
def createpvs():
    try:
        token = request.args.get('token')
        pvname = request.args.get('pvname')
        server = request.args.get('nfsserver')
        path = request.args.get('path')
        print("token: ", token)
        print("pvname: ", pvname)
        print("server: ", server)
        print("path: ", path)
        if hastoken(token):
            if checkpvrbac(token, server, path):
                createpv = cpv(pvname, server, path)
                return createpv
            else:
                return '"message": {"auth": "failed"}'
        else:
            return '"message": {"auth": "failed"}'
    except Exception as e:
        print("error: %s", e)
        return '"message": {"error": "Something borked!"}"'
Example #8
0
def getauth():
    token = request.args.get('token')
    if hastoken(token):
        return 'getauth'
    else:
        return '"message": {"auth": "failed"}'