當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。