Merge as much from autotest-tools in to autotest
as possible.
The following will be left in autotest-tools and will be eventually dropped:
borg, btfs, offloader, scripts, server_hosts, cloud_gestures
Migrated files:
etc_apache2 -> site_utils/admin/apache2.conf
etc_init.d -> site_utils/admin/autotest.init
global_config.ini ->merged and passwords removed. shadow_config.ini should be used on the server when deployed. And the passwords should be added from Valentine
Moved autotest/scripts under site_tuils/admin
syncfiles/
apache/conf moved everything but left the .crt file for now
frontend/afe/site_rpc* left there for now.
scheduler/ssh_start_wrapper.sh -> migrated to site_utils/admin
utils/* moved to site_utils. There is mention of loas but nothing really confendential there so I copied it over. There is already some mention to loas on the web.
BUG=chromium-os:22942
TEST=NA
Change-Id: I89fcb108aec1557820041644d799687212e3bd73
Reviewed-on: https://gerrit.chromium.org/gerrit/11995
Commit-Ready: Scott Zawalski <scottz@chromium.org>
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Tested-by: Scott Zawalski <scottz@chromium.org>
diff --git a/site_utils/prodcertstatus_checker.py b/site_utils/prodcertstatus_checker.py
new file mode 100755
index 0000000..de3f99c
--- /dev/null
+++ b/site_utils/prodcertstatus_checker.py
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+
+import datetime
+import getpass
+import optparse
+import os
+import socket
+
+
+def read_loascertstatus():
+ # prodcertstatus --simple_output returns the #of seconds remaining before the
+ # cert is expired.
+ f = os.popen('prodcertstatus --simple_output | grep LOAS')
+ loas_expire = int(f.read().split(':')[1])
+ f.close()
+ return loas_expire
+
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--expire_within', help='Send email if cert will expire '
+ 'within this time window in seconds.',
+ type='int', dest='expire_within', default=24*3600)
+ parser.add_option('--to', help='Comma separated Email notification TO '
+ 'recipients.', dest='to', type='string', default='')
+ parser.add_option('--cc', help='Comma separated Email notification CC '
+ 'recipients.', dest='cc', type='string', default='')
+ options, _ = parser.parse_args()
+
+ loas_expire = read_loascertstatus()
+ host = socket.gethostname()
+ if loas_expire < options.expire_within:
+ tt = datetime.timedelta(seconds=loas_expire)
+ body_text = ('prod access cert (LOAS) for %s will expire within %s on %s.'
+ % (getpass.getuser(), tt, host))
+ if not options.to:
+ print body_text
+ else:
+ email_to = ['%s@google.com' % to.strip() for to in options.to.split(',')]
+
+ p = os.popen('/usr/sbin/sendmail -t', 'w')
+ p.write('To: %s\n' % ','.join(email_to))
+ if options.cc:
+ email_cc = ['%s@google.com' % cc.strip()
+ for cc in options.cc.split(',')]
+ p.write('Cc: %s\n' % ','.join(email_cc))
+
+ p.write('Subject: Prod access cert (LOAS) for %s will expire soon on %s.'
+ '\n' % (getpass.getuser(), host))
+ p.write('Content-Type: text/plain')
+ p.write('\n') # blank line separating headers from body
+ p.write(body_text)
+ p.write('\n')
+ return_code = p.close()
+ if return_code is not None:
+ print 'Sendmail exit status %s' % return_code
+
+
+if __name__ == '__main__':
+ main()