X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FSliceExtendedInfo.py;h=19228eaed48666c749f0148268a31e3346ce5aad;hb=f7ce7ce813d4c44502629820a3583f32a99a98f7;hp=5469e8100fa40f6ec7090e2e515c5a2f7ade901f;hpb=9a608e111c7f8182f51753ea3f563ebc19eb4c71;p=plcapi.git diff --git a/PLC/Methods/SliceExtendedInfo.py b/PLC/Methods/SliceExtendedInfo.py index 5469e81..19228ea 100644 --- a/PLC/Methods/SliceExtendedInfo.py +++ b/PLC/Methods/SliceExtendedInfo.py @@ -14,8 +14,8 @@ class SliceExtendedInfo(Method): """ Deprecated. Can be implemented with GetSlices. - Returns an array of structs containing details about slices. - The summary can optionally include the list of nodes in and + Returns an array of structs containing details about slices. + The summary can optionally include the list of nodes in and users of each slice. Users may only query slices of which they are members. PIs may @@ -32,18 +32,18 @@ class SliceExtendedInfo(Method): Auth(), [Slice.fields['name']], Parameter(bool, "Whether or not to return users for the slices", nullok = True), - Parameter(bool, "Whether or not to return nodes for the slices", nullok = True) + Parameter(bool, "Whether or not to return nodes for the slices", nullok = True) ] returns = [Slice.fields] - + def call(self, auth, slice_name_list=None, return_users=None, return_nodes=None, return_attributes=None): - # If we are not admin, make sure to return only viewable - # slices. - slice_filter = slice_name_list - slices = Slices(self.api, slice_filter) - if not slices: + # If we are not admin, make sure to return only viewable + # slices. + slice_filter = slice_name_list + slices = Slices(self.api, slice_filter) + if not slices: raise PLCInvalidArgument, "No such slice" if 'admin' not in self.caller['roles']: @@ -56,31 +56,31 @@ class SliceExtendedInfo(Method): if not valid_slice_ids: return [] - - slices = filter(lambda slice: slice['slice_id'] in valid_slice_ids, slices) - for slice in slices: - index = slices.index(slice) + slices = filter(lambda slice: slice['slice_id'] in valid_slice_ids, slices) + + for slice in slices: + index = slices.index(slice) node_ids = slices[index].pop('node_ids') person_ids = slices[index].pop('person_ids') - attribute_ids = slices[index].pop('slice_tag_ids') + attribute_ids = slices[index].pop('slice_tag_ids') if return_users or return_users is None: persons = Persons(self.api, person_ids) - person_info = [{'email': person['email'], - 'person_id': person['person_id']} \ - for person in persons] + person_info = [{'email': person['email'], + 'person_id': person['person_id']} \ + for person in persons] slices[index]['users'] = person_info if return_nodes or return_nodes is None: nodes = Nodes(self.api, node_ids) - node_info = [{'hostname': node['hostname'], - 'node_id': node['node_id']} \ - for node in nodes] + node_info = [{'hostname': node['hostname'], + 'node_id': node['node_id']} \ + for node in nodes] slices[index]['nodes'] = node_info - if return_attributes or return_attributes is None: - attributes = SliceTags(self.api, attribute_ids) - attribute_info = [{'name': attribute['name'], - 'value': attribute['value']} \ - for attribute in attributes] - slices[index]['attributes'] = attribute_info - + if return_attributes or return_attributes is None: + attributes = SliceTags(self.api, attribute_ids) + attribute_info = [{'name': attribute['name'], + 'value': attribute['value']} \ + for attribute in attributes] + slices[index]['attributes'] = attribute_info + return slices