本文整理汇总了Python中Logging.log方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.log方法的具体用法?Python Logging.log怎么用?Python Logging.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logging
的用法示例。
在下文中一共展示了Logging.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def start(self):
self.cleanWildDhcpds()
# XXX/jshilkaitis: WARNING -- lame shitty hack that will break if
# VMware fixes vmnet-dhcpd. Today, vmnet-dhcpd assumes that the
# last character of the interface passed to it is the last
# character of the interface's associated device. Thus, for
# vmlocal, vmnet-dhcpd tries to attach to /dev/vmnetl (that's a
# lowercase L). It turns out we can hack around this by
# appending a 0 to the interface name. vmlocal0 causes
# vmnet-dhcpd to attach to /dev/vmnet0, ESXi's vmk0 properly gets
# a DHCP address from dhcpd and everything is happy. This is
# total crap and is brittle since VMware fixing dhcpd will
# almost certainly break us, but it works and, IMO, is better than
# slapping a random 0 after vmlocal that the user can see.
# I apologize to future generations for my expediency.
#
# P.S. I think my hack-guilt can be measured by the length
# of the XXX comment preceding the hack.
XXXlameHackSuffixForVMLocalInterface = "0"
commandList = [self.vmnetDhcpdCmd,
"-d",
"-cf", self.dhcpdConf,
"-lf", self.dhcpdLease,
"-pf", self.dhcpdPidFileName,
"%s%s" % (self.vmnetReal,
XXXlameHackSuffixForVMLocalInterface)]
Logging.log(Logging.LOG_INFO, "Starting dhcpd on %s" % (
self.interfaceName))
self.pid = self.launchProcess(commandList)
示例2: enableRPS
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def enableRPS(self):
# Enable RPS
Logging.log(Logging.LOG_INFO, "Enabling RPS")
commandList = ["/bin/cat", "/cgroup/cpuset/esx/cpuset.cpus"]
(retcode, output, errmsg) = self.launchProcessAndWait(
commandList, logLevel = Logging.LOG_INFO)
cpus = output.split("-")
no_of_cpus = int(cpus[1]) - int(cpus[0]) + 1
mask = ''
for bit in range(no_of_cpus):
mask = mask + '1'
hex_mask = hex(int(mask, 2)).replace('0x', '')
rps_file = '/sys/class/net/' + self.vmnetReal + '/queues/rx-0/rps_cpus'
cmd = "/bin/echo %s > %s" % (hex_mask, rps_file)
process = subprocess.Popen(
cmd, bufsize=-1, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, errmsg = process.communicate()
if process.returncode != 0:
Logging.log(Logging.LOG_ERR,
"Launch process '%s' with error(%s):%s" % (
' '.join(cmd),
process.returncode,
errmsg))
示例3: sendVmnetEvent
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def sendVmnetEvent(self, eventName):
binding = ("interface", "string", self.vmnetReal)
Mgmt.open()
Mgmt.event(eventName, binding)
Mgmt.close()
Logging.log(Logging.LOG_INFO, "Event %s on interface %s sent" % (
eventName, self.vmnetReal))
示例4: tail
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def tail(self):
while 1:
self.pos = self.f.tell()
line = self.f.readline()
if not line:
if stat(self.logfile)[ST_SIZE] < self.pos:
self._reset()
else:
time.sleep(1)
self.f.seek(self.pos)
else:
# Look for a matching line
if re.match(self.expression, line, re.M|re.I):
# Split out each word in the line
words = line.split()
# Slice list for Ethernet interface that has active Storm Control Policer
sc_int = words[19]
sc_int = sc_int[:-1]
Logging.log(STORMCONTROL_INT_SHUT, "Storm control triggered interface " + sc_int + " shutdown")
# Shutdown interface and start timer to re-enable if non-zero value
commands = 'configure', 'interface ' + sc_int, 'shutdown'
resp = switch.runCmds(1, commands)
print sc_int + " disabled due to storm control violation"
if hold_down >= 1:
t = Timer(60.0*hold_down, self.Hold_down_act, [sc_int])
t.start()
示例5: event
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def event(reason, version_info):
"""!
State machine event loop. The three possible states are:
1. initial
2. disconnected
3. connected
The graphical FSM may look like: ___
| |(resend_event)
___|___|________
____________ init_connect_timeout | |
| | ------------------------->| disconnected |
| initial |-------------------------->|______________|
|__________| (wdt_trigger) | |
| | | (wdt_trigger)
| (wdt_trigger) | |
| _|__________|__
| wdt_connect | |
|--------------------------->| connected |
|_____________|
| |
|___| (resend_event)
"""
global g_curr_wdt_state
mgmtd_pids = []
old_wdt_state = g_curr_wdt_state
new_wdt_state = None
mgmtd_pids = Vsp.get_pids('mgmtd')
if mgmtd_pids == None or g_mgmtd_pid not in mgmtd_pids:
Logging.log(Logging.LOG_ERR, "Unexpected termination of mgmtd, kill watchdog!")
sys.exit()
#
# wish python had switch statement, that would make it more pretty.
#
# Based on the current state, call appropriate state handler function,
# this function based on given input check if state needs to be changed,
# if yes, then would take required action as well (send event).
if g_curr_wdt_state in STATE_HANDLER_DICT.keys():
new_wdt_state = \
STATE_HANDLER_DICT[g_curr_wdt_state](reason, version_info)
else:
# unknown state detected, KILL ME !!!!
error_str = "Unknown state: %s, reset to initial" % g_curr_wdt_state
Logging.log(Logging.LOG_ERR, error_str)
sys.exit()
if old_wdt_state != new_wdt_state:
set_state(new_wdt_state, reason, version_info)
else:
# No state change detected. Verify if we need to resend event.
check_resend_event(reason, version_info)
示例6: cleanup_locks
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def cleanup_locks(esxi_root):
"""!
Removes the lck files
"""
#XXX:We might need to check if vmware-mount is running
for dir in os.listdir(esxi_root):
if dir.endswith(".lck"):
Logging.log(Logging.LOG_INFO, "Removing stale locks in %s" % dir)
shutil.rmtree("%s/%s" % (esxi_root, dir))
示例7: is_memlock_enabled
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def is_memlock_enabled():
"""!
Queries mgmtd to determine if workstation memlock is turned on
"""
memlock_node = "/rbt/vsp/config/memlock/enable"
memlocked = Mgmt.get_value(memlock_node)
if not memlocked or memlocked == "":
Logging.log(Logging.LOG_ERR, "Cannot determine if memlock is enabled")
memlocked = "false"
return memlocked == "true"
示例8: launchProcessAndWait
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def launchProcessAndWait(self, commandList,
logLevel = Logging.LOG_ERR):
processAndWait = subprocess.Popen(commandList,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, errmsg = processAndWait.communicate()
if processAndWait.returncode != 0:
Logging.log(logLevel,
"Launch process '%s' with error(%s):%s" % (
' '.join(commandList),
processAndWait.returncode,
errmsg))
return (processAndWait.returncode, output, errmsg)
示例9: terminate_usr1_handler
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def terminate_usr1_handler(signum, frame):
"""!
Signal handler for SIGUSR1. Used by RiOS factory reset feature to quickly
bring down vmx wrapper (via vmrun stop). It sleeps for
'factory_reset_wait_time' seconds so scrub.sh can remove the vmdks used by
vmx wrapper and other releveant files without PM automatically bringing the
wrapper back up.
"""
Logging.log(Logging.LOG_DEBUG, "Wrapper: got USR1 signal")
stop_vmware_vmx()
time.sleep(factory_reset_wait_time)
Logging.log(Logging.LOG_DEBUG, "Wrapper: End USR1 handler")
示例10: build_vmware_db
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def build_vmware_db():
global VmwareDb
if (os.path.exists(VmDbFile)):
db = open(VmDbFile, 'r')
for line in db:
list = line.split()
if list[0] == "answer":
VmwareDb[list[1]]=list[2]
else:
Logging.log(Logging.LOG_ERR, "Unable to open VMware's location file.")
fatal_error("Unable to open %s - is VMware installed?." % VmDbFile)
示例11: waitForVmwareVmx
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def waitForVmwareVmx():
"""!
Monitor vmware-vmx every 5 seconds to see if it is running
"""
vmx_conf_file_path = "%s/esxi.vmx" % Vsp.get_esxi_dir()
proc_id = Vsp.get_vmx_proc_id(vmx_conf_file_path)
while Vsp.is_process_running(proc_id):
Logging.log(Logging.LOG_DEBUG, "vmware-vmx is still running")
time.sleep(5)
#We are here means the process has exited
Logging.log(Logging.LOG_DEBUG, "vmware-vmx is not running")
示例12: get_rios_manage_esxi_ip
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def get_rios_manage_esxi_ip():
"""!
Queries mgmtd for the current RiOS manage ESXi IP address and returns it
Any callers of this function MUST have an open Mgmt GCL session
If failed, the function returns None.
"""
current_rios_mgmt_esxi_ip_node = "/rbt/vsp/state/network/rios_manage_esxi/ip"
current_rios_mgmt_esxi_ip = Mgmt.get_value(current_rios_mgmt_esxi_ip_node)
if not current_rios_mgmt_esxi_ip or current_rios_mgmt_esxi_ip == "0.0.0.0":
Logging.log(Logging.LOG_INFO, "Failed to get RiOS manage ESXi IP address")
current_rios_mgmt_esxi_ip = None
return current_rios_mgmt_esxi_ip
示例13: main
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def main():
"""!
Entry point of the wrapper, intialize logger and signal handler. Starts
vmware-vmx and starts monitoring it
"""
Logging.log_init('vmware_vmx_wrapper', 'vmware_vmx_wrapper', 0,
Logging.component_id(Logging.LCI_VSP), Logging.LOG_DEBUG,
Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)
Logging.log(Logging.LOG_INFO,
"vsp_vmware_vmx_wrapper started")
signal.signal(signal.SIGINT, terminate_term_handler)
signal.signal(signal.SIGTERM, terminate_term_handler)
signal.signal(signal.SIGQUIT, terminate_quit_handler)
signal.signal(signal.SIGUSR1, terminate_usr1_handler)
#get the esxi dir
esxi_dir = Vsp.get_esxi_dir()
vmx_conf_file_path = "%s/%s" %(esxi_dir, ESXI_VMX_NAME)
#Check if the vm configuration exists
if not os.path.exists(vmx_conf_file_path):
Logging.log(Logging.LOG_ERR,
"VM configuration %s doesn't exist" % vmx_conf_file_path)
sys.exit(1)
# Check if vmware-vmx is already running. The fuction returns None if no
# process_id exists or if there's multiple process_ids associated with
# the vmx_conf. However, it's not possible to launch two running vmware_vmx
# using the same vmx_conf. The chance this returns None b/c of multiple
# process ids is almost nonexistant.
proc_id = Vsp.get_vmx_proc_id(vmx_conf_file_path)
#Start vmware-vmx if an instance has not been started
if proc_id == None:
# Clean up the "shutting down" file used for ESXi HPN dependency
if os.path.exists(SHUTDOWN_MARKER):
os.remove(SHUTDOWN_MARKER)
cleanup_locks(esxi_dir)
start_vmware_vmx(vmx_conf_file_path)
#Get the new process id
proc_id = Vsp.get_vmx_proc_id(vmx_conf_file_path)
monitor_vmware_vmx(proc_id)
示例14: stop_vmware_vmx
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def stop_vmware_vmx():
"""!
Stop vmware-vmx.
"""
global g_shutdown_requested
#We just use vmrun stop to terminate vm right now but this
#will change when we handle graceful shutdown
path = "%s/%s" % (Vsp.get_esxi_dir(), ESXI_VMX_NAME)
Logging.log(Logging.LOG_INFO, "Stopping vm %s" % path)
pobj = subprocess.Popen([vmrun_path, "stop", "%s" % path])
pobj.wait()
g_shutdown_requested = True;
示例15: generate_mgmt_event
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import log [as 别名]
def generate_mgmt_event(event, reason, version_info):
"""!
Generate Mgmt event.
"""
binding_to_send = None
if event == READY_EVENT:
binding_to_send = ("version_info", "string", version_info)
elif event == DISCONNECTED_EVENT:
binding_to_send = ("reason", "string", reason)
else:
Logging.log(Logging.LOG_ERR, "Unknown event")
# suicide!
sys.exit()
Mgmt.event(event, binding_to_send)