git://git.onelab.eu
/
myplc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4cf339b
)
log when notifications, when the slice will expire and who was notified in /var/log...
author
Tony Mack
<tmack@cs.princeton.edu>
Wed, 8 Oct 2008 20:28:27 +0000
(20:28 +0000)
committer
Tony Mack
<tmack@cs.princeton.edu>
Wed, 8 Oct 2008 20:28:27 +0000
(20:28 +0000)
support-scripts/renew_reminder.py
patch
|
blob
|
history
diff --git
a/support-scripts/renew_reminder.py
b/support-scripts/renew_reminder.py
index
499a7d3
..
220fd14
100755
(executable)
--- a/
support-scripts/renew_reminder.py
+++ b/
support-scripts/renew_reminder.py
@@
-8,6
+8,7
@@
# $Id$
#
# $Id$
#
+import os
import sys
import time
from optparse import OptionParser
import sys
import time
from optparse import OptionParser
@@
-20,6
+21,21
@@
plc = Shell(globals())
PLC_WWW_HOST = plc.config.PLC_WWW_HOST
PLC_NAME = plc.config.PLC_NAME
PLC_WWW_HOST = plc.config.PLC_WWW_HOST
PLC_NAME = plc.config.PLC_NAME
+LOGFILE = '/var/log/renew_reminder'
+class Logfile:
+ def __init__(self, filename):
+ self.filename = filename
+ def write(self, data):
+ try:
+ fd = os.open(self.filename, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0644)
+ os.write(fd, '%s' % data)
+ os.close(fd)
+ except OSError:
+ sys.stderr.write(data)
+ sys.stderr.flush()
+
+log = Logfile(LOGFILE)
+
# Debug
verbose = False;
# Debug
verbose = False;
@@
-88,13
+104,22
@@
To update, renew, or delete this slice, visit the URL:
%(slice_url)s%(slice_id)d
"""
%(slice_url)s%(slice_id)d
"""
+ emails = [person['email'] for person in GetPersons(slice['person_ids'], ['email'])]
+ if not emails: emails = ['no contacts']
+ log_details = [time.ctime(now), slice['name'], time.ctime(slice['expires'])]
+ log_data = "%s\t%s" % ("\t".join(log_details), ",".join(emails))
+
# Send it
if slice['person_ids']:
if options.dryrun:
print message % locals()
# Send it
if slice['person_ids']:
if options.dryrun:
print message % locals()
+ print "log >> %s" % log_data
else:
NotifyPersons(slice['person_ids'],
"%(PLC_NAME)s slice %(name)s expires in %(days)s" % locals(),
message % locals())
else:
NotifyPersons(slice['person_ids'],
"%(PLC_NAME)s slice %(name)s expires in %(days)s" % locals(),
message % locals())
+ print >> log, log_data
+
elif options.verbose:
print slice['name'], "has no users, skipping"
elif options.verbose:
print slice['name'], "has no users, skipping"
+ print >> log, log_data