diff --git a/proxstar/mail.py b/proxstar/mail.py index ddb5520..3dd957b 100644 --- a/proxstar/mail.py +++ b/proxstar/mail.py @@ -23,9 +23,11 @@ def send_vm_expire_email(user, vms): subject = 'Proxstar VM Expiration Notice' body = "The following VMs in Proxstar are expiring soon:\n\n" for vm in vms: - if vm[1] != 1: - body += " - {} in {} days\n".format(vm[0], vm[1]) + if vm[1] == 0: + body += " - {} today (VM has been stopped)\n".format(vm[0], vm[1]) + if vm[1] == 1: + body += " - {} in 1 day\n".format(vm[0]) else: - body += " - {} in {} day\n".format(vm[0], vm[1]) + body += " - {} in {} days\n".format(vm[0], vm[1]) body += "\nPlease login to Proxstar and renew any VMs you would like to keep." send_email(toaddr, subject, body) diff --git a/proxstar/tasks.py b/proxstar/tasks.py index 9a6a5dd..8260615 100644 --- a/proxstar/tasks.py +++ b/proxstar/tasks.py @@ -85,9 +85,12 @@ def process_expiring_vms_task(): expire = get_vm_expire(db, vmid, app.config['VM_EXPIRE_MONTHS']) days = (expire - datetime.date.today()).days - if days in [10, 7, 3, 1]: + if days in [10, 7, 3, 1, 0]: name = get_vm_config(proxmox, vmid)['name'] expiring_vms.append([name, days]) + if days == 0: + #change_vm_power(proxmox, vmid, 'stop') + pass if expiring_vms: send_vm_expire_email('com6056', expiring_vms)