本文整理匯總了Python中tempest.lib.exceptions.TimeoutException方法的典型用法代碼示例。如果您正苦於以下問題:Python exceptions.TimeoutException方法的具體用法?Python exceptions.TimeoutException怎麽用?Python exceptions.TimeoutException使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tempest.lib.exceptions
的用法示例。
在下文中一共展示了exceptions.TimeoutException方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _wait_firewall_while
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _wait_firewall_while(self, firewall_id, statuses, not_found_ok=False):
start = int(time.time())
if not_found_ok:
expected_exceptions = (lib_exc.NotFound)
else:
expected_exceptions = ()
while True:
try:
fw = self.fwaasv1_client.show_firewall(firewall_id)
except expected_exceptions:
break
status = fw['firewall']['status']
if status not in statuses:
break
if int(time.time()) - start >= self.fwaasv1_client.build_timeout:
msg = ("Firewall %(firewall)s failed to reach "
"non PENDING status (current %(status)s)") % {
"firewall": firewall_id,
"status": status,
}
raise lib_exc.TimeoutException(msg)
time.sleep(constants.NSX_BACKEND_VERY_SMALL_TIME_INTERVAL)
示例2: wait_for_node
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_node(self, node_name):
def check_node():
try:
self.node_show(node_name)
except lib_exc.NotFound:
return False
return True
if not test_utils.call_until_true(
check_node,
duration=CONF.baremetal_introspection.discovery_timeout,
sleep_for=20):
msg = ("Timed out waiting for node %s " % node_name)
raise lib_exc.TimeoutException(msg)
inspected_node = self.node_show(self.node_info['name'])
self.wait_for_introspection_finished(inspected_node['uuid'])
# TODO(aarefiev): switch to call_until_true
示例3: _wait_until_deleted
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _wait_until_deleted(self, fw_id):
def _wait():
try:
firewall = self.fwaasv1_client.show_firewall(fw_id)
except lib_exc.NotFound:
return True
fw_status = firewall['firewall']['status']
if fw_status == 'ERROR':
raise lib_exc.DeleteErrorException(resource_id=fw_id)
if not test_utils.call_until_true(_wait, CONF.network.build_timeout,
CONF.network.build_interval):
m = ("Timed out waiting for firewall %s deleted" % fw_id)
raise lib_exc.TimeoutException(m)
示例4: _wait_until_ready
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _wait_until_ready(self, fw_id):
target_states = ('ACTIVE', 'CREATED')
def _wait():
firewall = self.fwaasv1_client.show_firewall(fw_id)
firewall = firewall['firewall']
return firewall['status'] in target_states
if not test_utils.call_until_true(_wait, CONF.network.build_timeout,
CONF.network.build_interval):
m = ("Timed out waiting for firewall %s to reach %s state(s)" %
(fw_id, target_states))
raise lib_exc.TimeoutException(m)
示例5: get_and_reserve_node
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def get_and_reserve_node(cls, node=None):
"""Pick an available node for deployment and reserve it.
Only one instance_uuid may be associated, use this behaviour as
reservation node when tests are launched concurrently. If node is
not passed directly pick random available for deployment node.
:param node: Ironic node to associate instance_uuid with.
:returns: Ironic node.
"""
instance_uuid = uuidutils.generate_uuid()
nodes = []
def _try_to_associate_instance():
n = node or cls.get_random_available_node()
try:
cls._associate_instance_with_node(n['uuid'], instance_uuid)
nodes.append(n)
except lib_exc.Conflict:
return False
return True
if (not test_utils.call_until_true(_try_to_associate_instance,
duration=CONF.baremetal.association_timeout, sleep_for=1)):
msg = ('Timed out waiting to associate instance to ironic node '
'uuid %s' % instance_uuid)
raise lib_exc.TimeoutException(msg)
return nodes[0]
示例6: _validate_power_state
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _validate_power_state(self, node_uuid, power_state):
# Validate that power state is set within timeout
if power_state == 'rebooting':
power_state = 'power on'
start = timeutils.utcnow()
while timeutils.delta_seconds(
start, timeutils.utcnow()) < self.power_timeout:
_, node = self.client.show_node(node_uuid)
if node['power_state'] == power_state:
return
message = ('Failed to set power state within '
'the required time: %s sec.' % self.power_timeout)
raise exceptions.TimeoutException(message)
示例7: _validate_provision_state
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _validate_provision_state(self, node_uuid, target_state):
# Validate that provision state is set within timeout
start = timeutils.utcnow()
while timeutils.delta_seconds(
start, timeutils.utcnow()) < self.unprovision_timeout:
_, node = self.client.show_node(node_uuid)
if node['provision_state'] == target_state:
return
message = ('Failed to set provision state %(state)s within '
'the required time: %(timeout)s sec.',
{'state': target_state,
'timeout': self.unprovision_timeout})
raise exceptions.TimeoutException(message)
示例8: wait_for_bm_node_status
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_bm_node_status(client, node_id, attr, status, timeout=None,
interval=None):
"""Waits for a baremetal node attribute to reach given status.
:param client: an instance of tempest plugin BaremetalClient.
:param node_id: identifier of the node.
:param attr: node's API-visible attribute to check status of.
:param status: desired status. Can be a list of statuses.
:param timeout: the timeout after which the check is considered as failed.
Defaults to client.build_timeout.
:param interval: an interval between show_node calls for status check.
Defaults to client.build_interval.
The client should have a show_node(node_id) method to get the node.
"""
timeout, interval = _determine_and_check_timeout_interval(
timeout, client.build_timeout, interval, client.build_interval)
if not isinstance(status, list):
status = [status]
def is_attr_in_status():
node = utils.get_node(client, node_id=node_id)
if node[attr] in status:
return True
return False
if not test_utils.call_until_true(is_attr_in_status, timeout,
interval):
message = ('Node %(node_id)s failed to reach %(attr)s=%(status)s '
'within the required time (%(timeout)s s).' %
{'node_id': node_id,
'attr': attr,
'status': status,
'timeout': timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
示例9: wait_for_server_termination
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_server_termination(client, server_id, ignore_error=False):
"""Waits for server to reach termination."""
try:
body = client.show_server(server_id)['server']
except exceptions.NotFound:
return
old_status = body['status']
old_task_state = _get_task_state(body)
start_time = int(time.time())
while True:
time.sleep(client.build_interval)
try:
body = client.show_server(server_id)['server']
except exceptions.NotFound:
return
server_status = body['status']
task_state = _get_task_state(body)
if (server_status != old_status) or (task_state != old_task_state):
LOG.info('State transition "%s" ==> "%s" after %d second wait',
'/'.join((old_status, str(old_task_state))),
'/'.join((server_status, str(task_state))),
time.time() - start_time)
if server_status == 'ERROR' and not ignore_error:
raise exceptions.DeleteErrorException(resource_id=server_id)
if int(time.time()) - start_time >= client.build_timeout:
raise exceptions.TimeoutException
old_status = server_status
old_task_state = task_state
示例10: _wait_for_failover
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def _wait_for_failover(self, server, original_host):
"""Waits for the given server to failover to another host.
:raises TimeoutException: if the given server did not failover to
another host within the configured "CONF.hyperv.failover_timeout"
interval.
"""
LOG.debug('Waiting for server %(server)s to failover from '
'compute node %(host)s',
dict(server=server['id'], host=original_host))
start_time = int(time.time())
timeout = CONF.hyperv.failover_timeout
while True:
elapsed_time = int(time.time()) - start_time
admin_server = self._get_server_as_admin(server)
current_host = admin_server['OS-EXT-SRV-ATTR:host']
if current_host != original_host:
LOG.debug('Server %(server)s failovered from compute node '
'%(host)s in %(seconds)s seconds.',
dict(server=server['id'], host=original_host,
seconds=elapsed_time))
return
if elapsed_time >= timeout:
msg = ('Server %(server)s did not failover in the given '
'amount of time (%(timeout)s s).')
raise lib_exc.TimeoutException(
msg % dict(server=server['id'], timeout=timeout))
time.sleep(CONF.hyperv.failover_sleep_interval)
示例11: wait_for_zone_404
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_zone_404(client, zone_id):
"""Waits for a zone to 404."""
LOG.info('Waiting for zone %s to 404', zone_id)
start = int(time.time())
while True:
time.sleep(client.build_interval)
try:
_, zone = client.show_zone(zone_id)
except lib_exc.NotFound:
LOG.info('Zone %s is 404ing', zone_id)
return
if int(time.time()) - start >= client.build_timeout:
message = ('Zone %(zone_id)s failed to 404 within the required '
'time (%(timeout)s s). Current status: '
'%(status_curr)s' %
{'zone_id': zone_id,
'status_curr': zone['status'],
'timeout': client.build_timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
示例12: wait_for_zone_status
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_zone_status(client, zone_id, status):
"""Waits for a zone to reach given status."""
LOG.info('Waiting for zone %s to reach %s', zone_id, status)
_, zone = client.show_zone(zone_id)
start = int(time.time())
while zone['status'] != status:
time.sleep(client.build_interval)
_, zone = client.show_zone(zone_id)
status_curr = zone['status']
if status_curr == status:
LOG.info('Zone %s reached %s', zone_id, status)
return
if int(time.time()) - start >= client.build_timeout:
message = ('Zone %(zone_id)s failed to reach status=%(status)s '
'within the required time (%(timeout)s s). Current '
'status: %(status_curr)s' %
{'zone_id': zone_id,
'status': status,
'status_curr': status_curr,
'timeout': client.build_timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
示例13: wait_for_zone_import_status
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_zone_import_status(client, zone_import_id, status):
"""Waits for an imported zone to reach the given status."""
LOG.info('Waiting for zone import %s to reach %s', zone_import_id, status)
_, zone_import = client.show_zone_import(zone_import_id)
start = int(time.time())
while zone_import['status'] != status:
time.sleep(client.build_interval)
_, zone_import = client.show_zone_import(zone_import_id)
status_curr = zone_import['status']
if status_curr == status:
LOG.info('Zone import %s reached %s', zone_import_id, status)
return
if int(time.time()) - start >= client.build_timeout:
message = ('Zone import %(zone_import_id)s failed to reach '
'status=%(status)s within the required time '
'(%(timeout)s s). Current '
'status: %(status_curr)s' %
{'zone_import_id': zone_import_id,
'status': status,
'status_curr': status_curr,
'timeout': client.build_timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
示例14: wait_for_zone_export_status
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_zone_export_status(client, zone_export_id, status):
"""Waits for an exported zone to reach the given status."""
LOG.info('Waiting for zone export %s to reach %s', zone_export_id, status)
_, zone_export = client.show_zone_export(zone_export_id)
start = int(time.time())
while zone_export['status'] != status:
time.sleep(client.build_interval)
_, zone_export = client.show_zone_export(zone_export_id)
status_curr = zone_export['status']
if status_curr == status:
LOG.info('Zone export %s reached %s', zone_export_id, status)
return
if int(time.time()) - start >= client.build_timeout:
message = ('Zone export %(zone_export_id)s failed to reach '
'status=%(status)s within the required time '
'(%(timeout)s s). Current '
'status: %(status_curr)s' %
{'zone_export_id': zone_export_id,
'status': status,
'status_curr': status_curr,
'timeout': client.build_timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
示例15: wait_for_recordset_status
# 需要導入模塊: from tempest.lib import exceptions [as 別名]
# 或者: from tempest.lib.exceptions import TimeoutException [as 別名]
def wait_for_recordset_status(client, zone_id, recordset_id, status):
"""Waits for a recordset to reach the given status."""
LOG.info('Waiting for recordset %s to reach %s',
recordset_id, status)
_, recordset = client.show_recordset(zone_id, recordset_id)
start = int(time.time())
while recordset['status'] != status:
time.sleep(client.build_interval)
_, recordset = client.show_recordset(zone_id, recordset_id)
status_curr = recordset['status']
if status_curr == status:
LOG.info('Recordset %s reached %s', recordset_id, status)
return
if int(time.time()) - start >= client.build_timeout:
message = ('Recordset %(recordset_id)s failed to reach '
'status=%(status) within the required time '
'(%(timeout)s s). Current '
'status: %(status_curr)s' %
{'recordset_id': recordset_id,
'status': status,
'status_curr': status_curr,
'timeout': client.build_timeout})
caller = test_utils.find_test_caller()
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)