vAPI configuration addr url parser
Get the scheme from the url (as described in http://www.rabbitmq.com/uri-spec.html)
Parameters: | url (str) – The addr url to parse |
---|---|
Return type: | str |
Returns: | url scheme |
Parse addr url (as described in http://www.rabbitmq.com/uri-spec.html) Note: This fn make no attempt to unescape the url, just like the urlparse
Parameters: | url (str) – The addr url to parse |
---|---|
Return type: | tuple of (scheme, host, port, user, password, path, query_dict) where scheme: url scheme host: hostname port: query_dict is a dictionary of (name, [values]) |
Returns: | Parsed addr url |
vAPI Connection factory
Check if name is a file and exists
:type str :param file name
Create a connection to the vAPI Provider using the specified arguments
Parameters: |
|
---|---|
Return type: | |
Returns: | Connection to the vAPI provider |
Create a connection that uses ‘requests’ library for http(s) connections to a vAPI Provider.
Parameters: |
|
---|---|
Return type: | |
Returns: | Connection to the vAPI provider |
Create a connection that uses SAML Hok based authentication using ‘requests’ library to connect to a vAPI Provider.
Parameters: |
|
---|---|
Return type: | |
Returns: | Connection to the vAPI provider |
Create a connection that uses SAML Hok based authentication to connect to a vAPI Provider
Parameters: |
|
---|---|
Return type: | |
Returns: | Connection to the vAPI provider |
String Constants used in vAPI runtime
Bases: object
String constants used in introsection service
Factory methods for creating application context
Create a default application context. The created context will only have opId.
Return type: | vmware.vapi.core.ApplicationContext |
---|---|
Returns: | Newly created application context |
Convenience methods for converting variable names
Bases: object
Convenience methods for converting variable names
Converts the argument from vAPI canonical format to PEP8 compliant parameter or attribute name
Parameters: | name (str) – The string to be converted |
---|---|
Return type: | str |
Returns: | The converted string |
Capitalize the first letter of the name
Parameters: | name (str) – name to be converted |
---|---|
Return type: | str |
Returns: | name with first letter capitalized |
Convert from CapWords to lower_case_with_underscore format
Parameters: | name (str) – name in CapWords format |
---|---|
Return type: | str |
Returns: | name in lower_case_with_underscore format |
Convert from mixedCase to lower_case_with_underscore format
Parameters: | name (str) – name in mixedCase format |
---|---|
Return type: | str |
Returns: | name in lower_case_with_underscore format |
Converts the argument into a name that conforms to PEP8 standard. i.e. lower_case_with_underscore
Parameters: | name (str) – The string to be converted |
---|---|
Return type: | str |
Returns: | The converted string |
Uncapitalize the first letter of the name
Parameters: | name (str) – name to be converted |
---|---|
Return type: | str |
Returns: | name with first letter uncapitalized |
Convert from lower_case_with_underscore to CapWords format
Parameters: | name (str) – name in lower_case_with_underscore |
---|---|
Return type: | str |
Returns: | name in CapWords |
Fingerprint related functions
JSON encoder for double values
Bases: json.encoder.JSONEncoder
Class that adds capability of encoding decimal in JSON
Constructor for JSONEncoder, with sensible defaults.
If skipkeys is False, then it is a TypeError to attempt encoding of keys that are not str, int, long, float or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is True, the output is guaranteed to be str objects with all incoming unicode characters escaped. If ensure_ascii is false, the output will be unicode object.
If check_circular is True, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.
If allow_nan is True, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is True, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be a (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘). To get the most compact JSON representation you should specify (‘,’, ‘:’) to eliminate whitespace.
If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.
If encoding is not None, then all input strings will be transformed into unicode using that encoding prior to JSON-encoding. The default is UTF-8.
Canonicalize double based on XML schema double canonical format
The exponent must be indicated by “E”. Leading zeroes and the preceding optional “+” sign are prohibited in the exponent. If the exponent is zero, it must be indicated by “E0”. For the mantissa, the preceding optional “+” sign is prohibited and the decimal point is required. Leading and trailing zeroes are prohibited subject to the following: number representations must be normalized such that there is a single digit which is non-zero to the left of the decimal point and at least a single digit to the right of the decimal point unless the value being represented is zero. The canonical representation for zero is 0.0E0 http://www.w3.org/TR/xmlschema-2/#double
Parameters: | o (decimal.Decimal) – Decimal object to be canonicalized |
---|---|
Return type: | str |
Returns: | Canonical string representation of the decimal |
Convenience methods for dynamic loading
Dynamically import a module and get the specified module attribute
Parameters: | constructor (str) – Fully qualified module attribute |
---|---|
Return type: | object |
Returns: | Python object |
Import multiple class names provided in the config file
Parameters: |
|
---|---|
Return type: | list of str |
Returns: | List of class references |
Convenience methods for loading the profiler
Mock decorator that is used when the PROFILER is not set
Mock decorator that is used when the PROFILER is not set
SSL Context factories
Bases: object
Context factory base class. This class should be used to set the SSL options
Bases: vmware.vapi.lib.ssl.ClientContextFactory
Default SSL context class. This chooses some default options for SSL context. Clients can retrieve the context.
To modify the context and set some options directly. Create a class like below and set the options. Pass this to the get_connector function
Initialize DefaultClientContextFactory
Parameters: |
|
---|
Bases: vmware.vapi.lib.ssl.DefaultClientContextFactory
Unverified SSL context class. This class retrieves an unverified SSL Context with other options from the DefaultClientContext
Helper functions for manipulating vAPI runtime objects corresponding to the standard types (e.g. LocalizableMessage) and errors
Create an error result for a “standard” error from a cause ErrorValue and an list of messages.
The list of message will be prepended to the messages from the cause (if any).
Parameters: |
|
---|---|
Return type: | |
Returns: | ErrorValue containing a single message |
Create an error result for a “standard” error
Parameters: |
|
---|---|
Return type: | |
Returns: | ErrorValue containing a single message |
Create an error result for a “standard” error
Parameters: |
|
---|---|
Return type: | |
Returns: | ErrorValue containing a single message |
Internal function to create a “standard” ErrorDefinition for use only by the vAPI runtime. :type name: str :param args: Fully qualified name of the standard error type :rtype: vmware.vapi.data.definition.ErrorDefinition :return: ErrorDefinition containing a single message field
This module is YATP (Yet another thread pool)
Bases: object
Thread pool
Thread pool constructor
Params min_workers: | |
---|---|
Min number of worker threads | |
Params max_workers: | |
Max number of worker threads | |
Params idle_timeout: | |
Worker threads idle timeout | |
Params logger: | logger to use. Default to stdout |
Generator to return work in normalize form: (fn, args, kwargs)
Parameters: | works (iteratable of fn / (fn, args) / (fn, args, kwargs)) – An iteratable of possible functor form |
---|---|
Return type: | tuple of (fn, args, kwargs) |
Returns: | A normalize tuple of (functor, args, kwargs) |
Queue work
Returns a work_item when work is queued to work queue The work will start when a ready worker is available to process the work User could call {work_item}.join() to wait for the work item to finish
Parameters: |
|
---|---|
Return type: | |
Returns: | work item when work is queued to work queue |
Queue a work and wait until the work is completed / error out
Parameters: |
|
---|---|
Return type: | tuple of (bool, object) or (bool, Exception) |
Returns: | (True, return val) / (False, exception) when work is done |
Queue a brunch of works and wait until all works are completed / error out
Parameters: | works (iteratable of fn / (fn, args) / (fn, args, kwargs)) – An iteratable of possible functor form |
---|---|
Return type: | list of {tuple} of bool,:class:object or bool,:class:Exception |
Returns: | A list of (True, return val) / (False, exception) when all works done |
Visitor helper class
Workers thread pool
get workers pool
Parameters: | pool_tag (str) – workers pool tag |
---|---|
Return type: | vmware.vapi.lib.thread_pool.ThreadPool |
Returns: | workers pool |