當前位置: 首頁>>代碼示例>>Python>>正文


Python node.Host方法代碼示例

本文整理匯總了Python中mininet.node.Host方法的典型用法代碼示例。如果您正苦於以下問題:Python node.Host方法的具體用法?Python node.Host怎麽用?Python node.Host使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mininet.node的用法示例。


在下文中一共展示了node.Host方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: network_ips

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def network_ips(self) -> Dict[str, List[str]]:
        """Return all the addresses of the nodes connected directly or not
        to this node"""
        ips = {}  # type: Dict[str, List[str]]
        visited = set()  # type: Set[str]
        to_visit = [self]
        while to_visit:
            node = to_visit.pop()
            if node.name in visited:
                continue
            visited.add(node.name)
            if isinstance(node, (Host, IPNode)):
                for i in node.intfList():
                    for ip in list(i.ips()) \
                              + list(i.ip6s(exclude_lls=True)):
                        ips.setdefault(node.name, []).append(ip.ip.compressed)

            for i in realIntfList(node):
                adj_i = otherIntf(i)
                if adj_i is not None:
                    to_visit.append(adj_i.node)
        return ips 
開發者ID:cnp3,項目名稱:ipmininet,代碼行數:24,代碼來源:__router.py

示例2: stop

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def stop( self ):
        "Stop network."
        if self.net is not None:
            # Stop host details
            for widget in self.widgetToItem:
                name = widget[ 'text' ]
                tags = self.canvas.gettags( self.widgetToItem[ widget ] )
                if 'Host' in tags:
                    newHost = self.net.get(name)
                    opts = self.hostOpts[name]
                    # Run User Defined Stop Command
                    if 'stopCommand' in opts:
                        newHost.cmdPrint(opts['stopCommand'])
                if 'Switch' in tags:
                    newNode = self.net.get(name)
                    opts = self.switchOpts[name]
                    # Run User Defined Stop Command
                    if 'stopCommand' in opts:
                        newNode.cmdPrint(opts['stopCommand'])

            self.net.stop()
        cleanUpScreens()
        self.net = None 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:25,代碼來源:miniedit.py

示例3: config

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def config(self, **params):
        r = super(Host, self).config(**params)

        self.defaultIntf().rename("eth0")

        for off in ["rx", "tx", "sg"]:
            cmd = "/sbin/ethtool --offload eth0 %s off" % off
            self.cmd(cmd)

        # disable IPv6
        self.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
        self.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
        self.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")

        return r 
開發者ID:netx-repo,項目名稱:netcache-p4,代碼行數:17,代碼來源:p4_mininet.py

示例4: isBroadcastDomainBoundary

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def isBroadcastDomainBoundary(node):
    return isinstance(node, Host) or isinstance(node, IPRouter) 
開發者ID:Fibbing,項目名稱:FibbingNode,代碼行數:4,代碼來源:ipnet.py

示例5: addNode

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def addNode( self, node, nodeNum, x, y, name=None):
        "Add a new node to our canvas."
        if 'Switch' == node:
            self.switchCount += 1
        if 'Host' == node:
            self.hostCount += 1
        if 'Controller' == node:
            self.controllerCount += 1
        if name is None:
            name = self.nodePrefixes[ node ] + nodeNum
        self.addNamedNode(node, name, x, y) 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:13,代碼來源:miniedit.py

示例6: findItem

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def findItem( self, x, y ):
        "Find items at a location in our canvas."
        items = self.canvas.find_overlapping( x, y, x, y )
        if len( items ) == 0:
            return None
        else:
            return items[ 0 ]

    # Canvas bindings for Select, Host, Switch and Link tools 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:11,代碼來源:miniedit.py

示例7: clickHost

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def clickHost( self, event ):
        "Add a new host to our canvas."
        self.newNode( 'Host', event ) 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:5,代碼來源:miniedit.py

示例8: hostDetails

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def hostDetails( self, _ignore=None ):
        if ( self.selection is None or
             self.net is not None or
             self.selection not in self.itemToWidget ):
            return
        widget = self.itemToWidget[ self.selection ]
        name = widget[ 'text' ]
        tags = self.canvas.gettags( self.selection )
        if 'Host' not in tags:
            return

        prefDefaults = self.hostOpts[name]
        hostBox = HostDialog(self, title='Host Details', prefDefaults=prefDefaults)
        self.master.wait_window(hostBox.top)
        if hostBox.result:
            newHostOpts = {'nodeNum':self.hostOpts[name]['nodeNum']}
            newHostOpts['sched'] = hostBox.result['sched']
            if len(hostBox.result['startCommand']) > 0:
                newHostOpts['startCommand'] = hostBox.result['startCommand']
            if len(hostBox.result['stopCommand']) > 0:
                newHostOpts['stopCommand'] = hostBox.result['stopCommand']
            if len(hostBox.result['cpu']) > 0:
                newHostOpts['cpu'] = float(hostBox.result['cpu'])
            if len(hostBox.result['cores']) > 0:
                newHostOpts['cores'] = hostBox.result['cores']
            if len(hostBox.result['hostname']) > 0:
                newHostOpts['hostname'] = hostBox.result['hostname']
                name = hostBox.result['hostname']
                widget[ 'text' ] = name
            if len(hostBox.result['defaultRoute']) > 0:
                newHostOpts['defaultRoute'] = hostBox.result['defaultRoute']
            if len(hostBox.result['ip']) > 0:
                newHostOpts['ip'] = hostBox.result['ip']
            if len(hostBox.result['externalInterfaces']) > 0:
                newHostOpts['externalInterfaces'] = hostBox.result['externalInterfaces']
            if len(hostBox.result['vlanInterfaces']) > 0:
                newHostOpts['vlanInterfaces'] = hostBox.result['vlanInterfaces']
            if len(hostBox.result['privateDirectory']) > 0:
                newHostOpts['privateDirectory'] = hostBox.result['privateDirectory']
            self.hostOpts[name] = newHostOpts
            info( 'New host details for ' + name + ' = ' + str(newHostOpts), '\n' ) 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:43,代碼來源:miniedit.py

示例9: xterm

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def xterm( self, _ignore=None ):
        "Make an xterm when a button is pressed."
        if ( self.selection is None or
             self.net is None or
             self.selection not in self.itemToWidget ):
            return
        name = self.itemToWidget[ self.selection ][ 'text' ]
        if name not in self.net.nameToNode:
            return
        term = makeTerm( self.net.nameToNode[ name ], 'Host', term=self.appPrefs['terminalType'] )
        if StrictVersion(MININET_VERSION) > StrictVersion('2.0'):
            self.net.terms += term
        else:
            self.net.terms.append(term) 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:16,代碼來源:miniedit.py

示例10: __init__

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def __init__(self):
        "Create Fat tree Topology"

        Topo.__init__(self)

        #Add hosts
        h7 = self.addHost('h7', cls=Host, ip='10.0.0.7', defaultRoute=None)
        h8 = self.addHost('h8', cls=Host, ip='10.0.0.8', defaultRoute=None)
        h1 = self.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
        h2 = self.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
        h4 = self.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
        h3 = self.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)
        h5 = self.addHost('h5', cls=Host, ip='10.0.0.5', defaultRoute=None)
        h6 = self.addHost('h6', cls=Host, ip='10.0.0.6', defaultRoute=None)

        #Add switches
        s10 = self.addSwitch('s10', cls=OVSKernelSwitch)
        s3 = self.addSwitch('s3', cls=OVSKernelSwitch)
        s17 = self.addSwitch('s17', cls=OVSKernelSwitch)
        s4 = self.addSwitch('s4', cls=OVSKernelSwitch)
        s18 = self.addSwitch('s18', cls=OVSKernelSwitch)
        s1 = self.addSwitch('s1', cls=OVSKernelSwitch)
        s11 = self.addSwitch('s11', cls=OVSKernelSwitch)
        s21 = self.addSwitch('s21', cls=OVSKernelSwitch)
        s22 = self.addSwitch('s22', cls=OVSKernelSwitch)
        s2 = self.addSwitch('s2', cls=OVSKernelSwitch)

        #Add links
        self.addLink(h1, s1)
        self.addLink(h2, s1)
        self.addLink(h3, s2)
        self.addLink(h4, s2)
        self.addLink(h5, s3)
        self.addLink(h6, s3)
        self.addLink(h7, s4)
        self.addLink(h8, s4)
        self.addLink(s1, s21)
        self.addLink(s21, s2)
        self.addLink(s1, s10)
        self.addLink(s2, s10)
        self.addLink(s3, s11)
        self.addLink(s4, s22)
        self.addLink(s11, s4)
        self.addLink(s3, s22)
        self.addLink(s21, s17)
        self.addLink(s11, s17)
        self.addLink(s10, s18)
        self.addLink(s22, s18) 
開發者ID:nayanseth,項目名稱:sdn-loadbalancing,代碼行數:50,代碼來源:topology.py

示例11: myNetwork

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6653)

    info( '*** Add switches\n')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=OVSKernelSwitch)
    s5 = net.addSwitch('s5', cls=OVSKernelSwitch, failMode='standalone')

    info( '*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h4 = net.addHost('h4', cls=Host, ip='10.0.0.4', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)

    info( '*** Add links\n')
    s1s2 = {'bw':400,'loss':0}
    net.addLink(s1, s2, cls=TCLink , **s1s2)
    s2h1 = {'bw':1000,'loss':10,'max_queue_size':10,'speedup':40}
    net.addLink(s2, h1, cls=TCLink , **s2h1)
    s2h2 = {'bw':120,'loss':0}
    net.addLink(s2, h2, cls=TCLink , **s2h2)
    s2h3 = {'bw':400,'loss':20}
    net.addLink(s2, h3, cls=TCLink , **s2h3)
    s1s5 = {'bw':200,'delay':'12','loss':10}
    net.addLink(s1, s5, cls=TCLink , **s1s5)
    s5h4 = {'bw':100,'loss':50}
    net.addLink(s5, h4, cls=TCLink , **s5h4)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s2').start([c0])
    net.get('s1').start([c0])
    net.get('s5').start([])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop() 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:55,代碼來源:10_3_sdn_onos.py

示例12: myNetwork

# 需要導入模塊: from mininet import node [as 別名]
# 或者: from mininet.node import Host [as 別名]
def myNetwork():

    net = Mininet( topo=None,
                   build=False,
                   ipBase='10.0.0.0/8')

    info( '*** Adding controller\n' )
    c0=net.addController(name='c0',
                      controller=RemoteController,
                      ip='127.0.0.1',
                      protocol='tcp',
                      port=6653)

    info( '*** Add switches\n')
    s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
    s1 = net.addSwitch('s1', cls=IVSSwitch)

    info( '*** Add hosts\n')
    h2 = net.addHost('h2', cls=Host, ip='10.0.0.2', defaultRoute=None)
    h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
    h3 = net.addHost('h3', cls=Host, ip='10.0.0.3', defaultRoute=None)

    info( '*** Add links\n')
    s1s2 = {'bw':400,'loss':0}
    net.addLink(s1, s2, cls=TCLink , **s1s2)
    s2h1 = {'bw':1000,'loss':10,'max_queue_size':10,'speedup':40}
    net.addLink(s2, h1, cls=TCLink , **s2h1)
    s2h2 = {'bw':120,'loss':0}
    net.addLink(s2, h2, cls=TCLink , **s2h2)
    s2h3 = {'bw':400,'loss':20}
    net.addLink(s2, h3, cls=TCLink , **s2h3)

    info( '*** Starting network\n')
    net.build()
    info( '*** Starting controllers\n')
    for controller in net.controllers:
        controller.start()

    info( '*** Starting switches\n')
    net.get('s2').start([c0])
    net.get('s1').start([c0])

    info( '*** Post configure switches and hosts\n')

    CLI(net)
    net.stop() 
開發者ID:PacktPublishing,項目名稱:Python-Network-Programming-Cookbook-Second-Edition,代碼行數:48,代碼來源:10_4_sdn_floodlight.py


注:本文中的mininet.node.Host方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。