def removeSsid5GhzRadius(): if request.method == 'GET': if session.get("username") is not None: conn = cardinalSql() status = request.args.get('status') removeSsidCursor = conn.cursor() removeSsidCursor.execute( "SELECT ap_ssid_id,ap_ssid_name FROM ssids_5ghz_radius") ssids = removeSsidCursor.fetchall() removeSsidCursor.close() conn.close() return render_template("remove-ssid-5ghz-radius.html", status=status, ssids=ssids) else: return msgAuthFailed, 401 elif request.method == 'POST': if session.get("username") is not None: conn = cardinalSql() ssidId = request.form["ssid_id"] apId = session.get('apId') apName = session.get('apName') ssidInfo = getSsidInfo(ssidId=ssidId, ssidType="ssid_5ghz_radius") checkSsidRelationship = ssidCheck(apId=apId, ssidId=ssidId, ssidType="ssid_5ghz_radius", action="remove", commit="False") if checkSsidRelationship: apInfoCursor = conn.cursor() apInfoCursor.execute( "SELECT ap_ip,ap_ssh_username,ap_ssh_password FROM access_points WHERE ap_id = %s", [apId]) apInfo = apInfoCursor.fetchall() apInfoCursor.close() encryptedSshPassword = bytes(apInfo[0][2], 'utf-8') apSshPassword = cipherSuite.decrypt( encryptedSshPassword).decode('utf-8') scout_ssid.scoutDeleteSsid5(ip=apInfo[0][0], username=apInfo[0][1], password=apSshPassword, ssid=ssidInfo[0][0], vlan=ssidInfo[0][1], radioSub=ssidInfo[0][3], gigaSub=ssidInfo[0][4]) commitRelationship = ssidCheck(apId=apId, ssidId=ssidId, ssidType="ssid_5ghz_radius", action="remove", commit="True") status = "Removal of 5GHz RADIUS SSID {0} for AP {1} Has Been Successfully Initiated!".format( ssidInfo[0][0], apName) conn.close() return redirect( url_for('cardinal_ssid_ops_bp.removeSsid5GhzRadius', status=status)) else: return msgAuthFailed, 401
def deploySsid24Ghz(): if request.method == 'GET': if session.get("username") is not None: conn = cardinalSql() status = request.args.get('status') deploySsidCursor = conn.cursor() deploySsidCursor.execute( "SELECT ap_ssid_id,ap_ssid_name FROM ssids_24ghz") ssids = deploySsidCursor.fetchall() deploySsidCursor.close() conn.close() return render_template("deploy-ssid-24ghz.html", status=status, ssids=ssids) else: return msgAuthFailed, 401 elif request.method == 'POST': if session.get("username") is not None: conn = cardinalSql() ssidId = request.form["ssid_id"] apId = session.get('apId') apName = session.get('apName') ssidInfo = getSsidInfo(ssidId=ssidId, ssidType="ssid_24ghz") encryptedWpa2Pass = bytes(ssidInfo[0][2], 'utf-8') wpa2Pass = cipherSuite.decrypt(encryptedWpa2Pass).decode('utf-8') checkSsidRelationship = ssidCheck(apId=apId, ssidId=ssidId, ssidType="ssid_24ghz", action="add", commit="False") if checkSsidRelationship: apInfoCursor = conn.cursor() apInfoCursor.execute( "SELECT ap_ip,ap_ssh_username,ap_ssh_password FROM access_points WHERE ap_id = %s", [apId]) apInfo = apInfoCursor.fetchall() apInfoCursor.close() encryptedSshPassword = bytes(apInfo[0][2], 'utf-8') apSshPassword = cipherSuite.decrypt( encryptedSshPassword).decode('utf-8') scout_ssid.scoutCreateSsid24(ip=apInfo[0][0], username=apInfo[0][1], password=apSshPassword, ssid=ssidInfo[0][0], vlan=ssidInfo[0][1], wpa2Pass=wpa2Pass, bridgeGroup=ssidInfo[0][3], radioSub=ssidInfo[0][4], gigaSub=ssidInfo[0][5]) commitRelationship = ssidCheck(apId=apId, ssidId=ssidId, ssidType="ssid_24ghz", action="add", commit="True") status = "Deployment of 2.4GHz SSID {0} for AP {1} Has Been Successfully Initiated!".format( ssidInfo[0][0], apName) conn.close() return redirect( url_for('cardinal_ssid_ops_bp.deploySsid24Ghz', status=status)) else: conn.close() status = "2.4GHz SSID {0} is already deployed on {1}".format( ssidInfo[0][0], apName) return redirect( url_for('cardinal_ssid_ops_bp.deploySsid24Ghz', status=status)) else: return msgAuthFailed, 401