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


Python node.RemoteController方法代码示例

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


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

示例1: connect_controller

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def connect_controller(net, host):
    controller = RemoteController("c")
    net.addController(controller)
    # Configure host
    net.addLink(controller, host)
    # Configure controller
    ctrl_iface = "c-eth0"
    return ctrl_iface 
开发者ID:dcgym,项目名称:iroko,代码行数:10,代码来源:control_test.py

示例2: __init__

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def __init__(self, *args, **kwargs):
        super(OpenStateErrorExperimenterMsg, self).__init__(*args, **kwargs)
        if os.geteuid() != 0:
            exit("You need to have root privileges to run this script")
        # Kill Mininet
        os.system("sudo mn -c 2> /dev/null")
        print 'Starting Mininet'
        self.net = Mininet(topo=SingleSwitchTopo(7),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
        self.net.start()
        self.last_error_queue = []
        self.test_id = 0 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:13,代码来源:experimenter_error_msg__ryu.py

示例3: restart_mininet

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def restart_mininet(self):
        print 'Restarting Mininet\n'
        os.system("sudo mn -c 2> /dev/null")
        self.net = Mininet(topo=SingleSwitchTopo(7),switch=UserSwitch,controller=RemoteController,cleanup=True,autoSetMacs=True,listenPort=6634,autoStaticArp=True)
        self.net.start() 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:7,代码来源:experimenter_error_msg__ryu.py

示例4: setUpClass

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def setUpClass(cls):
        cls.mn = Mininet()
        c = cls.mn.addController(controller=RemoteController,
                                 ip=RYU_HOST, port=RYU_PORT)
        c.start()

        s1 = cls.mn.addSwitch('s1', cls=OVS12KernelSwitch)
        s1.start(cls.mn.controllers)

        h1 = cls.mn.addHost('h1', ip='0.0.0.0/0')

        link = cls.mn.addLink(h1, s1)
        s1.attach(link.intf2) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:15,代码来源:run_tests_with_ovs12.py

示例5: delete_flow_by_cookie

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def delete_flow_by_cookie(self, cookie):
        """
        Removes a flow identified by the cookie

        :param cookie: The cookie for the specified flow
        :type cookie: ``int``
        :return: True if successful, else false
        :rtype: ``bool``
        """
        if not cookie:
            return False
        logging.debug("Deleting flow by cookie %d" % (cookie))
        flows = list()
        # we have to call delete-group for each switch
        for node in self.net.switches:
            flow = dict()
            flow["dpid"] = int(node.dpid, 16)
            flow["cookie"] = cookie
            flow['cookie_mask'] = int('0xffffffffffffffff', 16)

            flows.append(flow)
        for flow in flows:
            logging.debug("Deleting flowentry with cookie %d" % (
                flow["cookie"]))
            if self.net.controller == RemoteController:
                self.net.ryu_REST('stats/flowentry/delete', data=flow)

        self.cookies.remove(cookie)
        return True 
开发者ID:sonata-nfv,项目名称:son-emu,代码行数:31,代码来源:manage.py

示例6: _connect_controller

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def _connect_controller(self, net):
        controller = RemoteController(self.topo.switch_id + "_c")
        net.addController(controller)
        for i, host in enumerate(self.topo.host_list):
            # Configure host
            net.addLink(controller, host)
            # Configure controller
            ctrl_iface = "%s_c-eth%d" % (self.topo.switch_id, i)

            for index, switch in self.topo.ports[host].items():
                switch_iface = switch[0] + "-eth" + str(switch[1])
                self.host_ctrl_map[switch_iface] = ctrl_iface 
开发者ID:dcgym,项目名称:iroko,代码行数:14,代码来源:network_manager.py

示例7: execute

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def execute():

    # Create Mininet instance.
    net = Mininet()

    # Add the SDN controller to the network.
    c1 = net.addController(name='c1', controller=RemoteController,
                                       ip='127.0.0.1')

    # Add hosts to the network.
    h0=net.addHost('h0')
    h1=net.addHost('h1')

    # Add switches to the network.
    s0=net.addSwitch('s0')
    s1=net.addSwitch('s1')
    s2=net.addSwitch('s2')

    # Creating links between the switches in the network
    net.addLink(s0, s1)
    net.addLink(s1, s2)
    net.addLink(s0, s2)

    # Connect hosts to the relevant switches in the network.
    net.addLink(h0, s0)
    net.addLink(h1, s1)

    # Start execution.
    net.start()

    CLI( net ) 
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:33,代码来源:10_2_sdn_opendaylight.py

示例8: delete_loadbalancer

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def delete_loadbalancer(self, vnf_src_name, vnf_src_interface):
        '''
        Removes a loadbalancer that is configured for the node and interface

        :param src_vnf_name: Name of the source VNF
        :param src_vnf_interface: Name of the destination VNF
        '''
        flows = list()
        # we have to call delete-group for each switch
        delete_group = list()
        group_id = self.get_flow_group(vnf_src_name, vnf_src_interface)
        for node in self.net.switches:
            for cookie in self.lb_flow_cookies[(
                    vnf_src_name, vnf_src_interface)]:
                flow = dict()
                flow["dpid"] = int(node.dpid, 16)
                flow["cookie"] = cookie
                flow['cookie_mask'] = int('0xffffffffffffffff', 16)

                flows.append(flow)
            group_del = dict()
            group_del["dpid"] = int(node.dpid, 16)
            group_del["group_id"] = group_id
            delete_group.append(group_del)

        for flow in flows:
            logging.debug("Deleting flowentry with cookie %d belonging to lb at %s:%s" % (
                flow["cookie"], vnf_src_name, vnf_src_interface))
            if self.net.controller == RemoteController:
                self.net.ryu_REST('stats/flowentry/delete', data=flow)

        logging.debug("Deleting group with id %s" % group_id)
        for switch_del_group in delete_group:
            if self.net.controller == RemoteController:
                self.net.ryu_REST("stats/groupentry/delete",
                                  data=switch_del_group)

        # unmap groupid from the interface
        target_pair = (vnf_src_name, vnf_src_interface)
        if target_pair in self.flow_groups:
            del self.flow_groups[target_pair]
        if target_pair in self.full_lb_data:
            del self.full_lb_data[target_pair] 
开发者ID:sonata-nfv,项目名称:son-emu,代码行数:45,代码来源:manage.py

示例9: testSDNChainingSingleService_withLearning

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def testSDNChainingSingleService_withLearning(self):
        """
        Create a two data centers and interconnect them with additional
        switches between them.
        Uses Ryu SDN controller.
        Connect the Docker hosts to different datacenters and setup the links between.
        """
        # create network
        self.createNet(
            nswitches=3, ndatacenter=2, nhosts=0, ndockers=0,
            autolinkswitches=True,
            controller=RemoteController,
            enable_learning=True)
        # setup links
        self.net.addLink(self.dc[0], self.s[0])
        self.net.addLink(self.s[2], self.dc[1])
        # start Mininet network
        self.startNet()

        # add compute resources
        vnf1 = self.dc[0].startCompute(
            "vnf1", network=[{'id': 'intf1', 'ip': '10.0.10.1/24'}])
        vnf2 = self.dc[1].startCompute(
            "vnf2", network=[{'id': 'intf2', 'ip': '10.0.10.2/24'}])
        # check number of running nodes
        self.assertTrue(len(self.getContainernetContainers()) == 2)
        self.assertTrue(len(self.net.hosts) == 2)
        self.assertTrue(len(self.net.switches) == 5)
        # check status
        # check get status
        s1 = self.dc[0].containers.get("vnf1").getStatus()
        print(s1)
        self.assertTrue(s1["name"] == "vnf1")
        self.assertTrue(s1["state"]["Running"])
        self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
        self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')

        s2 = self.dc[1].containers.get("vnf2").getStatus()
        print(s2)
        self.assertTrue(s2["name"] == "vnf2")
        self.assertTrue(s2["state"]["Running"])
        self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
        self.assertTrue(s2["network"][0]['ip'] == '10.0.10.2/24')

        # should be connected because learning = True
        self.assertTrue(self.net.ping([vnf1, vnf2]) <= 0.0)
        # setup links
        self.net.setChain('vnf1', 'vnf2', 'intf1', 'intf2',
                          bidirectional=True, cmd='add-flow')
        # should still be connected
        self.assertTrue(self.net.ping([vnf1, vnf2]) <= 0.0)
        # stop Mininet network
        self.stopNet() 
开发者ID:sonata-nfv,项目名称:son-emu,代码行数:55,代码来源:test_emulator.py

示例10: testSDNChainingSingleService

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [as 别名]
def testSDNChainingSingleService(self):
        """
        Create a two data centers and interconnect them with additional
        switches between them.
        Uses Ryu SDN controller.
        Connect the Docker hosts to different datacenters and setup the links between.
        """
        # create network
        self.createNet(
            nswitches=3, ndatacenter=2, nhosts=0, ndockers=0,
            autolinkswitches=True,
            controller=RemoteController,
            enable_learning=False)
        # setup links
        self.net.addLink(self.dc[0], self.s[0])
        self.net.addLink(self.s[2], self.dc[1])
        # start Mininet network
        self.startNet()

        # add compute resources
        vnf1 = self.dc[0].startCompute(
            "vnf1", network=[{'id': 'intf1', 'ip': '10.0.10.1/24'}])
        vnf2 = self.dc[1].startCompute(
            "vnf2", network=[{'id': 'intf2', 'ip': '10.0.10.2/24'}])
        # check number of running nodes
        self.assertTrue(len(self.getContainernetContainers()) == 2)
        self.assertTrue(len(self.net.hosts) == 2)
        self.assertTrue(len(self.net.switches) == 5)
        # check status
        # check get status
        s1 = self.dc[0].containers.get("vnf1").getStatus()
        print(s1)
        self.assertTrue(s1["name"] == "vnf1")
        self.assertTrue(s1["state"]["Running"])
        self.assertTrue(s1["network"][0]['intf_name'] == 'intf1')
        self.assertTrue(s1["network"][0]['ip'] == '10.0.10.1/24')

        s2 = self.dc[1].containers.get("vnf2").getStatus()
        print(s2)
        self.assertTrue(s2["name"] == "vnf2")
        self.assertTrue(s2["state"]["Running"])
        self.assertTrue(s2["network"][0]['intf_name'] == 'intf2')
        self.assertTrue(s2["network"][0]['ip'] == '10.0.10.2/24')

        # should be not not yet connected
        self.assertTrue(self.net.ping([vnf1, vnf2]) > 0.0)
        # setup links
        self.net.setChain('vnf1', 'vnf2', 'intf1', 'intf2',
                          bidirectional=True, cmd='add-flow')
        # check connectivity by using ping
        self.assertTrue(self.net.ping([vnf1, vnf2]) <= 0.0)
        # stop Mininet network
        self.stopNet() 
开发者ID:sonata-nfv,项目名称:son-emu,代码行数:55,代码来源:test_emulator.py

示例11: myNetwork

# 需要导入模块: from mininet import node [as 别名]
# 或者: from mininet.node import RemoteController [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 RemoteController [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.RemoteController方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。