cfme.utils.providers module¶
Helper functions related to the creation, listing, filtering and destruction of providers
The list_providers function in this module depend on a (by default global) dict of filters. If you are writing tests or fixtures, you want to depend on this function as a de facto gateway.
The rest of the functions, such as get_mgmt, get_crud, get_provider_keys etc ignore this global dict and will provide you with whatever you ask for with no limitations.
The main clue to know what is limited by the filters and what isn’t is the ‘filters’ parameter.
-
class
cfme.utils.providers.
ProviderFilter
(keys=None, classes=None, required_fields=None, required_tags=None, required_flags=None, restrict_version=False, inverted=False, conjunctive=True)[source]¶ Bases:
object
Filter used to obtain only providers matching given requirements
Parameters: - keys – List of acceptable provider keys, all if None
- categories – List of acceptable provider categories, all if None
- types – List of acceptable provider types, all if None
- required_fields – List of required fields, see
providers_by_class()
- restrict_version – Checks provider version in yamls if True
- required_tags – List of tags that must be set in yamls
- inverted – Inclusive if False, exclusive otherwise
- conjunctive – If true, all subfilters are applied and all must match (default) If false (disjunctive), at least one of the subfilters must match
-
__call__
(provider)[source]¶ Applies this filter on a given provider
Usage:
pf = ProviderFilter('cloud_infra', categories=['cloud', 'infra']) providers = list_providers([pf]) pf2 = ProviderFilter( classes=[GCEProvider, EC2Provider], required_fields=['small_template']) provider_keys = [prov.key for prov in list_providers([pf, pf2])] ^ this will list keys of all GCE and EC2 providers ...or... pf = ProviderFilter(required_tags=['openstack', 'complete']) pf_inverted = ProviderFilter(required_tags=['disabled'], inverted=True) providers = list_providers([pf, pf_inverted]) ^ this will return providers that have both the "openstack" and "complete" tags set and at the same time don't have the "disabled" tag ...or... pf = ProviderFilter(keys=['rhevm34'], class=CloudProvider, conjunctive=False) providers = list_providers([pf]) ^ this will list all providers that either have the 'rhevm34' key or are an instance of the CloudProvider class and therefore are a cloud provider
Returns: True if provider passed all checks and was not filtered out, False otherwise. The result is opposite if the ‘inverted’ attribute is set to True.
-
exception
cfme.utils.providers.
UnknownProvider
(provider_key, *args, **kwargs)[source]¶ Bases:
exceptions.Exception
-
cfme.utils.providers.
get_crud
(provider_key, appliance=None)[source]¶ Creates a Provider object given a management_system key in cfme_data.
Usage:
get_crud('ec2east')
Returns: A Provider object that has methods that operate on CFME
-
cfme.utils.providers.
get_crud_by_name
(provider_name, appliance=None)[source]¶ Creates a Provider object given a management_system name in cfme_data.
Usage:
get_crud_by_name('My RHEV 3.6 Provider')
Returns: A Provider object that has methods that operate on CFME
-
cfme.utils.providers.
get_mgmt
(provider_key, providers=None, credentials=None)[source]¶ Provides a
wrapanapi
object, based on the request.Parameters: - provider_key – The name of a provider, as supplied in the yaml configuration files. You can also use the dictionary if you want to pass the provider data directly.
- providers – A set of data in the same format as the
management_systems
section in the configuration yamls. IfNone
then the configuration is loaded from the default locations. Expects a dict. - credentials – A set of credentials in the same format as the
credentials
yamls files. IfNone
then credentials are loaded from the default locations. Expects a dict.
- Return: A provider instance of the appropriate
wrapanapi.WrapanapiAPIBase
- subclass
-
cfme.utils.providers.
list_provider_keys
(provider_type=None)[source]¶ Lists provider keys from conf (yamls)
Parameters: provider_type – Optional filtering by ‘type’ string (from yaml); disabled by default Note: Doesn’t require the framework to be pointed at an appliance to succeed.
Returns: List of provider keys (strings).
-
cfme.utils.providers.
list_providers
(filters=None, use_global_filters=True, appliance=None)[source]¶ Lists provider crud objects, global filter optional
Parameters: - filters – List if
ProviderFilter
or None - use_global_filters – Will apply global filters as well if True, will not otherwise
- appliance – Optional
utils.appliance.IPAppliance
to be passed to provider CRUD objects
Note: Requires the framework to be pointed at an appliance to succeed.
Returns: List of provider crud objects.
- filters – List if
-
cfme.utils.providers.
list_providers_by_class
(prov_class, use_global_filters=True, appliance=None)[source]¶ Lists provider crud objects of a specific class (or its subclasses), global filter optional
Parameters: - prov_class – Provider class to apply for filtering
- use_global_filters – See
list_providers()
- appliance – Optional
utils.appliance.IPAppliance
to be passed to provider CRUD objects
Note: Requires the framework to be pointed at an appliance to succeed.
Returns: List of provider crud objects.