This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| scripting:python_scripts:checkpoint.py [2016/09/04 17:08] – created jotasandoku | scripting:python_scripts:checkpoint.py [2023/11/02 14:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | import sys | + | |
| - | import subprocess | + | import subprocess |
| - | import time | + | import time |
| - | import pexpect | + | import pexpect |
| - | import smtplib | + | import smtplib |
| - | + | ||
| - | + | ||
| - | #while dblock is 1 script will fail | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | dblock = 1 | + | |
| - | CPTMGMT = ' | + | |
| - | cpstat_output = 'set a true value so script fails if ssh does not run' | + | |
| - | pushpolicy_output = 'set a value here so i know nothing got set at the end' | + | |
| - | CPSTATCMD = ' | + | |
| - | PPCMD = 'fwm load -p firewall -m MKTX_DC03 DC03CPTFW' | + | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | #or this, this is the mail alert in case we have any problems pushing policy | + | |
| - | def mail_alert_push(ipaddr, | + | |
| - | SERVER = " | + | |
| - | FROM = " | + | |
| - | TO = ' | + | |
| - | SUBJECT = " | + | |
| - | TEXT = " | + | |
| - | message = 'TO: %s ' % (TO) + ' | + | |
| - | server = smtplib.SMTP(SERVER) | + | |
| - | server.sendmail(FROM, | + | |
| - | server.quit() | + | |
| - | + | ||
| - | #if we are lucky this is the only alert we will hit | + | |
| - | def mail_alert_final(ipaddr, | + | |
| - | SERVER = " | + | |
| - | FROM = " | + | |
| - | TO = ' | + | |
| - | SUBJECT = " | + | |
| - | TEXT = " | + | |
| - | message = 'TO: %s ' % (TO) + ' | + | |
| - | server = smtplib.SMTP(SERVER) | + | |
| - | server.sendmail(FROM, | + | |
| - | server.quit() | + | |
| | | ||
| | | ||
| - | + | #while dblock is 1 script will fail | |
| | | ||
| | | ||
| | | ||
| + | dblock = 1 | ||
| + | CPTMGMT = ' | ||
| + | cpstat_output = 'set a true value so script fails if ssh does not run' | ||
| + | pushpolicy_output = 'set a value here so i know nothing got set at the end' | ||
| + | CPSTATCMD = ' | ||
| + | PPCMD = 'fwm load -p firewall -m MKTX_DC03 DC03CPTFW' | ||
| | | ||
| | | ||
| | | ||
| + | #or this, this is the mail alert in case we have any problems pushing policy | ||
| + | def mail_alert_push(ipaddr, | ||
| + | SERVER = " | ||
| + | FROM = " | ||
| + | TO = ' | ||
| + | SUBJECT = " | ||
| + | TEXT = " | ||
| + | message = 'TO: %s ' % (TO) + ' | ||
| + | server = smtplib.SMTP(SERVER) | ||
| + | server.sendmail(FROM, | ||
| + | server.quit() | ||
| | | ||
| + | #if we are lucky this is the only alert we will hit | ||
| + | def mail_alert_final(ipaddr, | ||
| + | SERVER = " | ||
| + | FROM = " | ||
| + | TO = ' | ||
| + | SUBJECT = " | ||
| + | TEXT = " | ||
| + | message = 'TO: %s ' % (TO) + ' | ||
| + | server = smtplib.SMTP(SERVER) | ||
| + | server.sendmail(FROM, | ||
| + | server.quit() | ||
| + | | ||
| try: | try: | ||
| conn = pexpect.spawn(' | conn = pexpect.spawn(' | ||