Beispiel #1
0
def configApName():
    if request.method == 'GET':
        if session.get("username") is not None:
            status = request.args.get('status')
            return render_template("config-ap-name.html", status=status)
        else:
            return msgAuthFailed, 401
    elif request.method == 'POST':
        if session.get("username") is not None:
            apId = session.get('apId')
            if apId is None:
                apId = request.form["ap_id"]
            apNewName = request.form["ap_name"]
            apInfo = getApInfo(apId=apId)
            encryptedSshPassword = bytes(apInfo[0][3], 'utf-8')
            apSshPassword = cipherSuite.decrypt(encryptedSshPassword).decode('utf-8')
            scout_sys.scoutChangeName(ip=apInfo[0][1], username=apInfo[0][2], password=apSshPassword, apName=apNewName)
            status = "AP Name Changed from {0} to {1}".format(apInfo[0][0],apNewName)
            try:
                conn = cardinalSql()
                changeApNameCursor = conn.cursor()
                changeApNameCursor.execute("UPDATE access_points SET ap_name = %s WHERE ap_id = %s", (apNewName,apId))
                changeApNameCursor.close()
            except MySQLdb.Error as e:
                conn.close()
                return redirect(url_for('cardinal_ap_ops_bp.configApName', status=e))
            else:
                conn.close()
                conn.commit()
                return redirect(url_for('cardinal_ap_ops_bp.configApName', status=status))
        else:
            return msgAuthFailed, 401
Beispiel #2
0
def configApIp():
    if request.method == 'GET':
        if session.get("username") is not None:
            status = request.args.get('status')
            return render_template("config-ap-ip.html", status=status)
        else:
            return msgAuthFailed, 401
    elif request.method == 'POST':
        if session.get("username") is not None:
            apId = session.get('apId')
            if apId is None:
                apId = request.form["ap_id"]
            apNewIp = request.form["ap_new_ip"]
            apSubnetMask = request.form["ap_subnetmask"]
            apInfo = getApInfo(apId=apId)
            encryptedSshPassword = bytes(apInfo[0][3], 'utf-8')
            apSshPassword = cipherSuite.decrypt(encryptedSshPassword).decode('utf-8')
            scout_sys.scoutChangeIp(ip=apInfo[0][1], username=apInfo[0][2], password=apSshPassword, newIp=apNewIp, subnetMask=apSubnetMask)
            status = "{}'s IP was successfully updated!".format(apInfo[0][0])
            try:
                conn = cardinalSql()
                changeApIpCursor = conn.cursor()
                changeApIpCursor.execute("UPDATE access_points SET ap_ip = %s WHERE ap_id = %s", (apNewIp,apId))
                changeApIpCursor.close()
            except MySQLdb.Error as e:
                conn.close()
                return redirect(url_for('cardinal_ap_ops_bp.configApIp', status=e))
            else:
                conn.close()
                conn.commit()
                return redirect(url_for('cardinal_ap_ops_bp.configApIp', status=status))
        else:
            return msgAuthFailed, 401
Beispiel #3
0
def disableApSnmp():
    if session.get("username") is not None:
        apId = session.get('apId')
        if apId is None:
            apId = request.form["ap_id"]
        apInfo = getApInfo(apId=apId)
        encryptedSshPassword = bytes(apInfo[0][3], 'utf-8')
        apSshPassword = cipherSuite.decrypt(encryptedSshPassword).decode('utf-8')
        scout_sys.scoutDisableSnmp(ip=apInfo[0][1], username=apInfo[0][2], password=apSshPassword)
        status = "SNMP Server for {} Successfully Disabled!".format(apInfo[0][0])
        return redirect(url_for('cardinal_ap_ops_bp.configApSnmp', status=status))
    else:
        return msgAuthFailed, 401
Beispiel #4
0
def configApTftpBackup():
    if request.method == 'GET':
        if session.get("username") is not None:
            status = request.args.get('status')
            return render_template("config-ap-tftp-backup.html", status=status)
        else:
            return msgAuthFailed, 401
    elif request.method == 'POST':
        if session.get("username") is not None:
            apId = session.get('apId')
            if apId is None:
                apId = request.form["ap_id"]
            tftpIp = request.form["tftp_ip"]
            apInfo = getApInfo(apId=apId)
            encryptedSshPassword = bytes(apInfo[0][3], 'utf-8')
            apSshPassword = cipherSuite.decrypt(encryptedSshPassword).decode('utf-8')
            scout_sys.scoutTftpBackup(ip=apInfo[0][1], username=apInfo[0][2], password=apSshPassword, tftpIp=tftpIp)
            status = "Config Backup for {} Successfully Initiated!".format(apInfo[0][0])
            return redirect(url_for('cardinal_ap_ops_bp.configApTftpBackup', status=status))
        else:
            return msgAuthFailed, 401