Exemplo n.º 1
0
    def HandleIncomingPacket(self, node, rawData, fromAddr):
        Statistics.GetStatistics().OnPacketReceivedFromDownstream(rawData)
        try:
            packetType = node.attributes[
                "Type"].nodeValue  #All should have a Type attribute
            version = node.getElementsByTagName('Version')
        except Exception as ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Malformed Marvin Packet: " + rawData)
            return

        if packetType == "WatchdogTimer":
            self.HandleIncomingWatchdogPacket(node, rawData, fromAddr)

        elif packetType == "MinionTask":
            self.HandleMinionTask(rawData, node)

        elif packetType == "OscarTask":
            self.HandleOscarTask(node, rawData)

        elif packetType == "RemoteMarvinTask":
            self.HandleRemoteMarvinTask(rawData)

        elif packetType == "Bullhorn":
            self.HandleBullhornAnnouncement(node, rawData, fromAddr)

        else:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received unknown Packet Type: " + rawData)
Exemplo n.º 2
0
    def HandleIncomingMinionConnectionInformation(self, node, rawData,
                                                  fromAddr):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Minion Type="ConnectionInformation">
        #    <Version>1.0</Version>"
        #    <MinionVersion>17.02.12 Build 3</MinionVersion>"
        #    <Namespace>NamespaceFoo</Namespace>
        #    <Port>12345</Port>
        #</Minion>

        try:
            version = node.getElementsByTagName(
                'Version')[0].firstChild.nodeValue
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Minion Connection Information Packet : " +
                rawData)
            return

        try:
            namespace = node.getElementsByTagName(
                'Namespace')[0].firstChild.nodeValue
            namespace = namespace.lower()
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Minion ConnectionInformation Packet : " +
                rawData)
            return

        try:
            port = node.getElementsByTagName('Port')[0].firstChild.nodeValue
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Minion ConnectionInformation Packet : " +
                rawData)
            return

        IP = fromAddr[0].lower()
        TargetID = namespace + ":" + IP + ":" + port

        CP = TargetManager.GetTargetManager().GetUpstreamTarget(TargetID)
        if None == CP:
            objUpstreamTarget = Target.Target(
                IP, port, ConnectionPoint.ConnectionType.Minion, False)
            TargetManager.GetTargetManager().AddUpstreamTarget(
                objUpstreamTarget,
                TargetID)  # add it as a upstream target for tasks and such
            try:
                minionVersion = node.getElementsByTagName(
                    'MinionVersion')[0].firstChild.nodeValue
                Log.getLogger().info("Received Connection from Minion " +
                                     TargetID + " version: " + minionVersion)
            except Exception as Ex:
                pass

        elif CP.Type != ConnectionPoint.ConnectionType.Minion:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Unexpected Connection Type: " + str(CP.Type))
Exemplo n.º 3
0
    def HandleIncomingWatchdogPacket(self,node,rawData,fromAddr):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="WatchdogTimer">
        #    <Version>1.0</Version>
        #    <MarvinVersion>17.12.22</MarvinVersion>
        #    <UniqueID>3236</UniqueID>
        #    <Port>5000</Port>
        #</Marvin>

        Statistics.GetStatistics().OnPacketReceivedFromDownstream(rawData)
        try:
            _ = node.getElementsByTagName('Version')[0].firstChild.nodeValue 
            IP = fromAddr[0].lower()
            Port = node.getElementsByTagName('Port')[0].firstChild.nodeValue
            UniqueID = node.getElementsByTagName('UniqueID')[0].firstChild.nodeValue

        except Exception as _:
            Statistics.GetStatistics().OnMalformedPacketReceived("Received invalid Marvin WatchdogTimer  Packet : " + rawData)
            return

        try:
            marvinVersion = node.getElementsByTagName('MarvinVersion')[0].firstChild.nodeValue 

        except Exception:
            marvinVersion='Unknown'

        Key = IP + ":" + Port
        objTarget = TargetManager.GetTargetManager().GetDownstreamTarget(Key)  

        if None == objTarget:
            objTarget = TargetManager.GetTargetManager().GetDownstreamTargetEx(IP,Port)  # if using DNS, do lookup based on real IP, not DNS name

        if None == objTarget:
            Sleep.Sleep(50) #give it another shot, other thread may be doing a DNS resolution            
            objTarget = TargetManager.GetTargetManager().GetDownstreamTargetEx(IP,Port)  # if using DNS, do lookup based on real IP, not DNS name

        if None == objTarget:
            Log.getLogger().warning("Received Marvin Watchdog for unknown downstream Target: " +IP+":"+Port + " Version: " + marvinVersion)
            return
        
        if objTarget.getType() != ConnectionType.Marvin and objTarget.getType() != ConnectionType.DynamicMarvin : # would not know what this is until you hear back (could be another Oscar)
            objTarget.Type = ConnectionType.Marvin
            Log.getLogger().info("Connection established with Marvin Target: "+ IP + ":" + Port + " Version: " + marvinVersion)

        try:
            _ = node.getElementsByTagName('RefreshRequested')[0].firstChild.nodeValue 
            objTarget.ReArmRefreshRequest(UniqueID)  # Asked to refresh!

        except Exception as _:
            pass

        objTarget.StrokeWatchdogTimer()
Exemplo n.º 4
0
    def Shunt(self, namespace, ID, dataTuple, Value):

        Statistics.GetStatistics().OnPacketShunted()
        newTuple = (namespace, ID, dataTuple[4], Value)
        shuntFile = dataTuple[2]

        self.__ShuntLock.acquire()

        try:
            if not shuntFile in self.__ShuntedDataByFile:
                self.__ShuntedDataByFile[shuntFile] = []

            self.__ShuntedDataByFile[shuntFile].append(newTuple)

        except Exception as Ex:
            Log.getLogger().info("Unknown in Shunt function:  " + str(Ex))

        finally:
            self.__ShuntLock.release()

        if not self.__ShuntThreadCreated:
            self.__ShuntThreadCreated = True
            threadName = "ShuntProc:" + str(self)
            ThreadManager.GetThreadManager().CreateThread(
                threadName, self.ShuntWorkerProc)
            ThreadManager.GetThreadManager().StartThread(threadName)
    def HandleIncomingGroupPacket(self, rawData, node, fromAddress):
        from Helpers import Configuration

        if Configuration.get().GetBITW_Active():
            rawData = Configuration.get().HandleBITWBuffer(
                rawData)  # handle Bump in the wire

        if 0 != TargetManager.GetTargetManager().BroadcastDownstream(
                rawData, False, node, True):  # send to all - towards a Marvin
            Statistics.GetStatistics().OnPacketChainedDownstream(rawData)

        # Break up packet and do bump in the wire.
        # If BITW not active, maybe we don't need to do this could be a lot of processing for nothing....
        objGroupPacket = MarvinGroupData.MarvinDataGroup(
            "", "", "", 0, "1.0", True)
        for packet in node.getElementsByTagName('Oscar'):
            objMarvinPacket = self.CreateMarvinData(packet, rawData,
                                                    fromAddress)
            if None == objMarvinPacket:
                return
            objGroupPacket.AddPacket(objMarvinPacket)


#        objData = MarvinData.MarvinData(namespace,ID,value,0,version,True)
        GuiMgr.OnDataPacketSentDownstream(objGroupPacket, "Chained")
        Recorder.get().AddData(objGroupPacket)
    def updateGui(self):
        if self._LastUpdate + self._Interval < Time.GetCurrMS():
            self._LastUpdate = Time.GetCurrMS()
            sm = Statistics.GetStatistics()
            self.lblTotalPacketsDownstream.configure(
                text=str(sm._TotalPacketsDownstream))
            self.lblPacketDownstream.configure(
                text=str(sm._UniquePacketsDownstream))
            self.lblBytesTransmittedDownstream.configure(
                text=str(sm._totalTxBytesDownstream))
            self.lblBytesReceivedFromDownstream.configure(
                text=str(sm._totalRxBytesDownstream))

            self.lblTotalPacketsUpstream.configure(
                text=str(sm._TotalPacketsUpstream))
            self.lblPacketUpstream.configure(
                text=str(sm._UniquePacketsUpstream))
            self.lblBytesTransmittedUpstream.configure(
                text=str(sm._totalTxBytesUpstream))
            self.lblBytesReceivedFromUpstream.configure(
                text=str(sm._totalRxBytesUpstream))

            self.lblTotalDroppedPackets.configure(
                text=str(sm._TotalPacketsDropped))
            self.lblTotalMalformedPackets.configure(
                text=str(sm._TotalMalformedPacketsReceived))
            self.lblTotalChainedPackets.configure(
                text=str(sm._TotalChainedDownstreamPackets))
            self.lblTotalOscarTasks.configure(
                text=str(sm._TotalOscarTasksReceived))
            self.lblTotalMinionTasks.configure(
                text=str(sm._TotalMinionTasksReceived))
            self.lblTotalShuntedPackets.configure(
                text=str(sm._TotalShuntedPackets))
Exemplo n.º 7
0
    def _BroadcastDownstream(self,
                             sendBuffer,
                             ignoreTimeout,
                             domNode,
                             isGroup=False):
        from Helpers import Configuration
        sentCount = 0

        for targetKey in self._DownstreamTargets.keys():
            if True == self.SendToDownstreamTarget(sendBuffer, targetKey,
                                                   ignoreTimeout):
                sentCount += 1

        if sentCount > 0:
            Statistics.GetStatistics().OnPacketBroadcastDownstream()

        if Configuration.get().GetShunting() and (None != domNode
                                                  or True == isGroup):
            if None != domNode and not isGroup:
                self.HandleShuntingData(domNode)
            else:  # is a group and need to go through each item individually
                if None == domNode:
                    try:
                        dom = xml.dom.minidom.parseString(sendBuffer)
                        domNode = dom._get_firstChild()
                    except Exception as ex:
                        Log.getLogger().error(
                            "Error Something bad in Trying to read xml in BroadcastDownstream"
                        )

                if None != domNode:
                    for dataNode in domNode.getElementsByTagName('Oscar'):
                        self.HandleShuntingData(dataNode)

        return sentCount
Exemplo n.º 8
0
    def BroadcastUpstream(self, sendBuffer):
        Statistics.GetStatistics().OnPacketBroadcastUpstream()
        sentCount = 0
        for targetKey in self._UpstreamTargets.keys():
            if self.SendToUpstreamTarget(sendBuffer, targetKey):
                sentCount += 1

        return sentCount
    def alternateWorker(self):  ## Maybe have one thread that goes and
        self.m_objLockDict.acquire()  # thread safety

        if len(
                self.m_SendList
        ) == 0:  # rest if nothing to send, or sent a bunch of packets without a sleep
            dataToProcess = False

        else:
            buffer = self.m_SendList[0]
            del self.m_SendList[0]
            dataToProcess = True

        self.m_objLockDict.release()

        if dataToProcess:
            if None == self.m_IP_InUse:
                Log.getLogger().info("Getting IP address for host: " +
                                     self.ConfigurationDefinedTarget)
                try:
                    self.m_LastDNSResolution = Time.GetCurrMS()
                    self.m_IP_InUse = socket.gethostbyname(
                        self.ConfigurationDefinedTarget
                    )  #use this for looking at heartbeats

                except Exception as _:
                    self.m_IP_InUse = self.ConfigurationDefinedTarget

            try:
                self.m_socket.sendto(bytes(buffer, 'utf-8'),
                                     (self.m_IP_InUse, self.getPort()))
                self.m_PacketsSent += 1
                self.m_BytestSent += len(buffer)

            except Exception as ex:
                Log.getLogger().info("It appears that the target [" +
                                     self.ConfigurationDefinedTarget +
                                     "] has went away.")
                self.m_objLockDict.acquire()
                Statistics.GetStatistics().OnPacketDropped(
                    len(self.m_SendList) + 1)
                self.m_SendList.clear()
                self.m_objLockDict.release()

        if self.m_LastDNSResolution + self.m_DNSResolutionPeriod < Time.GetCurrMS(
        ) and self.m_hasTimedOut == True:
            self.m_IP_InUse = None  # Force a DNS resolution, may help when move laptop and gets new address -
            # eventually

#        if self.m_hasTimedOut:
#            Log.getLogger().error("Timed out" + str(ConnectionType.DynamicMarvin))

        if self.m_hasTimedOut and (self.Type == ConnectionType.DynamicMarvin or
                                   self.Type == ConnectionType.DynamicOscar):
            self.MarkedForRemoval = True
            self.Type += 1

        return dataToProcess
Exemplo n.º 10
0
    def SendToDownstreamTarget(self, sendBuffer, TargetID, ignoreTimeout):
        target = self.GetDownstreamTarget(TargetID)

        if None == target:
            Log.getLogger().error(
                "Attempted to send to invalid downstream target id: " +
                TargetID)
            return False

        if True == target.Send(sendBuffer, ignoreTimeout):
            Statistics.GetStatistics().OnPacketSentDownstream(sendBuffer)
            if self.__UseGoverner:
                self.__Governer(len(sendBuffer))
            return True

        else:
            Statistics.GetStatistics().OnPacketDropped()
            return False
Exemplo n.º 11
0
    def HandleBullhornAnnouncement(self,node,rawData,fromAddr):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="Bullhorn">
        #    <Version>1.0</Version>
        #    <UniqueID>3236</UniqueID>
        #    <Hostname>pgkutch.beervana.net</Hostname>
        #    <Key>md5 hash</Key>
        #    <Port>5000</Port>
        #</Marvin>

        try:
            version = node.getElementsByTagName('Version')[0].firstChild.nodeValue 
            Hash = node.getElementsByTagName('Key')[0].firstChild.nodeValue
            Port = node.getElementsByTagName('Port')[0].firstChild.nodeValue
            UniqueID = node.getElementsByTagName('UniqueID')[0].firstChild.nodeValue
            IP = fromAddr[0].lower()
            Hostname = node.getElementsByTagName('Hostname')[0].firstChild.nodeValue

        except Exception as _:
            Statistics.GetStatistics().OnMalformedPacketReceived("Received invalid Marvin Bullhorn  Packet : " + rawData)
            return

        RemoteKey = Configuration.get().GetMarvinAutoConnectKeyFromHash(Hash)

        strID = Hostname + ":[" + IP + ":" + Port +"]" 

        if None == RemoteKey:  #don't have anything configured that matches
            Log.getLogger().warning("Received Marvin Dynamic Connection Message, with no corropsonding Key from: " + strID)
            return
        
        strID += " Key=" + RemoteKey

        HashMapKey = IP + ":" + str(Port)
        objExisting = TargetManager.GetTargetManager().GetDownstreamTarget(HashMapKey)
        if None == objExisting: # could be NDS name not resolved, so try by IP address
            objExisting = TargetManager.GetTargetManager().GetDownstreamTargetEx(IP,Port)

        if None != objExisting:
            if hasattr(objExisting,'_ReceivedOnUniqueID') and UniqueID != objExisting._ReceivedOnUniqueID:
                Log.getLogger().warning("Received Marvin Dynamic Connection Message, for already active connection: " + strID)
            else:
                pass # is simply the additional packets (marvin sends multiples as it is UDP traffic)
            return

        # doesn't already exist, so let's to add!
        if "1.0" == version:
            objTarget = Target.Target(IP,Port,ConnectionType.DynamicMarvin,True)
        else:
            objTarget = Target.Target(IP,Port,ConnectionType.DynamicOscar,True)

        objTarget._ReceivedOnUniqueID = UniqueID # so we can filter out dups due to UDP
        objTarget._UserKey = RemoteKey
        TargetManager.GetTargetManager().AddDownstreamTarget(objTarget,HashMapKey)

        Log.getLogger().info("Creating Dynamic Connection:" + strID)

        return
Exemplo n.º 12
0
    def CreateMarvinPacket(self, rawData, node, fromAddress):
        try:
            version = node.getElementsByTagName('Version')[
                0].firstChild.nodeValue  # for future use, not there now
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Minion Data Packet without a Version tag: " +
                rawData)
            return None

        try:
            namespace = node.getElementsByTagName(
                'Namespace')[0].firstChild.nodeValue

        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Minion Packet without a namespace: " + rawData)
            return None

        try:
            ID = node.getElementsByTagName('ID')[0].firstChild.nodeValue
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Minion Packet without an ID: " + rawData)
            return None
        try:
            value = node.getElementsByTagName('Value')[0].firstChild.nodeValue
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Minion Packet without any data :" + rawData)
            return None

        try:
            eTime = node.getElementsByTagName(
                'ElapsedTime')[0].firstChild.nodeValue
        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Minion Packet without elapsed time tag :" + rawData)
            return None

        objData = MarvinData.MarvinData(namespace, ID, value, eTime, 1.0)

        return objData
Exemplo n.º 13
0
    def HandleMinionTask(self,rawData,node):
        Statistics.GetStatistics().OnMinionTaskReceived()
        TargetManager.GetTargetManager().BroadcastUpstream(rawData) # I could filter out based upon Namespace, but with chained Oscars it got harder, so now let minion filter it out

        try:
            TaskNode   = node.getElementsByTagName('Task')[0]
            
            Log.getLogger().debug("Passing Minion Task --> ID: " + TaskNode.attributes['ID'].nodeValue + " Namespace: " + TaskNode.attributes['Namespace'].nodeValue)
        except:
            pass
Exemplo n.º 14
0
    def BroadcastUpstreamToType(self, sendBuffer, targetType):
        sent = False
        for targetKey in self._UpstreamTargets.keys():
            objTarget = self.GetUpstreamTarget(targetKey)
            if objTarget.getType() == targetType:
                self.SendToUpstreamTarget(sendBuffer, targetKey)
                sent = True

        if True == sent:
            Statistics.GetStatistics().OnPacketBroadcastUpstream()

        return sent
Exemplo n.º 15
0
    def SendToUpstreamTarget(self, sendBuffer, TargetID):
        target = self.GetUpstreamTarget(TargetID)
        if None == target:
            Log.getLogger().error(
                "Attempted to send to invalid upstream target id: " + TargetID)
            return False

        target.Send(
            sendBuffer, True
        )  # timeouts don't matter for upstream, only down, so sent True to ignore
        Statistics.GetStatistics().OnPacketSentUpstream(sendBuffer)
        return True
    def HandleIncomingOscarConnectionInformation(self, node, rawData,
                                                 fromAddress):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Oscar Type="ConnectionInformation">
        #    <Version>1.0</Version>
        #    <OccarVersion>16.11.21 Build 2</OscarVersion>
        #    <ID>Foo</Foo>
        #    <Port>Port</Port>
        #</Oscar>

        try:
            version = node.getElementsByTagName(
                'Version')[0].firstChild.nodeValue
            ID = node.getElementsByTagName('ID')[0].firstChild.nodeValue
            Port = int(
                node.getElementsByTagName('Port')[0].firstChild.nodeValue)

        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Oscar Connection Information Packet : " +
                rawData)
            return

        try:
            oscarVersion = node.getElementsByTagName(
                'OscarVersion')[0].firstChild.nodeValue
        except Exception:
            oscarVersion = 'Unknown'

        IP = fromAddress[0].lower()
        Key = "Oscar:" + ID
        objTarget = TargetManager.GetTargetManager().GetUpstreamTarget(
            Key)  # Chained Oscar, from Upstream

        #        if None == objTarget:
        #            objTarget = TargetManager.GetTargetManager().GetDownstreamTargetEx(IP,Port)  # if using DNS, do lookup based on real IP, not DNS name

        if None == objTarget:
            Log.getLogger().info("Adding Upstream Oscar: " + Key +
                                 " version- " + oscarVersion)
            objTarget = Target.Target(IP, Port, ConnectionType.UpstreamOscar,
                                      False)
            TargetManager.GetTargetManager().AddUpstreamTarget(objTarget, Key)

        elif IP != objTarget.getIP() or Port != objTarget.getPort(
        ):  #hmm, doesn't match, Oscar ID's current connection inf should be unique, so assume is an update from a restart of Oscar
            strOld = str(objTarget)
            objTarget.IP = IP
            objTarget.Port = Port
            Log.getLogger().warning(
                "Received a Oscar Connection Information Packet, with Different Connection Info from previously configured ["
                + ID + "] " + strOld + "--> " + str(objTarget))
Exemplo n.º 17
0
    def HandleIncomingPacket(self, node, rawData, fromAddress):
        if node.nodeName == "MinionGroup":
            self.HandleIncomingGroupPacket(rawData, node, fromAddress)
            return

        Statistics.GetStatistics().OnPacketReceivedFromUpstream(rawData)
        try:
            packetType = node.attributes[
                "Type"].nodeValue  #All should have a Type attribute
        except Exception as ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Malformed Minion Packet: " + rawData)
            return

        if packetType == "Data":
            self.HandleIncomingMinionData(rawData, node, fromAddress)
        elif packetType == "ConnectionInformation":
            self.HandleIncomingMinionConnectionInformation(
                node, rawData, fromAddress)
        else:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received unknown Minion Packet Type: " + rawData)
    def HandleIncomingWatchdogPacket(self, node, rawData, fromAddress):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Oscar Type=?WatchdogTimer">
        #    <Version>1.0</Version>
        #     <Port>5000</Port>
        #</Oscar>

        Statistics.GetStatistics().OnPacketReceivedFromDownstream(rawData)
        try:
            version = node.getElementsByTagName(
                'Version')[0].firstChild.nodeValue
            IP = fromAddress[0].lower()
            Port = node.getElementsByTagName('Port')[0].firstChild.nodeValue

        except Exception as Ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Oscar WatchdogTimer  Packet : " + rawData)
            return

        Key = IP + ":" + Port
        objTarget = TargetManager.GetTargetManager().GetDownstreamTarget(
            Key)  # Chained Oscar

        if None == objTarget:
            objTarget = TargetManager.GetTargetManager().GetDownstreamTargetEx(
                IP, Port)  # Chained Oscar, used resolved IP

        if None == objTarget:
            Log.getLogger().warning(
                "Received Oscar Watchdog for unknown downstream Target: ",
                IP + ":" + Port)
            return

        if objTarget.getType(
        ) != ConnectionType.DownstreamOscar:  # would not know what this is until you hear back
            objTarget.Type = ConnectionType.DownstreamOscar
        objTarget.StrokeWatchdogTimer()
    def CreateMarvinData(self, node, rawData, fromAddress):
        try:
            version = node.getElementsByTagName('Version')[
                0].firstChild.nodeValue  # for future use, not there now
            namespace = node.getElementsByTagName(
                'Namespace')[0].firstChild.nodeValue
            value = node.getElementsByTagName('Value')[0].firstChild.nodeValue
            ID = node.getElementsByTagName('ID')[0].firstChild.nodeValue

        except Exception as _:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received Chained Oscar Packet:" + rawData)
            return None

        objData = MarvinData.MarvinData(namespace, ID, value, 0, version, True)
        return objData
    def HandleIncomingOscarDatapacket(self, node, rawData, fromAddress):
        from Helpers import Configuration
        # Use this object to update the gui and for recording
        # is also where BITW check update of checked map occurs
        objData = self.CreateMarvinData(node, rawData, fromAddress)

        if Configuration.get().GetBITW_Active():
            rawData = Configuration.get().HandleBITWBuffer(
                rawData)  # handle Bump in the wire

        if 0 != TargetManager.GetTargetManager().BroadcastDownstream(
                rawData, False, node):  # send to all - towards a Marvin
            Statistics.GetStatistics().OnPacketChainedDownstream(rawData)

        if None != objData:
            GuiMgr.OnDataPacketSentDownstream(objData, "Chained")
            Recorder.get().AddData(objData)
    def HandleFoghornPacket(self, node, rawData, fromAddr):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Foghorn>
        #    <Version>1.0</Version>
        #    <ConfigAddress>Kutch.system.foo.com</ConfigAddress>
        #    <NewIPAddress>129.234.1.22</NewIPAddress>
        #    <Port>Port</Port>
        #</Foghorn>
        try:
            _ = node.getElementsByTagName('Version')[0].firstChild.nodeValue
            ConfigAddr = node.getElementsByTagName(
                'ConfigAddress')[0].firstChild.nodeValue
            NewAddr = node.getElementsByTagName(
                'NewIPAddress')[0].firstChild.nodeValue

        except Exception as _:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received invalid Oscar Connection Information Packet : " +
                rawData)
            return

        TargetManager.GetTargetManager().UpdateDownstreamTarget(
            ConfigAddr, NewAddr)
Exemplo n.º 22
0
 def HandleRemoteMarvinTask(self, rawData):
     Statistics.GetStatistics().OnMarvinTaskReceived()
     TargetManager.GetTargetManager().BroadcastDownstream(
         rawData, False, none)
Exemplo n.º 23
0
    def HandleOscarTask(self, node, rawData):
        #<?xml version="1.0" encoding="utf-8"?>
        #<Marvin Type="OscarTask">
        #    <Version>1.0</Version>
        #     <OscarID>DemoOscar</OscarID>
        #     <UniqueID>1233456</UniqueID>
        #     <Task>taskid</Task>
        #     <Param>p1</Param>
        #</Marvin>
        Statistics.GetStatistics().OnOscarTaskReceived()
        try:
            UniqueID = node.getElementsByTagName(
                'UniqueID')[0].firstChild.nodeValue

            OscarID = node.getElementsByTagName(
                'OscarID')[0].firstChild.nodeValue
            task = node.getElementsByTagName('Task')[0].firstChild.nodeValue
            tTask = task.lower()
            Params = []

            for param in node.getElementsByTagName(
                    'Param'):  # Make an array of the params for the script
                strParam = param.firstChild.nodeValue
                Params.append(strParam)
        except Exception as ex:
            Statistics.GetStatistics().OnMalformedPacketReceived(
                "Received bad Oscar Task: " + rawData)

        if OscarID.lower() != Configuration.get().GetID().lower(
        ):  # Oscar packet, but probably not destined for this Oscar
            if OscarID.lower() == "Broadcast".lower():
                Log.getLogger().info("Received Broadcast Oscar task: " + task)
            else:
                Log.getLogger().info("Received Oscar task [" + task +
                                     "] for another Oscar with ID: " +
                                     OscarID)  # not for this guy
                #increment dropped stats?
                return

        if UniqueID == self.LastUniqueID:
            #Log.getLogger().info("Dropping duplicate Oscar Task")
            return

        self.LastUniqueID = UniqueID

        if tTask == "StartLive".lower():
            self.PerformGoLiveTask(Params)

        elif tTask == "StopLive".lower():
            self.PerformStopLiveTask(Params)

        elif tTask == "LoadFile".lower():
            self.PerformLoadFileTask(Params)

        elif tTask == "Playback".lower():
            self.PerformPlayFileTask(Params)

        elif tTask == "StopPlayback".lower():
            self.PerformStopPlaybackTask(Params)

        elif tTask == "PausePlayback".lower():
            self.PerformPausePlaybackTask(Params)

        elif tTask == "StartRecording".lower():
            self.PerformStartRecordingTask(Params)

        elif tTask == "StopRecording".lower():
            self.PerformStopRecordingTask(Params)

        else:
            Log.getLogger().warn("Unknown Oscar Task: " + task)