+##
+# Returns a string of keys that belong to the users of the given slice.
+# @param sliceHRN The hunman readable name of the slice.
+# @return sting()
+#
+def getKeysForSlice(sliceHRN):
+ try:
+ # convert hrn to slice name
+ plSliceName = hrn_to_pl_slicename(sliceHRN)
+ except IndexError, e:
+ print >>sys.stderr, 'Invalid slice name (%s)' % sliceHRN
+ return []
+
+ # Get the slice's information
+ sliceData = api.plshell.GetSlices(api.plauth, {'name':plSliceName})
+ if not sliceData:
+ print >>sys.stderr, 'Cannot get any data for slice %s' % plSliceName
+ return []
+
+ # It should only return a list with len = 1
+ sliceData = sliceData[0]
+
+ keys = []
+ person_ids = sliceData['person_ids']
+ if not person_ids:
+ print >>sys.stderr, 'No users in slice %s' % sliceHRN
+ return []
+
+ persons = api.plshell.GetPersons(api.plauth, person_ids)
+ for person in persons:
+ pkeys = api.plshell.GetKeys(api.plauth, person['key_ids'])
+ for key in pkeys:
+ keys.append(key['key'])
+
+ return ''.join(keys)
+