本文整理汇总了Python中nailgun.task.helpers.TaskHelper.set_error方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.set_error方法的具体用法?Python TaskHelper.set_error怎么用?Python TaskHelper.set_error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.task.helpers.TaskHelper
的用法示例。
在下文中一共展示了TaskHelper.set_error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: launch_verify
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import set_error [as 别名]
def launch_verify(self, cluster):
try:
data = self.validator.validate_networks_update(web.data())
except web.webapi.badrequest as exc:
task = Task(name='check_networks', cluster=cluster)
db().add(task)
db().commit()
TaskHelper.set_error(task.uuid, exc.data)
logger.error(traceback.format_exc())
json_task = build_json_response(TaskHandler.render(task))
raise web.accepted(data=json_task)
data["networks"] = [
n for n in data["networks"] if n.get("name") != "fuelweb_admin"
]
vlan_ids = [{
'name': n['name'],
'vlans': cluster.network_manager.generate_vlan_ids_list(
data, cluster, n)
} for n in data['networks']]
task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
try:
task = task_manager.execute(data, vlan_ids)
except errors.CantRemoveOldVerificationTask:
raise web.badrequest("You cannot delete running task manually")
return TaskHandler.render(task)
示例2: PUT
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import set_error [as 别名]
def PUT(self, cluster_id):
data = json.loads(web.data())
cluster = self.get_object_or_404(Cluster, cluster_id)
task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
task = task_manager.execute(data)
if task.status != 'error':
try:
if 'networks' in data:
network_configuration = self.validator.\
validate_networks_update(json.dumps(data))
NetworkConfiguration.update(cluster, data)
except web.webapi.badrequest as exc:
TaskHelper.set_error(task.uuid, exc.data)
logger.error(traceback.format_exc())
except Exception as exc:
TaskHelper.set_error(task.uuid, exc)
logger.error(traceback.format_exc())
data = build_json_response(TaskHandler.render(task))
if task.status == 'error':
db().rollback()
else:
db().commit()
raise web.accepted(data=data)
示例3: PUT
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import set_error [as 别名]
def PUT(self, cluster_id):
"""
:IMPORTANT: this method should be rewritten to be more RESTful
:returns: JSONized Task object.
:http: * 202 (network checking task failed)
* 200 (network verification task started)
* 404 (cluster not found in db)
"""
cluster = self.get_object_or_404(Cluster, cluster_id)
try:
data = self.validator.validate_networks_update(web.data())
except web.webapi.badrequest as exc:
task = Task(name='check_networks', cluster=cluster)
db().add(task)
db().commit()
TaskHelper.set_error(task.uuid, exc.data)
logger.error(traceback.format_exc())
json_task = build_json_response(TaskHandler.render(task))
raise web.accepted(data=json_task)
vlan_ids = [{
'name': n['name'],
'vlans': NetworkGroup.generate_vlan_ids_list(n)
} for n in data['networks']]
task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
task = task_manager.execute(data, vlan_ids)
return TaskHandler.render(task)
示例4: PUT
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import set_error [as 别名]
def PUT(self, cluster_id):
""":returns: JSONized Task object.
:http: * 202 (network checking task created)
* 404 (cluster not found in db)
"""
data = json.loads(web.data())
if data.get("networks"):
data["networks"] = [
n for n in data["networks"] if n.get("name") != "fuelweb_admin"
]
cluster = self.get_object_or_404(Cluster, cluster_id)
self.check_net_provider(cluster)
self.check_if_network_configuration_locked(cluster)
task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
task = task_manager.execute(data)
if task.status != 'error':
try:
if 'networks' in data:
self.validator.validate_networks_update(
json.dumps(data)
)
if 'dns_nameservers' in data:
self.validator.validate_dns_servers_update(
json.dumps(data)
)
NovaNetworkManager.update(cluster, data)
except web.webapi.badrequest as exc:
TaskHelper.set_error(task.uuid, exc.data)
logger.error(traceback.format_exc())
except Exception as exc:
TaskHelper.set_error(task.uuid, exc)
logger.error(traceback.format_exc())
data = build_json_response(TaskHandler.render(task))
if task.status == 'error':
db().rollback()
else:
db().commit()
raise web.accepted(data=data)
示例5: PUT
# 需要导入模块: from nailgun.task.helpers import TaskHelper [as 别名]
# 或者: from nailgun.task.helpers.TaskHelper import set_error [as 别名]
def PUT(self, cluster_id):
""":returns: JSONized Task object.
:http: * 202 (network checking task created)
* 404 (cluster not found in db)
"""
data = json.loads(web.data())
if data.get("networks"):
data["networks"] = [
n for n in data["networks"] if n.get("name") != "fuelweb_admin"
]
cluster = self.get_object_or_404(Cluster, cluster_id)
self.check_net_provider(cluster)
self.check_if_network_configuration_locked(cluster)
task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
task = task_manager.execute(data)
if task.status != 'error':
try:
if 'networks' in data:
self.validator.validate_networks_update(
json.dumps(data)
)
if 'dns_nameservers' in data:
self.validator.validate_dns_servers_update(
json.dumps(data)
)
objects.Cluster.get_network_manager(
cluster
).update(cluster, data)
except Exception as exc:
TaskHelper.set_error(task.uuid, exc)
logger.error(traceback.format_exc())
#TODO(enchantner): research this behaviour
if task.status == 'error':
db().rollback()
else:
db().commit()
raise self.http(202, Task.to_json(task))