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


Python hub.spawn方法代码示例

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


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

示例1: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
        super(SDNIP, self).__init__(*args, **kwargs)
        self.fwd_util = kwargs['fwd']
        self.hop_db = kwargs['hop_db']
        self.cfg_mgr = SDNIPConfigManager() #??SDN?IP????
        # ?Ryu?????iBGPSpeaker
        self.bgp_speaker =\
            BGPSpeaker(self.cfg_mgr.as_number,      #AS?
                       str(self.cfg_mgr.router_id),     #iBGP?router id
                       bgp_server_port=self.cfg_mgr.listen_port,        #??BGP??????
                       best_path_change_handler=self.best_path_change_handler,      #?????????????
                       peer_down_handler=self.peer_down_handler,        #BGP?????
                       peer_up_handler=self.peer_up_handler)        #BGP?????

        speaker_ids = self.cfg_mgr.get_all_speaker_id()
        # ??iBGPSpeaker?SDN???BGPSpeaker???
        for speaker_id in speaker_ids:
            self.bgp_speaker.neighbor_add(speaker_id,
                                          self.cfg_mgr.as_number,
                                          is_next_hop_self=True)
        # ??????????????????????
        #hub.spawn(self.prefix_check_loop) 
开发者ID:paradisecr,项目名称:SDN-IP-Ryu,代码行数:24,代码来源:sdn_ip.py

示例2: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkAwareness, self).__init__(*args, **kwargs)
		self.topology_api_app = self
		self.name = "awareness"
		self.link_to_port = {}                 # {(src_dpid,dst_dpid):(src_port,dst_port),}
		self.access_table = {}                # {(sw,port):(ip, mac),}
		self.switch_port_table = {}      # {dpid:set(port_num,),}
		self.access_ports = {}                # {dpid:set(port_num,),}
		self.interior_ports = {}              # {dpid:set(port_num,),}
		self.switches = []                         # self.switches = [dpid,]
		self.shortest_paths = {}            # {dpid:{dpid:[[path],],},}
		self.pre_link_to_port = {}
		self.pre_access_table = {}

		# Directed graph can record the loading condition of links more accurately.
		# self.graph = nx.Graph()
		self.graph = nx.DiGraph()
		# Get initiation delay.
		self.initiation_delay = self.get_initiation_delay(CONF.fanout)
		self.start_time = time.time()

		# Start a green thread to discover network resource.
		self.discover_thread = hub.spawn(self._discover) 
开发者ID:Huangmachi,项目名称:PureSDN,代码行数:25,代码来源:network_awareness.py

示例3: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkMonitor, self).__init__(*args, **kwargs)
		self.name = 'monitor'
		self.datapaths = {}
		self.port_stats = {}
		self.port_speed = {}
		self.flow_stats = {}
		self.flow_speed = {}
		self.stats = {}
		self.port_features = {}
		self.free_bandwidth = {}   # self.free_bandwidth = {dpid:{port_no:free_bw,},} unit:Kbit/s
		self.awareness = lookup_service_brick('awareness')
		self.graph = None
		self.capabilities = None
		self.best_paths = None

		# Start to green thread to monitor traffic and calculating
		# free bandwidth of links respectively.
		self.monitor_thread = hub.spawn(self._monitor)
		self.save_freebandwidth_thread = hub.spawn(self._save_bw_graph) 
开发者ID:Huangmachi,项目名称:PureSDN,代码行数:22,代码来源:network_monitor.py

示例4: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
        super(Switches, self).__init__(*args, **kwargs)

        self.name = 'switches'
        self.dps = {}                 # datapath_id => Datapath class
        self.port_state = {}          # datapath_id => ports
        self.ports = PortDataState()  # Port class -> PortData class
        self.links = LinkState()      # Link class -> timestamp
        self.hosts = HostState()      # mac address -> Host class list
        self.is_active = True

        self.link_discovery = self.CONF.observe_links
        if self.link_discovery:
            self.install_flow = self.CONF.install_lldp_flow
            self.explicit_drop = self.CONF.explicit_drop
            self.lldp_event = hub.Event()
            self.link_event = hub.Event()
            self.threads.append(hub.spawn(self.lldp_loop))
            self.threads.append(hub.spawn(self.link_loop)) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:21,代码来源:switches.py

示例5: test_spawn_event3

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def test_spawn_event3(self):
        def _child(ev, ev2, result):
            ev2.wait()
            hub.sleep(0.5)
            result.append(1)
            ev.set()

        ev = hub.Event()
        ev2 = hub.Event()
        result = []
        with hub.Timeout(2):
            hub.spawn(_child, ev, ev2, result)
            hub.spawn(_child, ev, ev2, result)
            hub.sleep(0.5)
            ev2.set()  # this should wake up the above created two threads
            ev.wait(timeout=1)
        assert len(result) == 2 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:19,代码来源:test_hub.py

示例6: test_spawn_kill_joinall

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def test_spawn_kill_joinall(self):
        def _child(ev2, result):
            ev2.wait()
            result.append(1)

        ev2 = hub.Event()
        threads = []
        result = []
        with hub.Timeout(2):
            threads.append(hub.spawn(_child, ev2, result))
            threads.append(hub.spawn(_child, ev2, result))
            hub.sleep(0.5)
            for t in threads:
                hub.kill(t)
            hub.joinall(threads)
        assert len(result) == 0 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:18,代码来源:test_hub.py

示例7: serve

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def serve(self):
        send_thr = hub.spawn(self._send_loop)

        # send hello message immediately
        hello = self.ofproto_parser.OFPHello(self)
        self.send_msg(hello)

        echo_thr = hub.spawn(self._echo_request_loop)

        try:
            self._recv_loop()
        finally:
            hub.kill(send_thr)
            hub.kill(echo_thr)
            hub.joinall([send_thr, echo_thr])
            self.is_active = False

    #
    # Utility methods for convenience
    # 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:22,代码来源:controller.py

示例8: _bulk_read_handler

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def _bulk_read_handler(self, ev):
        results = []

        def done(gt, *args, **kwargs):
            if gt in self.threads:
                self.threads.remove(gt)

            results.append(gt.wait())

        threads = []
        for c in self._clients.values():
            gt = hub.spawn(c.read_request_handler, ev, bulk=True)
            threads.append(gt)
            self.threads.append(gt)
            gt.link(done)

        hub.joinall(threads)
        rep = event.EventReadReply(None, results)
        self.reply_to_request(ev, rep) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:21,代码来源:manager.py

示例9: start

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def start(self):
        server = hub.listen((self._address, self._port))
        key = self.CONF.ovsdb.mngr_privkey or self.CONF.ctl_privkey
        cert = self.CONF.ovsdb.mngr_cert or self.CONF.ctl_cert

        if key is not None and cert is not None:
            ssl_kwargs = dict(keyfile=key, certfile=cert, server_side=True)

            if self.CONF.ca_certs is not None:
                ssl_kwargs['cert_reqs'] = ssl.CERT_REQUIRED
                ssl_kwargs['ca_certs'] = self.CONF.ca_certs

            server = ssl.wrap_socket(server, **ssl_kwargs)

        self._server = server

        self.logger.info('Listening on %s:%s for clients' % (self._address,
                                                             self._port))
        t = hub.spawn(self._accept, self._server)
        super(OVSDB, self).start()
        return t 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:23,代码来源:manager.py

示例10: read_request_handler

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def read_request_handler(self, ev):
        system_id = ev.system_id

        if system_id is None:
            def done(gt, *args, **kwargs):
                if gt in self.threads:
                    self.threads.remove(gt)

            thread = hub.spawn(self._bulk_read_handler, ev)
            self.threads.append(thread)
            return thread.link(done)

        client_name = client.RemoteOvsdb.instance_name(system_id)
        remote = self._clients.get(client_name)

        if not remote:
            msg = 'Unknown remote system_id %s' % system_id
            self.logger.info(msg)
            rep = event.EventReadReply(system_id, None, msg)
            return self.reply_to_request(ev, rep)

        return remote.read_request_handler(ev) 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:24,代码来源:manager.py

示例11: start

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def start(**kwargs):
    """Starts new context using provided configuration.

    Raises RuntimeConfigError if a context is already active.
    """
    if CORE_MANAGER.started:
        raise RuntimeConfigError('Current context has to be stopped to start '
                                 'a new context.')

    try:
        waiter = kwargs.pop('waiter')
    except KeyError:
        waiter = hub.Event()
    common_config = CommonConf(**kwargs)
    hub.spawn(CORE_MANAGER.start, *[], **{'common_conf': common_config,
                                          'waiter': waiter})
    return True 
开发者ID:lagopus,项目名称:ryu-lagopus-ext,代码行数:19,代码来源:core.py

示例12: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
        super(Network_Aware, self).__init__(*args, **kwargs)
        self.name = "Network_Aware"
        self.topology_api_app = self

        # links_to_port:(src_dpid,dst_dpid)->(src_port,dst_port)
        self.link_to_port = {}
        # access_table:{(sw,port) :[host1_ip]}
        self.access_table = {}
        # switch_port_table:dpip->port_num
        self.switch_port_table = {}
        # access_port:dpid->port_num
        self.access_ports = {}
        # interior_ports: dpid->port_num
        self.interior_ports = {}

        self.graph = nx.DiGraph()
        self.pre_graph = nx.DiGraph()
        self.pre_access_table = {}
        self.pre_link_to_port = {}
        self.shortest_paths = None

        self.discover_thread = hub.spawn(self._discover)

    # show topo ,and get topo again 
开发者ID:BenjaminUJun,项目名称:SDN-measure-project,代码行数:27,代码来源:network_aware.py

示例13: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkAwareness, self).__init__(*args, **kwargs)
		self.topology_api_app = self
		self.name = "awareness"
		self.link_to_port = {}               # {(src_dpid,dst_dpid):(src_port,dst_port),}
		self.switch_port_table = {}   # {dpid:set(port_num,),}
		self.access_ports = {}             # {dpid:set(port_num,),}
		self.interior_ports = {}           # {dpid:set(port_num,),}
		self.switches = []                     # self.switches = [dpid,]
		self.shortest_paths = {}        # {dpid:{dpid:[[path],],},}
		self.pre_link_to_port = {}
		self.pre_access_table = {}
		self.access_table = self.create_access_table(CONF.fanout)   # {(sw,port):(ip, mac),}

		# Directed graph can record the loading condition of links more accurately.
		# self.graph = nx.Graph()
		self.graph = nx.DiGraph()
		# Get initiation delay.
		self.initiation_delay = self.get_initiation_delay(CONF.fanout)
		self.start_time = time.time()

		# Start a green thread to discover network resource.
		self.discover_thread = hub.spawn(self._discover) 
开发者ID:Huangmachi,项目名称:Hedera,代码行数:25,代码来源:network_awareness.py

示例14: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
		super(NetworkMonitor, self).__init__(*args, **kwargs)
		self.name = 'monitor'
		self.awareness = lookup_service_brick('awareness')
		self.datapaths = {}
		self.port_stats = {}
		self.port_speed = {}
		self.flow_stats = {}
		self.flow_speed = {}
		self.stats = {}
		self.port_features = {}
		self.free_bandwidth = {}   # {dpid:{port_no:free_bw,},} Unit:Kbit/s
		self.graph = None
		self.capabilities = None
		self.best_paths = None
		# Create four data structures for Hedera specially.
		self.hostsList = []
		self.flows = []   # Record flows that need to be rescheduled. (hmc)
		self.statRecord = []
		self.pre_GFF_path = {}   # Record the last GFF path of flows

		# Start to green thread to monitor traffic and calculating
		# free bandwidth of links respectively.
		self.monitor_thread = hub.spawn(self._monitor)
		self.save_freebandwidth_thread = hub.spawn(self._save_bw_graph) 
开发者ID:Huangmachi,项目名称:Hedera,代码行数:27,代码来源:network_monitor.py

示例15: __init__

# 需要导入模块: from ryu.lib import hub [as 别名]
# 或者: from ryu.lib.hub import spawn [as 别名]
def __init__(self, *args, **kwargs):
        super(OpenFlowBackupRules, self).__init__(*args, **kwargs)
        
        self.G = nx.DiGraph()
        self.mac_learning = {}

        #parameters
        self.path_computation = "extended_disjoint"
        self.node_disjoint = False #Edge disjointness still implies crankback rules to the source. No segmenting occurs, need to confirm that the primary path will also be the shortest combination of segments.
        self.edge_then_node_disjoint = True #Only applicable to extended_disjoint
        self.number_of_disjoint_paths = 2 #Only applicable to simple_disjoint and bhandari. k>2 not well implemented for the source-node, rest should work
        
        self.is_active = True
        self.topology_update = None #datetime.now() 
        self.forwarding_update = None
        self.threads.append( hub.spawn(self._calc_ForwardingMatrix) ) 
开发者ID:TUDelftNAS,项目名称:SDN-OpenFlowBackupRules,代码行数:18,代码来源:OpenFlowBackupRules.py


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