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
32 roles = ['admin', 'peer']
36 Mixed(Peer.fields['peer_id'],
37 Peer.fields['peername']),
42 'Sites-local': Parameter([dict], "List of local sites"),
43 'Sites-peer': Parameter([dict], "List of foreign sites"),
44 'Keys-local': Parameter([dict], "List of local keys"),
45 'Keys-peer': Parameter([dict], "List of foreign keys"),
46 'Nodes-local': Parameter([dict], "List of local nodes"),
47 'Nodes-peer': Parameter([dict], "List of foreign nodes"),
48 'Persons-local': Parameter([dict], "List of local users"),
49 'Persons-peer': Parameter([dict], "List of foreign users"),
50 'SliceAttibuteTypes-local': Parameter([dict], "List of local slice attribute types"),
51 'SliceAttibuteTypes-peer': Parameter([dict], "List of foreign slice attribute types"),
52 'Slices-local': Parameter([dict], "List of local slices"),
53 'Slices-peer': Parameter([dict], "List of foreign slices"),
54 'SliceAttributes-local': Parameter([dict], "List of local slice attributes"),
55 'SliceAttributes-peer': Parameter([dict], "List of foreign slice attributes"),
58 def call (self, auth, peer_id_or_peername):
60 # checking the argument
62 peer_id = Peers(self.api,[peer_id_or_peername])[0]['peer_id']
64 raise PLCInvalidArgument,'GetPeerData: no such peer %r'%peer_id_or_peername
68 'Sites-local' : Sites (self.api,{'peer_id':None}),
69 'Sites-peer' : Sites (self.api,{'peer_id':peer_id}),
70 'Keys-local' : Keys (self.api,{'peer_id':None}),
71 'Keys-peer' : Keys (self.api,{'peer_id':peer_id}),
72 'Nodes-local' : Nodes (self.api,{'peer_id':None}),
73 'Nodes-peer' : Nodes (self.api,{'peer_id':peer_id}),
74 'Persons-local' : Persons (self.api,{'peer_id':None}),
75 'Persons-peer' : Persons (self.api,{'peer_id':peer_id}),
76 'SliceAttibuteTypes-local' : SliceAttributeTypes (self.api,{'peer_id':None}),
77 'SliceAttibuteTypes-peer' : SliceAttributeTypes (self.api,{'peer_id':peer_id}),
78 'Slices-local' : Slices (self.api,{'peer_id':None}),
79 'Slices-peer' : Slices (self.api,{'peer_id':peer_id}),
80 'SliceAttributes-local': SliceAttributes (self.api,{'peer_id':None}),
81 'SliceAttributes-peer': SliceAttributes (self.api,{'peer_id':peer_id}),
84 result['ellapsed'] = t_end-t_start