本文整理汇总了Python中nailgun.task.helpers.TaskHelper类的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper类的具体用法?Python TaskHelper怎么用?Python TaskHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_env
def create_env(self, nodes):
cluster = self.env.create(
nodes_kwargs=nodes)
cluster_db = self.db.query(Cluster).get(cluster['id'])
TaskHelper.prepare_for_deployment(cluster_db.nodes)
return cluster_db
开发者ID:Mellanox,项目名称:fuel-web,代码行数:7,代码来源:test_task_helpers.py
示例2: message
def message(cls, task):
logger.debug("ProvisionTask.message(task=%s)" % task.uuid)
nodes = TaskHelper.nodes_to_provision(task.cluster)
USE_FAKE = settings.FAKE_TASKS or settings.FAKE_TASKS_AMQP
# We need to assign admin ips
# and only after that prepare syslog
# directories
task.cluster.prepare_for_provisioning()
for node in nodes:
if USE_FAKE:
continue
if node.offline:
raise errors.NodeOffline(
u'Node "%s" is offline.' " Remove it from environment and try again." % node.full_name
)
TaskHelper.prepare_syslog_dir(node)
serialized_cluster = task.cluster.replaced_provisioning_info or provisioning_serializers.serialize(task.cluster)
message = {
"method": "provision",
"respond_to": "provision_resp",
"args": {"task_uuid": task.uuid, "provisioning_info": serialized_cluster},
}
return message
开发者ID:rsokolkov,项目名称:fuel-web,代码行数:30,代码来源:task.py
示例3: test_deploy_grow_controllers
def test_deploy_grow_controllers(self):
cluster = self.create_env(
nodes_kwargs=[
{"roles": ["controller"]},
{"roles": ["controller"], "pending_addition": True},
{"roles": ["controller"], "pending_addition": True},
]
)
# We have to build 2 new controllers
n_nodes = TaskHelper.nodes_to_provision(cluster)
self.assertEqual(len(n_nodes), 2)
# All controllers must re-deploy (run puppet)
r_nodes = TaskHelper.nodes_to_deploy(cluster)
self.assertEqual(len(r_nodes), 3)
supertask = self.env.launch_deployment()
self.assertEqual(supertask.name, "deploy")
self.env.wait_ready(supertask)
self.assertEqual(supertask.status, "ready")
controllers = self.filter_by_role(cluster.nodes, "controller")
self.assertEqual(len(controllers), 3)
开发者ID:mba811,项目名称:fuel-web,代码行数:25,代码来源:test_cluster_scaling.py
示例4: message
def message(cls, task, nodes_to_provisioning):
logger.debug("ProvisionTask.message(task=%s)" % task.uuid)
serialized_cluster = task.cluster.replaced_provisioning_info or \
provisioning_serializers.serialize(
task.cluster, nodes_to_provisioning)
for node in nodes_to_provisioning:
if settings.FAKE_TASKS or settings.FAKE_TASKS_AMQP:
continue
admin_net_id = objects.Node.get_network_manager(
node
).get_admin_network_group_id()
TaskHelper.prepare_syslog_dir(node, admin_net_id)
return make_astute_message(
'provision',
'provision_resp',
{
'task_uuid': task.uuid,
'provisioning_info': serialized_cluster
}
)
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:25,代码来源:task.py
示例5: test_do_not_redeploy_nodes_in_ready_status
def test_do_not_redeploy_nodes_in_ready_status(self):
self.env.create(nodes_kwargs=[
{"pending_addition": True},
{"pending_addition": True, 'roles': ['compute']}])
cluster_db = self.env.clusters[0]
# Generate ips, fqdns
TaskHelper.prepare_for_deployment(cluster_db.nodes)
# First node with status ready
# should not be readeployed
self.env.nodes[0].status = 'ready'
self.env.nodes[0].pending_addition = False
self.db.commit()
cluster_db.clear_pending_changes()
supertask = self.env.launch_deployment()
self.assertEquals(supertask.name, 'deploy')
self.assertIn(supertask.status, ('running', 'ready'))
self.assertEquals(self.env.nodes[0].status, 'ready')
self.env.wait_for_nodes_status([self.env.nodes[1]], 'provisioning')
self.env.wait_ready(supertask)
self.env.refresh_nodes()
self.assertEquals(self.env.nodes[1].status, 'ready')
self.assertEquals(self.env.nodes[1].progress, 100)
开发者ID:stamak,项目名称:fuel-web,代码行数:27,代码来源:test_task_managers.py
示例6: PUT
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)
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:32,代码来源:network_configuration.py
示例7: _create_cluster_for_vlan_splinters
def _create_cluster_for_vlan_splinters(self, segment_type='gre'):
meta = {
'interfaces': [
{'name': 'eth0', 'mac': self.env._generate_random_mac()},
{'name': 'eth1', 'mac': self.env._generate_random_mac()},
{'name': 'eth2', 'mac': self.env._generate_random_mac()},
{'name': 'eth3', 'mac': self.env._generate_random_mac()},
{'name': 'eth4', 'mac': self.env._generate_random_mac()}
]
}
cluster = self.env.create(
cluster_kwargs={
'mode': 'multinode',
'net_provider': 'neutron',
'net_segment_type': segment_type
},
nodes_kwargs=[
{'roles': ['controller'], 'pending_addition': True,
'meta': meta}
]
)
cluster_db = self.db.query(Cluster).get(cluster['id'])
TaskHelper.prepare_for_deployment(cluster_db.nodes)
return cluster_db
开发者ID:kdemina,项目名称:fuel-web,代码行数:25,代码来源:test_orchestrator_serializer.py
示例8: provision_resp
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)
开发者ID:adanin,项目名称:fuel-web,代码行数:31,代码来源:receiver.py
示例9: check_redhat_credentials_resp
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)
开发者ID:nfschina,项目名称:fuelweb,代码行数:35,代码来源:receiver.py
示例10: download_release_resp
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)
开发者ID:nfschina,项目名称:fuelweb,代码行数:29,代码来源:receiver.py
示例11: message
def message(cls, task, nodes_to_provisioning):
logger.debug("ProvisionTask.message(task=%s)" % task.uuid)
task = objects.Task.get_by_uid(
task.id,
fail_if_not_found=True,
lock_for_update=True
)
objects.NodeCollection.lock_nodes(nodes_to_provisioning)
serialized_cluster = provisioning_serializers.serialize(
task.cluster, nodes_to_provisioning)
for node in nodes_to_provisioning:
if settings.FAKE_TASKS or settings.FAKE_TASKS_AMQP:
continue
admin_net_id = objects.Node.get_network_manager(
node
).get_admin_network_group_id(node.id)
TaskHelper.prepare_syslog_dir(node, admin_net_id)
rpc_message = make_astute_message(
task,
'provision',
'provision_resp',
{
'provisioning_info': serialized_cluster
}
)
db().commit()
return rpc_message
开发者ID:cxb811201,项目名称:fuel-web,代码行数:31,代码来源:task.py
示例12: check_task_name_and_sanitized_data
def check_task_name_and_sanitized_data(self, pos, logger, task_name,
one_parameter=False):
"""Test task name against known value
Check sanitized data doesn't contain keys which are absent in
white_list
:param pos: position of call parameters inside logger.call_args_list,
(negative value: -1 - last call, -2 - pre-last call, etc.)
:param logger: mock object for logger method
:param task_name: expected task name
:param one_parameter: whether given call must go with one parameter
"""
log_args = logger.call_args_list
task = log_args[pos][0][0]
self.assertEqual(task.name, task_name)
if len(log_args[pos][0]) == 2:
log_record = log_args[pos][0][1]
if task_name in task_output_white_list:
self.check_keys_included(
task_output_white_list[task_name],
TaskHelper.sanitize_task_output(task.cache, log_record))
else:
self.assertIsNone(
TaskHelper.sanitize_task_output(task.cache, log_record))
else:
self.assertTrue(one_parameter)
开发者ID:jiaolongsun,项目名称:fuel-web,代码行数:27,代码来源:test_task_logging.py
示例13: launch_verify
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)
开发者ID:tsipa,项目名称:fuel-web,代码行数:29,代码来源:network_configuration.py
示例14: PUT
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)
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:27,代码来源:network_configuration.py
示例15: test_update_cluster_to_error_if_deploy_task_failed
def test_update_cluster_to_error_if_deploy_task_failed(self):
task = Task(name='deploy', cluster=self.cluster, status='error')
self.db.add(task)
self.db.commit()
TaskHelper.update_cluster_status(task.uuid)
self.assertEquals(self.cluster.status, 'error')
开发者ID:stamak,项目名称:fuel-web,代码行数:8,代码来源:test_task.py
示例16: test_update_cluster_to_operational
def test_update_cluster_to_operational(self):
task = Task(name='deploy', cluster=self.cluster, status='ready')
self.db.add(task)
self.db.commit()
TaskHelper.update_cluster_status(task.uuid)
self.assertEquals(self.cluster.status, 'operational')
开发者ID:stamak,项目名称:fuel-web,代码行数:8,代码来源:test_task.py
示例17: prepare_for_provisioning
def prepare_for_provisioning(self):
from nailgun.network.manager import NetworkManager
from nailgun.task.helpers import TaskHelper
netmanager = NetworkManager()
nodes = TaskHelper.nodes_to_provision(self)
TaskHelper.update_slave_nodes_fqdn(nodes)
for node in nodes:
netmanager.assign_admin_ips(node.id, len(node.meta.get("interfaces", [])))
开发者ID:rsokolkov,项目名称:fuel-web,代码行数:9,代码来源:cluster.py
示例18: _error_action
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)
开发者ID:nfschina,项目名称:fuelweb,代码行数:9,代码来源:receiver.py
示例19: _update_parent_instance
def _update_parent_instance(cls, instance):
subtasks = instance.subtasks
if len(subtasks):
data = dict()
if all(map(lambda s: s.status == consts.TASK_STATUSES.ready,
subtasks)):
data['status'] = consts.TASK_STATUSES.ready
data['progress'] = 100
data['message'] = u'\n'.join(map(
lambda s: s.message, filter(
lambda s: s.message is not None, subtasks)))
cls.update(instance, data)
TaskHelper.update_action_log(instance)
elif any(map(lambda s: s.status == consts.TASK_STATUSES.error,
subtasks)):
for subtask in subtasks:
if subtask.status not in (consts.TASK_STATUSES.error,
consts.TASK_STATUSES.ready):
subtask.status = consts.TASK_STATUSES.error
subtask.progress = 100
subtask.message = "Task aborted"
data['status'] = consts.TASK_STATUSES.error
data['progress'] = 100
data['message'] = u'\n'.join(list(set(map(
lambda s: (s.message or ""), filter(
lambda s: (
s.status == consts.TASK_STATUSES.error and not
# TODO(aroma): make this check less ugly
s.message == "Task aborted"
), subtasks)))))
cls.update(instance, data)
TaskHelper.update_action_log(instance)
elif instance.status == consts.TASK_STATUSES.pending and any(
map(lambda s: s.status in (consts.TASK_STATUSES.running,
consts.TASK_STATUSES.ready),
subtasks)):
instance.status = consts.TASK_STATUSES.running
else:
subtasks_with_progress = filter(
lambda s: s.progress is not None,
subtasks
)
if subtasks_with_progress:
instance.progress = \
TaskHelper.calculate_parent_task_progress(
subtasks_with_progress
)
else:
instance.progress = 0
开发者ID:ekorekin,项目名称:fuel-web,代码行数:57,代码来源:task.py
示例20: _update_cluster_data
def _update_cluster_data(cls, instance):
cluster = instance.cluster
if instance.name == "deploy":
if instance.status == "ready":
# If for some reasosns orchestrator
# didn't send ready status for node
# we should set it explicitly
for n in cluster.nodes:
if n.status == "deploying":
n.status = "ready"
n.progress = 100
cls.__update_cluster_status(cluster, "operational")
Cluster.clear_pending_changes(cluster)
elif instance.status == "error" and not TaskHelper.before_deployment_error(instance):
# We don't want to set cluster status to
# error because we don't want to lock
# settings if cluster wasn't delpoyed
cls.__update_cluster_status(cluster, "error")
elif instance.name == "deployment" and instance.status == "error":
cls.__update_cluster_status(cluster, "error")
q_nodes_to_error = TaskHelper.get_nodes_to_deployment_error(cluster)
cls.__update_nodes_to_error(q_nodes_to_error, error_type="deploy")
elif instance.name == "provision" and instance.status == "error":
cls.__update_cluster_status(cluster, "error")
q_nodes_to_error = TaskHelper.get_nodes_to_provisioning_error(cluster)
cls.__update_nodes_to_error(q_nodes_to_error, error_type="provision")
elif instance.name == "stop_deployment":
if instance.status == "error":
cls.__update_cluster_status(cluster, "error")
else:
cls.__update_cluster_status(cluster, "stopped")
elif instance.name == consts.TASK_NAMES.update:
if instance.status == consts.TASK_STATUSES.error:
cls.__update_cluster_status(cluster, consts.CLUSTER_STATUSES.update_error)
q_nodes_to_error = TaskHelper.get_nodes_to_deployment_error(cluster)
cls.__update_nodes_to_error(q_nodes_to_error, error_type=consts.NODE_ERRORS.deploy)
elif instance.status == consts.TASK_STATUSES.ready:
cls.__update_cluster_status(cluster, consts.CLUSTER_STATUSES.operational)
cluster.release_id = cluster.pending_release_id
cluster.pending_release_id = None
开发者ID:koder-ua,项目名称:nailgun-fcert,代码行数:55,代码来源:task.py
注:本文中的nailgun.task.helpers.TaskHelper类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论