Ejemplo n.º 1
0
 def init_generator(self,
                    module,
                    source,
                    node_type,
                    instance_id,
                    collectors,
                    client_context,
                    http_port,
                    sandesh_req_uve_pkg_list=None,
                    discovery_client=None,
                    connect_to_collector=True,
                    logger_class=None,
                    logger_config_file=None,
                    host_ip='127.0.0.1',
                    alarm_ack_callback=None):
     self._role = self.SandeshRole.GENERATOR
     self._module = module
     self._source = source
     self._node_type = node_type
     self._instance_id = instance_id
     self._host_ip = host_ip
     self._client_context = client_context
     self._collectors = collectors
     self._connect_to_collector = connect_to_collector
     self._rcv_queue = WorkQueue(self._process_rx_sandesh)
     self._init_logger(module,
                       logger_class=logger_class,
                       logger_config_file=logger_config_file)
     self._logger.info('SANDESH: CONNECT TO COLLECTOR: %s',
                       connect_to_collector)
     self._stats = SandeshStats()
     self._trace = trace.Trace()
     self._sandesh_request_dict = {}
     self._alarm_ack_callback = alarm_ack_callback
     self._uve_type_maps = SandeshUVETypeMaps(self._logger)
     if sandesh_req_uve_pkg_list is None:
         sandesh_req_uve_pkg_list = []
     # Initialize the request handling
     # Import here to break the cyclic import dependency
     import sandesh_req_impl
     sandesh_req_impl = sandesh_req_impl.SandeshReqImpl(self)
     sandesh_req_uve_pkg_list.append('pysandesh.gen_py')
     for pkg_name in sandesh_req_uve_pkg_list:
         self._create_sandesh_request_and_uve_lists(pkg_name)
     self._gev_httpd = None
     if http_port != -1:
         self._http_server = SandeshHttp(self, module, http_port,
                                         sandesh_req_uve_pkg_list)
         self._gev_httpd = gevent.spawn(self._http_server.start_http_server)
     primary_collector = None
     secondary_collector = None
     if self._collectors is not None:
         if len(self._collectors) > 0:
             primary_collector = self._collectors[0]
         if len(self._collectors) > 1:
             secondary_collector = self._collectors[1]
     if self._connect_to_collector:
         self._client = SandeshClient(self, primary_collector,
                                      secondary_collector, discovery_client)
         self._client.initiate()
Ejemplo n.º 2
0
 def init_generator(self,
                    module,
                    source,
                    node_type,
                    instance_id,
                    collectors,
                    client_context,
                    http_port,
                    sandesh_req_uve_pkg_list=None,
                    connect_to_collector=True,
                    logger_class=None,
                    logger_config_file=None,
                    host_ip='127.0.0.1',
                    alarm_ack_callback=None,
                    config=None):
     self._role = self.SandeshRole.GENERATOR
     self._module = module
     self._source = source
     self._node_type = node_type
     self._instance_id = instance_id
     self._sandesh_req_uve_pkg_list = sandesh_req_uve_pkg_list or []
     self._host_ip = host_ip
     self._client_context = client_context
     self._connect_to_collector = connect_to_collector
     self._rcv_queue = WorkQueue(self._process_rx_sandesh)
     self._send_level = SandeshLevel.INVALID
     self._init_logger(self._module,
                       logger_class=logger_class,
                       logger_config_file=logger_config_file)
     self._logger.info('SANDESH: CONNECT TO COLLECTOR: %s',
                       connect_to_collector)
     from sandesh_stats import SandeshMessageStatistics
     self._msg_stats = SandeshMessageStatistics()
     self._trace = trace.Trace()
     self._sandesh_request_map = {}
     self._alarm_ack_callback = alarm_ack_callback
     self._config = config or SandeshConfig.from_parser_arguments()
     self._uve_type_maps = SandeshUVETypeMaps(self._logger)
     # Initialize the request handling
     # Import here to break the cyclic import dependency
     import sandesh_req_impl
     sandesh_req_impl = sandesh_req_impl.SandeshReqImpl(self)
     self._sandesh_req_uve_pkg_list.append('pysandesh.gen_py')
     for pkg_name in self._sandesh_req_uve_pkg_list:
         self._create_sandesh_request_and_uve_lists(pkg_name)
     if self._config.disable_object_logs is not None:
         self.disable_sending_object_logs(self._config.disable_object_logs)
     if self._config.system_logs_rate_limit is not None:
         SandeshSystem.set_sandesh_send_rate_limit(
             self._config.system_logs_rate_limit)
     self._gev_httpd = None
     if http_port != -1:
         self.run_introspect_server(http_port)
     if self._connect_to_collector:
         self._client = SandeshClient(self)
         self._client.initiate(collectors)
Ejemplo n.º 3
0
 def init_generator(self,
                    module,
                    source,
                    node_type,
                    instance_id,
                    collectors,
                    client_context,
                    http_port,
                    sandesh_req_uve_pkg_list=None,
                    discovery_client=None):
     self._role = self.SandeshRole.GENERATOR
     self._module = module
     self._source = source
     self._node_type = node_type
     self._instance_id = instance_id
     self._client_context = client_context
     self._collectors = collectors
     self._rcv_queue = WorkQueue(self._process_rx_sandesh)
     self._init_logger(source + ':' + module + ':' + node_type + ':' \
         + instance_id)
     self._stats = SandeshStats()
     self._trace = trace.Trace()
     self._sandesh_request_dict = {}
     self._uve_type_maps = SandeshUVETypeMaps()
     if sandesh_req_uve_pkg_list is None:
         sandesh_req_uve_pkg_list = []
     # Initialize the request handling
     # Import here to break the cyclic import dependency
     import sandesh_req_impl
     sandesh_req_impl = sandesh_req_impl.SandeshReqImpl(self)
     sandesh_req_uve_pkg_list.append('pysandesh.gen_py')
     for pkg_name in sandesh_req_uve_pkg_list:
         self._create_sandesh_request_and_uve_lists(pkg_name)
     if http_port != -1:
         self._http_server = SandeshHttp(self, module, http_port,
                                         sandesh_req_uve_pkg_list)
         gevent.spawn(self._http_server.start_http_server)
     primary_collector = None
     secondary_collector = None
     if self._collectors is not None:
         if len(self._collectors) > 0:
             primary_collector = self._collectors[0]
         if len(self._collectors) > 1:
             secondary_collector = self._collectors[1]
     self._client = SandeshClient(self, primary_collector,
                                  secondary_collector, discovery_client)
     self._client.initiate()