本文整理汇总了Python中rally.task.utils.wait_for函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for函数的具体用法?Python wait_for怎么用?Python wait_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _associate_floating_ip
def _associate_floating_ip(self, server, address, fixed_address=None,
atomic_action=True):
"""Add floating IP to an instance
:param server: The :class:`Server` to add an IP to.
:param address: The ip address or FloatingIP to add to the instance
:param fixed_address: The fixedIP address the FloatingIP is to be
associated with (optional)
:param atomic_action: True if this is an atomic action (optional)
"""
if atomic_action:
with atomic.ActionTimer(self, "nova.associate_floating_ip"):
server.add_floating_ip(address, fixed_address=fixed_address)
utils.wait_for(
server,
is_ready=self.check_ip_address(address),
update_resource=utils.get_from_manager()
)
else:
server.add_floating_ip(address, fixed_address=fixed_address)
utils.wait_for(
server,
is_ready=self.check_ip_address(address),
update_resource=utils.get_from_manager()
)
# Update server data
server.addresses = server.manager.get(server.id).addresses
示例2: _migrate
def _migrate(self, server, skip_host_check=False):
"""Run migration of the given server.
:param server: Server object
:param skip_host_check: Specifies whether to verify the targeted host
availability
"""
server_admin = self.admin_clients("nova").servers.get(server.id)
host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
server_admin.migrate()
utils.wait_for(
server,
ready_statuses=["VERIFY_RESIZE"],
update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_migrate_timeout,
check_interval=(
CONF.benchmark.nova_server_migrate_poll_interval)
)
if not skip_host_check:
server_admin = self.admin_clients("nova").servers.get(server.id)
host_after_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
if host_pre_migrate == host_after_migrate:
raise exceptions.MigrateException(
"Migration complete but instance did not change host: %s" %
host_pre_migrate)
示例3: _live_migrate
def _live_migrate(self, server, target_host, block_migration=False,
disk_over_commit=False, skip_host_check=False):
"""Run live migration of the given server.
:param server: Server object
:param target_host: Specifies the target compute node to migrate
:param block_migration: Specifies the migration type
:param disk_over_commit: Specifies whether to overcommit migrated
instance or not
:param skip_host_check: Specifies whether to verify the targeted host
availability
"""
server_admin = self.admin_clients("nova").servers.get(server.id)
host_pre_migrate = getattr(server_admin, "OS-EXT-SRV-ATTR:host")
server_admin.live_migrate(target_host,
block_migration=block_migration,
disk_over_commit=disk_over_commit)
utils.wait_for(
server,
ready_statuses=["ACTIVE"],
update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_live_migrate_timeout,
check_interval=(
CONF.benchmark.nova_server_live_migrate_poll_interval)
)
server_admin = self.admin_clients("nova").servers.get(server.id)
if (host_pre_migrate == getattr(server_admin, "OS-EXT-SRV-ATTR:host")
and not skip_host_check):
raise exceptions.LiveMigrateException(
"Migration complete but instance did not change host: %s" %
host_pre_migrate)
示例4: _scale_stack
def _scale_stack(self, stack, output_key, delta):
"""Scale a stack up or down.
Calls the webhook given in the output value identified by
'output_key', and waits for the stack size to change by
'delta'.
:param stack: stack to scale up or down
:param output_key: The name of the output to get the URL from
:param delta: The expected change in number of instances in
the stack (signed int)
"""
num_instances = self._count_instances(stack)
expected_instances = num_instances + delta
LOG.debug("Scaling stack %s from %s to %s instances with %s" %
(stack.id, num_instances, expected_instances, output_key))
with atomic.ActionTimer(self, "heat.scale_with_%s" % output_key):
self._stack_webhook(stack, output_key)
utils.wait_for(
stack,
is_ready=lambda s: (
self._count_instances(s) == expected_instances),
update_resource=utils.get_from_manager(
["UPDATE_FAILED"]),
timeout=CONF.benchmark.heat_stack_scale_timeout,
check_interval=CONF.benchmark.heat_stack_scale_poll_interval)
示例5: test_wait_successful
def test_wait_successful(self, mock_time, mock_sleep):
res = {"status": "not_ready"}
upd = mock.MagicMock(side_effect=[{
"status": "not_ready"
}, {
"status": "not_ready_yet"
}, {
"status": "still_not_ready"
}, {
"status": "almost_ready"
}, {
"status": "ready"
}])
utils.wait_for(
resource=res, ready_statuses=["ready"], update_resource=upd)
upd.assert_has_calls([
mock.call({
"status": "not_ready"
}),
mock.call({
"status": "not_ready"
}),
mock.call({
"status": "not_ready_yet"
}),
mock.call({
"status": "still_not_ready"
}),
mock.call({
"status": "almost_ready"
})
])
示例6: _wait_for_ping
def _wait_for_ping(self, server_ip):
server_ip = netaddr.IPAddress(server_ip)
utils.wait_for(
server_ip,
is_ready=utils.resource_is(ICMP_UP_STATUS, self._ping_ip_address),
timeout=CONF.benchmark.vm_ping_timeout,
check_interval=CONF.benchmark.vm_ping_poll_interval
)
示例7: _wait_for_ping
def _wait_for_ping(self, server_ip):
server_ip = netaddr.IPAddress(server_ip)
utils.wait_for(
server_ip,
is_ready=utils.resource_is(ICMP_UP_STATUS,
self._ping_ip_address),
timeout=120
)
示例8: _wait_active
def _wait_active(self, cluster_object):
utils.wait_for(
resource=cluster_object,
ready_statuses=["active"],
failure_statuses=["error"],
update_resource=self._update_cluster,
timeout=CONF.benchmark.sahara_cluster_create_timeout,
check_interval=CONF.benchmark.sahara_cluster_check_interval,
)
示例9: _resize
def _resize(self, server, flavor):
server.resize(flavor)
utils.wait_for(
server,
ready_statuses=["VERIFY_RESIZE"],
update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_resize_timeout,
check_interval=CONF.benchmark.nova_server_resize_poll_interval
)
示例10: _wait_for_swarm_ping
def _wait_for_swarm_ping(self, swarm_connection):
utils.wait_for(
None,
is_ready=utils.resource_is(
"UP ALL",
swarm_connection.status),
timeout=CONF.benchmark.vm_swarm_ping_timeout,
check_interval=CONF.benchmark.vm_swarm_ping_poll_interval
)
示例11: _do_server_reboot
def _do_server_reboot(self, server, reboottype):
server.reboot(reboot_type=reboottype)
time.sleep(CONF.benchmark.nova_server_reboot_prepoll_delay)
utils.wait_for(
server, is_ready=utils.resource_is("ACTIVE"),
update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_reboot_timeout,
check_interval=CONF.benchmark.nova_server_reboot_poll_interval
)
示例12: _wait_for_ping_linux
def _wait_for_ping_linux(self, server_ip):
server_ip = netaddr.IPAddress(server_ip)
utils.wait_for(
server_ip,
ready_statuses=[Host.ICMP_UP_STATUS],
update_resource=Host.update_status,
timeout=CONF.benchmark.vm_ping_timeout,
check_interval=CONF.benchmark.vm_ping_poll_interval
)
示例13: test_exit_instantly
def test_exit_instantly(self, mock_sleep):
res = {"status": "ready"}
upd = mock.MagicMock(return_value=res)
utils.wait_for(resource=res, ready_statuses=["ready"],
update_resource=upd)
upd.assert_called_once_with(res)
self.assertFalse(mock_sleep.called)
示例14: setup
def setup(self):
utils.init_sahara_context(self)
self.context["sahara"]["clusters"] = {}
wait_dict = {}
for user, tenant_id in rutils.iterate_per_tenants(
self.context["users"]):
image_id = self.context["tenants"][tenant_id]["sahara"]["image"]
floating_ip_pool = self.config.get("floating_ip_pool")
temporary_context = {
"user": user,
"tenant": self.context["tenants"][tenant_id],
"task": self.context["task"],
"owner_id": self.context["owner_id"]
}
scenario = utils.SaharaScenario(context=temporary_context)
cluster = scenario._launch_cluster(
plugin_name=self.config["plugin_name"],
hadoop_version=self.config["hadoop_version"],
flavor_id=self.config.get("flavor_id"),
master_flavor_id=self.config["master_flavor_id"],
worker_flavor_id=self.config["worker_flavor_id"],
workers_count=self.config["workers_count"],
image_id=image_id,
floating_ip_pool=floating_ip_pool,
volumes_per_node=self.config.get("volumes_per_node"),
volumes_size=self.config.get("volumes_size", 1),
auto_security_group=self.config.get("auto_security_group",
True),
security_groups=self.config.get("security_groups"),
node_configs=self.config.get("node_configs"),
cluster_configs=self.config.get("cluster_configs"),
enable_anti_affinity=self.config.get("enable_anti_affinity",
False),
enable_proxy=self.config.get("enable_proxy", False),
wait_active=False,
use_autoconfig=self.config.get("use_autoconfig", True)
)
self.context["tenants"][tenant_id]["sahara"]["cluster"] = (
cluster.id)
# Need to save the client instance to poll for active status
wait_dict[cluster] = scenario.clients("sahara")
bench_utils.wait_for(
resource=wait_dict,
update_resource=self.update_clusters_dict,
is_ready=self.all_clusters_active,
timeout=CONF.openstack.sahara_cluster_create_timeout,
check_interval=CONF.openstack.sahara_cluster_check_interval)
示例15: _do_server_reboot
def _do_server_reboot(self, server, reboottype):
server.reboot(reboot_type=reboottype)
self.sleep_between(CONF.benchmark.nova_server_pause_prepoll_delay)
utils.wait_for(
server,
ready_statuses=["ACTIVE"],
update_resource=utils.get_from_manager(),
timeout=CONF.benchmark.nova_server_reboot_timeout,
check_interval=CONF.benchmark.nova_server_reboot_poll_interval
)