daemon/core/misc/xmlwriter1.py
def addChannels(self, netObj):
        ''' Add channels to a network XML element
        '''

        if isinstance(netObj, (nodes.WlanNode, nodes.EmaneNode)):
            modelconfigs = netObj.session.mobility.getmodels(netObj)
            modelconfigs += netObj.session.emane.getmodels(netObj)
            chan = None
            for (model, conf) in modelconfigs:
                # Handle mobility parameters below
                if model._type == coreapi.CORE_TLV_REG_MOBILITY:
                    continue

                # Create the channel
                if chan is None:
                    name = "wireless"
                    chan = ChannelElement(self.scenPlan, self, netObj,
                                          channelType=model._name,
                                          channelName=name,
                                          channelDomain="CORE")

                # Add wireless model parameters
                for i, key in enumerate(model.getnames()):
                    value = conf[i]
                    if value is not None:
                        chan.addParameter(key, model.valueof(key, conf))

            for (model, conf) in modelconfigs:
                if model._type == coreapi.CORE_TLV_REG_MOBILITY:
                    # Add wireless mobility parameters
                    mobility = XmlElement(self.scenPlan, chan, "CORE:mobility")
                    # Add a type child
                    typeEle = self.createElement("type")
                    typeEle.appendChild(self.createTextNode(model._name))
                    mobility.appendChild(typeEle)
                    for i, key in enumerate(model.getnames()):
                        value = conf[i]
                        if value is not None:
                            mobility.addParameter(key, value)

            # Add members to the channel
            if chan is not None:
                chan.addChannelMembers(self.endpoints)
                self.appendChild(chan.baseEle)
        elif isinstance(netObj, nodes.PtpNet) :
            if len(self.endpoints) < 2:
                if len(self.endpoints) == 1:
                    self.coreSession.warn('Pt2Pt network with only 1 endpoint: %s' % self.endpoints[0].id)
                else:
                    self.coreSession.warn('Pt2Pt network with no endpoints encountered in %s' % netObj.name)
                return
            name = "chan%d" % (0)
            chan = ChannelElement(self.scenPlan, self, netObj,
                                  channelType=Attrib.NetType.ETHERNET,
                                  channelName=name)

            # Add interface parameters
            if self.endpoints[0].params != self.endpoints[1].params:
                self.coreSession.warn('Pt2Pt Endpoint  parameters do not match in %s' % netObj.name)
            for key, value in self.endpoints[0].params:
                # XXX lifted from original addnetem function. revisit this.
                # default netem parameters are 0 or None
                if value is None or value == 0:
                    continue
                if key == "has_netem" or key == "has_tbf":
                    continue
                chan.addParameter(key, value)

            # Add members to the channel
            chan.addChannelMembers(self.endpoints)
            self.appendChild(chan)

        elif isinstance(netObj, (nodes.SwitchNode,
                              nodes.HubNode, nodes.TunnelNode)):
            cidx=0
            channels = []
            for ep in self.endpoints:
                # Create one channel member per ep
                if ep.type:
                    name = "chan%d" % (cidx)
                    chan = ChannelElement(self.scenPlan, self, netObj,
                                          channelType=Attrib.NetType.ETHERNET,
                                          channelName=name)

                    # Add interface parameters
                    for key, value in ep.params:
                        # XXX lifted from original addnetem function. revisit this.
                        # default netem parameters are 0 or None
                        if value is None or value == 0:
                            continue
                        if key == "has_netem" or key == "has_tbf":
                            continue
                        chan.addParameter(key, value)

                    # Add members to the channel
                    chan.addChannelMembers(ep)
                    channels.append(chan)
                    cidx += 1

            for chan in channels:
                self.appendChild(chan)
 Add channels to a network XML element
        
Add channels to a network XML element
Add channels to a network XML element
def addChannels(self, netObj):
        if isinstance(netObj, (nodes.WlanNode, nodes.EmaneNode)):
            modelconfigs = netObj.session.mobility.getmodels(netObj)
            modelconfigs += netObj.session.emane.getmodels(netObj)
            chan = None
            for (model, conf) in modelconfigs:
                if model._type == coreapi.CORE_TLV_REG_MOBILITY:
                    continue
                if chan is None:
                    name = "wireless"
                    chan = ChannelElement(self.scenPlan, self, netObj,
                                          channelType=model._name,
                                          channelName=name,
                                          channelDomain="CORE")
                for i, key in enumerate(model.getnames()):
                    value = conf[i]
                    if value is not None:
                        chan.addParameter(key, model.valueof(key, conf))
            for (model, conf) in modelconfigs:
                if model._type == coreapi.CORE_TLV_REG_MOBILITY:
                    mobility = XmlElement(self.scenPlan, chan, "CORE:mobility")
                    typeEle = self.createElement("type")
                    typeEle.appendChild(self.createTextNode(model._name))
                    mobility.appendChild(typeEle)
                    for i, key in enumerate(model.getnames()):
                        value = conf[i]
                        if value is not None:
                            mobility.addParameter(key, value)
            if chan is not None:
                chan.addChannelMembers(self.endpoints)
                self.appendChild(chan.baseEle)
        elif isinstance(netObj, nodes.PtpNet) :
            if len(self.endpoints) < 2:
                if len(self.endpoints) == 1:
                    self.coreSession.warn('Pt2Pt network with only 1 endpoint: %s' % self.endpoints[0].id)
                else:
                    self.coreSession.warn('Pt2Pt network with no endpoints encountered in %s' % netObj.name)
                return
            name = "chan%d" % (0)
            chan = ChannelElement(self.scenPlan, self, netObj,
                                  channelType=Attrib.NetType.ETHERNET,
                                  channelName=name)
            if self.endpoints[0].params != self.endpoints[1].params:
                self.coreSession.warn('Pt2Pt Endpoint  parameters do not match in %s' % netObj.name)
            for key, value in self.endpoints[0].params:
                if value is None or value == 0:
                    continue
                if key == "has_netem" or key == "has_tbf":
                    continue
                chan.addParameter(key, value)
            chan.addChannelMembers(self.endpoints)
            self.appendChild(chan)
        elif isinstance(netObj, (nodes.SwitchNode,
                              nodes.HubNode, nodes.TunnelNode)):
            cidx=0
            channels = []
            for ep in self.endpoints:
                if ep.type:
                    name = "chan%d" % (cidx)
                    chan = ChannelElement(self.scenPlan, self, netObj,
                                          channelType=Attrib.NetType.ETHERNET,
                                          channelName=name)
                    for key, value in ep.params:
                        if value is None or value == 0:
                            continue
                        if key == "has_netem" or key == "has_tbf":
                            continue
                        chan.addParameter(key, value)
                    chan.addChannelMembers(ep)
                    channels.append(chan)
                    cidx += 1
            for chan in channels:
                self.appendChild(chan)
def addChannels ( self , netObj ) : if isinstance ( netObj , ( nodes . WlanNode , nodes . EmaneNode ) ) : modelconfigs = netObj . session . mobility . getmodels ( netObj ) modelconfigs += netObj . session . emane . getmodels ( netObj ) chan = None for ( model , conf ) in modelconfigs : if model . _type == coreapi . CORE_TLV_REG_MOBILITY : continue if chan is None : name = "wireless" chan = ChannelElement ( self . scenPlan , self , netObj , channelType = model . _name , channelName = name , channelDomain = "CORE" ) for i , key in enumerate ( model . getnames ( ) ) : value = conf [ i ] if value is not None : chan . addParameter ( key , model . valueof ( key , conf ) ) for ( model , conf ) in modelconfigs : if model . _type == coreapi . CORE_TLV_REG_MOBILITY : mobility = XmlElement ( self . scenPlan , chan , "CORE:mobility" ) typeEle = self . createElement ( "type" ) typeEle . appendChild ( self . createTextNode ( model . _name ) ) mobility . appendChild ( typeEle ) for i , key in enumerate ( model . getnames ( ) ) : value = conf [ i ] if value is not None : mobility . addParameter ( key , value ) if chan is not None : chan . addChannelMembers ( self . endpoints ) self . appendChild ( chan . baseEle ) elif isinstance ( netObj , nodes . PtpNet ) : if len ( self . endpoints ) < 2 : if len ( self . endpoints ) == 1 : self . coreSession . warn ( 'Pt2Pt network with only 1 endpoint: %s' % self . endpoints [ 0 ] . id ) else : self . coreSession . warn ( 'Pt2Pt network with no endpoints encountered in %s' % netObj . name ) return name = "chan%d" % ( 0 ) chan = ChannelElement ( self . scenPlan , self , netObj , channelType = Attrib . NetType . ETHERNET , channelName = name ) if self . endpoints [ 0 ] . params != self . endpoints [ 1 ] . params : self . coreSession . warn ( 'Pt2Pt Endpoint  parameters do not match in %s' % netObj . name ) for key , value in self . endpoints [ 0 ] . params : if value is None or value == 0 : continue if key == "has_netem" or key == "has_tbf" : continue chan . addParameter ( key , value ) chan . addChannelMembers ( self . endpoints ) self . appendChild ( chan ) elif isinstance ( netObj , ( nodes . SwitchNode , nodes . HubNode , nodes . TunnelNode ) ) : cidx = 0 channels = [ ] for ep in self . endpoints : if ep . type : name = "chan%d" % ( cidx ) chan = ChannelElement ( self . scenPlan , self , netObj , channelType = Attrib . NetType . ETHERNET , channelName = name ) for key , value in ep . params : if value is None or value == 0 : continue if key == "has_netem" or key == "has_tbf" : continue chan . addParameter ( key , value ) chan . addChannelMembers ( ep ) channels . append ( chan ) cidx += 1 for chan in channels : self . appendChild ( chan )
Add channels to a network XML element
Add channels to a network XML element
''' Add channels to a network XML element
        ''' # Handle mobility parameters below # Create the channel # Add wireless model parameters # Add wireless mobility parameters # Add a type child # Add members to the channel # Add interface parameters # XXX lifted from original addnetem function. revisit this. # default netem parameters are 0 or None # Add members to the channel # Create one channel member per ep # Add interface parameters # XXX lifted from original addnetem function. revisit this. # default netem parameters are 0 or None # Add members to the channel
self
netObj