- roles = ['admin']
-
- accepts = [Auth(),
- Parameter (int, "Peer id"),
- ]
- # for RefreshPeer
- returns = Parameter (dict,"Sites, Keys, Nodes, Persons, Slices")
-
- def call (self, auth, peer_id):
- # xxx a peer cannot yet compute it's peer_id under another plc
- # so we return evrything by now
-
- return {
- 'Sites' : Sites (self.api),
- 'Keys' : Keys (self.api),
- 'Nodes' : Nodes (self.api),
- 'Persons' : Persons (self.api),
- 'SliceAttibuteTypes' : SliceAttributeTypes (self.api),
- 'Slices' : Slices (self.api),
- 'SliceAttributes': SliceAttributes (self.api)
+ roles = ['admin', 'peer']
+
+ accepts = [Auth()]
+
+ returns = {
+ 'Sites': Parameter([dict], "List of local sites"),
+ 'Keys': Parameter([dict], "List of local keys"),
+ 'Nodes': Parameter([dict], "List of local nodes"),
+ 'Persons': Parameter([dict], "List of local users"),
+ 'Slices': Parameter([dict], "List of local slices"),
+ 'db_time': Parameter(float, "(Debug) Database fetch time"),
+ }
+
+ def call (self, auth):
+ start = time.time()
+
+ # Filter out various secrets
+ node_fields = [ field for field in Node.fields if field \
+ not in ['boot_nonce', 'key', 'session', 'root_person_ids']]
+ nodes = Nodes(self.api, {'peer_id': None}, node_fields);
+ # filter out whitelisted nodes
+ nodes = [ n for n in nodes if not n['slice_ids_whitelist']]
+
+
+ person_fields = [ field for field in Person.fields if field \
+ not in ['password', 'verification_key', 'verification_expires']]
+
+ # XXX Optimize to return only those Persons, Keys, and Slices
+ # necessary for slice creation on the calling peer's nodes.
+
+ # filter out special person
+ persons = Persons(self.api, {'~email':[self.api.config.PLC_API_MAINTENANCE_USER,
+ self.api.config.PLC_ROOT_USER],
+ 'peer_id': None}, person_fields)
+
+ # filter out system slices
+ system_slice_ids = SliceTags(self.api, {'name': 'system', 'value': '1'}).dict('slice_id')
+ slices = Slices(self.api, {'peer_id': None,
+ '~slice_id':system_slice_ids.keys()})
+
+ result = {
+ 'Sites': Sites(self.api, {'peer_id': None}),
+ 'Keys': Keys(self.api, {'peer_id': None}),
+ 'Nodes': nodes,
+ 'Persons': persons,
+ 'Slices': slices,