git://git.onelab.eu
/
plcapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8b56189
)
- let everyone at a site see all the nodes at their site, even if the nodes have...
author
Tony Mack
<tmack@cs.princeton.edu>
Thu, 20 Sep 2007 17:55:17 +0000
(17:55 +0000)
committer
Tony Mack
<tmack@cs.princeton.edu>
Thu, 20 Sep 2007 17:55:17 +0000
(17:55 +0000)
PLC/Methods/GetNodes.py
patch
|
blob
|
history
diff --git
a/PLC/Methods/GetNodes.py
b/PLC/Methods/GetNodes.py
index
e442a95
..
912e84e
100644
(file)
--- a/
PLC/Methods/GetNodes.py
+++ b/
PLC/Methods/GetNodes.py
@@
-34,7
+34,7
@@
class GetNodes(Method):
# Must query at least slice_ids_whitelist
if return_fields is not None:
# Must query at least slice_ids_whitelist
if return_fields is not None:
- added_fields = set(['slice_ids_whitelist']).difference(return_fields)
+ added_fields = set(['slice_ids_whitelist'
, 'site_id'
]).difference(return_fields)
return_fields += added_fields
else:
added_fields =[]
return_fields += added_fields
else:
added_fields =[]
@@
-46,14
+46,23
@@
class GetNodes(Method):
if not isinstance(self.caller, Person) or \
'admin' not in self.caller['roles']:
slice_ids = set()
if not isinstance(self.caller, Person) or \
'admin' not in self.caller['roles']:
slice_ids = set()
+ site_ids = set()
if self.caller:
slice_ids.update(self.caller['slice_ids'])
if self.caller:
slice_ids.update(self.caller['slice_ids'])
- # if node has whitelist, make sure the user has a slice on the whitelist
+ site_ids.update(self.caller['site_ids'])
+
+ # if node has whitelist, only return it if users is at
+ # the same site or user has a slice on the whitelist
for node in nodes[:]:
for node in nodes[:]:
+ if 'site_id' in node and \
+ site_ids.intersection([node['site_id']]):
+ continue
if 'slice_ids_whitelist' in node and \
node['slice_ids_whitelist'] and \
not slice_ids.intersection(node['slice_ids_whitelist']):
nodes.remove(node)
if 'slice_ids_whitelist' in node and \
node['slice_ids_whitelist'] and \
not slice_ids.intersection(node['slice_ids_whitelist']):
nodes.remove(node)
+
+ # remove remaining admin only fields
for node in nodes:
for field in ['boot_nonce', 'key', 'session', 'root_person_ids']:
if field in node:
for node in nodes:
for field in ['boot_nonce', 'key', 'session', 'root_person_ids']:
if field in node: