本文整理汇总了Python中logger.ServiceMonitorLogger.log方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceMonitorLogger.log方法的具体用法?Python ServiceMonitorLogger.log怎么用?Python ServiceMonitorLogger.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logger.ServiceMonitorLogger
的用法示例。
在下文中一共展示了ServiceMonitorLogger.log方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SvcMonitor
# 需要导入模块: from logger import ServiceMonitorLogger [as 别名]
# 或者: from logger.ServiceMonitorLogger import log [as 别名]
class SvcMonitor(object):
"""
data + methods used/referred to by ssrc and arc greenlets
"""
_REACTION_MAP = {
"loadbalancer_pool": {
'self': [],
'virtual_ip': [],
'loadbalancer_member': [],
'loadbalancer_healthmonitor': [],
},
"loadbalancer_member": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"virtual_ip": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"loadbalancer_healthmonitor": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"service_instance": {
'self': [],
},
"service_template": {
'self': [],
}
}
def __init__(self, args=None):
self._args = args
# create database and logger
self.db = ServiceMonitorDB(args)
# initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(self._args.disc_server_ip,
self._args.disc_server_port,
ModuleNames[Module.SVC_MONITOR])
# initialize logger
self.logger = ServiceMonitorLogger(self.db, self._disc, args)
self.db.add_logger(self.logger)
self.db.init_database()
# rotating log file for catchall errors
self._err_file = self._args.trace_file
self._svc_err_logger = logging.getLogger('SvcErrLogger')
self._svc_err_logger.setLevel(logging.ERROR)
try:
with open(self._err_file, 'a'):
handler = logging.handlers.RotatingFileHandler(
self._err_file, maxBytes=64*1024, backupCount=2)
self._svc_err_logger.addHandler(handler)
except IOError:
self.logger.log("Failed to open trace file %s" % self._err_file)
# Connect to Rabbit and Initialize cassandra connection
# TODO activate this code
# self._connect_rabbit()
def _connect_rabbit(self):
rabbit_server = self._args.rabbit_server
rabbit_port = self._args.rabbit_port
rabbit_user = self._args.rabbit_user
rabbit_password = self._args.rabbit_password
rabbit_vhost = self._args.rabbit_vhost
self._db_resync_done = gevent.event.Event()
q_name = 'svc_mon.%s' % (socket.gethostname())
self._vnc_kombu = VncKombuClient(rabbit_server, rabbit_port,
rabbit_user, rabbit_password,
rabbit_vhost, q_name,
self._vnc_subscribe_callback,
self.config_log)
cass_server_list = self._args.cassandra_server_list
reset_config = self._args.reset_config
self._cassandra = VncCassandraClient(cass_server_list, reset_config,
self._args.cluster_id, None,
self.config_log)
DBBase.init(self, self.logger, self._cassandra)
# end _connect_rabbit
def config_log(self, msg, level):
self.logger.log(msg)
def _vnc_subscribe_callback(self, oper_info):
import pdb;pdb.set_trace()
self._db_resync_done.wait()
try:
msg = "Notification Message: %s" % (pformat(oper_info))
self.config_log(msg, level=SandeshLevel.SYS_DEBUG)
obj_type = oper_info['type'].replace('-', '_')
#.........这里部分代码省略.........
示例2: SvcMonitor
# 需要导入模块: from logger import ServiceMonitorLogger [as 别名]
# 或者: from logger.ServiceMonitorLogger import log [as 别名]
class SvcMonitor(object):
"""
data + methods used/referred to by ssrc and arc greenlets
"""
_REACTION_MAP = {
"service_appliance_set": {
'self': [],
'service_appliance': []
},
"service_appliance": {
'self': ['service_appliance_set'],
'service_appliance_set': []
},
"loadbalancer_pool": {
'self': [],
'virtual_ip': [],
'loadbalancer_member': [],
'loadbalancer_healthmonitor': [],
},
"loadbalancer_member": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"virtual_ip": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"loadbalancer_healthmonitor": {
'self': ['loadbalancer_pool'],
'loadbalancer_pool': []
},
"service_instance": {
'self': ['virtual_machine'],
'virtual_machine': []
},
"instance_ip": {
'self': [],
},
"floating_ip": {
'self': [],
},
"service_template": {
'self': [],
},
"physical_router": {
'self': [],
},
"physical_interface": {
'self': [],
},
"logical_interface": {
'self': [],
},
"virtual_network": {
'self': [],
},
"virtual_machine": {
'self': ['virtual_machine_interface'],
'service_instance': [],
'virtual_machine_interface': [],
},
"virtual_machine_interface": {
'self': ['interface_route_table', 'virtual_machine'],
'interface_route_table': [],
'virtual_machine': [],
},
"interface_route_table": {
'self': [],
'virtual_machine_interface': [],
},
"project": {
'self': [],
},
}
def __init__(self, args=None):
self._args = args
# create database and logger
self.si_db = ServiceInstanceDB(args)
# initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(self._args.disc_server_ip,
self._args.disc_server_port,
ModuleNames[Module.SVC_MONITOR])
# initialize logger
self.logger = ServiceMonitorLogger(self.si_db, self._disc, args)
self.si_db.add_logger(self.logger)
self.si_db.init_database()
# rotating log file for catchall errors
self._err_file = self._args.trace_file
self._svc_err_logger = logging.getLogger('SvcErrLogger')
self._svc_err_logger.setLevel(logging.ERROR)
try:
with open(self._err_file, 'a'):
#.........这里部分代码省略.........
示例3: SvcMonitor
# 需要导入模块: from logger import ServiceMonitorLogger [as 别名]
# 或者: from logger.ServiceMonitorLogger import log [as 别名]
class SvcMonitor(object):
"""
data + methods used/referred to by ssrc and arc greenlets
"""
def __init__(self, args=None):
self._args = args
# create database and logger
self.db = ServiceMonitorDB(args)
# initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(self._args.disc_server_ip,
self._args.disc_server_port,
client_type='Service Monitor')
# initialize logger
self.logger = ServiceMonitorLogger(self.db, self._disc, args)
self.db.add_logger(self.logger)
# rotating log file for catchall errors
self._err_file = '/var/log/contrail/svc-monitor.err'
self._tmp_file = '/var/log/contrail/svc-monitor.tmp'
try:
with open(self._err_file, 'a'):
pass
with open(self._tmp_file, 'a'):
pass
except IOError:
self._err_file = './svc-monitor.err'
self._tmp_file = './svc-monitor.tmp'
self._svc_err_logger = logging.getLogger('SvcErrLogger')
self._svc_err_logger.setLevel(logging.ERROR)
handler = logging.handlers.RotatingFileHandler(
self._err_file, maxBytes=64*1024, backupCount=2)
self._svc_err_logger.addHandler(handler)
def post_init(self, vnc_lib, args=None):
# api server
self._vnc_lib = vnc_lib
# create default analyzer template
self._create_default_template('analyzer-template', 'analyzer',
flavor='m1.medium',
image_name='analyzer')
# create default NAT template
self._create_default_template('nat-template', 'firewall',
svc_mode='in-network-nat',
image_name='analyzer',
flavor='m1.medium')
# create default netns SNAT template
self._create_default_template('netns-snat-template', 'source-nat',
svc_mode='in-network-nat',
hypervisor_type='network-namespace',
scaling=True)
# create default loadbalancer template
self._create_default_template('haproxy-loadbalancer-template', 'loadbalancer',
image_name='in-network',
hypervisor_type='network-namespace',
scaling=True)
# load vrouter scheduler
self.vrouter_scheduler = importutils.import_object(
self._args.si_netns_scheduler_driver,
self._vnc_lib,
self._args)
# load virtual machine instance manager
self.vm_manager = importutils.import_object(
'svc_monitor.instance_manager.VirtualMachineManager',
self._vnc_lib, self.db, self.logger,
self.vrouter_scheduler, self._args)
# load network namespace instance manager
self.netns_manager = importutils.import_object(
'svc_monitor.instance_manager.NetworkNamespaceManager',
self._vnc_lib, self.db, self.logger,
self.vrouter_scheduler, self._args)
# create service template
def _create_default_template(self, st_name, svc_type, svc_mode=None,
hypervisor_type='virtual-machine',
image_name=None, flavor=None, scaling=False):
domain_name = 'default-domain'
domain_fq_name = [domain_name]
st_fq_name = [domain_name, st_name]
self.logger.log("Creating %s %s hypervisor %s" %
(domain_name, st_name, hypervisor_type))
try:
st_obj = self._vnc_lib.service_template_read(fq_name=st_fq_name)
st_uuid = st_obj.uuid
self.logger.log("%s exists uuid %s" % (st_name, str(st_uuid)))
return
except NoIdError:
#.........这里部分代码省略.........
示例4: SvcMonitor
# 需要导入模块: from logger import ServiceMonitorLogger [as 别名]
# 或者: from logger.ServiceMonitorLogger import log [as 别名]
class SvcMonitor(object):
"""
data + methods used/referred to by ssrc and arc greenlets
"""
def __init__(self, args=None):
self._args = args
# create database and logger
self.db = ServiceMonitorDB(args)
# initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(self._args.disc_server_ip,
self._args.disc_server_port,
client_type='Service Monitor')
# initialize logger
self.logger = ServiceMonitorLogger(self.db, self._disc, args)
self.db.add_logger(self.logger)
self.db.init_database()
# rotating log file for catchall errors
self._err_file = '/var/log/contrail/svc-monitor.err'
self._tmp_file = '/var/log/contrail/svc-monitor.tmp'
try:
with open(self._err_file, 'a'):
pass
with open(self._tmp_file, 'a'):
pass
except IOError:
self._err_file = './svc-monitor.err'
self._tmp_file = './svc-monitor.tmp'
self._svc_err_logger = logging.getLogger('SvcErrLogger')
self._svc_err_logger.setLevel(logging.ERROR)
handler = logging.handlers.RotatingFileHandler(
self._err_file, maxBytes=64*1024, backupCount=2)
self._svc_err_logger.addHandler(handler)
def post_init(self, vnc_lib, args=None):
# api server
self._vnc_lib = vnc_lib
# create default analyzer template
self._create_default_template('analyzer-template', 'analyzer',
flavor='m1.medium',
image_name='analyzer')
# create default NAT template
self._create_default_template('nat-template', 'firewall',
svc_mode='in-network-nat',
image_name='analyzer',
flavor='m1.medium')
# create default netns SNAT template
self._create_default_template('netns-snat-template', 'source-nat',
svc_mode='in-network-nat',
hypervisor_type='network-namespace',
scaling=True)
# create default loadbalancer template
self._create_default_template('haproxy-loadbalancer-template', 'loadbalancer',
svc_mode='in-network-nat',
hypervisor_type='network-namespace',
scaling=True)
# load vrouter scheduler
self.vrouter_scheduler = importutils.import_object(
self._args.si_netns_scheduler_driver,
self._vnc_lib,
self._args)
# load virtual machine instance manager
self.vm_manager = importutils.import_object(
'svc_monitor.instance_manager.VirtualMachineManager',
self._vnc_lib, self.db, self.logger,
self.vrouter_scheduler, self._args)
# load network namespace instance manager
self.netns_manager = importutils.import_object(
'svc_monitor.instance_manager.NetworkNamespaceManager',
self._vnc_lib, self.db, self.logger,
self.vrouter_scheduler, self._args)
# create service template
def _create_default_template(self, st_name, svc_type, svc_mode=None,
hypervisor_type='virtual-machine',
image_name=None, flavor=None, scaling=False):
domain_name = 'default-domain'
domain_fq_name = [domain_name]
st_fq_name = [domain_name, st_name]
self.logger.log("Creating %s %s hypervisor %s" %
(domain_name, st_name, hypervisor_type))
try:
st_obj = self._vnc_lib.service_template_read(fq_name=st_fq_name)
st_uuid = st_obj.uuid
self.logger.log("%s exists uuid %s" % (st_name, str(st_uuid)))
return
#.........这里部分代码省略.........
示例5: SvcMonitor
# 需要导入模块: from logger import ServiceMonitorLogger [as 别名]
# 或者: from logger.ServiceMonitorLogger import log [as 别名]
class SvcMonitor(object):
"""
data + methods used/referred to by ssrc and arc greenlets
"""
def __init__(self, args=None):
self._args = args
# create database and logger
self.db = ServiceMonitorDB(args)
# initialize discovery client
self._disc = None
if self._args.disc_server_ip and self._args.disc_server_port:
self._disc = client.DiscoveryClient(
self._args.disc_server_ip, self._args.disc_server_port, client_type="Service Monitor"
)
# initialize logger
self.logger = ServiceMonitorLogger(self.db, self._disc, args)
self.db.add_logger(self.logger)
# rotating log file for catchall errors
self._err_file = "/var/log/contrail/svc-monitor.err"
self._tmp_file = "/var/log/contrail/svc-monitor.tmp"
try:
with open(self._err_file, "a"):
pass
with open(self._tmp_file, "a"):
pass
except IOError:
self._err_file = "./svc-monitor.err"
self._tmp_file = "./svc-monitor.tmp"
self._svc_err_logger = logging.getLogger("SvcErrLogger")
self._svc_err_logger.setLevel(logging.ERROR)
handler = logging.handlers.RotatingFileHandler(self._err_file, maxBytes=64 * 1024, backupCount=2)
self._svc_err_logger.addHandler(handler)
def post_init(self, vnc_lib, args=None):
# api server
self._vnc_lib = vnc_lib
# create default analyzer template
self._create_default_template("analyzer-template", "analyzer", flavor="m1.medium", image_name="analyzer")
# create default NAT template
self._create_default_template(
"nat-template", "firewall", svc_mode="in-network-nat", image_name="analyzer", flavor="m1.medium"
)
# create default netns SNAT template
self._create_default_template(
"netns-snat-template",
"source-nat",
svc_mode="in-network-nat",
hypervisor_type="network-namespace",
scaling=True,
)
# create default loadbalancer template
self._create_default_template(
"haproxy-loadbalancer-template",
"loadbalancer",
svc_mode="in-network-nat",
hypervisor_type="network-namespace",
scaling=True,
)
# load vrouter scheduler
self.vrouter_scheduler = importutils.import_object(
self._args.si_netns_scheduler_driver, self._vnc_lib, self._args
)
# load virtual machine instance manager
self.vm_manager = importutils.import_object(
"svc_monitor.instance_manager.VirtualMachineManager",
self._vnc_lib,
self.db,
self.logger,
self.vrouter_scheduler,
self._args,
)
# load network namespace instance manager
self.netns_manager = importutils.import_object(
"svc_monitor.instance_manager.NetworkNamespaceManager",
self._vnc_lib,
self.db,
self.logger,
self.vrouter_scheduler,
self._args,
)
# create service template
def _create_default_template(
self,
st_name,
svc_type,
svc_mode=None,
hypervisor_type="virtual-machine",
image_name=None,
flavor=None,
#.........这里部分代码省略.........