From f8f4a4d9f9a50e95f195edf8be9bb8e03a455b3c Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Wed, 11 Oct 2006 17:31:46 +0000 Subject: [PATCH] - allow members of slice to call - whitespace nits --- PLC/Methods/AddSliceToNodes.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index 249a1d8e..7e0a5d90 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -13,7 +13,7 @@ class AddSliceToNodes(Method): Returns 1 if successful, faults otherwise. """ - roles = ['admin', 'pi'] + roles = ['admin', 'pi', 'user'] accepts = [ PasswordAuth(), @@ -26,7 +26,6 @@ class AddSliceToNodes(Method): returns = Parameter(int, '1 if successful') def call(self, auth, slice_id_or_name, node_id_or_hostname_list): - # Get slice information slices = Slices(self.api, [slice_id_or_name]) if not slices: @@ -37,15 +36,17 @@ class AddSliceToNodes(Method): # Get specified nodes nodes = Nodes(self.api, node_id_or_hostname_list).values() - # If we are not admin, make sure the caller is a pi - # of the site associated with the slice - if 'admin' not in self.caller['roles']: - if slice['site_id'] not in self.caller['site_ids']: - raise PLCPermissionDenied, "Not allowed to add nodes to this slice" + if 'admin' not in self.caller['roles']: + if self.caller['person_id'] in slice['person_ids']: + pass + elif 'pi' not in self.caller['roles']: + raise PLCPermissionDenied, "Not a member of the specified slice" + elif slice['site_id'] not in self.caller['site_ids']: + raise PLCPermissionDenied, "Specified slice not associated with any of your sites" - # add slice to all nodes found + # Add slice to all nodes found for node in nodes: - if slice['slice_id'] not in node['slice_ids']: - slice.add_node(node) + if slice['slice_id'] not in node['slice_ids']: + slice.add_node(node) return 1 -- 2.47.0