本文整理汇总了Python中mcv_consoler.logger.LOG.info方法的典型用法代码示例。如果您正苦于以下问题:Python LOG.info方法的具体用法?Python LOG.info怎么用?Python LOG.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mcv_consoler.logger.LOG
的用法示例。
在下文中一共展示了LOG.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _evaluate_task_result
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def _evaluate_task_result(self, task, resulting_dict):
time_of_tests = resulting_dict.get('full_duration', None)
if time_of_tests:
time_of_tests = str(round(time_of_tests, 3)) + 's'
else:
time_of_tests = '0s'
self.time_of_tests[task] = {'duration': time_of_tests}
if type(resulting_dict) != dict:
LOG.debug(("Task {task} has failed with the following error: "
"{err}").format(task=task, err=resulting_dict))
LOG.info(" * FAILED")
return False
if not resulting_dict['sla']:
err = resulting_dict['result'][0]['error']
if err:
LOG.debug(("Task {task} has failed with the error: "
"{err}").format(task=task,
err=resulting_dict['result']))
LOG.info(" * FAILED")
return False
LOG.info(" * PASSED")
return True
if resulting_dict['sla'][0]['success'] is True:
LOG.debug("Task %s has completed successfully." % task)
else:
LOG.debug(("Task {task} has failed with the following error: "
"{err}").format(task=task,
err=resulting_dict['result']))
LOG.info(" * FAILED")
return False
LOG.info(" * PASSED")
return True
示例2: generate_report
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def generate_report(self, spd_res):
path = os.path.join(os.path.dirname(__file__), 'speed_template.html')
temp = open(path, 'r')
template = temp.read()
temp.close()
html_res = ''
avg_spds = []
for test_node, spd in spd_res.iteritems():
html_res += (
'<tr><td align="center">Network speed to node '
'{}:</td><tr>\n').format(test_node)
# Calculate speed from time
spd = [float(self.data_size) / i for i in spd]
for i in range(len(spd)):
html_res += ('<tr><td>{} attempt:</td><td align="right">Speed '
'{} MB/s</td><tr>\n').format(i + 1,
round(spd[i], 2))
avg_spd = round(sum(spd) / float(len(spd)), 2)
html_res += (
'<tr><td align="center">Average speed: {} '
'MB/s</td><tr>\n').format(avg_spd)
avg_spds.append(avg_spd)
total_avg_spd = round(sum(avg_spds) / float(len(avg_spds)), 2)
LOG.info("Node %s average network speed: %s MB/s \n" % (
self.node_name, total_avg_spd))
return template.format(node_name=self.node_name,
attempts=html_res,
avg=total_avg_spd), total_avg_spd
示例3: run_ssh_cmd
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def run_ssh_cmd(self, cmd, ssh_conn, nocheck=False):
command = 'sudo ' + cmd
buff_size = 4096
stdout_data = []
stderr_data = []
session = ssh_conn.open_channel(kind='session')
session.exec_command(command)
if nocheck:
return
while True:
if session.recv_ready():
stdout_data.append(session.recv(buff_size))
if session.recv_stderr_ready():
stderr_data.append(session.recv_stderr(buff_size))
if session.exit_status_ready():
break
status = session.recv_exit_status()
while session.recv_ready():
stdout_data.append(session.recv(buff_size))
while session.recv_stderr_ready():
stderr_data.append(session.recv_stderr(buff_size))
out = ''.join(stdout_data)
err = ''.join(stderr_data)
session.close()
if status != 0:
LOG.info('Command "%s" finished with exit code %d' % (cmd, status))
else:
LOG.debug('Command "%s" finished with exit code %d' % (cmd,
status))
LOG.debug('Stdout: %s' % out)
LOG.debug('Stderr: %s' % err)
return {'ret': status, 'out': out, 'err': err}
示例4: clear_shaker
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def clear_shaker(self):
cleanup = utils.GET(self.config, 'cleanup', 'shaker') or 'True'
if cleanup == 'True':
LOG.info("Removing shaker's image and flavor")
cmd = "docker exec -t %s shaker-cleanup --image-name %s " \
"--flavor-name %s" % (self.container_id, self.image_name,
self.flavor_name)
utils.run_cmd(cmd)
示例5: run_batch
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def run_batch(self, tasks, *args, **kwargs):
LOG.info("Time start: %s UTC\n" % str(datetime.datetime.utcnow()))
self._setup_rally_on_docker()
result = super(RallyRunner, self).run_batch(tasks, *args, **kwargs)
self.cleanup_fedora_image()
self.cleanup_test_flavor()
self.cleanup_network()
LOG.info("Time end: %s UTC" % str(datetime.datetime.utcnow()))
return result
示例6: _evaluate_task_results
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def _evaluate_task_results(self, task_results):
res = True
for speed in task_results:
if speed < float(self.threshold):
res = False
LOG.warning('Average speed is under the threshold')
LOG.info(" * FAILED")
break
else:
LOG.info(" * PASSED")
return res
示例7: run_individual_task
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def run_individual_task(self, task, *args, **kwargs):
LOG.info("-" * 60)
LOG.info("Starting task %s" % task)
try:
task_time = self.seconds_to_time(kwargs['db'][kwargs['tool_name']][task])
except KeyError:
task_time = 0
LOG.info(("You must update the database time tests. "
"There is no time for %s") % task)
LOG.info("Expected time to complete the test: %s " % task_time)
self._run_ostf_on_docker(task)
LOG.info("-" * 60)
示例8: _get_task_result_from_docker
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def _get_task_result_from_docker(self, task_id):
LOG.info("Retrieving task results for %s" % task_id)
cmd = "docker exec -t %s %s" % (self.container, task_id)
p = utils.run_cmd(cmd)
if task_id.find("detailed") == -1:
try:
res = json.loads(p)[0]
return res
except ValueError:
LOG.error("Gotten not-JSON object. Please see mcv-log")
LOG.debug("Not-JSON object: %s, After command: %s", p, cmd)
return "Not-JSON object"
else:
return p.split('\n')[-4:-1]
示例9: _check_shaker_setup
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def _check_shaker_setup(self):
LOG.info("Start shaker-image-builder. Creating infrastructure. "
"Please wait...")
cmd = "docker exec -t %s shaker-image-builder --image-name %s " \
"--flavor-name %s" % (self.container_id, self.image_name,
self.flavor_name)
p = utils.run_cmd(cmd)
if 'ERROR' in p:
LOG.debug("shaker-image-builder failed")
for stack in self.heat.stacks.list():
if 'shaker' in stack.stack_name:
stack.delete()
raise RuntimeError
LOG.debug('Finish running shaker-image-builder.')
示例10: measure_speed
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def measure_speed(self, node_name):
self.node_name = node_name
self.get_node_list()
self.prepare_tunnels()
LOG.info('Start measuring HW network speed on node %s' % node_name)
res = {}
for test_node in self.test_nodes:
spd = []
for i in range(0, 3):
speed = self.measure_nw_speed(test_node)
if speed != -1:
spd.append(speed)
res[test_node] = spd
time.sleep(3)
self.cleanup()
return self.generate_report(res)
示例11: check_and_fix_floating_ips
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def check_and_fix_floating_ips(self):
res = self.novaclient.floating_ips.list()
if len(res) >= 2:
LOG.debug("Apparently there is enough floating ips")
else:
LOG.info("Need to create a floating ip")
try:
self.fresh_floating_ips.append(
self.novaclient.floating_ips.create())
except Exception as ip_e:
LOG.warning("Apparently the cloud is out of free floating ip. "
"You might experience problems "
"with running some tests")
LOG.debug("Error creating floating IP - %s" % str(ip_e))
return
return self.check_and_fix_floating_ips()
示例12: _generate_one_row_report
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def _generate_one_row_report(self, result, task, threshold):
template = """
<tr role="row">
<td class="sorting_1">{test_case}</td>
<td>{scenario}</td>
<td>{speed}</td>
<td>{node}</td>
<td>
<a href="./{task}.html">shaker report</a>
</td>
<td>{status}</td>
</tr>
"""
test_case, speeds, agents, success, status = self._parse_shaker_report(
task, threshold)
speed = ''
if len(speeds):
to_gb = min(speeds) / 1024.0
speed = '%.2f' % to_gb
LOG.info('Average speed is %s Gb/s' % speed)
if (success):
LOG.info(' * PASSED')
else:
LOG.info('Average speed is less than threshold')
LOG.info(' * FAILED')
LOG.info('-' * 60)
speed = ''
node = ''
for agent in agents:
speed += '%.2f<br>' % agent['speed']
for n in agent['node']:
node += n + ', '
node = node[:-2]
node += '<br>'
return template.format(test_case=test_case,
scenario=task,
speed=speed,
node=node,
task=task,
status=status), success
示例13: parse_results
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def parse_results(self, res, task):
LOG.debug("Parsing results")
if res == '':
LOG.debug("Results of test set '%s': FAILURE" % task)
self.failure_indicator = TempestError.VERIFICATION_FAILED
self.test_failures.append(task)
LOG.info(" * FAILED")
return False
try:
self.task = json.loads(res)
except ValueError:
LOG.debug("Results of test set '%s': "
"FAILURE, gotten not-JSON object. "
"Please see logs" % task)
LOG.debug("Not-JSON object: %s", res)
self.test_failures.append(task)
LOG.info(" * FAILED")
return False
time_of_tests = float(self.task.get('time', '0'))
time_of_tests = str(round(time_of_tests, 3)) + 's'
self.time_of_tests[task] = {'duration': time_of_tests}
if self.task.get('tests', 0) == 0:
self.test_failures.append(task)
LOG.debug("Task '%s' was skipped. Perhaps the service "
"is not working" % task)
LOG.info(" * FAILED")
return False
failures = self.task.get('failures')
success = self.task.get('success')
self.failed_cases += failures
LOG.debug("Results of test set '%s': "
"SUCCESS: %d FAILURES: %d" % (task, success, failures))
if not failures:
self.test_success.append(task)
LOG.info(" * PASSED")
return True
else:
self.test_failures.append(task)
self.failure_indicator = TempestError.TESTS_FAILED
LOG.info(" * FAILED")
return False
示例14: describe_results
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def describe_results(self, results):
"""Pretty printer for results"""
x = prettytable.PrettyTable(["Group", "Plugin", "Test", "Time Duration", "Status"])
x.add_row([self.group_name, "", "", "", ""])
for key in results.iterkeys():
if results[key].get('major_crash') is not None:
LOG.info("A major tool failure has been detected for plugin '%s'" % key)
continue
if not validate_section(results[key]):
LOG.debug('Error: no results for %s' % key)
continue
test_success = results[key]['results']['test_success']
test_failures = results[key]['results']['test_failures']
test_not_found = results[key]['results']['test_not_found']
time_of_tests = results[key]['results']['time_of_tests']
msg = ""
if test_success:
msg += "SUCCESSFUL: " + str(len(test_success)) + ", "
if test_failures:
msg += "FAILED: " + str(len(test_failures)) + ", "
if test_not_found:
msg += "NOT FOUND: " + str(len(test_not_found)) + ", "
msg = msg[:-2]
x.add_row(["", key, msg, "", ""])
time_of_test = lambda x: time_of_tests[x].get('duration', '0s') if time_of_tests.get(x, None) else '0s'
for test in test_success:
x.add_row(["", "", test, time_of_test(test), " OK "])
for test in test_failures:
x.add_row(["", "", test, time_of_test(test), " FAILED "])
for test in test_not_found:
x.add_row(["", "", test, time_of_test(test), " NOT FOUND "])
x.add_row(["", "", "", "", ""])
x.align = "l"
print(x)
示例15: copy_tempest_image
# 需要导入模块: from mcv_consoler.logger import LOG [as 别名]
# 或者: from mcv_consoler.logger.LOG import info [as 别名]
def copy_tempest_image(self):
LOG.info('Copying image files required by tempest')
# here we fix glance image issues
subprocess.Popen(["sudo", "chmod", "a+r",
os.path.join(self.home,
"images",
"cirros-0.3.4-x86_64-disk.img")],
stdout=subprocess.PIPE,
preexec_fn=utils.ignore_sigint).stdout.read()
cmd = "mkdir " + os.path.join(self.homedir, "data")
utils.run_cmd(cmd)
cmd = ("sudo ln -s hotexamples_com/images/cirros-0.3.4-x86_64-disk.img "
"hotexamples_com/data/").format(homedir=self.homedir)
cmd = shlex.split(cmd)
subprocess.Popen(cmd, stdout=subprocess.PIPE,
preexec_fn=utils.ignore_sigint).stdout.read()