本文整理汇总了Python中nailgun.db.sqlalchemy.models.Task.name方法的典型用法代码示例。如果您正苦于以下问题:Python Task.name方法的具体用法?Python Task.name怎么用?Python Task.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nailgun.db.sqlalchemy.models.Task
的用法示例。
在下文中一共展示了Task.name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import name [as 别名]
def execute(self, nets, vlan_ids):
self.remove_previous_task()
task = Task(name=TASK_NAMES.check_networks, cluster=self.cluster)
if len(self.cluster.nodes) < 2:
task.status = TASK_STATUSES.error
task.progress = 100
task.message = "At least two nodes are required to be " "in the environment for network verification."
db().add(task)
db().commit()
return task
if len(self.cluster.node_groups) > 1:
task.status = TASK_STATUSES.error
task.progress = 100
task.message = (
"Network verfiication is disabled for " "environments containing more than one node " "group."
)
db().add(task)
db().commit()
return task
if self.cluster.status in self._blocking_statuses:
task.status = TASK_STATUSES.error
task.progress = 100
task.message = (
"Environment is not ready to run network verification "
"because it is in '{0}' state.".format(self.cluster.status)
)
db().add(task)
db().commit()
return task
db().add(task)
db().commit()
self._call_silently(task, tasks.CheckNetworksTask, data=nets, check_admin_untagged=True)
db().refresh(task)
if task.status != TASK_STATUSES.error:
# this one is connected with UI issues - we need to
# separate if error happened inside nailgun or somewhere
# in the orchestrator, and UI does it by task name.
task.name = TASK_NAMES.verify_networks
verify_task = tasks.VerifyNetworksTask(task, vlan_ids)
if tasks.CheckDhcpTask.enabled(self.cluster):
dhcp_subtask = objects.task.Task.create_subtask(task, name=TASK_NAMES.check_dhcp)
verify_task.add_subtask(tasks.CheckDhcpTask(dhcp_subtask, vlan_ids))
if tasks.MulticastVerificationTask.enabled(self.cluster):
multicast = objects.task.Task.create_subtask(task, name=TASK_NAMES.multicast_verification)
verify_task.add_subtask(tasks.MulticastVerificationTask(multicast))
db().commit()
self._call_silently(task, verify_task)
return task
示例2: execute
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import name [as 别名]
def execute(self, nets, vlan_ids):
self.remove_previous_task()
task = Task(
name="check_networks",
cluster=self.cluster
)
if (
self.cluster.status != 'new' and
self.cluster.net_provider == 'neutron'
):
task.status = 'error'
task.message = ('Network verification on Neutron'
' is not implemented yet')
db().add(task)
db().commit()
return task
if len(self.cluster.nodes) < 2:
task.status = 'error'
task.message = ('At least two nodes are required to be '
'in the environment for network verification.')
db().add(task)
db().commit()
return task
db().add(task)
db().commit()
self._call_silently(
task,
tasks.CheckNetworksTask,
data=nets,
check_admin_untagged=True
)
db().refresh(task)
if task.status != 'error':
# this one is connected with UI issues - we need to
# separate if error happened inside nailgun or somewhere
# in the orchestrator, and UI does it by task name.
dhcp_subtask = Task(
name='check_dhcp',
cluster=self.cluster,
parent_id=task.id)
db().add(dhcp_subtask)
db().commit()
db().refresh(task)
task.name = 'verify_networks'
self._call_silently(
task,
tasks.VerifyNetworksTask,
vlan_ids
)
return task
示例3: execute
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import name [as 别名]
def execute(self, nets, vlan_ids):
self.remove_previous_task()
task = Task(
name="check_networks",
cluster=self.cluster
)
if len(self.cluster.nodes) < 2:
task.status = 'error'
task.progress = 100
task.message = ('At least two nodes are required to be '
'in the environment for network verification.')
db().add(task)
db().commit()
return task
db().add(task)
db().commit()
self._call_silently(
task,
tasks.CheckNetworksTask,
data=nets,
check_admin_untagged=True
)
db().refresh(task)
if task.status != 'error':
# this one is connected with UI issues - we need to
# separate if error happened inside nailgun or somewhere
# in the orchestrator, and UI does it by task name.
task.name = 'verify_networks'
dhcp_subtask = objects.task.Task.create_subtask(
task, name='check_dhcp',)
multicast = objects.task.Task.create_subtask(
task, name='multicast_verification')
corosync = self.cluster.attributes['editable']['corosync']
group = corosync['group']['value']
port = corosync['port']['value']
conf = {'group': group, 'port': port}
verify_task = tasks.VerifyNetworksTask(task, vlan_ids)
verify_task.add_subtask(tasks.CheckDhcpTask(dhcp_subtask,
vlan_ids))
verify_task.add_subtask(
tasks.MulticastVerificationTask(multicast, conf))
self._call_silently(task, verify_task)
return task
示例4: execute
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import name [as 别名]
def execute(self, nets, vlan_ids):
self.remove_previous_task()
task = Task(
name=TASK_NAMES.check_networks,
cluster=self.cluster
)
if len(self.cluster.nodes) < 2:
task.status = TASK_STATUSES.error
task.progress = 100
task.message = ('At least two nodes are required to be '
'in the environment for network verification.')
db().add(task)
db().commit()
return task
db().add(task)
db().commit()
self._call_silently(
task,
tasks.CheckNetworksTask,
data=nets,
check_admin_untagged=True
)
db().refresh(task)
if task.status != TASK_STATUSES.error:
# this one is connected with UI issues - we need to
# separate if error happened inside nailgun or somewhere
# in the orchestrator, and UI does it by task name.
task.name = TASK_NAMES.verify_networks
verify_task = tasks.VerifyNetworksTask(task, vlan_ids)
if tasks.CheckDhcpTask.enabled(self.cluster):
dhcp_subtask = objects.task.Task.create_subtask(
task, name=TASK_NAMES.check_dhcp)
verify_task.add_subtask(tasks.CheckDhcpTask(
dhcp_subtask, vlan_ids))
if tasks.MulticastVerificationTask.enabled(self.cluster):
multicast = objects.task.Task.create_subtask(
task, name=TASK_NAMES.multicast_verification)
verify_task.add_subtask(
tasks.MulticastVerificationTask(multicast))
db().commit()
self._call_silently(task, verify_task)
return task
示例5: execute
# 需要导入模块: from nailgun.db.sqlalchemy.models import Task [as 别名]
# 或者: from nailgun.db.sqlalchemy.models.Task import name [as 别名]
def execute(self, nets, vlan_ids, **kwargs):
self.remove_previous_task()
task = Task(
name=consts.TASK_NAMES.check_networks,
cluster=self.cluster
)
if len([n for n in self.cluster.nodes if n.online]) < 2:
task.status = consts.TASK_STATUSES.error
task.progress = 100
task.message = ('At least two online nodes are required to be '
'in the environment for network verification.')
db().add(task)
db().commit()
return task
if len(self.cluster.node_groups) > 1:
task.status = consts.TASK_STATUSES.error
task.progress = 100
task.message = ('Network verification is disabled for '
'environments containing more than one node '
'group.')
db().add(task)
db().commit()
return task
if self.cluster.status in self._blocking_statuses:
task.status = consts.TASK_STATUSES.error
task.progress = 100
task.message = (
"Environment is not ready to run network verification "
"because it is in '{0}' state.".format(self.cluster.status)
)
db().add(task)
db().commit()
return task
db().add(task)
db().commit()
self._call_silently(
task,
tasks.CheckNetworksTask,
data=nets,
check_all_parameters=True
)
db().refresh(task)
if task.status != consts.TASK_STATUSES.error:
# this one is connected with UI issues - we need to
# separate if error happened inside nailgun or somewhere
# in the orchestrator, and UI does it by task name.
task.name = consts.TASK_NAMES.verify_networks
verify_task = tasks.VerifyNetworksTask(task, vlan_ids)
if tasks.CheckDhcpTask.enabled(self.cluster):
dhcp_subtask = objects.task.Task.create_subtask(
task, name=consts.TASK_NAMES.check_dhcp)
verify_task.add_subtask(
tasks.CheckDhcpTask(dhcp_subtask, vlan_ids))
if tasks.MulticastVerificationTask.enabled(self.cluster):
multicast = objects.task.Task.create_subtask(
task, name=consts.TASK_NAMES.multicast_verification)
verify_task.add_subtask(
tasks.MulticastVerificationTask(multicast))
# we have remote connectivity checks since fuel 6.1,
# so we should not create those tasks for old envs
if StrictVersion(self.cluster.release.environment_version) >= \
StrictVersion(consts.FUEL_REMOTE_REPOS):
# repo connectivity check via default gateway
repo_check_task = objects.task.Task.create_subtask(
task, name=consts.TASK_NAMES.check_repo_availability)
verify_task.add_subtask(
tasks.CheckRepoAvailability(repo_check_task, vlan_ids))
# repo connectivity check via external gateway
conf, errors = tasks.CheckRepoAvailabilityWithSetup.get_config(
self.cluster)
# if there is no conf - there is no nodes on which
# we need to setup network
if conf:
repo_check_task = objects.task.Task.create_subtask(
task,
consts.TASK_NAMES.check_repo_availability_with_setup)
verify_task.add_subtask(
tasks.CheckRepoAvailabilityWithSetup(
repo_check_task, conf))
if errors:
notifier.notify(
"warning",
'\n'.join(errors),
self.cluster.id
)
db().commit()
#.........这里部分代码省略.........