本文整理汇总了Python中pysandesh.connection_info.ConnectionState.init方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectionState.init方法的具体用法?Python ConnectionState.init怎么用?Python ConnectionState.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysandesh.connection_info.ConnectionState
的用法示例。
在下文中一共展示了ConnectionState.init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, conf):
self._conf = conf
module = Module.CONTRAIL_TOPOLOGY
self._moduleid = ModuleNames[module]
node_type = Module2NodeType[module]
self._node_type_name = NodeTypeNames[node_type]
self._hostname = socket.gethostname()
self.table = "ObjectCollectorInfo"
self._instance_id = '0'
sandesh_global.init_generator(self._moduleid, self._hostname,
self._node_type_name, self._instance_id,
self._conf.random_collectors,
self._node_type_name,
self._conf.http_port(),
['contrail_topology.sandesh'],
config=self._conf.sandesh_config())
sandesh_global.set_logging_params(
enable_local_log=self._conf.log_local(),
category=self._conf.log_category(),
level=self._conf.log_level(),
file=self._conf.log_file(),
enable_syslog=self._conf.use_syslog(),
syslog_facility=self._conf.syslog_facility())
ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self.table)
self._logger = sandesh_global.logger()
示例2: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, db, discovery, args=None):
self._args = args
self._db = db
module = Module.SVC_MONITOR
node_type = Module2NodeType[module]
self._module_name = ModuleNames[module]
self._node_type_name = NodeTypeNames[node_type]
self._instance_id = INSTANCE_ID_DEFAULT
self._hostname = socket.gethostname()
#sandesh init
self._sandesh = self._sandesh_init(discovery)
# connection state init
ConnectionState.init(self._sandesh, self._hostname, self._module_name,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
#create cpu_info object to send periodic updates
sysinfo_req = False
cpu_info = vnc_cpu_info.CpuInfo(self._module_name,
self._instance_id, sysinfo_req, self._sandesh, 60)
self._cpu_info = cpu_info
示例3: sandesh_init
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def sandesh_init(self, http_server_port=None):
""" Init sandesh """
self._sandesh = Sandesh()
self.redefine_sandesh_handles()
if not http_server_port:
http_server_port = self._args.http_server_port
self._sandesh.init_generator(
self._module_name, self._hostname, self._node_type_name,
self._instance_id, self._args.random_collectors,
'%s_context' % self.context, int(http_server_port),
['cfgm_common', '%s.sandesh' % self.module_pkg],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
self._sandesh.set_logging_params(
enable_local_log=self._args.log_local,
category=self._args.log_category,
level=self._args.log_level,
file=self._args.log_file,
enable_syslog=self._args.use_syslog,
syslog_facility=self._args.syslog_facility)
# connection state init
ConnectionState.init(
self._sandesh, self._hostname, self._module_name,
self._instance_id,
staticmethod(ConnectionState.get_conn_state_cb),
NodeStatusUVE, NodeStatus, self.table)
VncGreenlet.register_sandesh_handler()
示例4: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, rule_file, discovery_server,
discovery_port, collector_addr):
self.module = Module.COMPUTE_NODE_MGR
self.module_id = ModuleNames[self.module]
node_type = Module2NodeType[self.module]
node_type_name = NodeTypeNames[node_type]
self.sandesh_global = sandesh_global
EventManager.__init__(self, rule_file, discovery_server,
discovery_port, collector_addr, sandesh_global)
self.node_type = "contrail-vrouter"
self.table = "ObjectVRouter"
_disc = self.get_discovery_client()
sandesh_global.init_generator(
self.module_id, socket.gethostname(),
node_type_name, self.instance_id, self.collector_addr,
self.module_id, 8102, ['vrouter.loadbalancer',
'nodemgr.common.sandesh'], _disc)
sandesh_global.set_logging_params(enable_local_log=True)
self.supervisor_serverurl = "unix:///var/run/supervisord_vrouter.sock"
self.add_current_process()
ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
self.instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self.table)
self.lb_stats = LoadbalancerStatsUVE()
self.send_system_cpu_info()
self.third_party_process_dict = {}
示例5: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, conf):
self._conf = conf
module = Module.CONTRAIL_TOPOLOGY
self._moduleid = ModuleNames[module]
node_type = Module2NodeType[module]
self._node_type_name = NodeTypeNames[node_type]
self._hostname = socket.gethostname()
self._instance_id = '0'
if self._conf.sandesh_send_rate_limit() is not None:
SandeshSystem.set_sandesh_send_rate_limit( \
self._conf.sandesh_send_rate_limit())
sandesh_global.init_generator(self._moduleid, self._hostname,
self._node_type_name, self._instance_id,
self._conf.collectors(),
self._node_type_name,
self._conf.http_port(),
['contrail_topology.sandesh'],
self._conf._disc)
sandesh_global.set_logging_params(
enable_local_log=self._conf.log_local(),
category=self._conf.log_category(),
level=self._conf.log_level(),
file=self._conf.log_file(),
enable_syslog=self._conf.use_syslog(),
syslog_facility=self._conf.syslog_facility())
ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
示例6: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, rule_file, discovery_server,
discovery_port, collector_addr):
self.node_type = "contrail-config"
self.module = Module.CONFIG_NODE_MGR
self.module_id = ModuleNames[self.module]
self.supervisor_serverurl = "unix:///var/run/supervisord_config.sock"
self.add_current_process()
node_type = Module2NodeType[self.module]
node_type_name = NodeTypeNames[node_type]
self.sandesh_global = sandesh_global
EventManager.__init__(
self, rule_file, discovery_server,
discovery_port, collector_addr, sandesh_global)
_disc = self.get_discovery_client()
sandesh_global.init_generator(
self.module_id, socket.gethostname(),
node_type_name, self.instance_id, self.collector_addr,
self.module_id, 8100, ['cfgm_common.uve'], _disc)
sandesh_global.set_logging_params(enable_local_log=True)
ConnectionState.init(sandesh_global, socket.gethostname(),
self.module_id, self.instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ ]
示例7: sandesh_init
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def sandesh_init(self):
""" Init Sandesh """
self._sandesh = Sandesh()
# Initialize Sandesh generator.
self._sandesh.init_generator(
self.module['name'], self.module['hostname'],
self.module['node_type_name'], self.module['instance_id'],
self._args.collectors, 'mesos_manager_context',
int(self._args.http_server_port),
['cfgm_common', 'mesos_manager.sandesh'],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
# Set Sandesh logging params.
self._sandesh.set_logging_params(
enable_local_log=self._args.log_local,
category=self._args.log_category,
level=self._args.log_level, file=self._args.log_file,
enable_syslog=self._args.use_syslog,
syslog_facility=self._args.syslog_facility)
# Connect to collector.
ConnectionState.init(self._sandesh, self.module['hostname'],
self.module['name'], self.module['instance_id'],
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self.module['table'])
示例8: sandesh_init
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def sandesh_init(self):
""" Init Sandesh """
self._sandesh = Sandesh()
# Register custom sandesh request handlers.
self._redefine_sandesh_handles()
# Initialize Sandesh generator.
self._sandesh.init_generator(
self._module["name"], self._module["hostname"],
self._module["node_type_name"], self._module["instance_id"],
self._args.random_collectors, 'kube_manager_context',
int(self._args.http_server_port),
['cfgm_common', 'kube_manager'],
logger_class=self._args.logger_class,
logger_config_file=self._args.logging_conf,
config=self._args.sandesh_config)
# Set Sandesh logging params.
self._sandesh.set_logging_params(
enable_local_log=self._args.log_local,
category=self._args.log_category, level=self._args.log_level,
file=self._args.log_file, enable_syslog=self._args.use_syslog,
syslog_facility=self._args.syslog_facility)
# Connect to collector.
ConnectionState.init(
self._sandesh, self._module["hostname"], self._module["name"],
self._module["instance_id"],
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self._module["table"])
示例9: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, rule_file, discovery_server,
discovery_port, collector_addr):
EventManager.__init__(
self, rule_file, discovery_server,
discovery_port, collector_addr, sandesh_global)
self.node_type = 'contrail-analytics'
self.table = "ObjectCollectorInfo"
self.module = Module.ANALYTICS_NODE_MGR
self.module_id = ModuleNames[self.module]
self.supervisor_serverurl = "unix:///var/run/supervisord_analytics.sock"
self.add_current_process()
node_type = Module2NodeType[self.module]
node_type_name = NodeTypeNames[node_type]
_disc = self.get_discovery_client()
sandesh_global.init_generator(
self.module_id, socket.gethostname(),
node_type_name, self.instance_id, self.collector_addr,
self.module_id, 8104, ['analytics', 'nodemgr.common.sandesh'], _disc)
sandesh_global.set_logging_params(enable_local_log=True)
ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
self.instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self.table)
self.send_system_cpu_info()
self.third_party_process_list = [ ]
示例10: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, conf, instance='0'):
self._conf = conf
module = Module.CONTRAIL_SNMP_COLLECTOR
self._moduleid = ModuleNames[module]
node_type = Module2NodeType[module]
self._node_type_name = NodeTypeNames[node_type]
self._hostname = socket.gethostname()
self._instance_id = instance
sandesh_global.init_generator(self._moduleid, self._hostname,
self._node_type_name, self._instance_id,
self._conf.collectors(),
self._node_type_name,
self._conf.http_port(),
['contrail_snmp_collector.gen_py',
'opserver.sandesh'],
self._conf._disc)
sandesh_global.set_logging_params(
enable_local_log=self._conf.log_local(),
category=self._conf.log_category(),
level=self._conf.log_level(),
file=self._conf.log_file(),
enable_syslog=self._conf.use_syslog(),
syslog_facility=self._conf.syslog_facility())
ConnectionState.init(sandesh_global, self._hostname, self._moduleid,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.if_stat = {}
self._logger = sandesh_global.logger()
示例11: test_basic
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def test_basic(self):
ConnectionState.init(sandesh = self._sandesh, hostname = "TestHost",
module_id = "TestModule", instance_id = "0",
status_cb = self._check_process_status_cb,
uve_type_cls = NodeStatusTestUVE,
uve_data_type_cls = NodeStatusTest)
vcinfos = []
self._update_conn_info("Test1", ConnectionStatus.UP, "Test1 UP",
vcinfos)
self._update_conn_state("Test1", ConnectionStatus.UP, "Test1 UP",
vcinfos)
self._update_conn_info("Test2", ConnectionStatus.UP, "Test2 UP",
vcinfos)
self._update_conn_state("Test2", ConnectionStatus.UP, "Test2 UP",
vcinfos)
vcinfos = self._delete_conn_info("Test2", vcinfos)
self._delete_conn_state("Test2", vcinfos)
示例12: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, conf, instance="0"):
self._conf = conf
module = Module.CONTRAIL_SNMP_COLLECTOR
self._moduleid = ModuleNames[module]
node_type = Module2NodeType[module]
self._node_type_name = NodeTypeNames[node_type]
self.table = "ObjectCollectorInfo"
self._hostname = socket.gethostname()
self._instance_id = instance
if self._conf.sandesh_send_rate_limit() is not None:
SandeshSystem.set_sandesh_send_rate_limit(self._conf.sandesh_send_rate_limit())
sandesh_global.init_generator(
self._moduleid,
self._hostname,
self._node_type_name,
self._instance_id,
self._conf.collectors(),
self._node_type_name,
self._conf.http_port(),
["contrail_snmp_collector.sandesh"],
self._conf._disc,
)
sandesh_global.set_logging_params(
enable_local_log=self._conf.log_local(),
category=self._conf.log_category(),
level=self._conf.log_level(),
file=self._conf.log_file(),
enable_syslog=self._conf.use_syslog(),
syslog_facility=self._conf.syslog_facility(),
)
ConnectionState.init(
sandesh_global,
self._hostname,
self._moduleid,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE,
NodeStatus,
self.table,
)
self.if_stat = {}
self._logger = sandesh_global.logger()
示例13: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, rule_file, discovery_server,
discovery_port, collector_addr,
hostip, minimum_diskgb, contrail_databases,
cassandra_repair_interval,
cassandra_repair_logdir):
self.node_type = "contrail-database"
self.module = Module.DATABASE_NODE_MGR
self.module_id = ModuleNames[self.module]
self.hostip = hostip
self.minimum_diskgb = minimum_diskgb
self.contrail_databases = contrail_databases
self.cassandra_repair_interval = cassandra_repair_interval
self.cassandra_repair_logdir = cassandra_repair_logdir
self.supervisor_serverurl = "unix:///var/run/supervisord_database.sock"
self.add_current_process()
node_type = Module2NodeType[self.module]
node_type_name = NodeTypeNames[node_type]
self.sandesh_global = sandesh_global
EventManager.__init__(
self, rule_file, discovery_server,
discovery_port, collector_addr, sandesh_global, send_build_info = True)
self.sandesh_global = sandesh_global
if self.rule_file is '':
self.rule_file = "/etc/contrail/" + \
"supervisord_database_files/contrail-database.rules"
json_file = open(self.rule_file)
self.rules_data = json.load(json_file)
_disc = self.get_discovery_client()
sandesh_global.init_generator(
self.module_id, socket.gethostname(), node_type_name,
self.instance_id, self.collector_addr, self.module_id, 8103,
['database.sandesh'], _disc)
sandesh_global.set_logging_params(enable_local_log=True)
ConnectionState.init(sandesh_global, socket.gethostname(), self.module_id,
self.instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus)
self.send_system_cpu_info()
self.third_party_process_list = [ "cassandra", "zookeeper" ]
示例14: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, conf, test_logger=None):
self._conf = conf
module = Module.ALARM_GENERATOR
self._moduleid = ModuleNames[module]
node_type = Module2NodeType[module]
self._node_type_name = NodeTypeNames[node_type]
self._hostname = socket.gethostname()
self._instance_id = self._conf.worker_id()
is_collector = True
if test_logger is not None:
is_collector = False
self._sandesh = Sandesh()
# Reset the sandesh send rate limit value
if self._conf.sandesh_send_rate_limit() is not None:
SandeshSystem.set_sandesh_send_rate_limit(self._conf.sandesh_send_rate_limit())
self._sandesh.init_generator(
self._moduleid,
self._hostname,
self._node_type_name,
self._instance_id,
self._conf.collectors(),
self._node_type_name,
self._conf.http_port(),
["opserver.sandesh", "sandesh"],
host_ip=self._conf.host_ip(),
connect_to_collector=is_collector,
)
if test_logger is not None:
self._logger = test_logger
else:
self._sandesh.set_logging_params(
enable_local_log=self._conf.log_local(),
category=self._conf.log_category(),
level=self._conf.log_level(),
file=self._conf.log_file(),
enable_syslog=self._conf.use_syslog(),
syslog_facility=self._conf.syslog_facility(),
)
self._logger = self._sandesh._logger
# Trace buffer list
self.trace_buf = [{"name": "DiscoveryMsg", "size": 1000}]
# Create trace buffers
for buf in self.trace_buf:
self._sandesh.trace_buffer_create(name=buf["name"], size=buf["size"])
tables = ["ObjectCollectorInfo", "ObjectDatabaseInfo", "ObjectVRouter", "ObjectBgpRouter", "ObjectConfigNode"]
self.mgrs = {}
self.tab_alarms = {}
self.ptab_info = {}
self.tab_perf = {}
self.tab_perf_prev = {}
for table in tables:
self.mgrs[table] = hook.HookManager(
namespace="contrail.analytics.alarms",
name=table,
invoke_on_load=True,
invoke_args=(),
on_load_failure_callback=self.fail_cb,
)
for extn in self.mgrs[table][table]:
self._logger.info(
"Loaded extensions for %s: %s,%s doc %s"
% (table, extn.name, extn.entry_point_target, extn.obj.__doc__)
)
self.tab_alarms[table] = {}
self.tab_perf[table] = AGTabStats()
ConnectionState.init(
self._sandesh,
self._hostname,
self._moduleid,
self._instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE,
NodeStatus,
)
self._us = UVEServer(None, self._logger, self._conf.redis_password())
self._workers = {}
self._uvestats = {}
self._uveq = {}
self._uveqf = {}
self.disc = None
self._libpart_name = self._hostname + ":" + self._instance_id
self._libpart = None
self._partset = set()
if self._conf.discovery()["server"]:
data = {"ip-address": self._hostname, "port": self._instance_id}
self.disc = client.DiscoveryClient(
self._conf.discovery()["server"], self._conf.discovery()["port"], ModuleNames[Module.ALARM_GENERATOR]
)
self._logger.info("Disc Publish to %s : %s" % (str(self._conf.discovery()), str(data)))
self.disc.publish(ALARM_GENERATOR_SERVICE_NAME, data)
else:
# If there is no discovery service, use fixed redis_uve list
redis_uve_list = []
#.........这里部分代码省略.........
示例15: __init__
# 需要导入模块: from pysandesh.connection_info import ConnectionState [as 别名]
# 或者: from pysandesh.connection_info.ConnectionState import init [as 别名]
def __init__(self, config, type_info, rule_file, sandesh_instance,
update_process_list=False):
self.config = config
self.type_info = type_info
self.stdin = sys.stdin
self.stdout = sys.stdout
self.stderr = sys.stderr
self.rule_file = rule_file
self.rules_data = {'Rules':[]}
self.max_cores = 4
self.max_old_cores = 3
self.max_new_cores = 1
self.all_core_file_list = []
self.core_dir_modified_time = 0
self.tick_count = 0
self.fail_status_bits = 0
self.prev_fail_status_bits = 1
self.instance_id = INSTANCE_ID_DEFAULT
self.collector_addr = self.config.collectors
self.sandesh_instance = sandesh_instance
self.curr_build_info = None
self.new_build_info = None
self.last_cpu = None
self.last_time = 0
self.installed_package_version = None
SupervisorEventsReq.handle_request = self.sandesh_supervisor_handle_request
event_handlers = {}
event_handlers['PROCESS_STATE'] = self.event_process_state
event_handlers['PROCESS_COMMUNICATION'] = \
self.event_process_communication
event_handlers['PROCESS_LIST_UPDATE'] = self.update_current_process
ConnectionState.init(self.sandesh_instance, socket.gethostname(),
self.type_info._module_name, self.instance_id,
staticmethod(ConnectionState.get_process_state_cb),
NodeStatusUVE, NodeStatus, self.type_info._object_table)
self.sandesh_instance.init_generator(
self.type_info._module_name, socket.gethostname(),
self.type_info._node_type_name, self.instance_id,
self.collector_addr, self.type_info._module_name,
ServiceHttpPortMap[self.type_info._module_name],
['nodemgr.common.sandesh'] + self.type_info._sandesh_packages,
config=SandeshConfig.from_parser_arguments(self.config))
self.sandesh_instance.set_logging_params(
enable_local_log=self.config.log_local,
category=self.config.log_category,
level=self.config.log_level,
file=self.config.log_file,
enable_syslog=self.config.use_syslog,
syslog_facility=self.config.syslog_facility)
self.logger = self.sandesh_instance.logger()
if is_systemd_based():
if not pydbus_present:
self.msg_log('Node manager cannot run without pydbus', SandeshLevel.SYS_ERR)
exit(-1)
# In docker, systemd notifications via sd_notify do not
# work, hence we will poll the process status
self.process_info_manager = SystemdProcessInfoManager(
self.type_info._unit_names, event_handlers,
update_process_list, is_running_in_docker())
else:
if not 'SUPERVISOR_SERVER_URL' in os.environ:
self.msg_log('Node manager must be run as a supervisor event listener',
SandeshLevel.SYS_ERR)
exit(-1)
self.process_info_manager = SupervisorProcessInfoManager(
self.stdin, self.stdout, self.type_info._supervisor_serverurl,
event_handlers, update_process_list)
self.add_current_process()
for group in self.process_state_db:
self.send_init_info(group)
self.third_party_process_dict = self.type_info._third_party_processes