Esempio n. 1
0
def upgradeStatus():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from softwareupdate where id='{}'".format(
        formresult['id'])
    # Obtain the relevant software update information from the database
    upgraderesult = classes.sqlQuery(queryStr, "selectone")
    queryStr = "select ipaddress, description,ostype,osversion from devices where id='{}'".format(
        upgraderesult['switchid'])
    # Obtain the relevant device information from the database
    switchresult = classes.sqlQuery(queryStr, "selectone")
    upgraderesult['switchresult'] = switchresult
    return json.dumps(upgraderesult)
def dsservice():
    authOK = classes.checkAuth("ubtserviceaccess", "submenu")
    if authOK != 0:
        sysvars = classes.globalvars()
        authMethod = [
            "EAP PEAP", "EAP-TLS", "Allow All MAC", "Mac Auth", "PAP", "CHAP"
        ]
        authSource = [
            "Active Directory", "Local User Database", "Guest User Repository"
        ]
        result = {}
        editService = {}
        mcInfo = {}
        profileInfo = {}
        profileresult = {}
        message = []
        try:
            formresult = request.form
            result = classes.dsservicedbAction(formresult)
            queryStr = "select id, description, ipaddress from devices where ostype='Mobility Controller'"
            mcInfo = classes.sqlQuery(queryStr, "select")
            queryStr = "select * from dsprofiles"
            profileInfo = classes.sqlQuery(queryStr, "select")
            if formresult['action'] == "Edit":
                editService = classes.sqlQuery(
                    "select * from dsservices where id='{}'".format(
                        formresult['id']), "selectone")
                profileresult = classes.getProfile()
        except:
            formresult = []
        if authOK['hasaccess'] == True:
            authOK['hasaccess'] = "true"
            return render_template("dsservice.html",
                                   result=result,
                                   formresult=formresult,
                                   mcInfo=mcInfo,
                                   profileInfo=profileInfo,
                                   editService=editService,
                                   profileresult=profileresult,
                                   authMethod=authMethod,
                                   authSource=authSource,
                                   message=message,
                                   authOK=authOK,
                                   sysvars=sysvars)
        else:
            return render_template("noaccess.html",
                                   authOK=authOK,
                                   sysvars=sysvars)
    else:
        return render_template("login.html")
Esempio n. 3
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")
Esempio n. 4
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")
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)
Esempio n. 6
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 showGraph():
    queryStr = "select id,sysinfo,ostype,ports,vsx,vsxlags,vrf,vsf,bps from devices where id='{}'".format(
        request.args.get('deviceid'))
    deviceinfo = classes.sqlQuery(queryStr, "selectone")
    sysinfo = json.loads(deviceinfo['sysinfo'])
    if sysinfo:
        if 'vsf_member_element' in sysinfo:
            stacktype = "vsf"
            title = "CPU Utilization"
        elif 'bps_member_element' in sysinfo:
            stacktype = "bps"
        else:
            stacktype = "standalone"
    else:
        stacktype = "standalone"

    if request.args.get('entity') == "cpu":
        title = "CPU Utilization"
    elif request.args.get('entity') == "memory":
        if deviceinfo['ostype'] == "arubaos-cx":
            title = "Memory Utilization"
        elif deviceinfo['ostype'] == "arubaos-switch":
            if stacktype == "standalone":
                title = "Memory Utilization"
            else:
                title = "Available Memory"

    line_chart = classes.showLinechart(request.args.get('deviceid'),
                                       request.args.get('entity'),
                                       deviceinfo['ostype'], stacktype, title)
    return line_chart.render_response()
Esempio n. 8
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 showInterface():
    # Definition that shows the interface statistics of a selected interface
    lldpinfo = []
    queryStr = "select ostype from devices where id='{}'".format(
        request.args.get('deviceid'))
    deviceinfo = classes.sqlQuery(queryStr, "selectone")
    try:
        interfaceinfo = classes.interfacedbAction(
            request.args.get('deviceid'), request.args.get('interface'),
            deviceinfo['ostype'])
        if deviceinfo['ostype'] == "arubaos-cx":
            # Get the LLDP information for the given interface
            try:
                url = "system/interfaces/" + request.args.get(
                    'interface').replace('/',
                                         '%2f') + "/lldp_neighbors?depth=2"
                lldpinfo = classes.getcxREST(request.args.get('deviceid'), url)
            except:
                lldpinfo = {}
            return render_template("showcxinterface.html",
                                   interfaceinfo=interfaceinfo[0],
                                   lldpinfo=lldpinfo,
                                   interface=request.args.get('interface'))
        elif deviceinfo['ostype'] == "arubaos-switch":
            return render_template("showinterface.html",
                                   interfaceinfo=interfaceinfo[0],
                                   lldpinfo=interfaceinfo[1],
                                   interface=request.args.get('interface'))
        else:
            return ('', 204)
    except:
        return ('', 204)
Esempio n. 10
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)
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)
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"
Esempio n. 13
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)
Esempio n. 14
0
def afcauditItem():
    queryStr = "select * from afcaudit where id='{}'".format(
        request.args.get('id'))
    auditInfo = classes.sqlQuery(queryStr, "selectone")
    auditInfo['jsondata'] = json.loads(auditInfo['jsondata'])
    templateName = "afcauditTemplates/" + auditInfo['jsondata'][
        'event_type'] + ".html"
    return render_template(templateName, auditInfo=auditInfo)
Esempio n. 15
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)
Esempio n. 16
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 ztplog():
    sysvars = classes.globalvars()
    queryStr = "select * from ztpdevices where id='{}'".format(
        request.args.get('deviceid'))
    # Obtain the relevant ZTP logging information from the database
    deviceInfo = classes.sqlQuery(queryStr, "selectone")
    queryStr = "select * from ztplog where ztpdevice='{}'".format(
        request.args.get('deviceid'))
    # Obtain the relevant ZTP logging information from the database
    logInfo = classes.sqlQuery(queryStr, "selectone")
    if logInfo:
        logInfo = json.loads(logInfo['logging'])
    else:
        logInfo = ""
    return render_template("ztplog.html",
                           deviceInfo=deviceInfo,
                           logInfo=logInfo)
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)
Esempio n. 19
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 deleteTrackerselection():
    formresult = request.form
    try:
        queryStr = "delete from {} where id in ({})".format(
            formresult['dbtable'], formresult['selection'])
        result = classes.sqlQuery(queryStr, "selectone")
        return "200"
    except:
        return "400"
Esempio n. 21
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)
def devauth(profile, devauth):
    # Obtain the authentication methods and source from the profile
    if devauth == "dot1x":
        queryStr = "select dot1xmethod,dot1xsource from dsprofiles where id='{}'".format(
            profile)
    elif devauth == "macauth":
        queryStr = "select macauthmethod,macauthsource from dsprofiles where id='{}'".format(
            profile)
    result = classes.sqlQuery(queryStr, "selectone")
    return json.dumps(result)
Esempio n. 23
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
Esempio n. 24
0
def switchReboot():
    formresult = request.form
    sysvars = classes.globalvars()
    queryStr = "select * from softwareupdate where id='{}'".format(
        formresult['id'])
    # Obtain the relevant software update information
    upgraderesult = classes.sqlQuery(queryStr, "selectone")
    queryStr = "select ostype from devices where id='{}'".format(
        formresult['deviceid'])
    # Obtain the relevant software update information
    deviceresult = classes.sqlQuery(queryStr, "selectone")
    if deviceresult['ostype'] == "arubaos-switch":
        if upgraderesult['activepartition'] == "primary":
            activepartition = "BI_PRIMARY_IMAGE"
        else:
            activepartition = "BI_SECONDARY_IMAGE"
    else:
        activepartition = upgraderesult['activepartition']
    response = classes.bootSwitch(deviceresult['ostype'], formresult['id'],
                                  formresult['deviceid'], activepartition)
    return json.dumps(response)
Esempio n. 25
0
def changebranchBackup():
    sysvars = classes.globalvars()
    formresult = request.form
    # Based on the action, perform a branch backup submit, or edit submit
    classes.changebranchBackup(formresult['id'], formresult['sysuser'],
                               formresult['backupContent'],
                               formresult['backupDescription'])
    id = formresult['id']
    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)
def updateDHCPtracker():
    formresult = request.form
    response = {}
    if int(formresult['pageoffset']) < 1:
        pageoffset = 0
    else:
        pageoffset = (int(formresult['pageoffset']) - 1) * int(
            formresult['entryperpage'])
    queryStr = "select * from dhcptracker where dhcptype like '%{}%' AND information like '%{}%' ORDER BY utctime DESC LIMIT {} offset {} ".format(
        formresult['searchType'], formresult['searchInfo'],
        formresult['entryperpage'], pageoffset)
    result = classes.sqlQuery(queryStr, "select")
    response['result'] = result
    queryStr = "select COUNT(*) as totalentries from dhcptracker where dhcptype like '%{}%' AND information like '%{}%'".format(
        formresult['searchType'], formresult['searchInfo'])
    totalentries = classes.sqlQuery(queryStr, "selectone")
    response['totalentries'] = totalentries['totalentries']
    # Verify access
    response["accessright"] = classes.verifyAccess("dhcptrackeraccess",
                                                   "feature")
    return json.dumps(response)
Esempio n. 27
0
def deviceUpgrade():
    sysvars = classes.globalvars()
    # Obtain the device information
    queryStr = "select id, ipaddress, description, ostype, platform, osversion from devices where id='{}'".format(
        request.args.get('deviceid'))
    print(queryStr)
    deviceInfo = classes.sqlQuery(queryStr, "selectone")
    print(deviceInfo)
    bootInfo = classes.getupgradeInfo(deviceInfo)
    return render_template("deviceupgrade.html",
                           bootInfo=bootInfo,
                           deviceInfo=deviceinfo,
                           sysvars=sysvars)
def profileInfo(profile):
    profileInfo = {}
    queryStr = "select * from dsprofiles where id='{}'".format(profile)
    profileInfo = classes.sqlQuery(queryStr, "selectone")
    queryStr = "select id,ipaddress,description from devices where id='{}'".format(
        profileInfo['clearpass'])
    clearpassInfo = {"clearpass": classes.sqlQuery(queryStr, "selectone")}
    queryStr = "select id,ipaddress,description from devices where id='{}'".format(
        profileInfo['primarycontroller'])
    primarycontrollerInfo = {
        "primarycontroller": classes.sqlQuery(queryStr, "selectone")
    }
    queryStr = "select id,ipaddress,description from devices where id='{}'".format(
        profileInfo['backupcontroller'])
    backupcontrollerInfo = {
        "backupcontroller": classes.sqlQuery(queryStr, "selectone")
    }
    if backupcontrollerInfo['backupcontroller']:
        profileInfo.update(backupcontrollerInfo)
    profileInfo.update(clearpassInfo)
    profileInfo.update(primarycontrollerInfo)
    return json.dumps(profileInfo)
Esempio n. 29
0
def updateafcAudit():
    formresult = request.form
    response = {}
    if int(formresult['pageoffset']) < 1:
        pageoffset = 0
    else:
        pageoffset = (int(formresult['pageoffset']) - 1) * int(
            formresult['entryperpage'])
    queryStr = "select * from afcaudit where record_type like '%{}%' AND stream_id like '%{}%' AND severity like '%{}%' AND description like '%{}%' ORDER BY log_date DESC LIMIT {} offset {} ".format(
        formresult['searchRecordtype'], formresult['searchStreamid'],
        formresult['searchSeverity'], formresult['searchDescription'],
        formresult['entryperpage'], pageoffset)
    result = classes.sqlQuery(queryStr, "select")
    response['result'] = result
    queryStr = "select COUNT(*) as totalentries from afcaudit where record_type like '%{}%' AND stream_id like '%{}%' AND severity like '%{}%' AND description like '%{}%'".format(
        formresult['searchRecordtype'], formresult['searchStreamid'],
        formresult['searchSeverity'], formresult['searchDescription'])
    totalentries = classes.sqlQuery(queryStr, "selectone")
    response['totalentries'] = totalentries['totalentries']
    # Verify access
    response["accessright"] = classes.verifyAccess("dhcptrackeraccess",
                                                   "feature")
    return response
Esempio n. 30
0
def deviceattributesList():
    if request.form:
        if request.form['searchattributeName'] != "" or request.form[
                'searchattributeType'] != "":
            queryStr = "select * from deviceattributes where name like '%" + request.form[
                'searchattributeName'] + "%'"
            if request.form['searchattributeType'] != "":
                queryStr += " and type='{}'".format(
                    request.form['searchattributeType'])
        else:
            queryStr = "select * from deviceattributes"
    else:
        queryStr = "select * from deviceattributes"
    result = classes.sqlQuery(queryStr, "select")
    return json.dumps(result)