volttron.platform package¶
Core package.
-
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_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_volttron_root()[source]¶ Returns the root folder where the volttron code base resideds on disk.
Returns: absolute path to root folder
-
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.
Subpackages¶
- volttron.platform.agent package
- Subpackages
- volttron.platform.agent.base_market_agent package
- Submodules
- volttron.platform.agent.base_market_agent.buy_sell module
- volttron.platform.agent.base_market_agent.error_codes module
- volttron.platform.agent.base_market_agent.market_registration module
- volttron.platform.agent.base_market_agent.offer module
- volttron.platform.agent.base_market_agent.point module
- volttron.platform.agent.base_market_agent.poly_line module
- volttron.platform.agent.base_market_agent.poly_line_factory module
- volttron.platform.agent.base_market_agent.registration_manager module
- volttron.platform.agent.base_market_agent.rpc_proxy module
- volttron.platform.agent.base_market_agent package
- Submodules
- volttron.platform.agent.bacnet_proxy_reader module
- volttron.platform.agent.base module
- volttron.platform.agent.base_aggregate_historian module
- volttron.platform.agent.base_historian module
- volttron.platform.agent.base_tagging module
- volttron.platform.agent.base_weather module
- volttron.platform.agent.cron module
- volttron.platform.agent.driven module
- volttron.platform.agent.exit_codes module
- volttron.platform.agent.green module
- volttron.platform.agent.json module
- volttron.platform.agent.known_identities module
- volttron.platform.agent.matching module
- volttron.platform.agent.math_utils module
- volttron.platform.agent.multithreading module
- volttron.platform.agent.sched module
- volttron.platform.agent.utils module
- volttron.platform.agent.web module
- Subpackages
- volttron.platform.dbutils package
- Submodules
- volttron.platform.dbutils.basedb module
- volttron.platform.dbutils.crateutils module
- volttron.platform.dbutils.influxdbutils module
- volttron.platform.dbutils.mongoutils module
- volttron.platform.dbutils.mysqlfuncts module
- volttron.platform.dbutils.postgresqlfuncts module
- volttron.platform.dbutils.redshiftfuncts module
- volttron.platform.dbutils.sqlitefuncts module
- volttron.platform.dbutils.sqlutils module
- volttron.platform.lib package
- volttron.platform.messaging package
- volttron.platform.vip package
- Subpackages
- volttron.platform.vip.agent package
- Subpackages
- volttron.platform.vip.agent.subsystems package
- Submodules
- volttron.platform.vip.agent.subsystems.auth module
- volttron.platform.vip.agent.subsystems.base module
- volttron.platform.vip.agent.subsystems.channel module
- volttron.platform.vip.agent.subsystems.configstore module
- volttron.platform.vip.agent.subsystems.health module
- volttron.platform.vip.agent.subsystems.heartbeat module
- volttron.platform.vip.agent.subsystems.hello module
- volttron.platform.vip.agent.subsystems.peerlist module
- volttron.platform.vip.agent.subsystems.ping module
- volttron.platform.vip.agent.subsystems.pubsub module
- volttron.platform.vip.agent.subsystems.query module
- volttron.platform.vip.agent.subsystems.rmq_pubsub module
- volttron.platform.vip.agent.subsystems.rpc module
- volttron.platform.vip.agent.subsystems.volttronfncs module
- volttron.platform.vip.agent.subsystems.web module
- volttron.platform.vip.agent.subsystems package
- Submodules
- volttron.platform.vip.agent.compat module
- volttron.platform.vip.agent.connection module
- volttron.platform.vip.agent.core module
- volttron.platform.vip.agent.decorators module
- volttron.platform.vip.agent.dispatch module
- volttron.platform.vip.agent.errors module
- volttron.platform.vip.agent.example module
- volttron.platform.vip.agent.results module
- volttron.platform.vip.agent.utils module
- Subpackages
- volttron.platform.vip.agent package
- Submodules
- volttron.platform.vip.externalrpcservice module
- volttron.platform.vip.green module
- volttron.platform.vip.keydiscovery module
- volttron.platform.vip.proxy_zmq_router module
- volttron.platform.vip.pubsubservice module
- volttron.platform.vip.pubsubwrapper module
- volttron.platform.vip.rmq_connection module
- volttron.platform.vip.rmq_router module
- volttron.platform.vip.router module
- volttron.platform.vip.routingservice module
- volttron.platform.vip.socket module
- volttron.platform.vip.tracking module
- volttron.platform.vip.zmq_connection module
- Subpackages
- volttron.platform.web package
- Submodules
- volttron.platform.web.admin_endpoints module
- volttron.platform.web.authenticate_endpoint module
- volttron.platform.web.csr_endpoints module
- volttron.platform.web.discovery module
- volttron.platform.web.master_web_service module
- volttron.platform.web.webapp module
- volttron.platform.web.websocket module
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:
objectSend 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.
-
-
class
volttron.platform.async.Threadlet(*args, **kwargs)[source]¶ Bases:
threading.ThreadA subclass of threading.Thread supporting gevent Greenlets.
The run method is executed in the thread’s main greenlet and the thread will exit when that method returns. Other threads may run callbacks within this thread using the send() method. Unlike the base class, threading.Thread, daemon is set by default.
-
exception
volttron.platform.async.GreenletExit¶ Bases:
exceptions.BaseException
volttron.platform.auth module¶
volttron.platform.certs module¶
volttron.platform.config module¶
volttron.platform.control module¶
volttron.platform.instance_setup module¶
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:
exceptions.ExceptionRaised when a recoverable JSON-RPC protocol error occurs.
-
exception
volttron.platform.jsonrpc.MethodNotFound(code, message, data=None)[source]¶ Bases:
volttron.platform.jsonrpc.ErrorRaised when remote method is not implemented.
-
exception
volttron.platform.jsonrpc.RemoteError(message, **exc_info)[source]¶ Bases:
exceptions.ExceptionReport 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().
-
class
volttron.platform.jsonrpc.Dispatcher[source]¶ Bases:
objectParses 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(**kwds)[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.
-
dispatch(json_string, context=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.
-
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:
objectJSON-file-backed store for dictionaries
-
class
volttron.platform.keystore.KeyStore(filename=None)[source]¶ Bases:
volttron.platform.keystore.BaseJSONStoreHandle generation, storage, and retrival of CURVE key pairs
-
public¶ Return encoded public key
-
secret¶ Return encoded secret key
-
volttron.platform.main module¶
volttron.platform.packages module¶
volttron.platform.packaging module¶
volttron.platform.resmon module¶
Resource Monitor
The resource monitor manages resources assigned to the platform, assigns resources to agent execution environments, and monitors those resources for abuse.
There will typically be only a single resource monitor that is instantiated and then set using set_resource_monitor(). Other modules may then just import the module and call the module-level functions without worrying about where to find the monitor instance.
-
exception
volttron.platform.resmon.ResourceError[source]¶ Bases:
exceptions.ExceptionException raised for errors relating to this module.
-
class
volttron.platform.resmon.ExecutionEnvironment[source]¶ Bases:
objectEnvironment reserved for agent execution.
Deleting ExecutionEnvironment objects should cause the process to end and all resources to be returned to the system.
-
class
volttron.platform.resmon.ResourceMonitor(env, **kwargs)[source]¶ Bases:
object-
check_hard_resources(contract)[source]¶ Test contract against hard resources and return failed terms.
contract should be a dictionary of terms and conditions that are being requested. If all terms can be met, None is returned. Otherwise, a dictionary is returned with the terms that failed along with hints on values that would cause the terms to succeed, if any. The contract is tested against the platform’s hard capabilities and static resources.
-
get_static_resources(query_items=None)[source]¶ Return a dictionary of hard capabilities and static resources.
query_items is a list of resources the requester is interested in; only items in the list will appear in the returned dictionary. If query_items is not passed or is None, all items should be returned.
The returned dictionary contains the requested items that are available and their associated values and/or limits.
- Examples of static resources:
- architecture kernel version distribution (lsb_release) installed software
-
reserve_soft_resources(contract)[source]¶ Test contract against soft resources and reserve resources.
contract should be a dictionary of terms and conditions to test against the platform’s soft capabilities and dynamic resources.
A 2-tuple is returned: (reservation, failed_terms). If reservation is None, no resources were reserved and failed_terms is a dictionary that can be consulted for the terms that must be modified for a reservation to succeed. Otherwise, reservation will be a ExecutionEnvironment object that can later be used to execute an agent and failed_terms will be None.
-
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¶
volttron.platform.storeutils module¶
-
volttron.platform.storeutils.check_for_recursion(new_config_name, new_config, existing_configs)[source]¶