Beispiel #1
0
        def updateDB(self, conn):
            cursor = conn.cursor()

            for bssid in self.radio_bssid:

                ale_dbi.upsert(cursor,
                               'VAP', ('bssid', ),
                               schema=None,
                               bssid=bssid,
                               essid=self.ssid[bssid])

                params = (bssid, )
                cursor.execute("SELECT id FROM VAP WHERE bssid = %s", params)
                row = cursor.fetchone()
                if row == None:
                    print "VAP.updateDB(): Error in DB"
                else:
                    vap_id = row[0]

                radio_bssid = self.radio_bssid[bssid]
                essid = self.ssid[bssid]
                ts = self.ts[bssid]

                radio_id = ale_dbi.getRadioIdByMac(conn, radio_bssid)

                params = (essid, radio_id, vap_id)
                cursor.execute(
                    "UPDATE VAP SET essid=%s,radio_id=%s WHERE id=%s", params)
            conn.commit()
Beispiel #2
0
        def updateDB(self, conn, server_id):
            cursor = conn.cursor()

            for access_point_mac_addr in self.access_points_name:

                ale_dbi.upsert(
                    cursor,
                    'AP', ('macAddress', ),
                    schema=None,
                    macAddress=access_point_mac_addr,
                    name=self.access_points_name[access_point_mac_addr])

                params = (access_point_mac_addr, )
                cursor.execute("SELECT id FROM AP WHERE macAddress = %s",
                               params)
                row = cursor.fetchone()
                if row == None:
                    print "access_point.updateDB(): Error in DB"
                else:
                    ap_id = row[0]

                name = self.access_points_name[access_point_mac_addr]
                apGroup = self.access_points_group[access_point_mac_addr]
                model = self.access_points_model[access_point_mac_addr]
                mode = self.access_points_depl_mode[access_point_mac_addr]
                ip = self.access_points_ip_address[access_point_mac_addr]
                params = (name, apGroup, model, mode, ip, server_id, ap_id)
                cursor.execute(
                    "UPDATE AP SET name=%s,apGroup=%s,model=%s,mode=%s,ip=%s,server_id=%s WHERE id = %s",
                    params)
            conn.commit()
Beispiel #3
0
        def updateDB(self, conn):
            cursor = conn.cursor()

            for mac in self.stations_username:

                ale_dbi.upsert(cursor,
                               'Endpoint', ('macAddress', ),
                               schema=None,
                               macAddress=mac,
                               role=self.stations_role[mac])

                params = (mac, )
                cursor.execute("SELECT id FROM Endpoint WHERE macAddress = %s",
                               params)
                row = cursor.fetchone()
                if row == None:
                    print "station.updateDB(): Error in DB"
                else:
                    endpoint_id = row[0]

                username = self.stations_username[mac]
                role = self.stations_role[mac]
                devType = self.stations_device_type[mac]
                ip = self.stations_ip_address[mac]
                bssid = "%s" % self.stations_bssid[mac]

                params = ('restapi', username, role, ip, devType, bssid,
                          endpoint_id)
                cursor.execute(
                    "UPDATE Endpoint SET lastHeardMessage=%s,username=%s,role=%s,ip=%s,devType=%s,bssid=%s WHERE id=%s",
                    params)
            conn.commit()
Beispiel #4
0
        def updateDB(self,conn):
            cursor = conn.cursor()
    
            for bssid in self.radios_wired_mac:
                ale_dbi.upsert(cursor, 'Radio_BSSID', ('radio_bssid',), schema=None, radio_bssid=bssid,mode=self.radios_mode[bssid])

                params = (bssid,)            
                cursor.execute("SELECT id FROM Radio_BSSID WHERE radio_bssid = %s", params)
                row = cursor.fetchone()
                if row == None:
                    print "radio.updateDB(): Error in DB"
                else:
                    bssid_id = row[0]
                
                wired_mac = self.radios_wired_mac[bssid]
                phy_type = self.radios_phy_type[bssid]
                ht_type = self.radios_ht_type[bssid]
                mode = self.radios_mode[bssid]
                ts = self.radios_ts[bssid]
                ap_id = ale_dbi.getAPIdByMac(conn,wired_mac)
                if ap_id == 0:
                    params = (wired_mac,"UNKNOWN","UNKNOWN")
                    cursor.execute("INSERT INTO AP (macaddress,name,apGroup) VALUES (%s,%s,%s)", params)
                    ap_id = ale_dbi.getAPIdByMac(conn,wired_mac)
                
                params = (phy_type,mode,ht_type,ap_id,bssid_id)
                cursor.execute("UPDATE Radio_BSSID SET phyType=%s,mode=%s,ht=%s,ap_id=%s WHERE id=%s",params)
            conn.commit()
Beispiel #5
0
        def updateDB(self, conn):
            cursor = conn.cursor()

            for bssid in self.radios_wired_mac:
                ale_dbi.upsert(cursor,
                               'Radio_BSSID', ('radio_bssid', ),
                               schema=None,
                               radio_bssid=bssid,
                               mode=self.radios_mode[bssid])

                params = (bssid, )
                cursor.execute(
                    "SELECT id FROM Radio_BSSID WHERE radio_bssid = %s",
                    params)
                row = cursor.fetchone()
                if row == None:
                    print "radio.updateDB(): Error in DB"
                else:
                    bssid_id = row[0]

                wired_mac = self.radios_wired_mac[bssid]
                phy_type = self.radios_phy_type[bssid]
                ht_type = self.radios_ht_type[bssid]
                mode = self.radios_mode[bssid]
                ts = self.radios_ts[bssid]
                ap_id = ale_dbi.getAPIdByMac(conn, wired_mac)
                if ap_id == 0:
                    params = (wired_mac, "UNKNOWN", "UNKNOWN")
                    cursor.execute(
                        "INSERT INTO AP (macaddress,name,apGroup) VALUES (%s,%s,%s)",
                        params)
                    ap_id = ale_dbi.getAPIdByMac(conn, wired_mac)

                params = (phy_type, mode, ht_type, ap_id, bssid_id)
                cursor.execute(
                    "UPDATE Radio_BSSID SET phyType=%s,mode=%s,ht=%s,ap_id=%s WHERE id=%s",
                    params)
            conn.commit()
Beispiel #6
0
        def updateDB(self,conn,server_id):
            cursor = conn.cursor()
        
            for access_point_mac_addr in self.access_points_name:

                ale_dbi.upsert(cursor, 'AP', ('macAddress',), schema=None, macAddress=access_point_mac_addr, name=self.access_points_name[access_point_mac_addr])

                params = (access_point_mac_addr,)
                cursor.execute("SELECT id FROM AP WHERE macAddress = %s", params)
                row = cursor.fetchone()
                if row == None:
                    print "access_point.updateDB(): Error in DB"
                else:
                    ap_id = row[0]

                name = self.access_points_name[access_point_mac_addr]
                apGroup = self.access_points_group[access_point_mac_addr]
                model = self.access_points_model[access_point_mac_addr]
                mode = self.access_points_depl_mode[access_point_mac_addr]
                ip = self.access_points_ip_address[access_point_mac_addr]
                params = (name,apGroup,model,mode,ip,server_id,ap_id)
                cursor.execute("UPDATE AP SET name=%s,apGroup=%s,model=%s,mode=%s,ip=%s,server_id=%s WHERE id = %s", params)
            conn.commit()
Beispiel #7
0
        def updateDB(self,conn):
            cursor = conn.cursor()
    
            for bssid in self.radio_bssid:

                ale_dbi.upsert(cursor, 'VAP', ('bssid',), schema=None, bssid=bssid,essid=self.ssid[bssid])

                params = (bssid,)
                cursor.execute("SELECT id FROM VAP WHERE bssid = %s", params)
                row = cursor.fetchone()
                if row == None:
                    print "VAP.updateDB(): Error in DB"
                else:
                    vap_id = row[0]

                radio_bssid = self.radio_bssid[bssid]
                essid = self.ssid[bssid]
                ts = self.ts[bssid]

                radio_id = ale_dbi.getRadioIdByMac(conn,radio_bssid)

                params = (essid,radio_id,vap_id)
                cursor.execute("UPDATE VAP SET essid=%s,radio_id=%s WHERE id=%s",params)
            conn.commit()
Beispiel #8
0
        def updateDB(self,conn):
            cursor = conn.cursor()

            for mac in self.stations_username:

                ale_dbi.upsert(cursor, 'Endpoint', ('macAddress',), schema=None, macAddress=mac,role=self.stations_role[mac])

                params = (mac,)            
                cursor.execute("SELECT id FROM Endpoint WHERE macAddress = %s", params)
                row = cursor.fetchone()
                if row == None:
                    print "station.updateDB(): Error in DB"
                else:
                    endpoint_id = row[0]

                username = self.stations_username[mac]
                role = self.stations_role[mac]
                devType = self.stations_device_type[mac]
                ip = self.stations_ip_address[mac]
                bssid = "%s" % self.stations_bssid[mac]

                params = ('restapi',username,role,ip,devType,bssid,endpoint_id)
                cursor.execute("UPDATE Endpoint SET lastHeardMessage=%s,username=%s,role=%s,ip=%s,devType=%s,bssid=%s WHERE id=%s",params)
            conn.commit()