• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sandesh_http.SandeshHttp类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sandesh_http.SandeshHttp的典型用法代码示例。如果您正苦于以下问题:Python SandeshHttp类的具体用法?Python SandeshHttp怎么用?Python SandeshHttp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: send

 def send(self, isseq=False, seqno=0, context='',
          more=False, sandesh=sandesh_global):
     try:
         self.validate()
     except e:
         sandesh._logger.error('sandesh "%s" validation failed [%s]' %
                              (self.__class__.__name__, e))
         return -1
     if isseq is True:
         self._seqnum = seqno
     else:
         uve_type_map = sandesh._uve_type_maps.get_uve_type_map(
             self.__class__.__name__)
         if uve_type_map is None:
             return -1
         self._seqnum = self.next_seqnum()
         uve_type_map.update_uve(self)
     self._context = context
     self._more = more
     if self._context.find('http://') == 0:
         SandeshHttp.create_http_response(self, sandesh)
     else:
         if self.handle_test(sandesh):
             return 0
         if sandesh._client:
             sandesh._client.send_uve_sandesh(self)
         else:
             sandesh._logger.debug(self.log())
     return 0
开发者ID:nischalsheth,项目名称:contrail-sandesh,代码行数:29,代码来源:sandesh_base.py


示例2: send

 def send(self, isseq=False, seqno=0, context='',
          more=False, sandesh=sandesh_global,
          level=SandeshLevel.SYS_NOTICE):
     try:
         self.validate()
     except e:
         sandesh.drop_tx_sandesh(self, SandeshTxDropReason.ValidationFailed)
         return -1
     if self._type == SandeshType.UVE and \
             self._level == SandeshLevel.INVALID:
         self._level = level
     if isseq is True:
         self._seqnum = seqno
         self._hints |= SANDESH_SYNC_HINT
     else:
         uve_type_map = sandesh._uve_type_maps.get_uve_type_map(
             self.__class__.__name__)
         if uve_type_map is None:
             sandesh._logger.error('sandesh uve <%s> not registered %s'\
                 % (self.__class__.__name__, str(sandesh._uve_type_maps._uve_global_map)))
             sandesh.drop_tx_sandesh(self,
                 SandeshTxDropReason.ValidationFailed)
             return -1
         self._seqnum = self.next_seqnum()
         if not uve_type_map.update_uve(self):
             sandesh._logger.error('Failed to update sandesh in cache')
             sandesh.drop_tx_sandesh(self,
                 SandeshTxDropReason.ValidationFailed)
             return -1
     self._context = context
     self._more = more
     if self._context.find('http://') == 0 or \
             self._context.find('https://') == 0:
         SandeshHttp.create_http_response(self, sandesh)
     else:
         if self.handle_test(sandesh):
             return 0
         if sandesh._client:
             if sandesh.is_sending_all_messages_disabled():
                 sandesh.drop_tx_sandesh(self,
                     SandeshTxDropReason.SendingDisabled, self.level())
                 return -1
             # SandeshUVE has an implicit send level of SandeshLevel.SYS_UVE
             # which is irrespective of the level set by the user in the
             # send. This is needed so that the send queue does not grow
             # unbounded. Once the send queue's sending level reaches
             # SandeshLevel.SYS_UVE we will reset the connection to the
             # collector to initiate resync of the UVE cache
             if SandeshLevel.SYS_UVE >= sandesh.send_level():
                 sandesh._client.close_sm_session()
             sandesh._client.send_uve_sandesh(self)
         else:
             sandesh._logger.debug(self.log())
     return 0
开发者ID:Juniper,项目名称:contrail-sandesh,代码行数:54,代码来源:sandesh_base.py


示例3: init_generator

 def init_generator(self, module, source, 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._client_context = client_context
     self._collectors = collectors
     self._rcv_queue = WorkQueue(self._process_rx_sandesh)
     self._init_logger(module)
     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)
     self._http_server = SandeshHttp(self, module, http_port, sandesh_req_uve_pkg_list)
     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]
     gevent.spawn(self._http_server.start_http_server)
     self._client = SandeshClient(self, primary_collector, secondary_collector, 
                                  discovery_client)
     self._client.initiate()
开发者ID:routelastresort,项目名称:contrail-sandesh,代码行数:35,代码来源:sandesh_base.py


示例4: send_trace

 def send_trace(self, context='', more=False,
                sandesh=sandesh_global):
     try:
         self.validate()
     except e:
         sandesh.drop_tx_sandesh(self, SandeshTxDropReason.ValidationFailed)
         return -1
     self._context = context
     self._more = more
     if self._context.find('http://') == 0:
         SandeshHttp.create_http_response(self, sandesh)
     else:
         if self.handle_test(sandesh):
             return 0
         sandesh.send_sandesh(self)
     return 0
开发者ID:th3architect,项目名称:contrail-sandesh,代码行数:16,代码来源:sandesh_base.py


示例5: send_trace

 def send_trace(self, context='', more=False,
                sandesh=sandesh_global):
     try:
         self.validate()
     except e:
         sandesh._logger.error('sandesh "%s" validation failed [%s]' %
                              (self.__class__.__name__, e))
         return -1
     self._context = context
     self._more = more
     if self._context.find('http://') == 0:
         SandeshHttp.create_http_response(self, sandesh)
     else:
         if self.handle_test(sandesh):
             return 0
         sandesh.send_sandesh(self)
     return 0
开发者ID:nischalsheth,项目名称:contrail-sandesh,代码行数:17,代码来源:sandesh_base.py


示例6: init_generator

 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._send_level = SandeshLevel.INVALID
     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)
     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._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()
开发者ID:th3architect,项目名称:contrail-sandesh,代码行数:53,代码来源:sandesh_base.py


示例7: send

 def send(self, isseq=False, seqno=0, context='',
          more=False, sandesh=sandesh_global):
     try:
         self.validate()
     except e:
         sandesh.drop_tx_sandesh(self, SandeshTxDropReason.ValidationFailed)
         return -1
     if isseq is True:
         self._seqnum = seqno
         self._hints |= SANDESH_SYNC_HINT
     else:
         uve_type_map = sandesh._uve_type_maps.get_uve_type_map(
             self.__class__.__name__)
         if uve_type_map is None:
             sandesh._logger.error('sandesh uve <%s> not registered %s'\
                 % (self.__class__.__name__, str(sandesh._uve_type_maps._uve_global_map)))
             sandesh.drop_tx_sandesh(self,
                 SandeshTxDropReason.ValidationFailed)
             return -1
         self._seqnum = self.next_seqnum()
         if not uve_type_map.update_uve(self):
             sandesh._logger.error('Failed to update sandesh in cache')
             sandesh.drop_tx_sandesh(self,
                 SandeshTxDropReason.ValidationFailed)
             return -1
     self._context = context
     self._more = more
     if self._context.find('http://') == 0:
         SandeshHttp.create_http_response(self, sandesh)
     else:
         if self.handle_test(sandesh):
             return 0
         if sandesh._client:
             sandesh._client.send_uve_sandesh(self)
         else:
             sandesh._logger.debug(self.log())
     return 0
开发者ID:th3architect,项目名称:contrail-sandesh,代码行数:37,代码来源:sandesh_base.py


示例8: Sandesh

class Sandesh(object):
    _DEFAULT_LOG_FILE = SandeshLogger._DEFAULT_LOG_FILE
    _DEFAULT_SYSLOG_FACILITY = SandeshLogger._DEFAULT_SYSLOG_FACILITY

    class SandeshRole:
        INVALID = 0
        GENERATOR = 1
        COLLECTOR = 2
    # end class SandeshRole

    def __init__(self):
        self._context = ''
        self._scope = ''
        self._module = ''
        self._source = ''
        self._node_type = ''
        self._instance_id = ''
        self._timestamp = 0
        self._versionsig = 0
        self._type = 0
        self._hints = 0
        self._client_context = ''
        self._client = None
        self._role = self.SandeshRole.INVALID
        self._logger = None
        self._level = SandeshLevel.INVALID
        self._category = ''
        self._send_queue_enabled = True
        self._http_server = None
    # end __init__

    # Public functions

    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()
    # end init_generator

    def logger(self):
        return self._logger
    # end logger

    def sandesh_logger(self):
        return self._sandesh_logger
    # end sandesh_logger

    def set_logging_params(self, enable_local_log=False, category='',
                           level=SandeshLevel.SYS_INFO,
                           file=SandeshLogger._DEFAULT_LOG_FILE,
                           enable_syslog=False,
                           syslog_facility=_DEFAULT_SYSLOG_FACILITY):
        self._sandesh_logger.set_logging_params(
            enable_local_log, category, level, file,
            enable_syslog, syslog_facility)
    # end set_logging_params

    def set_local_logging(self, enable_local_log):
        self._sandesh_logger.set_local_logging(enable_local_log)
    # end set_local_logging

    def set_logging_level(self, level):
#.........这里部分代码省略.........
开发者ID:nischalsheth,项目名称:contrail-sandesh,代码行数:101,代码来源:sandesh_base.py


示例9: Sandesh

class Sandesh(object):
    _DEFAULT_LOG_FILE = sand_logger.SandeshLogger._DEFAULT_LOG_FILE
    _DEFAULT_SYSLOG_FACILITY = (
        sand_logger.SandeshLogger._DEFAULT_SYSLOG_FACILITY)

    class SandeshRole:
        INVALID = 0
        GENERATOR = 1
        COLLECTOR = 2
    # end class SandeshRole

    def __init__(self):
        self._context = ''
        self._scope = ''
        self._module = ''
        self._source = ''
        self._node_type = ''
        self._instance_id = ''
        self._timestamp = 0
        self._versionsig = 0
        self._type = 0
        self._hints = 0
        self._client_context = ''
        self._client = None
        self._role = self.SandeshRole.INVALID
        self._logger = None
        self._level = SandeshLevel.INVALID
        self._category = ''
        self._send_queue_enabled = True
        self._http_server = None
        self._connect_to_collector = True
    # end __init__

    # Public functions

    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._send_level = SandeshLevel.INVALID
        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)
        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._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()
    # end init_generator

    def uninit(self):
        self.kill_httpd()

    def kill_httpd(self):
        if self._gev_httpd:
            try:
                self._http_server.stop_http_server()
                self._http_server = None
                gevent.sleep(0)
                self._gev_httpd.kill()
#.........这里部分代码省略.........
开发者ID:th3architect,项目名称:contrail-sandesh,代码行数:101,代码来源:sandesh_base.py


示例10: run_introspect_server

 def run_introspect_server(self, http_port):
     self._http_server = SandeshHttp(
         self, self._module, http_port,
         self._sandesh_req_uve_pkg_list, self._config)
     self._gev_httpd = gevent.spawn(self._http_server.start_http_server)
开发者ID:Juniper,项目名称:contrail-sandesh,代码行数:5,代码来源:sandesh_base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sanetime.time函数代码示例发布时间:2022-05-27
下一篇:
Python Util.Util类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap