Changeset 2276 for trunk/scripts/outage


Ignore:
Timestamp:
Mar 26, 2009, 1:32:18 AM (16 years ago)
Author:
price
Message:

outage-mail: send xvm@ just one message for the whole batch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/outage/outage-mail

    r2275 r2276  
    1818    msg = MIMEText(message % vm)
    1919    msg['To'] = contact
    20     msg['CC'] = 'XVM <xvm@mit.edu>'
     20    msg['From'] = opts.from_addr
    2121    msg['Reply-To'] = 'XVM <xvm@mit.edu>'
    22     msg['From'] = opts.from_addr
    2322    msg['Subject'] = opts.subject % vm
    2423    smtp.sendmail(opts.from_addr,
    25         [contact, 'xvm@mit.edu'],
     24        [contact],
     25        msg.as_string())
     26    return msg.as_string()
     27
     28def send_summary(smtp, opts, messages):
     29    msg = MIMEText('\n\n\n'.join(messages))
     30    msg['To'] = 'xvm@mit.edu'
     31    msg['From'] = opts.from_addr
     32    msg['Subject'] = ("xvm outage-mail summary (%d): %s"
     33                      % (len(messages), opts.subject))
     34    smtp.sendmail(opts.from_addr,
     35        ['xvm@mit.edu'],
    2636        msg.as_string())
    2737
     
    6676    s.connect()
    6777
     78    messages = []
    6879    for vm in vms:
    69         send_mail(s, opts, message, vm)
     80        messages.append(send_mail(s, opts, message, vm))
     81    send_summary(s, opts, messages)
    7082
    7183    s.close()
Note: See TracChangeset for help on using the changeset viewer.