paradrop.core.agent package¶
Submodules¶
paradrop.core.agent.http module¶
-
class
CurlRequestDriver
[source]¶ Bases:
paradrop.core.agent.http.HTTPRequestDriver
-
code_pattern
= <_sre.SRE_Pattern object>¶
-
curl
= <MagicMock name='mock.Curl()' id='140413200025744'>¶
-
header_pattern
= <_sre.SRE_Pattern object>¶
-
lock
= <twisted.internet.defer.DeferredLock object>¶
-
-
class
JSONReceiver
(response, finished)[source]¶ Bases:
twisted.internet.protocol.Protocol
JSON Receiver
A JSONReceiver object can be used with the twisted HTTP client to receive data from a request and provide it to a callback function when complete.
Example (response came from an HTTP request): finished = Deferred() response.deliverBody(JSONReceiver(finished)) finished.addCallback(func_that_takes_result)
Some error conditions will result in the callback firing with a result of None. The receiver needs to check for this. This seems to occur on 403 errors where the server does not return any data, but twisted just passes us a ResponseDone object the same type as a normal result.
-
class
PDServerRequest
(path, driver=<class 'paradrop.core.agent.http.TwistedRequestDriver'>, headers={}, setAuthHeader=True)[source]¶ Bases:
object
Make an HTTP request to pdserver.
The API is assumed to use application/json for sending and receiving data. Authentication is automatically handled here if the router is provisioned.
We handle missing, invalid, or expired tokens by making the request and detecting a 401 (Unauthorized) response. We request a new token and retry the failed request. We do this at most once and return failure if the second attempt returns anything other than 200 (OK).
PDServerRequest objects are not reusable; create a new one for each request.
URL String Substitutions: router_id -> router id
Example: /routers/{router_id}/states -> /routers/halo06/states
-
classmethod
getServerInfo
()[source]¶ Return the information needed to send API messages to the server.
This can be used by an external program (e.g. pdinstall).
-
patch
(*ops)[source]¶ Expects a list of operations in jsonpatch format (http://jsonpatch.com/).
An example operation would be: {‘op’: ‘replace’, ‘path’: ‘/completed’, ‘value’: True}
-
receiveResponse
(response)[source]¶ Intercept the response object, and if it’s a 401 authenticate and retry.
-
classmethod
resetToken
()[source]¶ Reset the auth token, to be called if the router’s identity has changed.
-
token
= None¶
-
classmethod
-
class
PDServerResponse
(response, data=None)[source]¶ Bases:
object
A PDServerResponse object contains the results of a request to pdserver.
This wraps twisted.web.client.Response (cannot be subclassed) and exposes the same variables in addition to a ‘data’ variables. The ‘data’ variable, if not None, is the parsed object from the response body.
-
class
TwistedRequestDriver
[source]¶ Bases:
paradrop.core.agent.http.HTTPRequestDriver
-
pool
= <twisted.web.client.HTTPConnectionPool object>¶
-
receive
(response)[source]¶ Receive response from twisted web client and convert it to a PDServerResponse object.
-
sem
= <twisted.internet.defer.DeferredSemaphore object>¶
-
paradrop.core.agent.reporting module¶
paradrop.core.agent.wamp_session module¶
The WAMP session of the paradrop daemon
-
class
WampSession
(*args, **kwargs)[source]¶ Bases:
paradrop.base.cxbr.BaseSession
-
update_fetcher
= None¶
-