envoie un mail lors de la modification d'une machine
darcs-hash:20041107182114-4ec08-376837b3095c11a61155350ccc66707c70f8340b.gz
This commit is contained in:
parent
bcafe0e7a2
commit
5e8e7cf42f
1 changed files with 26 additions and 0 deletions
|
@ -251,6 +251,32 @@ if hostname == 'zamok':
|
|||
if auto : db.services_to_restart('switch',to_do['switch'])
|
||||
sys.stdout.write('Erreur dans la config des switchs.\n')
|
||||
|
||||
if 'mail_modification_machine' in to_do.keys() :
|
||||
from whos import machine_details
|
||||
if auto : db.services_to_restart('-mail_modification_machine')
|
||||
cprint('Modification d\'une machine : envoie d\'un mail à roots@crans.org','gras')
|
||||
for ip in to_do['mail_modification_machine'] :
|
||||
anim('\t' + ip)
|
||||
try :
|
||||
From = "roots@crans.org"
|
||||
To = "roots@crans.org"
|
||||
base_txt_mail = """From: %(From)s
|
||||
To: %(To)s
|
||||
Subject: Modifications sur une machine du CR@NS
|
||||
|
||||
%(Texte)s"""
|
||||
machine = db.search('ipHostNumber=%s' % ip)['machine'][0]
|
||||
conn=smtplib.SMTP(smtpserv)
|
||||
conn.sendmail(From, To , base_txt_mail % { 'From' : From, 'To' : To, 'Texte' : machine_details(machine) })
|
||||
conn.quit()
|
||||
print OK
|
||||
except Exception, c:
|
||||
print ERREUR
|
||||
if auto : db.services_to_restart('mail_modification_machine',[ip])
|
||||
if debug :
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if 'autostatus' in to_do.keys() :
|
||||
if auto : db.services_to_restart('-autostatus')
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue