X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FAddSliceToNodes.py;h=1b2942c9e93a405575324a553683a88106c24fa3;hb=d3caf68dfe082cd1f623550ee78b259ad3b019f0;hp=3b194b41e86d084896586fa89d089820a2af1299;hpb=0a42d0abbc2b448a84477481b06bff52b24f7130;p=plcapi.git diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index 3b194b4..1b2942c 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -7,7 +7,10 @@ from PLC.Auth import Auth class AddSliceToNodes(Method): """ - Adds the specified slice to the specified nodes. If the slice is + Adds the specified slice to the specified nodes. + Nodes can be either local or foreign nodes, as returned by GetNodes + + If the slice is already associated with a node, no errors are returned. Returns 1 if successful, faults otherwise. @@ -27,7 +30,6 @@ class AddSliceToNodes(Method): event_type = 'AddTo' object_type = 'Node' - object_ids = [] def call(self, auth, slice_id_or_name, node_id_or_hostname_list): # Get slice information @@ -35,20 +37,21 @@ class AddSliceToNodes(Method): if not slices: raise PLCInvalidArgument, "No such slice" - slice = slices.values()[0] - - # Get specified nodes - nodes = Nodes(self.api, node_id_or_hostname_list).values() + slice = slices[0] if 'admin' not in self.caller['roles']: if self.caller['person_id'] in slice['person_ids']: pass + # Thierry : I cannot figure out how this works + # how is having pi role related to being in a slice ? 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 + # Get specified nodes, add them to the slice + + nodes = Nodes(self.api, node_id_or_hostname_list) for node in nodes: if slice['slice_id'] not in node['slice_ids']: slice.add_node(node, commit = False)