volttron.platform package

Core package.

volttron.platform.build_vip_address_string(vip_root, serverkey, publickey, secretkey)[source]

Build a full vip address string based upon the passed arguments

All arguments are required to be non-None in order for the string to be created successfully.

:raises ValueError if one of the parameters is None.

volttron.platform.get_address()[source]

Return the VIP address of the platform If the VOLTTRON_VIP_ADDR environment variable is set, it used. Otherwise, it is derived from get_home().

volttron.platform.get_config_path() → str[source]

Returns the platforms main configuration file.

Returns:
volttron.platform.get_examples(agent_dir)[source]
volttron.platform.get_home()[source]

Return the home directory with user and variables expanded.

If the VOLTTRON_HOME environment variable is set, it used. Otherwise, the default value of ‘~/.volttron’ is used.

volttron.platform.get_ops(agent_dir=None)[source]
volttron.platform.get_platform_config()[source]
volttron.platform.get_services_core(agent_dir=None)[source]
volttron.platform.get_volttron_data()[source]
volttron.platform.get_volttron_root()[source]

Returns the root folder where the volttron code base resideds on disk.

Returns:absolute path to root folder
volttron.platform.is_instance_running(volttron_home=None)[source]
volttron.platform.is_rabbitmq_available()[source]
volttron.platform.set_home(home=None)[source]

Set the home directory with user and variables expanded.

If the home is sent in, it used. Otherwise, the default value of ‘~/.volttron’ is used.

volttron.platform.update_platform_config(values: dict) → None[source]

Subpackages

Submodules

volttron.platform.aip module

volttron.platform.async_ module

Run gevent Greenlets in their own threads.

Supports killing threads and executing callbacks from other threads.

class volttron.platform.async_.AsyncCall(hub=None)[source]

Bases: object

Send functions to another thread’s gevent hub for execution.

send(receiver, func, *args, **kwargs)[source]

Send a function to the hub to be called there.

All the arguments to this method are placed in a queue and the hub is signaled that a function is ready. When the hub switches to this handler, the functions are iterated over, each being called with its results sent to the receiver.

func is called with args and kwargs in the thread of the associated hub. If receiver is None, results are ignored and errors are printed when exceptions occur. Otherwise, receiver is called with the 2-tuple (exc_info, result). If an unhandled exception occurred, exc_info is the 3-tuple returned by sys.exc_info() and result is None. Otherwise exc_info is None and the result is func’s return value.

Note that receiver is called from the hub’s thread and may need to be injected into the thread of the receiver.

exception volttron.platform.async_.GreenletExit

Bases: BaseException

volttron.platform.auth module

class volttron.platform.auth.AuthEntry(domain=None, address=None, mechanism='CURVE', credentials=None, user_id=None, groups=None, roles=None, capabilities=None, comments=None, enabled=True, **kwargs)[source]

Bases: object

An authentication entry contains fields for authenticating and granting permissions to an agent that connects to the platform.

Parameters:
  • domain (str) – Name assigned to locally bound address
  • address (str) – Remote address of the agent
  • mechanism (str) – Authentication mechanism, valid options are ‘NULL’ (no authentication), ‘PLAIN’ (username/password), ‘CURVE’ (CurveMQ public/private keys)
  • credentials (str) – Value depends on mechanism parameter: None if mechanism is ‘NULL’; password if mechanism is ‘PLAIN’; encoded public key if mechanism is ‘CURVE’ (see volttron.platform.vip.socket.encode_key() for method to encode public key)
  • user_id (str) – Name to associate with agent (Note: this does not have to match the agent’s VIP identity)
  • capabilities (list) – Authorized capabilities for this agent
  • roles (list) – Authorized roles for this agent. (Role names map to a set of capabilities)
  • groups (list) – Authorized groups for this agent. (Group names map to a set of roles)
  • comments (str) – Comments to associate with entry
  • enabled (bool) – Entry will only be used if this value is True
  • kwargs – These extra arguments will be ignored
add_capabilities(capabilities)[source]
static build_capabilities_field(value)[source]
match(domain, address, mechanism, credentials)[source]
static valid_credentials(cred, mechanism='CURVE')[source]

Raises AuthEntryInvalid if credentials are invalid

static valid_mechanism(mechanism)[source]

Raises AuthEntryInvalid if mechanism is invalid

exception volttron.platform.auth.AuthEntryInvalid[source]

Bases: volttron.platform.auth.AuthException

Exception for invalid AuthEntry objects

exception volttron.platform.auth.AuthException[source]

Bases: Exception

General exception for any auth error

class volttron.platform.auth.AuthFile(auth_file=None)[source]

Bases: object

add(auth_entry, overwrite=False)[source]

Adds an AuthEntry to the auth file

Parameters:
  • auth_entry (AuthEntry) – authentication entry
  • overwrite (bool) – set to true to overwrite matching entries

Warning

If overwrite is set to False and if auth_entry matches an existing entry then this method will raise AuthFileEntryAlreadyExists

find_by_credentials(credentials)[source]

Find all entries that have the given credentials

Parameters:credentials (str) – The credentials to search for
Returns:list of entries
Return type:list
read()[source]

Gets the allowed entries, groups, and roles from the auth file.

Returns:tuple of allow-entries-list, groups-dict, roles-dict
Return type:tuple
read_allow_entries()[source]

Gets the allowed entries from the auth file.

Returns:list of allow-entries
Return type:list
remove_by_credentials(credentials)[source]

Removes entry from auth file by credential

Para credential:
 entries will this credential will be removed
remove_by_index(index)[source]

Removes entry from auth file by index

Parameters:index (int) – index of entry to remove

Warning

Calling with out-of-range index will raise AuthFileIndexError

remove_by_indices(indices)[source]

Removes entry from auth file by indices

Parameters:indices (list) – list of indicies of entries to remove

Warning

Calling with out-of-range index will raise AuthFileIndexError

set_groups(groups)[source]

Define the mapping of group names to role lists

Parameters:groups (dict) – dict where the keys are group names and the values are lists of capability names

Warning

Calling with invalid groups will raise ValueError

set_roles(roles)[source]

Define the mapping of role names to capability lists

Parameters:roles – dict where the keys are role names and the values are lists of group names

Warning

Calling with invalid roles will raise ValueError

update_by_index(auth_entry, index)[source]

Updates entry will given auth entry at given index

Parameters:
  • auth_entry (AuthEntry) – new authorization entry
  • index (int) – index of entry to update

Warning

Calling with out-of-range index will raise AuthFileIndexError

version
exception volttron.platform.auth.AuthFileEntryAlreadyExists(indicies, message=None)[source]

Bases: volttron.platform.auth.AuthFileIndexError

Exception if adding an entry that already exists

exception volttron.platform.auth.AuthFileIndexError(indices, message=None)[source]

Bases: volttron.platform.auth.AuthException, IndexError

Exception for invalid indices provided to AuthFile

exception volttron.platform.auth.AuthFileUserIdAlreadyExists(user_id, indicies, message=None)[source]

Bases: volttron.platform.auth.AuthFileEntryAlreadyExists

Exception if adding an entry that has a taken user_id

class volttron.platform.auth.AuthService(auth_file, protected_topics_file, setup_mode, aip, *args, **kwargs)[source]

Bases: volttron.platform.vip.agent.Agent

approve_authorization_failure(user_id)[source]

RPC method

Approves a previously failed authorization

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
authenticate(domain, address, mechanism, credentials)[source]
delete_authorization_failure(user_id)[source]

RPC method

Denies a previously failed authorization

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
deny_authorization_failure(user_id)[source]

RPC method

Denies a previously failed authorization

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
get_authorization_approved()[source]
get_authorization_denied()[source]
get_authorization_failures()[source]
get_authorizations(user_id)[source]

RPC method

Gets capabilities, groups, and roles for a given user.

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
Returns:tuple of capabiliy-list, group-list, role-list
Return type:tuple
get_capabilities(user_id)[source]

RPC method

Gets capabilities for a given user.

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
Returns:list of capabilities
Return type:list
get_groups(user_id)[source]

RPC method

Gets groups for a given user.

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
Returns:list of groups
Return type:list
get_protected_topics()[source]
get_roles(user_id)[source]

RPC method

Gets roles for a given user.

Parameters:user_id (str) – user id field from VOLTTRON Interconnect Protocol
Returns:list of roles
Return type:list
get_user_to_capabilities()[source]

RPC method

Gets a mapping of all users to their capabiliites.

Returns:mapping of users to capabilities
Return type:dict
read_auth_file()[source]
setup_zap(sender, **kwargs)[source]
stop_zap(sender, **kwargs)[source]
unbind_zap(sender, **kwargs)[source]
zap_loop(sender, **kwargs)[source]

The zap loop is the starting of the authentication process for the VOLTTRON zmq message bus. It talks directly with the low level socket so all responses must be byte like objects, in this case we are going to send zmq frames across the wire.

Parameters:
  • sender
  • kwargs
Returns:

class volttron.platform.auth.List[source]

Bases: list

match(value)[source]
class volttron.platform.auth.String[source]

Bases: str

match(value)[source]
volttron.platform.auth.dump_user(*args)[source]
volttron.platform.auth.isregex(obj)[source]
volttron.platform.auth.load_user(string)[source]

volttron.platform.certs module

exception volttron.platform.certs.CertError[source]

Bases: Exception

class volttron.platform.certs.CertWrapper[source]

Bases: object

This class is a wrapper around the building of certificates.

static get_cert_public_key(certfile)[source]
static get_private_key(keyfile)[source]
static load_cert(certfile)[source]
static load_key(keyfile)[source]
static make_self_signed_ca(ca_name, **kwargs)[source]

Creates a self signed certificate.

Parameters:
  • ca_name
  • kwargs
Returns:

static make_signed_cert(ca_cert, ca_key, common_name, **kwargs)[source]
class volttron.platform.certs.Certs(certificate_dir=None)[source]

Bases: object

A wrapper class around certificate creation, retrieval and verification.

append_external_certificate(certificate_str)[source]
approve_csr(common_name)[source]
ca_cert(public_bytes: bool = False)[source]

Get the X509 CA certificate. :return: the CA certificate of current volttron instance

ca_db_file(name)[source]

return path to the ca db file of the passed name. Name passed should not contain any file extension :param name: name of the file :return: Full path the <name>_cadb.json file :rtype: str

ca_exists()[source]

Returns true if the ca cert has been created already :return: True if CA cert exists, False otherwise

ca_serial_file(name)[source]

return the file in which ca stores the next serial number to use :param name: name of the ca :return: Full path the <name>-serial file :rtype: str

cert(name, remote=False, public_bytes: bool = False)[source]

Get the X509 certificate based upon the name :param public_bytes: :param name: name of the certificate to be loaded :param remote: determines correct path to search for the cert. :return: The certificate object by the given name :rtype: :class: x509._Certificate or byte PEM encoding

cert_exists(cert_name, remote=False)[source]

Verifies that the cert exists by filename. :param cert_name: name of the cert to look up :return: True if cert exists, False otherwise

cert_file(name, remote=False)[source]

Returns path to the certificate with passed name. .crt extension is added to the passed name be :param name: Name of the certificate file :param remote: Toggle between local and remote cert connections. :return: Full path the <name>.crt file :rtype: str

create_csr(fully_qualified_identity, remote_instance_name)[source]

Create a csr with name as the common name.

The key that is used to sign the csr is <instance_name>.name.

Parameters:
  • fully_qualified_identity
  • target_volttron
Returns:

create_requests_ca_bundle(agent_remote_cert_dir)[source]
create_root_ca(overwrite=True, valid_days=365, **kwargs)[source]

Create a CA certificate with the given args and save it with the given name :param overwrite: boolan to indicate if we should overwrite

any existing CA
Parameters:
  • valid_days – Number of days for which the certificate should be valid. Defaults to 365 days
  • kwargs

    Details about the certificate. Possible arguments:

    C - Country ST - State L - Location O - Organization OU - Organizational Unit CN - Common Name
Returns:

create_signed_cert_files(name, cert_type='client', ca_name=None, overwrite=True, valid_days=365, **kwargs)[source]

Create a new certificate and sign it with the volttron instance’s CA certificate. Save the created certificate and the private key of the certificate with the given name :param valid_days: number of days for which cert should be valid :param ca_name: name of the ca to sign this cert :param cert_type: client or server :param overwrite: boolean to denote if existing cert should be

overwritten
Parameters:
  • name – name used to save the newly created certificate and private key. Files are saved as <name>.crt and <name>.pem
  • kwargs

    dictionary object containing various details about who we are. Possible arguments:

    C - Country ST - State L - Location O - Organization OU - Organizational Unit CN - Common Name
Returns:

True if certificate creation was successful

csr_pending_file(name, target=None)[source]
delete_csr(common_name)[source]
delete_remote_cert(name)[source]
deny_csr(common_name)[source]
export_pkcs12(name, outfile)[source]
static get_admin_cert_names(instance_name)[source]

Returns the name of the instance ca certificate(root ca), instance server certificate and instance client (admin user) certificate :param instance_name: name of the volttron instance :return: names of volttron instance certs

get_all_cert_subjects()[source]
get_cert_from_csr(common_name)[source]
get_cert_public_key(name, remote=False)[source]

Retrieves a publickey from the passed named certificate.

Traditional openssl format begins as follows

b’—–BEGIN PUBLIC KEY—–’

Parameters:
  • name – full instance and identity of the key
  • remote
Returns:

serialized public key

get_cert_subject(name)[source]

Retrieves the subject details of a certificate :param name: name of the certificate :return: dictionary object with the format {

‘country’:value, ‘state’: value, ‘location’: value, ‘organization’: value, ‘organization-unit’: value, ‘common-name’:value

}

get_csr_common_name(data)[source]
get_csr_status(common_name)[source]
get_pending_certs()[source]
get_pending_csr_requests()[source]
get_pk_bytes(name)[source]

Serialize a private key in a traditional openssl manner to be able to use it with JWT and other technologies.

Traditional openssl format begins as follows

b’—–BEGIN RSA PRIVATE KEY—–’

Parameters:name – full instance and identity of the key
Returns:serialized private key
get_rejected_certs()[source]
load_csr(data)[source]

Loads a PEM X.509 CSR.

private_key_file(name)[source]

return path to the private key of the passed name. Name passed should not contain any file extension as .pem is prefixed :param name: name of the key file :return: Full path the <name>.pem file :rtype: str

remote_cert_bundle_file()[source]
remote_certs_file(name)[source]
save_agent_remote_info(directory, local_keyname, remote_cert_name, remote_cert, remote_ca_name, remote_ca_cert)[source]

Save the remote info file, remote certificates and remote ca to the proper place in the remote_certificate directory.

Parameters:
  • local_keyname – identity of the local agent connected to the local messagebux
  • remote_cert_name – identity of the dynamic agent connected to the remote message bus
  • remote_cert – certificate returned from the remote instance
  • remote_ca_name – name of the remote ca
  • remote_ca_cert – certificate of the remote ca certificate
save_cert(file_path)[source]
save_key(file_path)[source]
save_pending_csr_request(ip_addr, common_name, csr)[source]
save_remote_cert(name, cert_string, remote_cert_dir=None)[source]
sign_csr(csr_file)[source]
update_ca_db(cert, ca_name, serial)[source]

Update the CA db with details of the file that the ca signed. :param cert: cert that was signed by ca_name :param ca_name: name of the ca that signed the cert

static validate_key_pair(public_key_file, private_key_file)[source]

Given a public private key pair, validate the pair. :param public_key_file: path to public certificate file :param private_key_file: path to private key file :return True if the pair is valid, False otherwise

verify_cert(cert_name)[source]

Verify a the given cert is signed by the root ca. :param cert_name: The name of the certificate to be verified against the CA :return:

class volttron.platform.certs.Subject[source]

Bases: volttron.platform.certs.SubjectObj

static create_from_x509_subject(subject)[source]
volttron.platform.certs.get_passphrase(verify=True, prompt1='Enter passphrase:', prompt2='Verify passphrase:')[source]

Prompt passphrase from user and return it :param verify: If user should be prompt twice for verification :param prompt1: Prompt to be used for initial input :param prompt2: Prompt to used for verification :return: The passphrase entered by user :type verify: bool :type prompt1: str :type prompt2: str

volttron.platform.config module

volttron.platform.control module

volttron.platform.deployment module

volttron.platform.instance_setup module

volttron.platform.jsonapi module

volttron.platform.jsonapi.dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)[source]

Serialize obj as a JSON formatted stream to fp (a .write()-supporting file-like object).

If skipkeys is true then dict keys that are not basic types (str, int, float, bool, None) will be skipped instead of raising a TypeError.

If ensure_ascii is false, then the strings written to fp can contain non-ASCII characters if they appear in strings contained in obj. Otherwise, all such characters are escaped in JSON strings.

If check_circular is false, then the circular reference check for container types will be skipped and a circular reference will result in an OverflowError (or worse).

If allow_nan is false, then it will be a ValueError to serialize out of range float values (nan, inf, -inf) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN, Infinity, -Infinity).

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 an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

default(obj) is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.

If sort_keys is true (default: False), then the output of dictionaries will be sorted by key.

To use a custom JSONEncoder subclass (e.g. one that overrides the .default() method to serialize additional types), specify it with the cls kwarg; otherwise JSONEncoder is used.

volttron.platform.jsonapi.dumpb(data, **kwargs)[source]
volttron.platform.jsonapi.dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)[source]

Serialize obj to a JSON formatted str.

If skipkeys is true then dict keys that are not basic types (str, int, float, bool, None) will be skipped instead of raising a TypeError.

If ensure_ascii is false, then the return value can contain non-ASCII characters if they appear in strings contained in obj. Otherwise, all such characters are escaped in JSON strings.

If check_circular is false, then the circular reference check for container types will be skipped and a circular reference will result in an OverflowError (or worse).

If allow_nan is false, then it will be a ValueError to serialize out of range float values (nan, inf, -inf) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN, Infinity, -Infinity).

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 an (item_separator, key_separator) tuple. The default is (', ', ': ') if indent is None and (',', ': ') otherwise. To get the most compact JSON representation, you should specify (',', ':') to eliminate whitespace.

default(obj) is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.

If sort_keys is true (default: False), then the output of dictionaries will be sorted by key.

To use a custom JSONEncoder subclass (e.g. one that overrides the .default() method to serialize additional types), specify it with the cls kwarg; otherwise JSONEncoder is used.

volttron.platform.jsonapi.load(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)[source]

Deserialize fp (a .read()-supporting file-like object containing a JSON document) to a Python object.

object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).

object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.

To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.

volttron.platform.jsonapi.loadb(s, **kwargs)[source]
volttron.platform.jsonapi.loads(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)[source]

Deserialize s (a str, bytes or bytearray instance containing a JSON document) to a Python object.

object_hook is an optional function that will be called with the result of any object literal decode (a dict). The return value of object_hook will be used instead of the dict. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).

object_pairs_hook is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). If object_hook is also defined, the object_pairs_hook takes priority.

parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).

parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).

parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.

To use a custom JSONDecoder subclass, specify it with the cls kwarg; otherwise JSONDecoder is used.

The encoding argument is ignored and deprecated.

volttron.platform.jsonrpc module

Implementation of JSON-RPC 2.0 with support for bi-directional calls.

See http://www.jsonrpc.org/specification for the complete specification.

exception volttron.platform.jsonrpc.Error(code, message, data=None)[source]

Bases: Exception

Raised when a recoverable JSON-RPC protocol error occurs.

exception volttron.platform.jsonrpc.MethodNotFound(code, message, data=None)[source]

Bases: volttron.platform.jsonrpc.Error

Raised when remote method is not implemented.

exception volttron.platform.jsonrpc.RemoteError(message, **exc_info)[source]

Bases: Exception

Report the details of an error which occurred remotely.

Instances of this exception are usually created by exception_from_json(), which uses the ‘detail’ element of the JSON-RPC error for message, if it is set, otherwise the JSON-RPC error message. The exc_info argument is set from the ‘exception.py’ element associated with an error code of -32000 (UNHANDLED_EXCEPTION). Typical keys in exc_info are exc_type, exc_args, and exc_tb (if tracebacks are allowed) which are stringified versions of the tuple returned from sys.exc_info().

print_tb(file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>)[source]

Pretty print the traceback in the standard format.

class volttron.platform.jsonrpc.Dispatcher[source]

Bases: object

Parses and directs JSON-RPC 2.0 requests/responses.

Parses a JSON-RPC message conatained in a dictionary (JavaScript object) or a batch of messages (list of dictionaries) and dispatches them appropriately.

Subclasses must implement the serialize and deserialize methods with the JSON library of choice. The exception, result, error, method and batch handling methods should also be implemented.

batch(request, context=None)[source]

Context manager for batch requests.

Entered before processing a batch request and exited afterward.

batch_call(requests)[source]

Create and return a request for a batch of method calls.

requests is an iterator of lists or tuples with 4 items each: ident, method, args, kwargs. These are the same 4 arguments required by the call() method. The first (ident) element may be None to indicate a notification.

call(ident, method, args=None, kwargs=None)[source]

Create and return a request for a single method call.

deserialize(json_string)[source]

Unpack a JSON string and return Python object(s).

dispatch(message: (<class 'dict'>, <class 'list'>), context: str = None)[source]

Dispatch a JSON-RPC message and return a response or None.

error(response, ident, code, message, data=None, context=None)[source]

Called when an error resposne is received.

exception(response, ident, message, context=None)[source]

Called for response errors.

Typically called when a response, such as an error, does not contain all the necessary members and sending an error to the remote peer is not possible. Also called when serializing a response fails.

method(request, ident, name, args, kwargs, batch=None, context=None)[source]

Called to get make method call and return results.

request is the original JSON request (as dict). name is the name of the method requested. Only one of args or kwargs will contain parameters. If method is being executed as part of a batch request, batch will be the value returned from the batch() context manager.

This method should raise NotImplementedError() if the method is unimplemented. Otherwise, it should return the result of the method call or raise an exception. If the raised exception has a traceback attribute, which should be a string (if set), it will be sent back in the returned error. An exc_info attribute may also be set which must be a dictionary and will be used as the basis for the exception.py member of the returned error.

notify(method, args=None, kwargs=None)[source]

Create and return a request for a single notification.

result(response, ident, result, context=None)[source]

Called when a result response is received.

serialize(json_obj)[source]

Pack compatible Python objects into and return JSON string.

volttron.platform.jsonrpc.json_result(ident, result)[source]

Builds a JSON-RPC response object (dictionary).

volttron.platform.jsonrpc.json_validate_request(jsonrequest)[source]
volttron.platform.jsonrpc.json_validate_response(jsonresponse)[source]

volttron.platform.keystore module

Module for storing local public and secret keys and remote public keys

class volttron.platform.keystore.BaseJSONStore(filename, permissions=384)[source]

Bases: object

JSON-file-backed store for dictionaries

load()[source]
remove(key)[source]
store(data)[source]
update(new_data)[source]
class volttron.platform.keystore.KeyStore(filename=None, encoded_public=None, encoded_secret=None)[source]

Bases: volttron.platform.keystore.BaseJSONStore

Handle generation, storage, and retrival of CURVE key pairs

generate()[source]

Generate and store new key pair

static generate_keypair_dict()[source]

Generate and return new keypair as dictionary

static get_agent_keystore_path(identity=None)[source]
static get_default_path()[source]
isvalid()[source]

Check if key pair is valid

public

Return encoded public key

secret

Return encoded secret key

class volttron.platform.keystore.KnownHostsStore(filename=None)[source]

Bases: volttron.platform.keystore.BaseJSONStore

Handle storage and retrival of known hosts

add(addr, server_key)[source]
serverkey(addr)[source]

volttron.platform.main module

volttron.platform.packages module

volttron.platform.packaging module

volttron.platform.resmon module

volttron.platform.scheduling module

Schedule generators.

volttron.platform.scheduling.cron(cron_string, start=None, stop=None, second=0)[source]

Return a schedule generator from a cron-style string.

cron_string is a cron-style time expression consisting of five whitespace-separated fields explained in further detail below. start and stop are used to bound the schedule and can be None, datetime.datetime or datetime.timedelta objects or numeric values, such as is returned by time.time(). If start is None, the current time is used. If it is a timedelta, it will be added to the current time. If stop is None, cron will generate values infinitely. If it is a timedelta, the end time is the start time plus stop. Each iteration yields a datetime.datetime object. Since the smallest cron unit is a minute, second may be passed in to offset the time within the minute.

The following description of the cron fields is taken from the crontab(5) man page (with slight modifications).

The time and date fields are:

field allowed values —– ————– minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sunday, or use names)

A field may contain an asterisk (*), which always stands for “first-last”.

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ‘hours’ entry specifies execution at hours 8, 9, 10, and 11. If the range start or end value is left off, the first or last value will be used. For example, -8 for an ‘hours’ entry is equivalent to 0-8, 20- for a ‘days of month’ entry is equivalent to 20-31, and - for a ‘months’ entry is equivalent to 1-12.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: “1,2,5,9”, “0-4,8-12”.

Step values can be used in conjunction with ranges. Following a range with “/<number>” specifies skips of the number’s value through the range. For example, “0-23/2” can be used in the ‘hours’ field to specify every other hour. Step values are also permitted after an asterisk, “*/2” in the ‘hours’ field is equivalent to “0-23/2”.

Names can also be used for the ‘month’ and ‘day of week’ fields. Use at least the first three letters of the particular day or month (case does not matter).

Note: The day can be specified in the following two fields: ‘day of month’, and ‘day of week’. If both fields are restricted (i.e., do not contain the “*” character), then both are used to compute date/time values. For example, “30 4 1,15 * 5” is interpreted as “4:30 am on the 1st and 15th of each month, plus every Friday.”

volttron.platform.scheduling.periodic(period, start=None, stop=None)[source]

Generate periodic datetime objects.

Yields datetime objects increasing by the given period, which can be of type int, long, float, or datetime.timedelta. start and stop are used to bound the schedule and can be None, datetime.datetime or datetime.timedelta objects or numeric values, such as is returned by time.time(). If start is None, the current time is used. If it is a timedelta, it will be added to the current time. If stop is None, cron will generate values infinitely. If it is a timedelta, the end time is the start time plus stop. Each iteration yields a datetime.datetime object.

volttron.platform.store module

class volttron.platform.store.ConfigStoreService(*args, **kwargs)[source]

Bases: volttron.platform.vip.agent.Agent

delete(identity, config_name, trigger_callback=False, send_update=True)[source]
delete_config(config_name, trigger_callback=False, send_update=True)[source]

Called by an Agent to delete a configuration.

get_configs()[source]

Called by an Agent at startup to trigger initial configuration state push.

manage_delete_config(identity, config_name)[source]
manage_delete_store(identity)[source]
manage_get(identity, config_name, raw=True)[source]
manage_get_metadata(identity, config_name)[source]
manage_list_configs(identity)[source]
manage_list_stores()[source]
manage_store(identity, config_name, raw_contents, config_type='raw')[source]
set_config(config_name, contents, trigger_callback=False, send_update=True)[source]
store_config(identity, config_name, contents, trigger_callback=False, send_update=True)[source]
volttron.platform.store.process_raw_config(config_string, config_type='raw')[source]

Parses raw config string into python objects

volttron.platform.store.process_store(identity, store)[source]

Parses raw store data and returns contents. Called at startup to initialize the parsed version of the store.

volttron.platform.storeutils module

volttron.platform.storeutils.check_for_recursion(new_config_name, new_config, existing_configs)[source]

Returns a set of config files referenced in this configuration

volttron.platform.storeutils.strip_config_name(config_name)[source]

volttron.platform.vpm module