本文整理汇总了Python中nailgun.task.helpers.TaskHelper.update_task_status方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.update_task_status方法的具体用法?Python TaskHelper.update_task_status怎么用?Python TaskHelper.update_task_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.task.helpers.TaskHelper
的用法示例。
在下文中一共展示了TaskHelper.update_task_status方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: provision_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def provision_resp(cls, **kwargs):
logger.info(
"RPC method provision_resp received: %s" %
json.dumps(kwargs))
task_uuid = kwargs.get('task_uuid')
message = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
nodes = kwargs.get('nodes', [])
task = get_task_by_uuid(task_uuid)
for node in nodes:
uid = node.get('uid')
node_db = db().query(Node).get(uid)
if not node_db:
logger.warn('Task with uid "{0}" not found'.format(uid))
continue
if node.get('status') == 'error':
node_db.status = 'error'
node_db.progress = 100
node_db.error_type = 'provision'
node_db.error_msg = node.get('error_msg', 'Unknown error')
else:
node_db.status = node.get('status')
node_db.progress = node.get('progress')
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例2: check_redhat_credentials_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def check_redhat_credentials_resp(cls, **kwargs):
logger.info("RPC method check_redhat_credentials_resp received: %s" % json.dumps(kwargs))
task_uuid = kwargs.get("task_uuid")
error_msg = kwargs.get("error")
status = kwargs.get("status")
progress = kwargs.get("progress")
task = db().query(Task).filter_by(uuid=task_uuid).first()
if not task:
logger.error(
"check_redhat_credentials_resp: task \
with UUID %s not found!",
task_uuid,
)
return
release_info = task.cache["args"]["release_info"]
release_id = release_info["release_id"]
release = db().query(Release).get(release_id)
if not release:
logger.error("download_release_resp: Release" " with ID %s not found", release_id)
return
if error_msg:
status = "error"
cls._update_release_state(release_id, "error")
# TODO(NAME): remove this ugly checks
if "Unknown error" in error_msg:
error_msg = "Failed to check Red Hat " "credentials"
if error_msg != "Task aborted":
notifier.notify("error", error_msg)
result = {"release_info": {"release_id": release_id}}
TaskHelper.update_task_status(task_uuid, status, progress, error_msg, result)
示例3: download_release_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def download_release_resp(cls, **kwargs):
logger.info("RPC method download_release_resp received: %s" % json.dumps(kwargs))
task_uuid = kwargs.get("task_uuid")
error_msg = kwargs.get("error")
status = kwargs.get("status")
progress = kwargs.get("progress")
task = db().query(Task).filter_by(uuid=task_uuid).first()
if not task:
logger.error("download_release_resp: task" " with UUID %s not found", task_uuid)
return
release_info = task.cache["args"]["release_info"]
release_id = release_info["release_id"]
release = db().query(Release).get(release_id)
if not release:
logger.error("download_release_resp: Release" " with ID %s not found", release_id)
return
if error_msg:
status = "error"
error_msg = "{0} download and preparation " "has failed.".format(release.name)
cls._download_release_error(release_id, error_msg)
elif progress == 100 and status == "ready":
cls._download_release_completed(release_id)
result = {"release_info": {"release_id": release_id}}
TaskHelper.update_task_status(task_uuid, status, progress, error_msg, result)
示例4: _error_action
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def _error_action(cls, task, status, progress, message=None):
if message:
message = u"Deployment has failed. {0}".format(message)
else:
message = u"Deployment has failed. Check these nodes:\n{0}".format(
cls._generate_error_message(task, error_types=("deploy", "provision"), names_only=True)
)
notifier.notify("error", message, task.cluster_id)
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例5: download_release_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def download_release_resp(cls, **kwargs):
logger.info("RPC method download_release_resp received: %s" % kwargs)
task_uuid = kwargs.get('task_uuid')
error_msg = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
release_info = kwargs.get('release_info')
if progress == 100:
cls._download_release_completed(release_info['release_id'])
TaskHelper.update_task_status(task_uuid, status,
progress, error_msg)
示例6: _success_action
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def _success_action(cls, task, status, progress):
network_manager = NetworkManager()
# check if all nodes are ready
if any(map(lambda n: n.status == "error", task.cluster.nodes)):
cls._error_action(task, "error", 100)
return
if task.cluster.mode in ("singlenode", "multinode"):
# determining horizon url - it's an IP
# of a first cluster controller
controller = (
db()
.query(Node)
.filter_by(cluster_id=task.cluster_id)
.filter(Node.role_list.any(name="controller"))
.first()
)
if controller:
logger.debug(u"Controller is found, node_id=%s, " "getting it's IP addresses", controller.id)
public_net = filter(
lambda n: n["name"] == "public" and "ip" in n, network_manager.get_node_networks(controller.id)
)
if public_net:
horizon_ip = public_net[0]["ip"].split("/")[0]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at "
"http://{1}/ or via internal network at http://{2}/"
).format(task.cluster.name, horizon_ip, controller.ip)
else:
message = (u"Deployment of environment '{0}' is done").format(task.cluster.name)
logger.warning(u"Public ip for controller node " "not found in '{0}'".format(task.cluster.name))
else:
message = (u"Deployment of environment" " '{0}' is done").format(task.cluster.name)
logger.warning(u"Controller node not found in '{0}'".format(task.cluster.name))
elif task.cluster.mode == "ha":
# determining horizon url in HA mode - it's vip
# from a public network saved in task cache
args = task.cache.get("args")
try:
vip = args["attributes"]["public_vip"]
message = (
u"Deployment of environment '{0}' is done. "
"Access the OpenStack dashboard (Horizon) at http://{1}/"
).format(task.cluster.name, vip)
except Exception as exc:
logger.error(": ".join([str(exc), traceback.format_exc()]))
message = (u"Deployment of environment" " '{0}' is done").format(task.cluster.name)
logger.warning(u"Cannot find virtual IP for '{0}'".format(task.cluster.name))
notifier.notify("done", message, task.cluster_id)
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例7: remove_nodes_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def remove_nodes_resp(cls, **kwargs):
logger.info("RPC method remove_nodes_resp received: %s" % kwargs)
task_uuid = kwargs.get('task_uuid')
nodes = kwargs.get('nodes') or []
error_nodes = kwargs.get('error_nodes') or []
error_msg = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
for node in nodes:
node_db = cls.db.query(Node).get(node['uid'])
if not node_db:
logger.error(
u"Failed to delete node '%s': node doesn't exist",
str(node)
)
break
cls.db.delete(node_db)
for node in error_nodes:
node_db = cls.db.query(Node).get(node['uid'])
if not node_db:
logger.error(
u"Failed to delete node '%s' marked as error from Naily:"
" node doesn't exist", str(node)
)
break
node_db.pending_deletion = False
node_db.status = 'error'
cls.db.add(node_db)
node['name'] = node_db.name
cls.db.commit()
success_msg = u"No nodes were removed"
err_msg = u"No errors occurred"
if nodes:
success_msg = u"Successfully removed {0} node(s)".format(
len(nodes)
)
notifier.notify("done", success_msg)
if error_nodes:
err_msg = u"Failed to remove {0} node(s): {1}".format(
len(error_nodes),
', '.join(
[n.get('name') or "ID: {0}".format(n['uid'])
for n in error_nodes])
)
notifier.notify("error", err_msg)
if not error_msg:
error_msg = ". ".join([success_msg, err_msg])
TaskHelper.update_task_status(task_uuid, status, progress, error_msg)
示例8: download_release_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def download_release_resp(cls, **kwargs):
logger.info("RPC method download_release_resp received: %s" % kwargs)
task_uuid = kwargs.get('task_uuid')
nodes = kwargs.get('nodes')
error_msg = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
if progress == 100:
release_info = kwargs.get('release_info')
release = db().query(Release).get(release_info['release_id'])
release.available = True
db().commit()
TaskHelper.update_task_status(task_uuid, status,
progress, error_msg)
示例9: redhat_check_licenses_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def redhat_check_licenses_resp(cls, **kwargs):
logger.info(
"RPC method redhat_check_licenses_resp received: %s" %
json.dumps(kwargs)
)
task_uuid = kwargs.get('task_uuid')
error_msg = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
notify = kwargs.get('msg')
task = get_task_by_uuid(task_uuid)
if not task:
logger.error("redhat_check_licenses_resp: task \
with UUID %s not found!", task_uuid)
return
release_info = task.cache['args']['release_info']
release_id = release_info['release_id']
release = db().query(Release).get(release_id)
if not release:
logger.error("download_release_resp: Release"
" with ID %s not found", release_id)
return
if error_msg:
status = 'error'
cls._update_release_state(release_id, 'error')
# TODO(NAME): remove this ugly checks
if 'Unknown error' in error_msg:
error_msg = 'Failed to check Red Hat licenses '
if error_msg != 'Task aborted':
notifier.notify('error', error_msg)
if notify:
notifier.notify('error', notify)
result = {
"release_info": {
"release_id": release_id
}
}
TaskHelper.update_task_status(
task_uuid,
status,
progress,
error_msg,
result
)
示例10: remove_nodes_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def remove_nodes_resp(cls, **kwargs):
logger.info("RPC method remove_nodes_resp received: %s" % json.dumps(kwargs))
task_uuid = kwargs.get("task_uuid")
nodes = kwargs.get("nodes") or []
error_nodes = kwargs.get("error_nodes") or []
inaccessible_nodes = kwargs.get("inaccessible_nodes") or []
error_msg = kwargs.get("error")
status = kwargs.get("status")
progress = kwargs.get("progress")
for node in nodes:
node_db = db().query(Node).get(node["uid"])
if not node_db:
logger.error(u"Failed to delete node '%s': node doesn't exist", str(node))
break
db().delete(node_db)
for node in inaccessible_nodes:
# Nodes which not answered by rpc just removed from db
node_db = db().query(Node).get(node["uid"])
if node_db:
logger.warn(u"Node %s not answered by RPC, removing from db", node_db.human_readable_name)
db().delete(node_db)
for node in error_nodes:
node_db = db().query(Node).get(node["uid"])
if not node_db:
logger.error(u"Failed to delete node '%s' marked as error from Naily:" " node doesn't exist", str(node))
break
node_db.pending_deletion = False
node_db.status = "error"
db().add(node_db)
node["name"] = node_db.name
db().commit()
success_msg = u"No nodes were removed"
err_msg = u"No errors occurred"
if nodes:
success_msg = u"Successfully removed {0} node(s)".format(len(nodes))
notifier.notify("done", success_msg)
if error_nodes:
err_msg = u"Failed to remove {0} node(s): {1}".format(
len(error_nodes), ", ".join([n.get("name") or "ID: {0}".format(n["uid"]) for n in error_nodes])
)
notifier.notify("error", err_msg)
if not error_msg:
error_msg = ". ".join([success_msg, err_msg])
TaskHelper.update_task_status(task_uuid, status, progress, error_msg)
示例11: download_release_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def download_release_resp(cls, **kwargs):
logger.info(
"RPC method download_release_resp received: %s" %
json.dumps(kwargs)
)
task_uuid = kwargs.get('task_uuid')
error_msg = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
task = get_task_by_uuid(task_uuid)
if not task:
logger.error("download_release_resp: task"
" with UUID %s not found", task_uuid)
return
release_info = task.cache['args']['release_info']
release_id = release_info['release_id']
release = db().query(Release).get(release_id)
if not release:
logger.error("download_release_resp: Release"
" with ID %s not found", release_id)
return
if error_msg:
status = 'error'
error_msg = "{0} download and preparation " \
"has failed.".format(release.name)
cls._download_release_error(
release_id,
error_msg
)
elif progress == 100 and status == 'ready':
cls._download_release_completed(release_id)
result = {
"release_info": {
"release_id": release_id
}
}
TaskHelper.update_task_status(
task_uuid,
status,
progress,
error_msg,
result
)
示例12: provision_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def provision_resp(cls, **kwargs):
# For now provision task is nothing more than just adding
# system into cobbler and rebooting node. Then we think task
# is ready. We don't wait for end of node provisioning.
logger.info("RPC method provision_resp received: %s" % json.dumps(kwargs))
task_uuid = kwargs.get("task_uuid")
message = kwargs.get("error")
status = kwargs.get("status")
progress = kwargs.get("progress")
task = db().query(Task).filter_by(uuid=task_uuid).first()
if not task:
logger.warning(u"No task with uuid %s found", task_uuid)
return
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例13: test_update_cluster_status_if_task_was_already_in_error_status
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def test_update_cluster_status_if_task_was_already_in_error_status(self):
for node in self.cluster.nodes:
node.status = 'provisioning'
node.progress = 12
task = Task(name='provision', cluster=self.cluster, status='error')
self.db.add(task)
self.db.commit()
TaskHelper.update_task_status(task.uuid, 'error', 100)
self.assertEquals(self.cluster.status, 'error')
self.assertEquals(task.status, 'error')
for node in self.cluster.nodes:
self.assertEquals(node.status, 'error')
self.assertEquals(node.progress, 0)
示例14: provision_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def provision_resp(cls, **kwargs):
# For now provision task is nothing more than just adding
# system into cobbler and rebooting node. Then we think task
# is ready. We don't wait for end of node provisioning.
logger.info("RPC method provision_resp received: %s" % kwargs)
task_uuid = kwargs.get('task_uuid')
nodes = kwargs.get('nodes') or []
message = kwargs.get('error')
status = kwargs.get('status')
progress = kwargs.get('progress')
task = cls.db.query(Task).filter_by(uuid=task_uuid).first()
if not task:
logger.warning(u"No task with uuid %s found", task_uuid)
return
TaskHelper.update_task_status(task.uuid, status, progress, message)
示例15: dump_environment_resp
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import update_task_status [as 别名]
def dump_environment_resp(cls, **kwargs):
logger.info(
"RPC method dump_environment_resp received: %s" %
json.dumps(kwargs)
)
task_uuid = kwargs.get('task_uuid')
status = kwargs.get('status')
progress = kwargs.get('progress')
error = kwargs.get('error')
msg = kwargs.get('msg')
if status == 'error':
notifier.notify('error', error)
TaskHelper.update_task_status(task_uuid, status, 100, error)
elif status == 'ready':
dumpfile = os.path.basename(msg)
notifier.notify('done', 'Snapshot is ready. '
'Visit Support page to download')
TaskHelper.update_task_status(
task_uuid, status, progress,
'/dump/{0}'.format(dumpfile))