def use(self, task): """Set active task. Alias for "rally use task". :param task: Task uuid. """ print("Using task: %s" % task) db.task_get(task) fileutils.update_globals_file("RALLY_TASK", task)
def task(self, task_id): """Set active task. :param task_id: a UUID of task """ print('Using task: %s' % task_id) self._ensure_rally_configuration_dir_exists() db.task_get(task_id) self._update_attribute_in_global_file('RALLY_TASK', task_id)
def task(self, task_id): """Set the RALLY_TASK env var so the user does not need to specify a task UUID in the command requiring this parameter. If the task uuid specified in parameter by the user does not exist, a TaskNotFound will be raised by task_get(). :param task_id: a UUID of a task """ print('Using task: %s' % task_id) self._ensure_rally_configuration_dir_exists() db.task_get(task_id) self._update_attribute_in_global_file('RALLY_TASK', task_id)
def status(self, task_id): """Get status of task :param task_id: Task uuid Returns current status of task """ task = db.task_get(task_id) print(_("Task %(task_id)s is %(status)s.") % {"task_id": task_id, "status": task["status"]})
def status(self, task_id=None): """Get status of task :param task_id: Task uuid Returns current status of task """ task = db.task_get(task_id) print(_("Task %(task_id)s is %(status)s.") % {'task_id': task_id, 'status': task['status']})
def status(self, task_id=None): """Display current status of task. :param task_id: Task uuid Returns current status of task """ task = db.task_get(task_id) print(_("Task %(task_id)s: %(status)s") % {"task_id": task_id, "status": task["status"]})
def get(uuid): return Task(db.task_get(uuid))
def collect_and_send_report(self, task_name, task_output): """ { "results": { "actions": { "$action": { "duration": { "summary": { "min (sec)": xx, "max (sec)": xx, "avg (sec)": xx, "success": xx, "errors": xx, "total": xx }, "data": [xx,xx,xx] } } }, 'total_errors': x }, "category": "xxx", "raw_output": {...} } """ report_name = get_report_name(task_name) report_url = "/".join((self.url, report_name)) match = re.search("\s?rally task results\s+([\da-f\-]+)\s?", task_output) if not match: raise HealthException("Unknown rally internel error!", report_url) task_uuid = match.group(1) task_obj = db.task_get(task_uuid) if task_obj["status"] == "failed": raise HealthException(task_obj["verification_log"], report_url) command = "rally task results %s" % task_uuid logging.info("[collect_and_send_report] command is %s" % command) logging.info("Start to collect report for task [%s]" % task_name) return_code, task_result, err = self.exec_cli(command) if return_code > 0: raise HealthException(err, report_url) output = json.loads(task_result)[0] report = {"actions": {}} actions = [] # Get the name of actions actions = [] if output["result"]: actions = output["result"][0]["atomic_actions"].keys() for result in output["result"]: if result["error"]: continue actions = result["atomic_actions"].keys() break if not actions: actions.append(report_name) # Get and set report for each action for action in actions: report["actions"].setdefault(action, {"duration": {}}) report["actions"][action]["duration"] = self._get_action_dur_report(action, output) # Get and set errors if any errors = self._get_total_errors(output) report["total_errors"] = errors logging.debug("task [%s] report is: %s" % (task_name, report)) final_report = {"results": report, "raw_output": output} self.send_report(final_report, report_url)
def _get_task(self, uuid): return db.task_get(uuid)
def collect_and_send_report(self, task_name, task_output): """ { "results": { "actions": { "$action": { "duration": { "summary": { "min (sec)": xx, "max (sec)": xx, "avg (sec)": xx, "success": xx, "errors": xx, "total": xx }, "data": [xx,xx,xx] } } }, 'total_errors': x }, "category": "xxx", "raw_output": {...} } """ report_name = get_report_name(task_name) report_url = '/'.join((self.url, report_name)) match = re.search('\s?rally task results\s+([\da-f\-]+)\s?', task_output) if not match: raise HealthException('Unknown rally internel error!', report_url) task_uuid = match.group(1) task_obj = db.task_get(task_uuid) if task_obj['status'] == 'failed': raise HealthException(task_obj['verification_log'], report_url) command = "rally task results %s" % task_uuid logging.info("[collect_and_send_report] command is %s" % command) print "Start to collect report for task [%s]" % task_name return_code, task_result, err = self.exec_cli(command) if return_code > 0: raise HealthException(err, report_url) output = json.loads(task_result)[0] report = {'actions': {}} actions = [] # Get the name of actions actions = [] if output['result']: actions = output['result'][0]['atomic_actions'].keys() for result in output['result']: if result['error']: continue actions = result['atomic_actions'].keys() break if not actions: actions.append(report_name) # Get and set report for each action for action in actions: report['actions'].setdefault(action, {'duration': {}}) report['actions'][action]['duration'] \ = self._get_action_dur_report(action, output) # Get and set errors if any errors = self._get_total_errors(output) report['total_errors'] = errors logging.info("task [%s] report is: %s" % (task_name, report)) final_report = {"results": report, "raw_output": output} self.send_report(final_report, report_url)