当前位置: 首页>>代码示例>>Python>>正文


Python Host.config方法代码示例

本文整理汇总了Python中mininet.node.Host.config方法的典型用法代码示例。如果您正苦于以下问题:Python Host.config方法的具体用法?Python Host.config怎么用?Python Host.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mininet.node.Host的用法示例。


在下文中一共展示了Host.config方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)

        debug("configuring route %s" % self.route)

        self.cmd('ip addr add %s dev %s-eth0' % (self.ip, self.name))
        self.cmd('ip route add default via %s' % self.route)
开发者ID:CrazyCooper,项目名称:onos,代码行数:9,代码来源:tutorial_ipv6.py

示例2: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)
        self.cmd('sysctl net.ipv4.ip_forward=1')

        for intf, attrs in self.intfDict.items():
            self.cmd('ip addr flush dev %s' % intf)
            if 'mac' in attrs:
                self.cmd('ip link set %s down' % intf)
                self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
                self.cmd('ip link set %s up ' % intf)
                self.nameToIntf[intf].mac=attrs['mac']
            # for addr in attrs['ipAddrs']:
            if 'vlan' in attrs:
                # self.cmd('ip addr flush dev %s')
                self.cmd('ip link add link %s name %s.%s type vlan id %s' % (intf, intf, attrs['vlan'], attrs['vlan']))
                self.cmd('ip addr add %s dev %s.%s' % (attrs['ipAddrs'], intf, attrs['vlan']))
                self.cmd('ip link set dev %s.%s up' % (intf, attrs['vlan']))
            if ('ipAddrs' in attrs) & ('vlan' not in attrs):
                self.cmd('ip addr add %s dev %s' % (attrs['ipAddrs'], intf))
                self.nameToIntf[intf].ip=attrs['ipAddrs'].split('/')[0]
                self.nameToIntf[intf].prefixLen=attrs['ipAddrs'].split('/')[1]


        self.cmd('%s/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (
        QUAGGA_DIR, self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
        self.cmd('%s/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (
        QUAGGA_DIR, self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))

        for attrs in self.ARPDict.itervalues():
            if 'localdev' in attrs:
                self.cmd('ip route add %s%s dev %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['localdev']))
                self.setARP(attrs['remoteIP'], attrs['remoteMAC'])
            elif 'nexthop' in attrs:
                self.cmd('ip route add %s%s via %s' % (attrs['remoteIP'], attrs['remoteMask'], attrs['nexthop']))
                self.setARP(attrs['nexthop'], attrs['remoteMAC'])
开发者ID:piotrekz79,项目名称:demo_invitation,代码行数:37,代码来源:coco_multidomain_invitation.py

示例3: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)

        debug("configuring route %s" % self.gateway)

        self.cmd('ip addr flush dev %s' % self.defaultIntf())
        for ip in self.ips:
            self.cmd('ip addr add %s dev %s' % (ip, self.defaultIntf()))

        self.cmd('ip route add default via %s' % self.gateway)
开发者ID:ckannan,项目名称:iSDX,代码行数:12,代码来源:sdnip.py

示例4: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
 def config(self, **kwargs):
     Host.config(self, **kwargs)
     self.cmd('sysctl net.ipv4.ip_forward=1')
     for intf, attrs in self.intfDict.items():
         self.cmd('ip addr flush dev %s' % intf)
         if 'mac' in attrs:
             self.cmd('ip link set %s down' % intf)
             self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
             self.cmd('ip link set %s up ' % intf)
         for addr in attrs['ipAddrs']:
             self.cmd('ip addr add %s dev %s' % (addr, intf))
     self.cmd('/usr/lib/quagga/zebra -d -f %s -z %s/zebra%s.api -i %s/zebra%s.pid' % (self.zebraConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
     self.cmd('/usr/lib/quagga/bgpd -d -f %s -z %s/zebra%s.api -i %s/bgpd%s.pid' % (self.quaggaConfFile, QUAGGA_RUN_DIR, self.name, QUAGGA_RUN_DIR, self.name))
开发者ID:hyunsun,项目名称:mininet-scripts,代码行数:15,代码来源:sdnip.py

示例5: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)
        intf = self.defaultIntf()
        self.vlanIntf = "%s.%s" % (intf, self.vlan)
        self.cmd('ip -4 addr flush dev %s' % intf)
        self.cmd('ip link add link %s name %s type vlan id %s' % (intf, self.vlanIntf, self.vlan))
        self.cmd('ip link set up %s' % self.vlanIntf)

        for ip in self.ips:
            self.cmd('ip addr add %s dev %s' % (ip, self.vlanIntf))

        self.cmd('ip route add default via %s' % self.gateway)
        intf.name = self.vlanIntf
        self.nameToIntf[self.vlanIntf] = intf
开发者ID:opennetworkinglab,项目名称:OnosSystemTest,代码行数:16,代码来源:trellislib.py

示例6: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)
        self.cmd('sysctl net.ipv4.ip_forward=1')

        for intf, attrs in self.intfDict.items():
            self.cmd('ip addr flush dev %s' % intf)
            if 'mac' in attrs:
                self.cmd('ip link set %s down' % intf)
                self.cmd('ip link set %s address %s' % (intf, attrs['mac']))
                self.cmd('ip link set %s up ' % intf)
            for addr in attrs['ipAddrs']:
                print str(attrs)
                mask = attrs['mask']
                gateway = attrs['gateway']
                # print str('ifconfig %s %s netmask %s' % (intf, addr, mask))
                self.cmd('ifconfig %s %s netmask %s' % (intf, addr, mask))
                self.cmd('route add default gw %s' % (gateway))
开发者ID:michaelph,项目名称:mininet-lab,代码行数:19,代码来源:wpgec2016.py

示例7: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
	def config(self, *_parm, **_params):
		rv = Host.config(self, *_parm, **_params)
		qcall(self,self.cmd,'iptables -P INPUT ACCEPT')
		qcall(self,self.cmd,'iptables -P OUTPUT ACCEPT')
		qcall(self,self.cmd,'iptables -P FORWARD DROP')
		qcall(self,self.cmd,'iptables -A FORWARD -p icmp -j ACCEPT')
		qcall(self,self.cmd,'iptables -A FORWARD -i s1-lan -o s1-wan -p tcp --sport 1024:65535 --dport 80 -j ACCEPT')
		qcall(self,self.cmd,'iptables -A FORWARD -i s1-wan -o s1-lan -p tcp --sport 80 --dport 1024:65535 -j ACCEPT')
		#qcall(self,self.cmd,'iptables -A FORWARD -i s1-lan -o s1-wan -p tcp --sport 49152:65535 --dport 80 -j ACCEPT')
		#qcall(self,self.cmd,'iptables -A FORWARD -i s1-wan -o s1-lan -p tcp --sport 80 --dport 49152:65535 -j ACCEPT')
		self.ifc()
		qcall(self,self.cmd,'ip route add default via 10.0.2.1 dev s1-wan')
		self.cmd('sysctl -w net.ipv4.ip_forward=1')
		return rv
开发者ID:ammbauer,项目名称:Iptables_Semantics,代码行数:16,代码来源:3chn.py

示例8: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
 def config(self, **kwargs):
     Host.config(self, **kwargs)
     mtu = "ifconfig "+self.name+"-eth0 mtu 1490"
     self.cmd(mtu)
     self.cmd('ip route add default via %s' % self.gateway)
开发者ID:akoshibe,项目名称:ecord-topos,代码行数:7,代码来源:twoCOs.py

示例9: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)

        debug("configuring route %s" % self.route)

        self.cmd('ip route add default via %s' % self.route)
开发者ID:Irishsmurf,项目名称:onos-1.4.0-custom-build,代码行数:8,代码来源:tutorial.py

示例10: config

# 需要导入模块: from mininet.node import Host [as 别名]
# 或者: from mininet.node.Host import config [as 别名]
    def config(self, **kwargs):
        Host.config(self, **kwargs)

        debug("configuring gateway %s" % (self.gw, ))
        self.cmd('ip route add default via %s' % (self.gw, ))
开发者ID:pichuang,项目名称:SDN-IP-Example-VM,代码行数:7,代码来源:sdnip_quagga.py


注:本文中的mininet.node.Host.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。