コード例 #1
0
ファイル: eventlet_manager.py プロジェクト: rraabb/powerdb2
 def __init__(self, conn_manager, route, timeout=300, nb_connections=10):
     self.conn_manager = conn_manager
     self.route = route
     self.nb_connections = nb_connections
     self.timeout = timeout
     self.connections = queue.PriorityQueue()
     self.iddle_connections = {}
     self.active_connections = {}
コード例 #2
0
    def __init__(self, chassis_name, nb_api):
        #用于缓存obj
        self.db_store = db_store.get_instance()
        self._queue = queue.PriorityQueue()
        # pending_id -> (model, pender_id)
        #       'pending_id' is the ID of the object for which we are waiting.
        #       'model' and 'pender_id' are the model and the ID of the object
        #       which is waiting for the object described by 'pending_id'
        self._pending_objects = collections.defaultdict(set)

        self.chassis_name = chassis_name
        #北向api
        self.nb_api = nb_api
        #指定database change event的处理函数
        self.nb_api.set_db_change_callback(self.db_change_callback)
        #指明本主机ip地址
        self.ip = cfg.CONF.df.local_ip
        # Virtual tunnel port support multiple tunnel types together
        self.tunnel_types = cfg.CONF.df.tunnel_types
        self.neutron_notifier = None
        if cfg.CONF.df.enable_neutron_notifier:
            self.neutron_notifier = df_utils.load_driver(
                cfg.CONF.df.neutron_notifier,
                df_utils.DF_NEUTRON_NOTIFIER_DRIVER_NAMESPACE)
        #加载switch_backend
        self.switch_backend = df_utils.load_driver(
            cfg.CONF.df.switch_backend,
            df_utils.DF_SWITCH_BACKEND_DRIVER_NAMESPACE, nb_api,
            cfg.CONF.df.management_ip)

        #switch_backend初始化
        self.switch_backend.initialize(self.db_change_callback,
                                       self.neutron_notifier)
        self.topology = None
        self.enable_selective_topo_dist = \
            cfg.CONF.df.enable_selective_topology_distribution
        self._sync = sync.Sync(
            nb_api=self.nb_api,
            #指明同步对应的update,delete回调
            update_cb=self.update,
            delete_cb=self.delete,
            selective=self.enable_selective_topo_dist,
        )
        #周期性产生controller_sync事件
        self._sync_pulse = loopingcall.FixedIntervalLoopingCall(
            self._submit_sync_event)

        self.sync_rate_limiter = df_utils.RateLimiter(
            max_rate=1, time_unit=db_common.DB_SYNC_MINIMUM_INTERVAL)
コード例 #3
0
ファイル: api_nb.py プロジェクト: omeranson/dragonflow
 def __init__(self, db_driver, use_pubsub=False, is_neutron_server=False):
     super(NbApi, self).__init__()
     self.driver = db_driver
     self.controller = None
     self._queue = queue.PriorityQueue()
     self.use_pubsub = use_pubsub
     self.publisher = None
     self.subscriber = None
     self.is_neutron_server = is_neutron_server
     self.enable_selective_topo_dist = \
         cfg.CONF.df.enable_selective_topology_distribution
     self.pub_sub_use_multiproc = False
     if self.is_neutron_server:
         # multiproc pub/sub is only supported in neutron server
         self.pub_sub_use_multiproc = cfg.CONF.df.pub_sub_use_multiproc
コード例 #4
0
    def __init__(self, chassis_name, nb_api):
        self.db_store = db_store.get_instance()
        self._queue = queue.PriorityQueue()
        # pending_id -> (model, pender_id)
        #       'pending_id' is the ID of the object for which we are waiting.
        #       'model' and 'pender_id' are the model and the ID of the object
        #       which is waiting for the object described by 'pending_id'
        self._pending_objects = collections.defaultdict(set)

        self.chassis_name = chassis_name
        self.nb_api = nb_api
        self.nb_api.set_db_change_callback(self.db_change_callback)
        self.ip = cfg.CONF.df.local_ip
        # Virtual tunnel port support multiple tunnel types together
        self.tunnel_types = cfg.CONF.df.tunnel_types
        self.sync_finished = False
        self.vswitch_api = vswitch_impl.OvsApi(cfg.CONF.df.management_ip)
        self.neutron_notifier = None
        if cfg.CONF.df.enable_neutron_notifier:
            self.neutron_notifier = df_utils.load_driver(
                     cfg.CONF.df.neutron_notifier,
                     df_utils.DF_NEUTRON_NOTIFIER_DRIVER_NAMESPACE)

        app_mgr = app_manager.AppManager.get_instance()
        self.open_flow_app = app_mgr.instantiate(
            ryu_base_app.RyuDFAdapter,
            nb_api=self.nb_api,
            vswitch_api=self.vswitch_api,
            neutron_server_notifier=self.neutron_notifier,
            db_change_callback=self.db_change_callback
        )
        # The OfctlService is needed to support the 'get_flows' method
        self.open_flow_service = app_mgr.instantiate(of_service.OfctlService)
        self.topology = None
        self.enable_selective_topo_dist = \
            cfg.CONF.df.enable_selective_topology_distribution
        self._sync = sync.Sync(
            nb_api=self.nb_api,
            update_cb=self.update,
            delete_cb=self.delete,
            selective=self.enable_selective_topo_dist,
        )
        self._sync_pulse = loopingcall.FixedIntervalLoopingCall(
            self._submit_sync_event)

        self.sync_rate_limiter = df_utils.RateLimiter(
                max_rate=1, time_unit=db_common.DB_SYNC_MINIMUM_INTERVAL)
コード例 #5
0
    def setUp(self):
        super(DFTestBase, self).setUp()
        if os.environ.get('DF_FULLSTACK_USE_ENV'):
            try:
                self.neutron = clients.get_neutron_client_from_env()
            except KeyError as e:
                message = ('Cannot find environment variable %s. '
                           'Have you sourced openrc?')
                LOG.error(message, e.args[0])
                self.fail(message % e.args[0])
        else:
            self.neutron = clients.get_neutron_client_from_cloud_config()
        self.neutron.format = 'json'

        # NOTE: Each env can only have one default subnetpool for each
        # IP version.
        if not self.get_default_subnetpool():
            self.create_default_subnetpool()

        df_utils.config_parse()
        self.conf = cfg.CONF.df
        self.integration_bridge = self.conf.integration_bridge

        self._queue = queue.PriorityQueue()
        self.nb_api = api_nb.NbApi.get_instance()
        # As we are running in the same process over and over,
        # do not perform redundant calls to the subscriber
        if not self.nb_api.subscriber.is_running:
            self.nb_api.set_db_change_callback(self._db_change_callback)

        self.mgt_ip = self.conf.management_ip
        self.__objects_to_close = []
        self.addCleanup(self._close_stored_objects)

        self.vswitch_api = utils.OvsTestApi(self.mgt_ip)
        self.vswitch_api.initialize(self._db_change_callback)

        if cfg.CONF.df.enable_selective_topology_distribution:
            self.start_subscribing()

        if cfg.CONF.df.enable_df_pub_sub:
            self._publish_log_event('started')
            self.addCleanup(self._publish_log_event, 'finished')

        self.dfdp = datapath.load_datapath()
コード例 #6
0
    def __init__(self, chassis_name, nb_api):
        self.db_store = db_store.get_instance()
        self._queue = queue.PriorityQueue()

        self.chassis_name = chassis_name
        self.nb_api = nb_api
        self.nb_api.set_db_change_callback(self.db_change_callback)
        self.ip = cfg.CONF.df.local_ip
        # Virtual tunnel port support multiple tunnel types together
        self.tunnel_types = cfg.CONF.df.tunnel_types
        # self.sync_finished = False
        # self.vswitch_api = vswitch_impl.OvsApi(cfg.CONF.df.management_ip)
        # self.neutron_notifier = None
        # if cfg.CONF.df.enable_neutron_notifier:
        #     self.neutron_notifier = df_utils.load_driver(
        #              cfg.CONF.df.neutron_notifier,
        #              df_utils.DF_NEUTRON_NOTIFIER_DRIVER_NAMESPACE)

        # app_mgr = app_manager.AppManager.get_instance()
        # self.open_flow_app = app_mgr.instantiate(
        #     ryu_base_app.RyuDFAdapter,
        #     nb_api=self.nb_api,
        #     vswitch_api=self.vswitch_api,
        #     neutron_server_notifier=self.neutron_notifier,
        #     db_change_callback=self.db_change_callback
        # )
        # The OfctlService is needed to support the 'get_flows' method
        # self.open_flow_service = app_mgr.instantiate(of_service.OfctlService)
        # self.topology = None
        # self.enable_selective_topo_dist = \
        #     cfg.CONF.df.enable_selective_topology_distribution
        # self._sync = sync.Sync(
        #     nb_api=self.nb_api,
        #     update_cb=self.update,
        #     delete_cb=self.delete,
        #     selective=self.enable_selective_topo_dist,
        # )
        # self._sync_pulse = loopingcall.FixedIntervalLoopingCall(
        #     self._submit_sync_event)

        self.sync_rate_limiter = df_utils.RateLimiter(
            max_rate=1, time_unit=db_common.DB_SYNC_MINIMUM_INTERVAL)