Source code for cfme.exceptions

# -*- coding: utf-8 -*-
"""Provides custom exceptions for the ``cfme`` module. """
import pytest
from cfme.utils.log import logger


[docs]class CFMEException(Exception): """Base class for exceptions in the CFME tree Used to easily catch errors of our own making, versus errors from external libraries. """ pass
[docs]class ConsoleNotSupported(CFMEException): """Raised by functions in :py:mod:`cfme.configure.configuration` when an invalid console type is given""" def __init__(self, product_name, version): self.product_name = product_name self.version = version def __str__(self): return "Console not supported on current version: {} {}".format( self.product_name, self.version )
[docs]class ConsoleTypeNotSupported(CFMEException): """Raised by functions in :py:mod:`cfme.configure.configuration` when an invalid console type is given""" def __init__(self, console_type): self.console_type = console_type def __str__(self): return "Console type not supported: {}".format(self.console_type)
[docs]class FlashMessageException(CFMEException): """Raised by functions in :py:mod:`cfme.web_ui.flash`"""
[docs] def skip_and_log(self, message="Skipping due to flash message"): logger.error("Flash message error: %s", str(self)) pytest.skip("{}: {}".format(message, str(self)))
[docs]class CFMEExceptionOccured(CFMEException): """Raised by :py:func:`cfme.web_ui.cfme_exception.assert_no_cfme_exception` when there is a Rails exception currently on page.""" pass
[docs]class ToolbarOptionGreyedOrUnavailable(CFMEException): """Raised when toolbar wants to click item that is greyed or unavailable""" pass
[docs]class AddProviderError(CFMEException): pass
[docs]class AuthModeUnknown(CFMEException): """ Raised if an invalid authenctication mode is passed to :py:func:`cfme.configure.configuration.set_auth_mode` """ pass
[docs]class AutomateImportError(CFMEException): """Raised by scripts dealing with Automate when importing automate XML fails""" pass
[docs]class BlockTypeUnknown(CFMEException): """ Raised if the block type requested to :py:class:`cfme.web_ui.InfoBlock`. """ pass
[docs]class CandidateNotFound(CFMEException): """ Raised if there is no candidate found whilst trying to traverse a tree in :py:meth:`cfme.web_ui.Tree.click_path`. """ def __init__(self, d): self.d = d @property def message(self): return ", ".join("{}: {}".format(k, v) for k, v in self.d.iteritems()) def __str__(self): return self.message
[docs]class TreeNotFound(CFMEException): """ Raised if the tree used for :py:meth:`cfme.web_ui.Tree.expand_path` cannot be found """ pass
[docs]class ElementOrBlockNotFound(CFMEException): """ Raised if an Element or a Block is not found whilst locating in :py:meth:`cfme.web_ui.InfoBlock`. """ pass
[docs]class HostStatsNotContains(CFMEException): """ Raised if the hosts information does not contain the specified key whilst running :py:meth:`cfme.cloud.provider.Provider.do_stats_match`. """ pass
[docs]class CannotContinueWithNavigation(CFMEException): """Used when it is not possible to continue with navigation. Raising it will recycle the browser, therefore refresh the session. If you pass a string to the constructor, it will be written to the log. """ pass
[docs]class NoElementsInsideValue(CFMEException): """ Raised if the value part of key/value contains no elements during :py:meth:`cfme.web_ui.InfoBlock.get_el_or_els`. """ pass
[docs]class NotAllItemsClicked(CFMEException): """ Raised if not all the items could be clicked during :py:meth:`cfme.web_ui.Table.click_cell`. """ def __init__(self, failed_clicks): self.failed_clicks = failed_clicks def __str__(self): return "Not all the required data elements were clicked [{}]".format( ",".join(self.failed_clicks))
[docs]class NotAllCheckboxesFound(CFMEException): """ Raised if not all the checkboxes could be found during e.g. :py:meth:`cfme.web_ui.CheckboxTable.select_rows` and other methods of this class. """ def __init__(self, failed_selects): self.failed_selects = failed_selects def __str__(self): return "Not all the required data elements were selected/deselected [{}]".format( ",".join(self.failed_selects))
[docs]class ProviderHasNoKey(CFMEException): """ Raised if the :py:meth:`cfme.cloud.provider.Provider.get_mgmt_system` method is called but the Provider instance has no key. """ pass
[docs]class ProviderHasNoProperty(CFMEException): """ Raised if the provider does not have the property requested whilst running :py:meth:`cfme.cloud.provider.Provider.do_stats_match`. """ pass
[docs]class ScheduleNotFound(CFMEException): """ Raised if a schedule was not found in :py:meth:`cfme.configure.configuration.Schedule.delete_by_name` """ pass
[docs]class RequestException(CFMEException): """ Raised if a request was not found or multiple rows matched during _request functions in :py:mod:`cfme.services.requests` """ pass
[docs]class TreeTypeUnknown(CFMEException): """ Raised if the tree type is known whilst detection in :py:class:`cfme.web_ui.Tree` """ pass
[docs]class UnidentifiableTagType(CFMEException): """ Raised if a tag type is not identifiable when processing a form in :py:meth:`cfme.web_ui.Form.fill_fields`. """ pass
[docs]class VmNotFoundViaIP(CFMEException): """ Raised if a specific VM cannot be found. """ pass
[docs]class VmOrInstanceNotFound(CFMEException): pass
[docs]class VmNotFound(VmOrInstanceNotFound): """ Raised if a specific VM cannot be found. """ pass
[docs]class InstanceNotFound(VmOrInstanceNotFound): """ Raised if a specific instance cannot be found. """ pass
[docs]class ImageNotFound(VmOrInstanceNotFound): """ Raised if a specific image cannot be found """ pass
[docs]class TenantNotFound(CFMEException): """ Raised if a specific tenant cannot be found """ pass
[docs]class TemplateNotFound(CFMEException): """ Raised if a specific Template cannot be found. """ pass
[docs]class ClusterNotFound(CFMEException): """Raised if a cluster is not found""" pass
[docs]class HostNotFound(CFMEException): """Raised if a specific host cannot be found in UI.""" pass
[docs]class NodeNotFound(CFMEException): """Raised if a specific container node cannot be found in the UI""" pass
[docs]class StackNotFound(CFMEException): """ Raised if a specific stack cannot be found. """ pass
[docs]class FlavorNotFound(CFMEException): """ Raised if a specific cloud flavor cannot be found in the UI """ pass
[docs]class KeyPairNotFound(CFMEException): """ Raised if a specific cloud key pair cannot be found in the UI """ pass
[docs]class ResourcePoolNotFound(CFMEException): """ Raised if a specific cloud key pair cannot be found in the UI """ pass
[docs]class AvailabilityZoneNotFound(CFMEException): """ Raised if a specific Cloud Availability Zone cannot be found. """ pass
[docs]class VolumeNotFound(CFMEException): """ Raised if a specific cloud volume cannot be found in the UI """ pass
[docs]class OptionNotAvailable(CFMEException): """ Raised if a specified option is not available. """ pass
[docs]class ListAccordionLinkNotFound(CFMEException): """ Raised when active link containing specific text could not be found in expended :py:mod:`cfme.web_ui.listaccordion` content section. """ pass
[docs]class ZoneNotFound(CFMEException): """ Raised when a specific Zone cannot be found in the method :py:mod:`cfme.configure.configuration`. """ pass
[docs]class UnknownProviderType(CFMEException): """ Raised when the passed provider or provider type is not known or usable in given context e.g. when getting a provider from yaml and the provider type doesn't match any of known types or when an infra provider is passed to the cloud's instance_factory method """ pass
[docs]class AccordionItemNotFound(CFMEException): """Raised when it's not possible to locate and accordion item."""
[docs]class CannotScrollException(CFMEException): """Raised when even during the heaviest workarounds for scrolling failure comes."""
[docs]class StorageManagerNotFound(CFMEException): """Raised when a Storage Manager is not found""" pass
[docs]class CUCommandException(CFMEException): """Raised when one of the commands run to set up a CU VM fails """ pass
[docs]class PaginatorException(CFMEException): """Raised by functions in :py:mod:`cfme.web_ui.paginator`""" pass
[docs]class MiddlewareProviderNotFound(CFMEException): """ Raised if a specific Middleware Provider cannot be found. """ pass
[docs]class MiddlewareServerNotFound(CFMEException): """ Raised if a specific Middleware Server cannot be found. """ pass
[docs]class MiddlewareServerGroupNotFound(CFMEException): """ Raised if a specific Middleware Server Group cannot be found. """ pass
[docs]class MiddlewareDomainNotFound(CFMEException): """ Raised if a specific Middleware Domain cannot be found. """ pass
[docs]class MiddlewareDatasourceNotFound(CFMEException): """ Raised if a specific Middleware Datasource cannot be found. """ pass
[docs]class MiddlewareDeploymentNotFound(CFMEException): """ Raised if a specific Middleware Deployment cannot be found. """ pass
[docs]class MiddlewareMessagingNotFound(CFMEException): """ Raised if a specific Middleware Messaging cannot be found. """ pass
[docs]class JDBCDriverConfigNotFound(CFMEException): """Raised when cdme_data.yaml file does not contain configuration of 'jdbc_drivers'."""
[docs]class DbAllocatorConfigNotFound(CFMEException): """Raised when cdme_data.yaml file does not contain configuration of 'db_allocator'."""
[docs]class LabelNotFoundException(Exception): "Raises when failed to remove label from object via cli" pass
[docs]class UsingSharedTables(CFMEException): """Raised if the :py:class:`cfme.web_ui.Table` suspects there is a use of shared tables."""
[docs]class DestinationNotFound(CFMEException): """Raised during navigation where the navigator destination is not found"""
[docs]class ItemNotFound(CFMEException): """Raised when an item is not found in general."""
[docs]class ManyEntitiesFound(CFMEException): """Raised when one or no items were expected but several/many items were obtained instead."""
[docs]class RoleNotFound(CFMEException): """Raised when Deployment role not found"""
[docs]class RBACOperationBlocked(CFMEException): """ Raised when a Role Based Access Control operation is blocked from execution due to invalid permissions. Also thrown when trying to perform actions CRUD operations on roles/groups/users that are CFME defaults """