- # Send it
- if slice['person_ids']:
- if options.dryrun:
- print message % locals()
- else:
- NotifyPersons(slice['person_ids'],
- "%(PLC_NAME)s slice %(name)s expires in %(days)s" % locals(),
- message % locals())
- elif options.verbose:
- print slice['name'], "has no users, skipping"
+ # compute set of persons but keep federated users (the ones with sfa_created) out
+ slice_persons = [ persons_by_id[id] for id in slice['person_ids'] ]
+ recipient_emails = [ person['email'] for person in slice_persons if not person['sfa_created'] ]
+ recipient_ids = [ person['email'] for person in slice_persons if not person['sfa_created'] ]
+ nb_in_slice = len(slice_persons)
+ nb_not_sfa = len(recipient_emails)
+
+ if not recipient_emails:
+ if options.verbose:
+ print """{slice_name} has no recipient
+({nb_in_slice} in slice, {nb_not_sfa} not sfa_created)""".format(**locals())
+ continue
+
+ log_details = [time.ctime(now), slice_name, time.ctime(slice['expires'])]
+ log_data = "{}\t{}".format("\t".join(log_details), ",".join(recipient_emails))
+
+ if options.dryrun:
+ print "-------------------- Found slice to renew {slice_name}".format(**locals())
+ print message_format.format(**locals())
+ print "log >> {}".format(log_data)
+ else:
+ NotifyPersons(slice['person_ids'],
+ "{PLC_NAME} slice {slice_name} expires in {days}".format(**locals()),
+ message_format.format(**locals()))
+ print >> log, log_data
+