enable vm deletions, wait 7 days before deleting, fix emails, add rtp deletion email

This commit is contained in:
Jordan Rodgers 2018-04-16 15:14:36 -04:00
parent 8808389b46
commit d9658aaf07
4 changed files with 43 additions and 38 deletions

View file

@ -21,14 +21,31 @@ def send_email(toaddr, subject, body):
def send_vm_expire_email(user, vms):
toaddr = "{}@csh.rit.edu".format(user)
subject = 'Proxstar VM Expiration Notice'
body = "The following VMs in Proxstar are expiring soon:\n\n"
body = "The following VMs in Proxstar are expiring soon or have already expired:\n\n"
for vm in vms:
if vm[1] == 0:
body += " - {} expires today (VM has been stopped and will be deleted tomorrow)\n".format(
vm[0], vm[1])
elif vm[1] == 1:
body += " - {} expires in 1 day\n".format(vm[0])
if vm[2] == -6:
body += " - {} ({}) has expired (VM has been stopped and will be deleted in 1 day)\n".format(vm[1], vm[0])
elif vm[2] < 0:
body += " - {} ({}) has expired (VM has been stopped and will be deleted in {} days)\n".format(
vm[1], vm[0], (7 + int(vm[2])))
elif vm[2] == 0:
body += " - {} ({}) expires today (VM has been stopped and will be deleted in 7 days)\n".format(vm[1], vm[0])
elif vm[2] == 1:
body += " - {} ({}) expires in 1 day\n".format(vm[1], vm[0])
else:
body += " - {} expires in {} days\n".format(vm[0], vm[1])
body += "\nPlease login to Proxstar and renew any VMs you would like to keep."
body += " - {} ({}) expires in {} days\n".format(vm[1], vm[0], vm[2])
body += "\nPlease login to Proxstar (https://proxstar.csh.rit.edu/) and renew any VMs you would like to keep."
send_email(toaddr, subject, body)
def send_rtp_vm_delete_email(vms):
toaddr = 'rtp@csh.rit.edu'
subject = 'Proxstar VM Deletion Report'
body = "The following VMs in Proxstar have expired and will be deleted soon:\n\n"
for vm in vms:
if vm[2] == -6:
body += " - {} ({}) will be deleted in 1 day\n".format(vm[1], vm[0])
else:
body += " - {} ({}) will be deleted in {} days\n".format(vm[1], vm[0], (7 + int(vm[2])))
body += "\nPlease verify this list to ensure there aren't any pools included in Proxstar that shouldn't be."
send_email(toaddr, subject, body)