volttron.platform.web package

exception volttron.platform.web.NotAuthorized[source]

Bases: Exception

volttron.platform.web.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.web.get_bearer(env)[source]
volttron.platform.web.get_user_claim_from_bearer(bearer)[source]
volttron.platform.web.get_user_claims(env)[source]

Submodules

volttron.platform.web.admin_endpoints module

class volttron.platform.web.admin_endpoints.AdminEndpoints(rmq_mgmt, ssl_public_key: bytes)[source]

Bases: object

add_user(username, unencrypted_pw, groups=[], overwrite=False)[source]
admin(env, data)[source]
get_routes()[source]

Returns a list of tuples with the routes for the adminstration endpoints available in it.

Returns:
reload_userdict()[source]
verify_and_dispatch(env, data)[source]

Verify that the user is an admin and dispatch

Parameters:
  • env – web environment
  • data – data associated with a web form or json/xml request data
Returns:

Response object.

volttron.platform.web.admin_endpoints.template_env(env)[source]

volttron.platform.web.authenticate_endpoint module

class volttron.platform.web.authenticate_endpoint.AuthenticateEndpoints(ssl_private_key)[source]

Bases: object

get_auth_token(env, data)[source]

Creates an authentication token to be returned to the caller. The response will be a text/plain encoded user

Parameters:
  • env
  • data
Returns:

get_routes()[source]

Returns a list of tuples with the routes for authentication.

Tuple should have the following:

  • regular expression for calling the endpoint
  • ‘callable’ keyword specifying that a method is being specified
  • the method that should be used to call when the regular expression matches

code:

return [
(re.compile(‘^/csr/request_new$’), ‘callable’, self._csr_request_new)

]

Returns:
reload_userdict()[source]

volttron.platform.web.csr_endpoints module

class volttron.platform.web.csr_endpoints.CSREndpoints(core)[source]

Bases: object

auto_allow_csr
get_routes()[source]

Returns a list of tuples with the routes for authentication.

Tuple should have the following:

  • regular expression for calling the endpoint
  • ‘callable’ keyword specifying that a method is being specified
  • the method that should be used to call when the regular expression matches

code:

return [
(re.compile(‘^/csr/request_new$’), ‘callable’, self._csr_request_new)

]

Returns:

volttron.platform.web.discovery module

exception volttron.platform.web.discovery.DiscoveryError[source]

Bases: Exception

Raised when a different volttron central tries to register.

class volttron.platform.web.discovery.DiscoveryInfo(**kwargs)[source]

Bases: object

A DiscoveryInfo class.

The DiscoveryInfo class provides a wrapper around the return values from a call to the /discovery/ endpoint of the `volttron.platform.web.

static request_discovery_info(web_address)[source]

Construct a DiscoveryInfo object.

Requests a response from discovery_address and constructs a DiscoveryInfo object with the returned json.

Parameters:web_address – An http(s) address with volttron running.
Returns:

volttron.platform.web.master_web_service module

exception volttron.platform.web.master_web_service.CouldNotRegister[source]

Bases: Exception

exception volttron.platform.web.master_web_service.DuplicateEndpointError[source]

Bases: Exception

class volttron.platform.web.master_web_service.MasterWebService(serverkey, identity, address, bind_web_address, aip, volttron_central_address=None, volttron_central_rmq_address=None, web_ssl_key=None, web_ssl_cert=None, **kwargs)[source]

Bases: volttron.platform.vip.agent.Agent

The service that is responsible for managing and serving registered pages

Agents can register either a directory of files to serve or an rpc method that will be called during the request process.

app_routing(env, start_response)[source]

The main routing function that maps the incoming request to a response.

Depending on the registered routes map the request data onto an rpc function or a specific named file.

create_raw_response(res, start_response)[source]
create_response(res, start_response)[source]
get_bind_web_address()[source]
get_serverkey()[source]
get_user_claims(bearer)[source]
get_volttron_central_address()[source]

Return address of external Volttron Central

Note: this only applies to Volltron Central agents that are running on a different platform.

is_json_content(env)[source]
onsetup(sender, **kwargs)[source]
process_response(start_response, response)[source]
register_agent_route(regex, fn)[source]

Register an agent route to an exported function.

When a http request is executed and matches the passed regular expression then the function on peer is executed.

register_endpoint(endpoint, res_type)[source]

RPC method to register a dynamic route.

Parameters:endpoint
Returns:
register_path_route(regex, root_dir)[source]
register_websocket(endpoint)[source]
remove_unconnnected_routes()[source]
startupagent(sender, **kwargs)[source]
unregister_all_agent_routes()[source]
unregister_websocket(endpoint)[source]
websocket_send(endpoint, message)[source]

volttron.platform.web.webapp module

class volttron.platform.web.webapp.WebApplicationWrapper(masterweb, host, port)[source]

Bases: object

A container class that will hold all of the applications registered with it. The class provides a contianer for managing the routing of websocket, static content, and rpc function calls.

client_closed(client, endpoint, identity, reason='Client left without proper explaination')[source]
client_opened(client, endpoint, identity)[source]
client_received(endpoint, message)[source]
create_ws_endpoint(endpoint, identity)[source]
destroy_ws_endpoint(endpoint)[source]
favicon(environ, start_response)[source]

Don’t care about favicon, let’s send nothing.

websocket_send(endpoint, message)[source]

volttron.platform.web.websocket module

class volttron.platform.web.websocket.VolttronWebSocket(*args, **kwargs)[source]

Bases: ws4py.websocket.WebSocket

closed(code, reason='A client left the room without a proper explanation.')[source]

Called when the websocket stream and connection are finally closed. The provided code is status set by the other point and reason is a human readable message.

See also

Defined Status Codes http://tools.ietf.org/html/rfc6455#section-7.4.1

opened()[source]

Called by the server when the upgrade handshake has succeeded.

received_message(m)[source]

Called whenever a complete message, binary or text, is received and ready for application’s processing.

The passed message is an instance of messaging.TextMessage or messaging.BinaryMessage.

Note

You should override this method in your subclass.