X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetPeerData.py;h=b220f180d3f326d06fc3efc18e12a65948de2c31;hb=bd0cbf4f7f2e4cf7ceda500bfa6f98c0a700018b;hp=696aca1e0d5d2a853d3cbf0591f42dea6dc7f2ff;hpb=02ff42f73c5665e1d73b0f565566f9be5f94788a;p=plcapi.git diff --git a/PLC/Methods/GetPeerData.py b/PLC/Methods/GetPeerData.py index 696aca1..b220f18 100644 --- a/PLC/Methods/GetPeerData.py +++ b/PLC/Methods/GetPeerData.py @@ -1,6 +1,6 @@ # # Thierry Parmentelat - INRIA -# +# import time @@ -16,7 +16,7 @@ from PLC.Keys import Key, Keys from PLC.Nodes import Node, Nodes from PLC.Persons import Person, Persons from PLC.Slices import Slice, Slices -from PLC.SliceAttributes import SliceAttributes +from PLC.SliceTags import SliceTags class GetPeerData(Method): """ @@ -24,7 +24,7 @@ class GetPeerData(Method): database as foreign objects. Also returns the list of foreign nodes in this database, for which the calling peer is authoritative, to assist in synchronization of slivers. - + See the implementation of RefreshPeer for how this data is used. """ @@ -45,30 +45,33 @@ class GetPeerData(Method): start = time.time() # Filter out various secrets - node_fields = filter(lambda field: field not in \ - ['boot_nonce', 'key', 'session', 'root_person_ids'], - Node.fields) + 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 = filter(lambda field: field not in \ - ['password', 'verification_key', 'verification_expires'], - Person.fields) + + 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, - 'peer_id': None}, person_fields) + # 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()}) - # filter out system slices - system_slice_ids = SliceAttributes(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(self.api, {'peer_id': None}, node_fields), + 'Nodes': nodes, 'Persons': persons, 'Slices': slices, }