当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.TimeoutException方法代码示例

本文整理汇总了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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:24,代码来源:test_v1_fwaas_basic_ops.py

示例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 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:21,代码来源:introspection_manager.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:16,代码来源:test_v1_fwaas_basic_ops.py

示例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) 
开发者ID:openstack,项目名称:vmware-nsx-tempest-plugin,代码行数:14,代码来源:test_v1_fwaas_basic_ops.py

示例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] 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:31,代码来源:baremetal_standalone_manager.py

示例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) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:15,代码来源:test_nodestates.py

示例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) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:15,代码来源:test_nodestates.py

示例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) 
开发者ID:openstack,项目名称:ironic-tempest-plugin,代码行数:41,代码来源:waiters.py

示例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 
开发者ID:openstack,项目名称:octavia-tempest-plugin,代码行数:31,代码来源:server_util.py

示例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) 
开发者ID:openstack,项目名称:oswin-tempest-plugin,代码行数:33,代码来源:test_cluster.py

示例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) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:30,代码来源:waiters.py

示例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) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:32,代码来源:waiters.py

示例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) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:33,代码来源:waiters.py

示例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) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:33,代码来源:waiters.py

示例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) 
开发者ID:openstack,项目名称:designate-tempest-plugin,代码行数:34,代码来源:waiters.py


注:本文中的tempest.lib.exceptions.TimeoutException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。