1
# Copyright 2014 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Common RPC classes and utilties."""
6
from __future__ import (
20
from provisioningserver.rpc.interfaces import IConnection
21
from provisioningserver.utils import asynchronous
22
from twisted.protocols import amp
25
class Identify(amp.Command):
26
"""Request the identity of the remote side, e.g. its UUID."""
28
response = [(b"ident", amp.Unicode())]
32
"""Wrapper around an :class:`amp.AMP` instance.
34
Limits the API to a subset of the behaviour of :class:`amp.AMP`'s,
35
with alterations to make it suitable for use from a thread outside
39
def __init__(self, conn):
40
super(Client, self).__init__()
41
assert IConnection.providedBy(conn), (
42
"%r does not provide IConnection" % (conn,))
47
"""Something that identifies the far end of the connection."""
48
return self._conn.ident
51
def __call__(self, cmd, **kwargs):
52
return self._conn.callRemote(cmd, **kwargs)
55
def getHostCertificate(self):
56
return self._conn.hostCertificate
59
def getPeerCertificate(self):
60
return self._conn.peerCertificate
64
return self._conn.peerCertificate is not None
66
def __eq__(self, other):
67
return type(other) is type(self) and other._conn is self._conn
70
return hash(self._conn)