provider Package

provider Package

aggregator Module

Aggregator Api Provider

class vmware.vapi.provider.aggregator.AggregatorProvider[source]

Bases: vmware.vapi.core.ApiProvider

AggregatorProvider is an aggregating implementation of the ApiProvider interface. It aggregates a bunch of ApiProvider instances and expose it.

get_providers()[source]

Return the connection information of ApiProviders registered with the AggregatorProvider

Return type:list of tuple of (str, str, str)
Returns:Tuple containing rpc protocol, msg protocol and uri
static get_service_identifiers(api_provider)[source]

Invokes introspection service list on the Api Provider and retrieves the list of services

Parameters:api_provider (vmware.vapi.core.ApiProvider) – ApiProvider instance to be used for retrieving service identifiers
Return type:list of str
Returns:List of service identifiers
Raise :Exception: if service identifiers could not be retrieved
invoke(service_id, operation_id, input_value, ctx)[source]

Invokes the specified method using the execution context and the input provided

Parameters:
Return type:

vmware.vapi.core.MethodResult

Returns:

Result of the method invocation

register_by_properties(properties)[source]

Register a provider using a properties dictionary

Parameters:properties (dict) – Properties dictionary
register_provider(provider, name, rpc, msg, addr)[source]

Register a ApiProvider with the AggregatorProvider

Parameters:
  • provider (vmware.vapi.core.ApiProvider) – ApiProvider to be registered
  • name (str) – Provider name
  • rpc (str) – RPC Protocol
  • msg (str) – Msg Protocol
  • addr (str) – URI of the ApiProvider
register_service(service_id, provider)[source]

Register an service with the AggregatorProvider

Parameters:
  • service_id (str) – Service identifier
  • provider (vmware.vapi.core.ApiProvider) – ApiProvider impl. for the specified service identifier
reload_providers()[source]

Reload all the providers in the AggregatorProvider

unregister_provider(provider_name)[source]

Unregister a provider from AggregatorProvider

Parameters:provider_name (str) – Provider to be unregistered
unregister_provider_by_name(provider_name)[source]

Unregister a provider from AggregatorProvider

Parameters:provider_name (str) – Provider to be unregistered
unregister_service(service_id)[source]

Unregister an service from AggregatorProvider

Parameters:service_id (str) – service to be unregistered
vmware.vapi.provider.aggregator.get_provider()[source]

Returns the singleton AggregatorProvider instance

Return type:vmware.vapi.provider.AggregatorProvider
Returns:AggregatorProvider instance

authentication Module

Authentication API Provider filter

class vmware.vapi.provider.authentication.AuthenticationFilter(next_provider=None)[source]

Bases: vmware.vapi.provider.filter.ApiProviderFilter

AuthenticationFilter in API Provider chain enforces the authentication schemes specified in the authentication metadata file

Initialize AuthenticationFilter

Parameters:next_provider (vmware.vapi.core.ApiProvider or None) – API Provider to invoke the requests
invoke(service_id, operation_id, input_value, ctx)[source]

Invoke an API request

Parameters:
Return type:

vmware.vapi.core.MethodResult

Returns:

Result of the method invocation

vmware.vapi.provider.authentication.get_provider()[source]

Returns the singleton AuthenticationFilter instance

Return type:vmware.vapi.provider.authentication.AuthenticationFilter
Returns:AuthenticationFilter instance
vmware.vapi.provider.authentication.load_metadata()[source]

Load the metadata from the json file

Return type:dict
Returns:Authentication metadata

filter Module

API Provider filter

class vmware.vapi.provider.filter.ApiProviderFilter(next_provider=None, errors_to_augment=None)[source]

Bases: vmware.vapi.core.ApiProvider

ApiProviderFilter is a base class for all ApiProvider filters. This handles all the common methods and also takes care of augmenting errors reported by an ApiProvider filter.

Variables:next_provider – Next API Provider in the chain

Initialize ApiProviderFilter

Parameters:
invoke(service_id, operation_id, input_value, ctx)[source]

Invoke an API request. Derived classes of ApiProviderFilter should call this method to invoke the request. This can be done by: ApiProviderFilter.invoke(self, ctx, method_id, input_value).

This method calls the next API Provider. If the request is made to “get” operation of vAPI Operation Introspection service, errors are augmented to the method result.

Parameters:
Return type:

vmware.vapi.core.MethodResult

Returns:

Result of the method invocation

interposer Module

introspection Module

Introspection services

class vmware.vapi.provider.introspection.AggregatorIntrospector(name, local_provider)[source]

Bases: vmware.vapi.provider.introspection.ApiProviderIntrospector

Specialization of vmware.vapi.provider.introspection.ApiProviderIntrospector that uses data available in Aggregator Provider to process the Introspection service API requests

Initialize AggregatorIntrospector

Parameters:
  • name (str) – Name of the provider
  • local_provider (vmware.vapi.core.ApiProvider) – LocalProvider that will be used to serve introspection requests for introspection services itself.
add_service(service_id, api_provider)[source]

Add a new service to the introspector

Parameters:
get_checksum()[source]
get_operation_info(service_id, operation_id)[source]
get_operations(service_id)[source]
get_service_info(service_id)[source]
get_services()[source]
remove_service(service_id)[source]

Add a new service to the introspector

Parameters:service_id (str) – Service identifier
class vmware.vapi.provider.introspection.ApiProviderIntrospector(name)[source]

Bases: object

Abstract class for fetching introspection information

Initialize ApiProviderIntrospector

Parameters:name (str) – Name of the provider
get_checksum()[source]

Returns the checksum of the API information available

Return type:str
Returns:Checksum of the API information available
get_introspection_services()[source]

Returns the list of introspection services

Return type:list of vmware.vapi.core.ApiInterface
Returns:list of introspection services
get_operation_info(service_id, operation_id)[source]

Get the operation information

Parameters:
  • service_id (str) – Service identifier
  • operation_id (str) – Operation identifier
Return type:

vmware.vapi.core.MethodResult

Returns:

Result that contains operation information. The DataValue in the output represents :class:’com.vmware.vapi.std.introspection.Operation.Info’

get_operations(service_id)[source]

Get the list of available operations for a particular service

Parameters:service_id (str) – Service identifier
Return type:vmware.vapi.core.MethodResult
Returns:Result that contains list of available operations. The DataValue in the output is list of StringValues containing the operation names.
get_service_info(service_id)[source]

Get information about a particular service

Parameters:service_id (str) – Service identifier
Return type:vmware.vapi.core.MethodResult
Returns:Introspection service info. The DataValue in the output represents :class:’com.vmware.vapi.std.introspection.Service.Info’
get_services()[source]

Returns the list of available services

Return type:list of str
Returns:List of available services
class vmware.vapi.provider.introspection.IntrospectionBaseApiInterface(iface_id, method_defs, methods)[source]

Bases: vmware.vapi.core.ApiInterface

Helper base class for all Introspection VMODL2 dynamic services

Initialize the Api Interface instance

Parameters:
  • iface_id (vmware.vapi.core.InterfaceIdentifier) – Interface identifier
  • method_defs (dict) – Dictionary of method identifiers to method definitions
  • methods (dict) – Dictionary of method identifiers to method references
get_definition()[source]

Returns interface definition

Return type:InterfaceDefinition
Returns:Interface definition
get_identifier()[source]

Returns interface identifier

Return type:InterfaceIdentifier
Returns:Interface identifier
get_method_definition(method_id)[source]

Returns the method definition

Return type:MethodDefinition
Returns:Method definition
invoke(ctx, method_id, input_value)[source]

Invokes the specified method using the execution context and the input provided

Parameters:
  • ctx (ExecutionContext) – Execution context for this method
  • method_id (MethodIdentifier) – Method identifier
  • input_value (vmware.vapi.data.value.StructValue) – Method input parameters
Return type:

MethodResult

Returns:

Result of the method invocation

class vmware.vapi.provider.introspection.LocalProviderIntrospector(name)[source]

Bases: vmware.vapi.provider.introspection.ApiProviderIntrospector

Specialization of vmware.vapi.provider.introspection.ApiProviderIntrospector that uses data available in Local Provider to process the Introspection service API requests

Initialize LocalProviderIntrospector

Parameters:name (str) – Name of the provider
add_service(service_id, api_interface)[source]

Add a new service to the introspector

Parameters:
get_checksum()[source]
get_operation_info(service_id, operation_id)[source]
get_operations(service_id)[source]
get_service_info(service_id)[source]
get_services()[source]
class vmware.vapi.provider.introspection.OperationApiInterface(name, introspection_adapter)[source]

Bases: vmware.vapi.provider.introspection.IntrospectionBaseApiInterface

This service exposes a list of operations to retrieve information about the operations present in a vAPI service

Initialize OperationApiInterface

Parameters:
class vmware.vapi.provider.introspection.ProviderApiInterface(name, introspection_adapter)[source]

Bases: vmware.vapi.provider.introspection.IntrospectionBaseApiInterface

This service provides operations to retrieve information of a vAPI Provider. A provider represents a vAPI endpoint that is exposing a collection of vAPI services.

Initialize ProviderApiInterface

Parameters:
class vmware.vapi.provider.introspection.ServiceApiInterface(name, introspection_adapter)[source]

Bases: vmware.vapi.provider.introspection.IntrospectionBaseApiInterface

This service exposes operations to retrieve information about the services exposed by a vAPI endpoint

Initialize ServiceApiInterface

Parameters:
vmware.vapi.provider.introspection.get_checksum(api_services)[source]

Returns the checksum of services registered with LocalProvider

Parameters:api_services (dict) – Dictionary of all the services registered with local provider Key is vmware.vapi.core.InterfaceIdentifier and value is vmware.vapi.core.ApiInterface
Return type:str
Returns:checksum of the service information
vmware.vapi.provider.introspection.register_instance()[source]

Services to be registered with LocalProvider

Return type:list of vmware.vapi.core.ApiInterface
Returns:List of services to be registered with LocalProvider

lib Module

Utility library for Provider modules

vmware.vapi.provider.lib.augment_method_def_with_errors(method_def, errors)[source]

Add errors reported by this ApiProviderFilter to a method definition. This method clones the input method definition and appends errors. It does not modify the parameter.

Parameters:
Return type:

vmware.vapi.core.MethodDefinition

Returns:

Method definition after augmenting the errors

vmware.vapi.provider.lib.augment_method_result_with_errors(service_id, operation_id, method_result, errors_to_augment)[source]

Returns a new method result that is identical to method_result except that the errors_definition field in the output (which is of type Operation.Info from Introspection service) contains the errors from the Info structure in method_result plus the errors in errors_to_augment. This code will be executed only for “get” operation in vAPI Operation Introspection service.

Parameters:
  • service_id (str) – Service identifier
  • operation_id (str) – Operation identifier
  • method_result (vmware.vapi.core.MethodResult) – Operation result
  • errors_to_augment (list of vmware.vapi.data.value.StructValue) – Errors to augment. These are struct values of type com.vmware.vapi.std.introspection.Operation.DataDefinition whose type field has the value ERROR to the DataDefinition type in Introspection service IDL.
Return type:

vmware.vapi.data.value.DataValue

Returns:

Output data value

local Module

Local Api Provider

class vmware.vapi.provider.local.LocalProvider(load_introspection=True)[source]

Bases: vmware.vapi.core.ApiProvider

LocalProvider is a local in-process implementation of the ApiProvider interface

Initialize LocalProvider

Parameters:load_introspection (bool) – If true, load introspection services
add_interface(ifaces)[source]

Register an interface with LocalProvider

Parameters:ifaces (list of vmware.vapi.core.ApiInterface) – Interfaces to be registered
invoke(service_id, operation_id, input_value, ctx)[source]
register_by_properties(properties)[source]

Register set of interfaces using properties dictionary

Parameters:properties (ConfigParser.SafeConfigParser) – Configuration for this vAPI provider
vmware.vapi.provider.local.get_provider()[source]

Returns the singleton LocalProvider instance

Return type:LocalProvider
Returns:LocalProvider instance

services Module

Helper classes for aggregator services

class vmware.vapi.provider.services.Stats[source]

Bases: object

Class that provides stats hooks to ApiAggregator

Initialize StatsMixin

decrement_provider_count()[source]

Decrement the number of providers

get()[source]

Get the stats information

Return type:tuple(:class:`time, long)`
Returns:Return the init time and list of providers
increment_provider_count()[source]

Increment the number of providers