本文整理汇总了Python中wait_for.wait_for函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for函数的具体用法?Python wait_for怎么用?Python wait_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wait_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _reload
def _reload(self):
self._legends = []
self._elements = []
self._lines = []
self.search_box = TopologySearchBox()
self.display_names = TopologyDisplayNames()
# load elements
# we have to wait few seconds, initial few seconds elements are moving
if len(sel.elements(self.ELEMENTS)) > 0:
self._el_ref = TopologyElement(o=self, element=sel.elements(self.ELEMENTS)[-1])
wait_for(lambda: self._is_el_movement_stopped(), delay=2, num_sec=30)
for element in sel.elements(self.ELEMENTS):
self._elements.append(TopologyElement(o=self, element=element))
# load lines
for line in sel.elements(self.LINES):
self._lines.append(TopologyLine(element=line))
# load legends
# remove old legends
for legend_id in self._legends:
try:
delattr(self, legend_id)
except AttributeError:
pass
# load available legends
for legend in sel.elements(self.LEGENDS):
legend_text = sel.text_sane(legend.find_element_by_tag_name('label'))
legend_id = attributize_string(legend_text.strip())
legend_object = TopologyLegend(name=legend_text, element=legend)
setattr(self, legend_id, legend_object)
self._legends.append(legend_id)
示例2: test_appliance_console_restore_pg_basebackup_ansible
def test_appliance_console_restore_pg_basebackup_ansible(get_appliance_with_ansible):
appl1 = get_appliance_with_ansible
# Restore DB on the second appliance
appl1.evmserverd.stop()
appl1.db.restart_db_service()
command_set = ('ap', '', '4', '1', '/tmp/backup/base.tar.gz', TimedCommand('y', 60), '')
appl1.appliance_console.run_commands(command_set)
manager.quit()
appl1.start_evm_service()
appl1.wait_for_web_ui()
appl1.reboot()
appl1.start_evm_service()
appl1.wait_for_web_ui()
appl1.ssh_client.run_command(
'curl -kL https://localhost/ansibleapi | grep "Ansible Tower REST API"')
repositories = appl1.collections.ansible_repositories
repository = repositories.create('example', REPOSITORIES[0], description='example')
view = navigate_to(repository, "Details")
refresh = view.toolbar.refresh.click
wait_for(
lambda: view.entities.summary("Properties").get_text_of("Status") == "successful",
timeout=60,
fail_func=refresh,
message="Check if playbook repo added"
)
示例3: delete_vm
def delete_vm(self, vm_name):
self.wait_vm_steady(vm_name)
if not self.is_vm_stopped(vm_name):
self.stop_vm(vm_name)
self.logger.debug(' Deleting RHEV VM %s' % vm_name)
def _do_delete():
"""Returns True if you have to retry"""
if not self.does_vm_exist(vm_name):
return False
try:
vm = self._get_vm(vm_name)
vm.delete()
except RequestError as e:
# Handle some states that can occur and can be circumvented
if e.status == 409 and "Related operation" in e.detail:
self.logger.info("Waiting for RHEV: {}:{} ({})".format(
e.status, e.reason, e.detail))
return True
else:
raise # Raise other so we can see them and eventually add them into handling
# TODO: handle 400 - but I haven't seen the error message, it was empty.
else:
return False
wait_for(_do_delete, fail_condition=True, num_sec=600, delay=15, message="execute delete")
wait_for(
lambda: self.does_vm_exist(vm_name),
fail_condition=True,
message="wait for RHEV VM %s deleted" % vm_name,
num_sec=300
)
return True
示例4: test_appliance_console_dedicated_db
def test_appliance_console_dedicated_db(unconfigured_appliance, app_creds):
""" Commands:
1. 'ap' launch appliance_console,
2. RETURN clear info screen,
3. '7' setup db,
4. '1' Creates v2_key,
5. '1' selects internal db,
6. '2' use /dev/vdb partition,
7. 'y' create dedicated db,
8. 'pwd' db password,
9. 'pwd' confirm db password + wait 360 secs
10. RETURN finish.
Polarion:
assignee: mnadeem
caseimportance: high
casecomponent: Appliance
initialEstimate: 1/3h
testtype: structural
"""
pwd = app_creds['password']
command_set = ('ap', RETURN, '7', '1', '1', '2', 'y', pwd, TimedCommand(pwd, 360), RETURN)
unconfigured_appliance.appliance_console.run_commands(command_set)
wait_for(lambda: unconfigured_appliance.db.is_dedicated_active)
示例5: test_sdn_nsg_firewall_rules
def test_sdn_nsg_firewall_rules(provider, appliance, secgroup_with_rule):
""" Pulls the list of firewall ports from Provider API and from appliance. Compare the 2
results. If same, then test is successful.
Metadata:
test_flag: sdn, inventory
Polarion:
assignee: mmojzis
initialEstimate: 1/4h
"""
# Navigate to network provider.
prov_collection = appliance.collections.network_providers.filter({'provider': provider})
network_provider = prov_collection.all()[0]
network_provider.refresh_provider_relationships()
wait_for(network_provider.is_refreshed, func_kwargs=dict(refresh_delta=10), timeout=600)
view = navigate_to(network_provider, 'Details')
parent_name = view.entities.relationships.get_text_of("Parent Cloud Provider")
assert parent_name == provider.name
secgrp_collection = appliance.collections.network_security_groups
secgroup = [i for i in secgrp_collection.all() if i.name == secgroup_with_rule][0]
view = navigate_to(secgroup, 'Details')
if appliance.version < '5.10':
# The table has one header row. The first non-header row has column
# names.
assert 'Port' == view.entities.firewall_rules[1][3].text
assert '22' == view.entities.firewall_rules[2][3].text
else:
# The table has two header rows. We cannot access the second one with
# widgetastic. So let's hope the column of index 3 is the Port Range
# column.
assert '22' == view.entities.firewall_rules[1][3].text
示例6: test_appliance_console_dhcp
def test_appliance_console_dhcp(unconfigured_appliance, soft_assert):
""" Commands:
1. 'ap' launches appliance_console,
2. RETURN clears info screen,
3. '1' configure network,
4. '1' configure DHCP,
5. 'y' confirm IPv4 configuration,
6. 'y' IPv6 configuration.
Polarion:
assignee: mnadeem
casecomponent: Appliance
caseimportance: critical
initialEstimate: 1/6h
"""
command_set = ('ap', RETURN, '1', '1', 'y', TimedCommand('y', 90), RETURN, RETURN)
unconfigured_appliance.appliance_console.run_commands(command_set)
def appliance_is_connective():
unconfigured_appliance.ssh_client.run_command("true")
wait_for(appliance_is_connective, handle_exception=True, delay=1, timeout=30)
soft_assert(unconfigured_appliance.ssh_client.run_command(
r"ip a show dev eth0 | grep 'inet\s.*dynamic'").success)
soft_assert(unconfigured_appliance.ssh_client.run_command(
r"ip a show dev eth0 | grep 'inet6\s.*dynamic'").success)
示例7: test_appliance_console_ipa
def test_appliance_console_ipa(ipa_crud, configured_appliance):
""" Commands:
1. 'ap' launches appliance_console,
2. RETURN clears info screen,
3. '12' setup IPA, + wait 40 secs,
4. RETURN finish.
Polarion:
assignee: mnadeem
caseimportance: high
casecomponent: Auth
initialEstimate: 1/4h
"""
command_set = ('ap', RETURN, '12', ipa_crud.host1, ipa_crud.ipadomain, ipa_crud.iparealm,
ipa_crud.ipaprincipal, ipa_crud.bind_password, TimedCommand('y', 60),
RETURN, RETURN)
configured_appliance.appliance_console.run_commands(command_set, timeout=20)
configured_appliance.sssd.wait_for_running()
assert configured_appliance.ssh_client.run_command("cat /etc/ipa/default.conf |"
"grep 'enable_ra = True'")
# Unconfigure to cleanup
# When setup_ipa option selected, will prompt to unconfigure, then to proceed with new config
command_set = ('ap', RETURN, '12', TimedCommand('y', 40), TimedCommand('n', 5), RETURN, RETURN)
configured_appliance.appliance_console.run_commands(command_set)
wait_for(lambda: not configured_appliance.sssd.running)
示例8: test_appliance_console_static_ipv6
def test_appliance_console_static_ipv6(unconfigured_appliance, soft_assert):
""" Commands:
1. 'ap' launches appliance_console,
2. RETURN clears info screen,
3. '1' configure network,
4. '3' configure static IPv6,
5. '1::1' set IPv4 addr,
6. RETURN set deafault prefix length,
7. '1::f' set IPv6 gateway,
8. RETURN confirm default primary DNS,
9. RETURN confirm default secondary DNS,
10. RETURN confirm default search order,
11. 'y' apply static configuration.
Polarion:
assignee: mnadeem
caseimportance: high
casecomponent: Appliance
initialEstimate: 1/4h
"""
command_set = ('ap', RETURN, '1', '3', '1::1', RETURN, '1::f', RETURN, RETURN, RETURN, 'y', '')
unconfigured_appliance.appliance_console.run_commands(command_set, timeout=30)
def appliance_is_connective():
unconfigured_appliance.ssh_client.run_command("true")
wait_for(appliance_is_connective, handle_exception=True, delay=1, timeout=30)
soft_assert(unconfigured_appliance.ssh_client.run_command(
"ip -6 a show dev eth0 | grep 'inet6 1::1.*scope global'"))
soft_assert(unconfigured_appliance.ssh_client.run_command(
"ip -6 r show dev eth0 | grep 'default via 1::f'"))
示例9: test_appliance_console_static_ipv4
def test_appliance_console_static_ipv4(unconfigured_appliance, soft_assert):
""" Commands:
1. 'ap' launches appliance_console,
2. RETURN clears info screen,
3. '1' configure network,
4. '2' configure static IPv4,
5. RETURN confirm default IPv4 addr,
6. RETURN confirm default netmask,
7. RETURN confirm default gateway,
8. RETURN confirm default primary DNS,
9. RETURN confirm default secondary DNS,
10. RETURN confirm default search order,
11. 'y' apply static configuration.
Polarion:
assignee: mnadeem
casecomponent: Appliance
caseimportance: critical
initialEstimate: 1/6h
"""
command_set = ('ap', RETURN, '1', '2', RETURN, RETURN, RETURN, RETURN, RETURN, RETURN, 'y')
unconfigured_appliance.appliance_console.run_commands(command_set)
def appliance_is_connective():
unconfigured_appliance.ssh_client.run_command("true")
wait_for(appliance_is_connective, handle_exception=True, delay=1, timeout=30)
soft_assert(unconfigured_appliance.ssh_client.run_command(
"ip -4 a show dev eth0 | grep 'inet .*scope global eth0'"))
soft_assert(unconfigured_appliance.ssh_client.run_command(
"ip -4 r show dev eth0 | grep 'default via'"))
示例10: restart_vm
def restart_vm(self, instance_name):
self.logger.info("Restarting Google Cloud instance {}".format(instance_name))
operation = self._instances.reset(
project=self._project, zone=self._zone, instance=instance_name).execute()
wait_for(lambda: self._nested_operation_wait(operation['name']),
message="Restart {}".format(instance_name))
return True
示例11: test_appliance_console_set_hostname
def test_appliance_console_set_hostname(configured_appliance):
""" Commands:
1. 'ap' launch appliance_console,
2. RETURN clear info screen,
3. '1' loads network settings,
4. '5' gives access to set hostname,
5. 'hostname' sets new hostname.
Polarion:
assignee: mnadeem
caseimportance: high
casecomponent: Appliance
initialEstimate: 1/6h
"""
hostname = 'test.example.com'
command_set = ('ap', RETURN, '1', '5', hostname, RETURN, RETURN)
configured_appliance.appliance_console.run_commands(command_set, timeout=30)
def is_hostname_set(appliance):
return appliance.ssh_client.run_command("hostname -f | grep {hostname}"
.format(hostname=hostname)).success
wait_for(is_hostname_set, func_args=[configured_appliance])
result = configured_appliance.ssh_client.run_command("hostname -f")
assert result.success
assert result.output.strip() == hostname
示例12: client
def client():
url = 'http://localhost:8088/v1-catalog/schemas'
templates = cattle.from_env(url=url).list_template(catalogId='qa-catalog')
wait_for(
lambda: len(templates) > 0
)
return cattle.from_env(url=url)
示例13: pause_vm
def pause_vm(self, instance_name):
self.logger.info(" Pausing OpenStack instance %s" % instance_name)
if self.is_vm_paused(instance_name):
return True
instance = self._find_instance_by_name(instance_name)
instance.pause()
wait_for(lambda: self.is_vm_paused(instance_name), message="pause %s" % instance_name)
示例14: test_appliance_console_cli_datetime
def test_appliance_console_cli_datetime(temp_appliance_preconfig_funcscope):
"""Grab fresh appliance and set time and date through appliance_console_cli and check result"""
app = temp_appliance_preconfig_funcscope
app.ssh_client.run_command("appliance_console_cli --datetime 2020-10-20T09:59:00")
def date_changed():
return app.ssh_client.run_command("date +%F-%T | grep 2020-10-20-10:00").success
wait_for(date_changed)
示例15: suspend_vm
def suspend_vm(self, instance_name):
self.logger.info(" Suspending OpenStack instance %s" % instance_name)
if self.is_vm_suspended(instance_name):
return True
instance = self._find_instance_by_name(instance_name)
instance.suspend()
wait_for(lambda: self.is_vm_suspended(instance_name), message="suspend %s" % instance_name)