• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python node.Node类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: connectToRootNS

def connectToRootNS(network, switch, ip, routes):
    root = Node('root', inNamespace=False)
    intf = network.addLink(root, switch).intf1
    root.setIP(ip, intf=intf)
    network.start()
    for route in routes:
        root.cmd('route add -net {} dev {} '.format(route, intf)) 
开发者ID:amwelch,项目名称:mininet-sandbox,代码行数:7,代码来源:chatty.py


示例2: stop

 def stop( self, deleteIntfs=False ):
     dev_null = open(os.devnull, 'w')
     subprocess.call( [ 'docker rm -f ' + self.name ],
                      stdin=dev_null, stdout=dev_null,
                      stderr=dev_null, shell=True )
     dev_null.close()
     Node.stop( self, deleteIntfs )
开发者ID:25dedezembro,项目名称:p4factory,代码行数:7,代码来源:docker_node.py


示例3: checkOVS

	def checkOVS(self):
		root = Node('root', inNamespace=False)
		modinfo = root.cmd("modinfo openvswitch | grep version: |awk -F':' '{print $2}' | awk '{ gsub (\" \", \"\", $0); print}'")
		versions = modinfo.split("\n")
		version = versions[0]
		print "modinfo openviswitch : " + version
		# SS 2017-10-21 I've disabled the version check because in the packaged openvswitch there is no version info
		# modversion = float(version[:3])
		# if modversion < 2.3:
		# 	error( 'OVS Kernel Module does not respect version requirement\nPlease check your OVS installation\n' )
		# 	exit( 1 )

		vswitchdinfo = root.cmd("ovs-vswitchd --version | grep ovs-vswitchd |awk -F')' '{print $2}' | awk '{ gsub (\" \", \"\", $0); print}'")
		versions = vswitchdinfo.split("\n")
		version = versions[0]
		print "ovs-vswitchd --version : " + version

		#vswitchdversion = float(version[:3])
		#if vswitchdversion < 2.3:
		major = version.split(".")[0]
		minor = version.split(".")[1]
		if major < 2:
			error( 'OVS vswitchd does not respect version requirement\nPlease check your OVS installation\n' )
			exit( 1 )
		if minor < 3:
			error( 'OVS vswitchd does not respect version requirement\nPlease check your OVS installation\n' )
			exit( 1 )		

		# SS 2017-10-21 I've disabled the version check because in the packaged openvswitch there is no version info
		# if modversion != vswitchdversion:
		# 	error( 'OVS Kernel module version and OVS vswitchd version are different\nPlease check your OVS installation\n' )
		# 	exit( 1)

		openvswitchd = root.cmd('ls %s 2> /dev/null | wc -l' % self.ovs_initd)
开发者ID:netgroup,项目名称:Dreamer-Mininet-Extensions,代码行数:34,代码来源:nodes.py


示例4: MyTopo

class MyTopo(object):
    def __init__(self, cname='onos', cips=['10.0.3.1']):
        # Create network with multiple controllers
        self.net = Mininet(controller=RemoteController, switch=OVSKernelSwitch,
                           build=False)
 
        # Add controllers with input IPs to the network
        ctrls = [RemoteController(cname, cip, 6633) for cip in cips]
        for ctrl in ctrls:
            print ctrl.ip
            self.net.addController(ctrl)
 
        # Add switch
        self.s2 = self.net.addSwitch('s2', dpid='00000000000000a2')
	
	# Connect root namespace to the switch
	self.root = Node('root', inNamespace=False)
	intf = self.net.addLink(self.root, self.s2).intf1
	self.root.setIP('10.0.0.1/32', intf=intf)

	# Add host
	h2 = self.net.addHost('h2', ip='10.0.0.12/24', mac='00:00:00:00:00:02')
	self.net.addLink(h2, self.s2)

    def run(self):
        self.net.build()
        self.net.start()
        self.s2.cmd('ovs-vsctl set bridge s2 protocols=OpenFlow13')
        self.s2.cmd('ovs-vsctl add-port s2 vxlan2')
        self.s2.cmd('ovs-vsctl set interface vxlan2 type=vxlan option:remote_ip=104.236.158.75 option:key=flow')
	self.root.cmd('route add -net 10.0.0.0/24 dev root-eth0')
        CLI(self.net)
        self.net.stop()
开发者ID:hyunsun,项目名称:mininet-scripts,代码行数:33,代码来源:floating-network.py


示例5: __init__

    def __init__(self, name, inMountNamespace=False, inPIDNamespace=False,
                 inUTSNamespace=False, **params):
        """name: name of node
           inNamespace: in network namespace?
           inMountNamespace: has private mountspace?
           inPIDNamespace: has private PID namespace?
           params: Node parameters (see config() for details)"""

        # PID and Mount Namespace handling
        self.inPIDNamespace = inPIDNamespace
        self.inUTSNamespace = inUTSNamespace
        self.inMountNamespace = inMountNamespace

        # Private config monitoring
        self.hasPrivateLogs = False
        self.hasPrivateRun = False

        # Sanity check on namespace config
        if self.inPIDNamespace is True and self.inMountNamespace is False:
            raise Exception('PID namespaces require mount namespace for /proc')

        # Stash extended configuration information
        self.services = {}  # dict of services and parameters for this node
        self.privateMounts = {}  # dict of private mounts for this node

        # Network information
        self.loIntfs = {}

        # Request initialization of the BaseNode
        BaseNode.__init__(self, name, **params)
开发者ID:USC-NSL,项目名称:miniNExT,代码行数:30,代码来源:node.py


示例6: startNetwork

def startNetwork(network, switch, ip, routes):
    root = Node('root', inNamespace=False)
    intf = Link(root, switch).intf1
    root.setIP(ip, intf=intf)
    network.start()
    for route in routes:
        root.cmd( 'route add -net ' + route + ' dev ' + str( intf ) )
开发者ID:krman,项目名称:thesis,代码行数:7,代码来源:simple.py


示例7: connectToInternet

def connectToInternet( network ):
    "Connect the network to the internet"
    switch = network.switches[ 0 ]  # switch to use
    ip = '10.0.0.254'  # our IP address on host network
    routes = [ '10.0.0.0/24' ]  # host networks to route to
    prefixLen = 24 # subnet mask length
    inetIface = "eth0" # host interface for internet connectivity

    # Create a node in root namespace and link to switch 0
    root = Node( 'root', inNamespace=False )
    intf = Link( root, switch ).intf1
    #intf = createLink( root, switch )[ 0 ]
    #root.setIP( intf, ip, prefixLen )
    root.setIP( ip, prefixLen, intf)

    # Start network that now includes link to root namespace
    network.start()

    # Start NAT and establish forwarding
    startNAT( inetIface, root )

    # Establish routes from end hosts
    for host in network.hosts:
        host.cmd( 'ip route flush root 0/0' )
        #host.cmd( 'route add -net 10.0.0.0/24 dev ' + host.intfs[0] )
        host.cmd( 'route add -net 10.0.0.0/24 dev ' + host.intfs[0].name )
        host.cmd( 'route add default gw ' + ip )
        
    return root
开发者ID:ZubairNabi,项目名称:minerva,代码行数:29,代码来源:connect_internet.py


示例8: start

def start():

    global net, attacker, running

    if running:
        return '\nServer already running.\n'

    setLogLevel('info')

    topo = MixTopo()
    net = Mininet(topo=topo)

    s1 = net['s1']
    plc2 = net['plc2']
    plc3 = net['plc3']

    s2, rtu2a, scada = net.get('s2', 'rtu2a', 'scada')
    rtu2b, attacker2 = net.get('rtu2b', 'attacker2')
    s3 = net.get('s3')

    # NOTE: root-eth0 interface on the host
    root = Node('root', inNamespace=False)
    intf = net.addLink(root, s3).intf1
    print('DEBUG root intf: {}'.format(intf))
    root.setIP('10.0.0.30', intf=intf)
    # NOTE: all packet from root to the 10.0.0.0 network
    root.cmd('route add -net ' + '10.0.0.0' + ' dev ' + str(intf))


    net.start()
    info('Welcome')

    # NOTE: use for debugging
    #s1.cmd('tcpdump -i s1-eth1 -w /tmp/s1-eth1.pcap &')
    #s1.cmd('tcpdump -i s1-eth2 -w /tmp/s1-eth2.pcap &')

    SLEEP = 0.5

    # NOTE: swat challenge 1 and 2
    plc3.cmd(sys.executable + ' plc3.py &')
    sleep(SLEEP)
    plc2.cmd(sys.executable + ' plc2.py &')
    sleep(SLEEP)

    # NOTE: wadi challenge 1
    scada.cmd(sys.executable + ' scada.py &')
    sleep(SLEEP)
    rtu2a.cmd(sys.executable + ' rtu2a.py &')
    sleep(SLEEP)
    # NOTE: wadi challenge 2
    rtu2b.cmd(sys.executable + ' rtu2b.py &')
    sleep(SLEEP)


    running = True
    return '\nServer started.\n'
开发者ID:scy-phy,项目名称:minicps,代码行数:56,代码来源:run.py


示例9: sendInt

 def sendInt(self, sig=signal.SIGINT):
     """Interrupt running command."""
     if self.lastPid and self.inPIDNamespace:
         # Cannot kill via os.kill (wrong PID namespace)
         # Instead, we kill by running 'kill -SIGNAL pid
         # inside of the namespace itself....
         killStr = "kill -%d %d" % (sig, self.lastPid)
         self.pexec(killStr)
     else:
         BaseNode.sendInt(self)
开发者ID:USC-NSL,项目名称:miniNExT,代码行数:10,代码来源:node.py


示例10: configure_l2_accessnetwork

def configure_l2_accessnetwork():
	print "*** Configure L2 Access Networks"
	root = Node( 'root', inNamespace=False )
	print "*** Configure L2 Access Ports" 
	for key, value in ACCESS_TO_TAG.iteritems():
		print "*** Configure", key, "As Access Port, TAG=", value
		root.cmd("ovs-vsctl set port %s tag=%s" %(key, value))
	print "*** Configure L2 Trunk Ports"
	for key, value in TRUNK_TO_TAG.iteritems():
		print "*** Configure", key, "As Trunk Port, TAG=", value
		root.cmd("ovs-vsctl set port %s trunks=%s" %(key, value))
开发者ID:netgroup,项目名称:Dreamer-Mininet-Deployer,代码行数:11,代码来源:mininet_deployer.py


示例11: __init__

 def __init__(self, name, image=None, port_map=None, fs_map=None, **kwargs):
     if image is None:
         raise UnboundLocalError('Docker image is not specified')
     img_id = subprocess.check_output(['docker', 'images', '-q', image])
     if not img_id:
         raise ValueError('Docker image "%s" does not exist' % image)
     self.docker_image = image
     self.port_map = port_map
     self.fs_map = fs_map
     kwargs['inNamespace'] = True
     Node.__init__(self, name, **kwargs)
开发者ID:p4lang,项目名称:ntf,代码行数:11,代码来源:docker_node.py


示例12: fixSwitchIntf

def fixSwitchIntf(swi):
  for i in range(0, len(swi)):
    for obj in swi[i].nameToIntf:
      if 'lo' not in obj:
	fixNetworkManager(obj)	
    fixNetworkManager(swi[i])    
  root = Node( 'root', inNamespace=False )
  print "Restarting Network Manager"
  time.sleep(10)
  root.cmd('service network-manager restart')
  time.sleep(2)
开发者ID:StefanoSalsano,项目名称:alien-ofelia-conet-ccnx,代码行数:11,代码来源:start_mininet.py


示例13: sshd_connectToRootNS

def sshd_connectToRootNS(args,network):
	
	#we create node root and attach it to a swtich
	switch = network.getNodeByName(args.names.sw_sshd[0])

	#ip of root
	ip = '172.16.255.1/32' 
	
	root = Node( 'root', inNamespace=False )
	intf = Link( root, switch ).intf1
	root.setIP( ip, intf=intf )

	return root,intf
开发者ID:Romain-Ly,项目名称:PRES,代码行数:13,代码来源:pyMPTCP_options.py


示例14: __init__

    def __init__(self, verbose=False):

        self.checkPATHs()

        Mininet.__init__(self, build=False)

        self.cr_oshis = []
        self.pe_oshis = []
        self.ce_routers = []
        self.ctrls = []
        self.nodes_in_rn = []
        self.node_to_data = defaultdict(list)
        self.node_to_node = {}
        self.node_to_default_via = {}
        self.coex = {}
        

        self.verbose = verbose
        lg.setLogLevel('info')

        self.vlls = []

        self.node_to_pw_data = defaultdict(list)
        self.pws = []

        self.cer_to_customer = {}
        self.customer_to_vtepallocator = {}

        self.vsfs = []
        self.pe_cer_to_vsf = {}

        self.is_vs = False
        self.vss = []
        self.vss_data = []
        self.id_peo_to_vs = {}
        self.last_ipnet = IPv4Network(u'0.0.0.0/24')

        self.id_to_node = {}
        self.ip_to_mac = {}

        self.overall_info = {}
        
        self.mgmt = None

        root = Node( 'root', inNamespace=False )
        root.cmd('/etc/init.d/network-manager stop')
        mylog("*** Stop Network Manager\n")

        self.cluster_to_ctrl = defaultdict(list)
        self.cluster_to_nodes = defaultdict(list)
        self.nodes_to_cluster = {}
开发者ID:netgroup,项目名称:Dreamer-Mininet-Extensions,代码行数:51,代码来源:mininet_extensions.py


示例15: connectToRootNS

def connectToRootNS( network, switch, ip, routes ):
    """Connect hosts to root namespace via switch. Starts network.
      network: Mininet() network object
      switch: switch to connect to root namespace
      ip: IP address for root namespace node
      routes: host networks to route to"""
    # Create a node in root namespace and link to switch 0
    root = Node( 'root', inNamespace=False )
    intf = network.addLink( root, switch ).intf1
    root.setIP( ip, intf=intf )
    # Start network that now includes link to root namespace
    network.start()
    # Add routes from root ns to hosts
    for route in routes:
        root.cmd( 'route add -net ' + route + ' dev ' + str( intf ) )
开发者ID:lctseng,项目名称:NCTU-CS-Thesis-Undegraduated,代码行数:15,代码来源:topo.py


示例16: __init__

    def __init__( self, name, sw_path = "dc_full",
		  dpid=None,
		  opts='',
                  thrift_port = None,
                  pcap_dump = False,
                  verbose = False, **kwargs ):
        Node.__init__( self, name, **kwargs )
        self.dpid = self.defaultDpid(dpid)
	self.opts = opts
	self.sw_path = sw_path
        self.verbose = verbose
        logfile = '/tmp/p4ns.%s.log' % self.name
        self.output = open(logfile, 'w')
        self.thrift_port = thrift_port
        self.pcap_dump = pcap_dump
开发者ID:holidayfun,项目名称:bfr,代码行数:15,代码来源:bier_demo.py


示例17: connectToRootNS

def connectToRootNS( network, switch, ip, prefixLen, routes ):
    "Connect hosts to root namespace via switch. Starts network."
    "network: Mininet() network object"
    "switch: switch to connect to root namespace"
    "ip: IP address for root namespace node"
    "prefixLen: IP address prefix length (e.g. 8, 16, 24)"
    "routes: host networks to route to"
    # Create a node in root namespace and link to switch 0
    root = Node( 'root', inNamespace=False )
    intf = TCLink( root, switch ).intf1
    root.setIP( ip, prefixLen, intf )
    # Start network that now includes link to root namespace
    network.start()
    # Add routes from root ns to hosts
    for route in routes:
        root.cmd( 'route add -net ' + route + ' dev ' + str( intf ) )
开发者ID:PawelBorawski,项目名称:MNScenarioGenerator,代码行数:16,代码来源:agis2.py


示例18: init_floating_network

    def init_floating_network(self):
        """
        Initialize the floating network component for the emulator.
        Will not do anything if already initialized.
        """
        if self.net is not None and self.floating_switch is None:
            # create a floating network
            fn = self.floating_network = Net("default")
            fn.id = str(uuid.uuid4())
            fn.set_cidr(self.floating_netmask)

            # create a subnet
            fn.subnet_id = str(uuid.uuid4())
            fn.subnet_name = fn.name + "-sub"

            # create a port for the host
            port = Port("root-port")
            #port.id = str(uuid.uuid4())
            port.net_name = fn.name

            # get next free ip
            root_ip = fn.get_new_ip_address(port.name)
            port.ip_address = root_ip
            # floating ip network setup
            # wierd way of getting a datacenter object
            first_dc = self.net.dcs.values()[0]
            # set a dpid for the switch. for this we have to get the id of the next possible dc
            self.floating_switch = self.net.addSwitch("fs1", dpid=hex(first_dc._get_next_dc_dpid())[2:])
            # this is the interface appearing on the physical host
            self.floating_root = Node('root', inNamespace=False)
            self.net.hosts.append(self.floating_root)
            self.net.nameToNode['root'] = self.floating_root
            self.floating_intf = self.net.addLink(self.floating_root, self.floating_switch).intf1
            self.floating_root.setIP(root_ip, intf=self.floating_intf)
            self.floating_nodes[(self.floating_root.name, root_ip)] = self.floating_root
开发者ID:stevenvanrossem,项目名称:son-emu,代码行数:35,代码来源:manage.py


示例19: config

    def config(self, privateLogDir=None, privateRunDir=None,
               privateMounts=None, services=None, hostname=None,
               loIntfs=None, **_params):
        """Configure Node according to (optional) parameters:
           mac: MAC address for default interface
           ip: IP address for default interface
           defaultRoute: default route for all traffic
           privateLogDir = boolean or path to dir to bind over /var/log
           privateRunDir = boolean or path to dir to bind over /run
           privateMounts = mount / path properties objects
           loopbackIntfs = list of loopback interfaces and parameters
           services = service objects for service manager"""

        r = BaseNode.config(self, **_params)
        # Process private mounts and services in this order:
        # (1) - privateLogDir (/var/log), privateRunDir (/run) if requested
        # (2) - user private mounts
        # (3) - services and service mounts
        # (4) - setup hostname, loopback adapters, and other network components
        self.setParam(r, 'setupPrivateLogs', privateLogDir=privateLogDir)
        self.setParam(r, 'setupPrivateRun', privateRunDir=privateRunDir)
        self.setParam(r, 'setupPrivateMounts', privateMounts=privateMounts)
        self.setParam(r, 'setupServices', services=services)
        self.setParam(r, 'setupHostname', hostname=hostname)
        self.setParam(r, 'setupLoopbacks', loIntfs=loIntfs)
        return r
开发者ID:USC-NSL,项目名称:miniNExT,代码行数:26,代码来源:node.py


示例20: connectTo

	def connectTo(self,Node):
		"Fetch next available port number on destination node and generate a remote interface name"
		remoteCandidIntfName = Node.name +"-eth" + str(Node.newPort())
		"Pass the remote intf name to generate a link"
		self.createLink(remoteCandidIntfName)
		"Connect the other end of the created link to the passed mininet node"
		"""
		if type(Node) is (Node or Host or OVSSwitch):
	             _intf = Intf( remoteCandidIntfName, node=Node )
		     return 	          
                #Node.incrIfIndex()
		"""
		if isinstance(Node, NFVMiddlebox):
	             Node.incrIfIndex()
		else:
                     _intf = Intf( remoteCandidIntfName, node=Node )
		return
开发者ID:rakeshgn31,项目名称:SDN_Project,代码行数:17,代码来源:nfv.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python node.OVSSwitch类代码示例发布时间:2022-05-27
下一篇:
Python node.Host类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap