1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Auth import Auth
4 from PLC.Peers import Peer, Peers
6 can_update = lambda (field, value): field in \
7 ['peername', 'peer_url', 'key', 'cacert']
9 class UpdatePeer(Method):
11 Updates a peer. Only the fields specified in peer_fields are
12 updated, all other fields are left untouched.
14 Returns 1 if successful, faults otherwise.
19 peer_fields = dict(filter(can_update, Peer.fields.items()))
23 Mixed(Peer.fields['peer_id'],
24 Peer.fields['peername']),
28 returns = Parameter(int, "1 if successful")
30 def call(self, auth, peer_id_or_name, peer_fields):
31 peer_fields = dict(filter(can_update, peer_fields.items()))
33 # Get account information
34 peers = Peers(self.api, [peer_id_or_name])
36 raise PLCInvalidArgument, "No such peer"
39 peer.update(peer_fields)
42 # Log affected objects
43 self.object_ids = [peer['peer_id']]