4b0f06881da1f8d3fdbde141c7b0e0bdb5796f22
[plcapi.git] / PLC / Methods / GetPeerData.py
1 #
2 # Thierry Parmentelat - INRIA
3
4
5 from PLC.Faults import *
6 from PLC.Method import Method
7 from PLC.Parameter import Parameter, Mixed
8 from PLC.Auth import Auth
9
10 from PLC.Peers import Peer, Peers
11
12 from PLC.Sites import Site, Sites
13 from PLC.Keys import Key, Keys
14 from PLC.Nodes import Node, Nodes
15 from PLC.Persons import Person, Persons
16 from PLC.SliceAttributeTypes import SliceAttributeType, SliceAttributeTypes
17 from PLC.Slices import Slice, Slices
18 from PLC.SliceAttributes import SliceAttribute, SliceAttributes
19
20 class GetPeerData (Method):
21     """
22     Gather all data needed by RefreshPeer in a single xmlrpc request
23
24     Expects a peer id or peer name, that identifies the requesting peer
25     
26     Returns a dict containing, for the various types of cached entities,
27     the local objects as well as the ones attached to that peer
28     """
29
30     roles = ['admin']
31
32     accepts = [Auth(),
33                Parameter (int, "Peer id"),
34                ]
35     # for RefreshPeer 
36     returns = Parameter (dict,"Sites, Keys, Nodes, Persons, Slices")
37     event_type = 'Get'
38     object_type = 'Peer'
39
40     def call (self, auth, peer_id):
41         # xxx a peer cannot yet compute it's peer_id under another plc
42         # so we return evrything by now
43         
44         return {
45             'Sites' : Sites (self.api),
46             'Keys' : Keys (self.api),
47             'Nodes' : Nodes (self.api),
48             'Persons' : Persons (self.api),
49             'SliceAttibuteTypes' : SliceAttributeTypes (self.api),
50             'Slices' : Slices (self.api),
51             'SliceAttributes': SliceAttributes (self.api)
52             }
53