本文整理汇总了Python中log.LOG.error方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.error方法的具体用法?Python LOG.error怎么用?Python LOG.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log.LOG
的用法示例。
在下文中一共展示了LOG.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_controller_info
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def get_controller_info(ssh_access, net, res_col, retry_count):
if not ssh_access:
return
LOG.info('Fetching OpenStack deployment details...')
sshcon = sshutils.SSH(ssh_access, connect_retry_count=retry_count)
if sshcon is None:
LOG.error('Cannot connect to the controller node')
return
res = {}
res['distro'] = sshcon.get_host_os_version()
res['openstack_version'] = sshcon.check_openstack_version()
res['cpu_info'] = sshcon.get_cpu_info()
if net:
l2type = res_col.get_result('l2agent_type')
encap = res_col.get_result('encapsulation')
if l2type:
if encap:
res['nic_name'] = sshcon.get_nic_name(l2type, encap,
net.internal_iface_dict)
res['l2agent_version'] = sshcon.get_l2agent_version(l2type)
# print results
CONLOG.info(res_col.ppr.pformat(res))
FILELOG.info(json.dumps(res, sort_keys=True))
res_col.add_properties(res)
示例2: savestatstofile
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def savestatstofile(filename="serverstats.bin", servers=[]):
if not config.getboolean("serverstats", "savehistory"):
return
t = time.time()
try:
try:
import cPickle as pickle
except:
import pickle
except ImportError:
LOG.error("error while loading the pickle module...")
return
try:
f = open(filename, 'rb')
oldstats = pickle.load(f)
f.close()
except IOError:
oldstats = {}
oldstats[t] = servers
try:
f = open(filename, 'wb')
pickle.dump(oldstats, f)
f.close()
except IoError:
LOG.error("error while saving history file!")
示例3: measure_flow
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def measure_flow(self, label, target_ip):
label = self.add_location(label)
FlowPrinter.print_desc(label)
# results for this flow as a dict
perf_output = self.client.run_client(label, target_ip,
self.server,
bandwidth=self.config.vm_bandwidth,
az_to=self.server.az)
if self.config.keep_first_flow_and_exit:
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
LOG.info('Stopping execution after first flow, cleanup all VMs/networks manually')
sys.exit(0)
if self.config.stop_on_error:
# check if there is any error in the results
results_list = perf_output['results']
for res_dict in results_list:
if 'error' in res_dict:
LOG.error('Stopping execution on error, cleanup all VMs/networks manually')
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
sys.exit(2)
self.rescol.add_flow_result(perf_output)
CONLOG.info(self.rescol.ppr.pformat(perf_output))
FILELOG.info(json.dumps(perf_output, sort_keys=True))
示例4: get_bdw_kbps
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def get_bdw_kbps(bdw, bdw_unit):
if not bdw_unit:
# bits/sec
return bdw / 1000
if bdw_unit in MULTIPLIERS:
return int(bdw * MULTIPLIERS[bdw_unit])
LOG.error('Error: unknown multiplier: ' + bdw_unit)
return bdw
示例5: delete
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def delete(self, obj_typ, id=None, obj=None):
if not (id or obj):
LOG.error('Give either net_id or net_obj')
if obj:
id = obj.get('id')
return self.sendjson('delete', '%(obj_typ)s/%(id)s' %
{'obj_typ': obj_typ,
'id': id})
示例6: func
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def func(engine):
if not engine.running():
LOG.error("Engine not running! Not executing action")
return 0
engine._update_game_lock.acquire()
done_lines = f(engine)
engine.print_game()
engine._update_game_lock.release()
return done_lines
示例7: decode_size_list
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def decode_size_list(argname, size_list):
try:
pkt_sizes = size_list.split(',')
for i in xrange(len(pkt_sizes)):
pkt_sizes[i] = int(pkt_sizes[i])
except ValueError:
LOG.error('Invalid %s parameter. A valid input must be '
'integers seperated by comma.' % argname)
sys.exit(1)
return pkt_sizes
示例8: save_to_db
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def save_to_db(self, cfg):
'''Save results to MongoDB database.'''
LOG.info("Saving results to MongoDB database...")
post_id = pns_mongo.\
pns_add_test_result_to_mongod(cfg.vmtp_mongod_ip,
cfg.vmtp_mongod_port,
cfg.vmtp_db,
cfg.vmtp_collection,
self.results)
if post_id is None:
LOG.error("Failed to add result to DB")
示例9: test_native_tp
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def test_native_tp(nhosts, ifname, config):
FlowPrinter.print_desc('Native Host to Host throughput')
result_list = []
server_host = nhosts[0]
server = PerfInstance('Host-' + server_host.host + '-Server', config, server=True)
if not server.setup_ssh(server_host):
server.display('SSH failed, check IP or make sure public key is configured')
else:
server.display('SSH connected')
server.create()
# if inter-node-only requested we avoid running the client on the
# same node as the server - but only if there is at least another
# IP provided
if config.inter_node_only and len(nhosts) > 1:
# remove the first element of the list
nhosts.pop(0)
# IP address clients should connect to, check if the user
# has passed a server listen interface name
if ifname:
# use the IP address configured on given interface
server_ip = server.get_interface_ip(ifname)
if not server_ip:
LOG.error('Cannot get IP address for interface ' + ifname)
else:
server.display('Clients will use server IP address %s (%s)' %
(server_ip, ifname))
else:
# use same as ssh IP
server_ip = server_host.host
if server_ip:
# start client side, 1 per host provided
for client_host in nhosts:
client = PerfInstance('Host-' + client_host.host + '-Client', config)
if not client.setup_ssh(client_host):
client.display('SSH failed, check IP or make sure public key is configured')
else:
client.buginf('SSH connected')
client.create()
if client_host == server_host:
desc = 'Native intra-host'
else:
desc = 'Native inter-host'
res = client.run_client(desc,
server_ip,
server,
bandwidth=config.vm_bandwidth)
result_list.append(res)
client.dispose()
server.dispose()
return result_list
示例10: get_file_from_host
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def get_file_from_host(self, from_path, to_path):
'''
A wrapper api on top of paramiko scp module, to scp
a remote file to the local.
'''
sshcon = self._get_client()
scpcon = scp.SCPClient(sshcon.get_transport())
try:
scpcon.get(from_path, to_path)
except scp.SCPException as exp:
LOG.error("Receive failed: [%s]", exp)
return 0
return 1
示例11: put_file_to_host
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def put_file_to_host(self, from_path, to_path):
'''
A wrapper api on top of paramiko scp module, to scp
a local file to the remote.
'''
sshcon = self._get_client()
scpcon = scp.SCPClient(sshcon.get_transport())
try:
scpcon.put(from_path, remote_path=to_path)
except scp.SCPException as exp:
LOG.error("Send failed: [%s]", exp)
return 0
return 1
示例12: savetofile
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def savetofile(self, filename):
"""
Save the grf database from a file
@type filename: string
@param filename: the filename to save to
"""
if not self.canSaveLoad or not self.listchanged or not config.getboolean("serverstats", "savenewgrfs"):
return
import pickle
try:
f = open(filename, 'wb')
pickle.dump(self.__database, f, 1)
f.close()
except IOError:
LOG.error("error while saving newgrf cache file!")
示例13: http_retriable_request
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def http_retriable_request(verb, url, headers={}, authenticate=False, params={}):
"""
Sends an HTTP request, with automatic retrying in case of HTTP Errors 500 or ConnectionErrors
_http_retriable_request('POST', 'http://cc.cloudcomplab.ch:8888/app/', headers={'Content-Type': 'text/occi', [...]}
, authenticate=True)
:param verb: [POST|PUT|GET|DELETE] HTTP keyword
:param url: The URL to use.
:param headers: Headers of the request
:param kwargs: May contain authenticate=True parameter, which is used to make requests requiring authentication,
e.g. CC requests
:return: result of the request
"""
LOG.debug(verb + ' on ' + url + ' with headers ' + headers.__repr__())
auth = ()
if authenticate:
user = CONFIG.get('cloud_controller', 'user')
pwd = CONFIG.get('cloud_controller', 'pwd')
auth = (user, pwd)
if verb in ['POST', 'DELETE', 'GET', 'PUT']:
try:
r = None
if verb == 'POST':
if authenticate:
r = requests.post(url, headers=headers, auth=auth, params=params)
else:
r = requests.post(url, headers=headers, params=params)
elif verb == 'DELETE':
if authenticate:
r = requests.delete(url, headers=headers, auth=auth, params=params)
else:
r = requests.delete(url, headers=headers, params=params)
elif verb == 'GET':
if authenticate:
r = requests.get(url, headers=headers, auth=auth, params=params)
else:
r = requests.get(url, headers=headers, params=params)
elif verb == 'PUT':
if authenticate:
r = requests.put(url, headers=headers, auth=auth, params=params)
else:
r = requests.put(url, headers=headers, params=params)
r.raise_for_status()
return r
except requests.HTTPError as err:
LOG.error('HTTP Error: should do something more here!' + err.message)
raise err
示例14: get_ssh_access
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def get_ssh_access(opt_name, opt_value, config):
'''Allocate a HostSshAccess instance to the option value
Check that a password is provided or the key pair in the config file
is valid.
If invalid exit with proper error message
'''
if not opt_value:
return None
host_access = sshutils.SSHAccess(opt_value)
host_access.private_key_file = config.private_key_file
host_access.public_key_file = config.public_key_file
if host_access.error:
LOG.error('Error for --' + (opt_name + ':' + host_access.error))
sys.exit(2)
return host_access
示例15: dispatch
# 需要导入模块: from log import LOG [as 别名]
# 或者: from log.LOG import error [as 别名]
def dispatch(self):
"""
Dispatch an event to all dispatchers
Calls every dispatcher in dispatchTo, if it's a string, it uses getattr, else, it tries to execute
"""
for to in self.dispatchTo:
if not type(to) == str:
to(self)
else:
try:
function = getattr(self, to)
except AttributeError:
LOG.error("Unknown dispatcher in %s: %s" % (self.__class__, to))
else:
function()