2 # Thierry Parmentelat - INRIA
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.Auth import Auth
12 from PLC.Peers import Peer, Peers
14 from PLC.Sites import Site, Sites
15 from PLC.Keys import Key, Keys
16 from PLC.Nodes import Node, Nodes
17 from PLC.Persons import Person, Persons
18 from PLC.SliceAttributeTypes import SliceAttributeType, SliceAttributeTypes
19 from PLC.Slices import Slice, Slices
20 from PLC.SliceAttributes import SliceAttribute, SliceAttributes
22 class GetPeerData (Method):
24 Gather all data needed by RefreshPeer in a single xmlrpc request
26 Expects a peer id or peer name, that identifies the requesting peer
28 Returns a dict containing, for the various types of cached entities,
29 the local objects as well as the ones attached to that peer
35 Mixed (Parameter (Peer.fields['peer_id']),
36 Parameter (Peer.fields['peername'])),
39 returns = Parameter (dict,
40 "Sites-local Sites-peer Keys-local Keys-peer "
41 "Nodes-local Nodes-peer Persons-local Persons-peer "
42 "SliceAttibuteTypes-local SliceAttibuteTypes-peer "
43 "Slices-local Slices-peer "
44 "SliceAttributes-local SliceAttributes-peer")
46 def call (self, auth, peer_id_or_peername):
48 # checking the argument
50 peer_id = Peers(self.api,[peer_id_or_peername])[0]['peer_id']
52 raise PLCInvalidArgument,'GetPeerData: no such peer %r'%peer_id_or_peername
56 'Sites-local' : Sites (self.api,{'peer_id':None}),
57 'Sites-peer' : Sites (self.api,{'peer_id':peer_id}),
58 'Keys-local' : Keys (self.api,{'peer_id':None}),
59 'Keys-peer' : Keys (self.api,{'peer_id':peer_id}),
60 'Nodes-local' : Nodes (self.api,{'peer_id':None}),
61 'Nodes-peer' : Nodes (self.api,{'peer_id':peer_id}),
62 'Persons-local' : Persons (self.api,{'peer_id':None}),
63 'Persons-peer' : Persons (self.api,{'peer_id':peer_id}),
64 'SliceAttibuteTypes-local' : SliceAttributeTypes (self.api,{'peer_id':None}),
65 'SliceAttibuteTypes-peer' : SliceAttributeTypes (self.api,{'peer_id':peer_id}),
66 'Slices-local' : Slices (self.api,{'peer_id':None}),
67 'Slices-peer' : Slices (self.api,{'peer_id':peer_id}),
68 'SliceAttributes-local': SliceAttributes (self.api,{'peer_id':None}),
69 'SliceAttributes-peer': SliceAttributes (self.api,{'peer_id':peer_id}),
72 result['ellapsed'] = t_end-t_start