def ztptemplate():
    authOK = classes.checkAuth("ztptemplateaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        formresult = request.form
        # Obtain the relevant device information from the database
        result = classes.ztptemplatedbAction(formresult)
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            print(result['message'])
            return render_template("ztptemplate.html",
                                   result=result['result'],
                                   message=result['message'],
                                   formresult=formresult,
                                   totalentries=int(result['totalentries']),
                                   pageoffset=int(result['pageoffset']),
                                   entryperpage=int(result['entryperpage']),
                                   authOK=authOK,
                                   sysvars=sysvars)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #2
0
def afcswitches():
    authOK = classes.checkAuth("afcswitchesaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        try:
            formresult = request.form
        except:
            formresult = []
        result = classes.getafcSwitches(formresult)
        message = ""
        if result['afcfabrics'] == "Authentication token header required":
            result['afcswitches'] = []
            result['afcfabric'] = ""
            result['afcfabrics'] = []
            message = result['afcfabrics']
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("afcswitches.html",
                                   formresult=formresult,
                                   afcfabrics=result['afcfabrics'],
                                   afcswitches=result['afcswitches'],
                                   afcfabric=result['afcfabric'],
                                   message=message,
                                   totalentries=result['totalentries'],
                                   pageoffset=result['pageoffset'],
                                   entryperpage=result['entryperpage'],
                                   authOK=authOK,
                                   sysvars=sysvars)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
def ipamgetIPaddress():
    sysvars = classes.globalvars()
    formresult = request.form
    if sysvars['ipamsystem'] == "PHPIPAM":
        ipamsubnet = classes.PHPipamget('subnets/{}'.format(
            formresult['subnetid']))
        # Obtain the active IP addresses from the subnet
        ipamIpaddress = classes.PHPipamget('subnets/{}/addresses'.format(
            formresult['subnetid']))
        response = {
            'ipamsubnet': ipamsubnet,
            'ipamIpaddress': ipamIpaddress,
            'sysvars': sysvars
        }
    elif sysvars['ipamsystem'] == "Infoblox":
        ipamsubnet = classes.getInfoblox(
            "network?network={}&_return_fields%2B=options,members".format(
                formresult['subnetid']))
        ipamIpaddress = classes.getInfoblox(
            'ipv4address?status=USED&network={}&_return_as_object=1'.format(
                formresult['subnetid']))
        response = {
            'ipamsubnet': ipamsubnet,
            'ipamIpaddress': ipamIpaddress,
            'sysvars': sysvars
        }
    return json.dumps(response)
Exemple #4
0
def afcvmareinventory():
    authOK = classes.checkAuth("afcvmwareinventoryaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        try:
            formresult = request.form
        except:
            formresult = []
        queryStr = "select * from afc where infotype='vmwareinventory'"
        afcvmwareinventory = classes.sqlQuery(queryStr, "selectone")
        if afcvmwareinventory == None:
            afcvmwareinventory = {}
            afcvmwareinventory['jsondata'] = []
            afcvmwareinventory[
                'message'] = "No VMWare inventory information available"
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template(
                "afcvmwareinventory.html",
                formresult=formresult,
                afcvmwareinventory=json.dumps(afcvmwareinventory),
                authOK=authOK,
                sysvars=sysvars)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #5
0
def editdeviceattribute():
    formresult=request.form
    sysvars=classes.globalvars()
    queryStr="select * from deviceattributes where id='{}'".format(formresult['id'])
    # Obtain the relevant device attribute information from the database
    result=classes.sqlQuery(queryStr,"selectone")
    return json.dumps(result)
def showDevice():
    # Show the device information from the selected device
    globalvars = classes.globalvars()
    # Obtain the device information from the database
    queryStr = "select id, description, ipaddress, platform, sysinfo, ostype, ports, vsx, vsxlags, vrf, vsf, bps, routeinfo from devices where id='{}'".format(
        request.args.get('deviceid'))
    deviceinfo = classes.sqlQuery(queryStr, "selectone")
    if deviceinfo['ostype'] == "arubaos-cx":
        vsfinfo = []
        if isinstance(deviceinfo['vsf'], str):
            vsfitems = json.loads(deviceinfo['vsf'])
        else:
            vsfitems = deviceinfo['vsf']
        try:
            for items in vsfitems[1]:
                vsfinfo.append(vsfitems[1][items])
            vsfstatus = vsfitems[0]
        except:
            vsfstatus = {}
        return render_template("showcxdevice.html",
                               deviceid=request.args.get('deviceid'),
                               ipaddress=deviceinfo['ipaddress'],
                               description=deviceinfo['description'],
                               platform=deviceinfo['platform'],
                               sysinfo=json.loads(deviceinfo['sysinfo']),
                               portinfo=json.loads(deviceinfo['ports']),
                               vsxinfo=json.loads(deviceinfo['vsx']),
                               vsxlags=json.loads(deviceinfo['vsxlags']),
                               vrfinfo=json.loads(deviceinfo['vrf']),
                               vsfinfo=vsfinfo,
                               vsfstatus=vsfstatus,
                               routeinfo=json.loads(deviceinfo['routeinfo']),
                               globalvars=globalvars)
    elif deviceinfo['ostype'] == "arubaos-switch":
        # Check whether the device is a stackable or standalone device. The json structure is different so rendering different scripts
        sysinfo = json.loads(deviceinfo['sysinfo'])
        vsfinfo = json.loads(deviceinfo['vsf'])
        bpsinfo = json.loads(deviceinfo['bps'])
        if 'vsf_member_element' in sysinfo:
            return render_template("showdevicevsf.html",
                                   deviceid=request.args.get('deviceid'),
                                   ipaddress=deviceinfo['ipaddress'],
                                   description=deviceinfo['description'],
                                   sysinfo=sysinfo,
                                   vsfinfo=vsfinfo)
        elif 'bps_member_element' in sysinfo:
            return render_template("showdevicebps.html",
                                   deviceid=request.args.get('deviceid'),
                                   ipaddress=deviceinfo['ipaddress'],
                                   description=deviceinfo['description'],
                                   sysinfo=sysinfo,
                                   bpsinfo=bpsinfo)
        else:
            return render_template("showdevicesa.html",
                                   deviceid=request.args.get('deviceid'),
                                   ipaddress=deviceinfo['ipaddress'],
                                   description=deviceinfo['description'],
                                   sysinfo=sysinfo)
    else:
        return ('', 204)
Exemple #7
0
def gateways():
    authOK = classes.checkAuth("mobilityaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        formresult = request.form
        # Obtain the relevant Mobility Controller information from the database
        result = classes.mobilitydbAction(formresult)
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("gateways.html",
                                   result=result['result'],
                                   platformResult=result['platformResult'],
                                   osversionResult=result['osversionResult'],
                                   formresult=formresult,
                                   totalentries=int(result['totalentries']),
                                   pageoffset=int(result['pageoffset']),
                                   entryperpage=int(result['entryperpage']),
                                   authOK=authOK,
                                   sysvars=sysvars)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #8
0
def switches():
    authOK = classes.checkAuth("switchaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        formresult = request.form
        # Obtain the relevant device information from the database
        result = classes.devicedbAction(formresult)
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("switch.html",
                                   result=result['result'],
                                   switchos=result['switchos'],
                                   platforms=result['platforms'],
                                   formresult=formresult,
                                   totalentries=int(result['totalentries']),
                                   pageoffset=int(result['pageoffset']),
                                   entryperpage=int(result['entryperpage']),
                                   authOK=authOK,
                                   sysvars=sysvars,
                                   entryExists=result['entryExists'])
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #9
0
def telemetry():
    authOK = classes.checkAuth("telemetry", "menu")
    if authOK != 0:
        # Check on which IP address the server is listening
        # Obtain the active IP address
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(("8.8.8.8", 80))
        hostip = s.getsockname()[0]
        sysvars = classes.globalvars()
        formresult = request.form
        # Obtain the relevant device information from the database
        result = classes.telemetrydbAction(formresult)
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("telemetry.html",
                                   result=result['result'],
                                   formresult=formresult,
                                   totalentries=int(result['totalentries']),
                                   pageoffset=int(result['pageoffset']),
                                   entryperpage=int(result['entryperpage']),
                                   authOK=authOK,
                                   sysvars=sysvars,
                                   hostip=hostip)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #10
0
def subscriptions():
    formresult = request.form
    sysvars = classes.globalvars()
    # Perform actions based on the form input

    if "resource" in formresult:
        resource = formresult['resource']
    else:
        resource = ""
    if "subscriber" in formresult:
        subscriber = formresult['subscriber']
    else:
        subscriber = ""
    if "addSubscription" in formresult:
        addSubscription = formresult['addSubscription']
    else:
        addSubscription = ""
    if "confirmDelete" in formresult:
        confirmDelete = formresult['confirmDelete']
    else:
        confirmDelete = 0
    deviceinfo = classes.subscriptionAction(formresult['action'],
                                            formresult['id'], subscriber,
                                            resource, addSubscription,
                                            confirmDelete)
    return json.dumps({
        'deviceinfo': deviceinfo,
        'subscriptions': deviceinfo['subscriptions']
    })
Exemple #11
0
def resetClient():
    sysvars = classes.globalvars()
    formresult = request.form
    result = classes.clearClient(formresult['deviceid'],
                                 formresult['macaddress'], formresult['port'],
                                 formresult['authmethod'])
    return json.dumps(result)
def deleteztpdevice():
    sysvars = classes.globalvars()
    formresult = request.form
    queryStr = "delete from ztpdevices where id='{}'".format(
        request.form['deviceid'])
    response = classes.sqlQuery(queryStr, "delete")
    return json.dumps(response)
Exemple #13
0
def backupInfo():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from configmgr where id='{}'".format(formresult['id'])
    # Obtain the relevant device information from the database
    result = classes.sqlQuery(queryStr, "selectone")
    return json.dumps(result)
Exemple #14
0
def getuserinfo():
    formresult=request.form
    sysvars=classes.globalvars()
    queryStr="select * from sysuser where id='{}'".format(formresult['userid'])
    userinfo=classes.sqlQuery(queryStr,"selectone")
    userinfo['password']=classes.decryptPassword(sysvars['secret_key'], userinfo['password'])
    return json.dumps(userinfo)
def ztpCredentials():
    sysvars = classes.globalvars()
    formresult = request.form
    response = classes.verifyCredentials(formresult['deviceid'],
                                         formresult['username'],
                                         formresult['password'], sysvars)
    return json.dumps(response)
def checkIpamstatus():
    sysvars = classes.globalvars()
    if "ipamenabled" in sysvars:
        # IPAM is enabled. Check whether IPAM is online
        if sysvars['ipamsystem'] == "PHPIPAM":
            info = {
                'phpipamauth': sysvars['phpipamauth'],
                'ipamipaddress': sysvars['ipamipaddress'],
                'phpipamappid': sysvars['phpipamappid'],
                'ipamuser': sysvars['ipamuser'],
                'ipampassword': sysvars['ipampassword']
            }
            ipamstatus = classes.checkPhpipam(info)
        elif sysvars['ipamsystem'] == "Infoblox":
            info = {
                'ipamipaddress': sysvars['ipamipaddress'],
                'ipamuser': sysvars['ipamuser'],
                'ipampassword': sysvars['ipampassword']
            }
            ipamstatus = classes.checkInfoblox(info)
        else:
            ipamstatus = "Online"
    else:
        ipamstatus = "Online"
    return ipamstatus
def topoInfo():
    sysvars = classes.globalvars()
    formresult = request.form
    # Obtain the device status from the database
    result = classes.topoInfo(formresult['id'])
    topoInfo = {'nodes': result[0], 'links': result[1]}
    return json.dumps(topoInfo)
Exemple #18
0
def afcintegrations():
    authOK = classes.checkAuth("afcintegrationsaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        try:
            formresult = request.form
        except:
            formresult = []
        queryStr = "select * from afc where infotype='integrations'"
        result = classes.sqlQuery(queryStr, "selectone")
        if result is not None:
            if isinstance(result, str):
                result = json.loads(result)
            if result['jsondata'] == '"Authentication token header required"':
                message = "Authentication token header required"
                afcintegrations = "[]"
            else:
                message = ""
                afcintegrations = result['jsondata']
        else:
            afcintegrations = "[]"
            message = "No AFC integration information available"
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("afcintegrations.html",
                                   formresult=formresult,
                                   afcintegrations=afcintegrations,
                                   authOK=authOK,
                                   message=message,
                                   sysvars=sysvars)
        else:
            return render_template("noaccess.html", authOK=authOK)
    else:
        return render_template("login.html")
Exemple #19
0
def briefdeviceInfo():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select ipaddress,description,platform, osversion,ostype from devices where id='{}'".format(
        formresult['id'])
    # Obtain the relevant device information from the database
    result = classes.sqlQuery(queryStr, "selectone")
    return json.dumps(result)
Exemple #20
0
def checkupgradeStatus():
    sysvars = classes.globalvars()
    formresult = request.form
    queryStr = "select * from softwareupdate where id='{}'".format(
        formresult['id'])
    scheduleInfo = classes.sqlQuery(queryStr, "selectone")
    scheduleInfo['schedule'] = str(scheduleInfo['schedule'])
    return json.dumps(scheduleInfo)
def clearztpLog():
    sysvars = classes.globalvars()
    formresult = request.form
    queryStr = "delete from ztplog where ztpdevice='{}'".format(
        formresult['deviceid'])
    # Remove the ZTP log for this device
    result = classes.sqlQuery(queryStr, "selectone")
    return "ok"
Exemple #22
0
def upgradeprofileStatus():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from upgradeprofiles where id='{}'".format(
        formresult['profileid'])
    # Obtain the relevant software update information from the database
    profileInfo = classes.sqlQuery(queryStr, "selectone")
    return json.dumps(profileInfo)
def ztptemplateInfo():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from ztptemplates where id='{}'".format(
        formresult['id'])
    # Obtain the relevant ZTP template information from the database
    result = classes.sqlQuery(queryStr, "selectone")
    return json.dumps(result)
Exemple #24
0
def deviceInfo():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from devices where id='{}'".format(formresult['id'])
    # Obtain the relevant device information from the database
    result = classes.sqlQuery(queryStr, "selectone")
    result['password'] = classes.decryptPassword(sysvars['secret_key'],
                                                 result['password'])
    return json.dumps(result)
def ztpDeactivate():
    authOK = classes.checkAuth("ztpdevice", "feature")
    if authOK != 0:
        sysvars = classes.globalvars()
        formresult = request.form
        # Obtain the relevant device information from the database
        result = classes.ztpDeactivate(formresult)
        return json.dumps(result)
    else:
        return render_template("login.html")
Exemple #26
0
def deleteupgrade():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "delete from softwareupdate where id='{}'".format(
        formresult['id'])
    try:
        response = classes.sqlQuery(queryStr, "selectone")
    except:
        response = {"message": "Scheduled upgrade removal failed"}
    return json.dumps(response)
Exemple #27
0
def sysconf():
    authOK=classes.checkAuth("sysadminaccess","submenu")
    if authOK!=0:
        sysvars=classes.globalvars()
        formresult=request.form
        try:
            if formresult['action']=="Submit changes":
                classes.submitsysConf(formresult)
                sysvars=classes.globalvars()
        except:
            pass
        if authOK['hasaccess']==True:
            authOK['hasaccess']="true"
            timezoneregion=["Africa","America","Asia","Europe","Indian","Pacific","Antarctica"]
            return render_template("sysconf.html",authOK=authOK, sysvars=sysvars, timezoneregion=timezoneregion)
        else:
            return render_template("noaccess.html",authOK=authOK, sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #28
0
def createbranchBackup():
    sysvars = classes.globalvars()
    formresult = request.form
    #Obtain the master backup information
    if formresult:
        queryStr = "select * from configmgr where id='{}'".format(
            formresult['masterbackup'])
        result = classes.sqlQuery(queryStr, "selectone")
        return json.dumps(result)
    else:
        return
def psmdss ():
    authOK=classes.checkAuth("psmdssaccess","submenu")
    if authOK!=0:
        sysvars=classes.globalvars()
        url="configs/cluster/v1/distributedservicecards"
        psminfo=classes.getRestpsm(url)
        if authOK['hasaccess']==True:
            authOK['hasaccess']="true"
        return render_template("psmdss.html", authOK=authOK, psminfo=psminfo, sysvars=sysvars)
    else:
        return render_template("login.html")
Exemple #30
0
def telemetrystatus():
    formresult = request.form
    sysvars = classes.globalvars()
    # Perform actions based on the form input
    isRunning = classes.checkRunningws(formresult['deviceid'])
    subscriptions = classes.checkSubscriptions(formresult['deviceid'])
    return json.dumps({
        "deviceid": formresult['deviceid'],
        "isRunning": isRunning,
        "subscriptions": subscriptions
    })