#!/usr/bin/python """ VM names on stdin. """ import smtplib import optparse import sys from email.mime.text import MIMEText from invirt import database def send_mail(smtp, opts, message, vm): contact = database.Machine.query.filter_by(name=vm).first().contact if '@' not in contact: contact += '@mit.edu' msg = MIMEText(message % vm) msg['To'] = contact msg['CC'] = 'XVM ' msg['Reply-To'] = 'XVM ' msg['From'] = opts.from_addr msg['Subject'] = '[xvm] Unexpected reboot of your VM %s' % vm smtp.sendmail(opts.from_addr, [contact, 'xvm@mit.edu'], msg.as_string()) def main(argv): parser = optparse.OptionParser( usage = '%prog {-m message, -f from} [options]