uncloud-mravi/uncloud/uncloud_vm/management/commands/vmhealth.py

27 lines
816 B
Python
Raw Normal View History

2020-02-25 21:01:55 +00:00
import json
from django.core.management.base import BaseCommand
from django.contrib.auth import get_user_model
from uncloud_vm.models import VMProduct, VMHost
class Command(BaseCommand):
help = 'Check health of VMs and VMHosts'
def add_arguments(self, parser):
pass
def handle(self, *args, **options):
pending_vms = VMProduct.objects.filter(vmhost__isnull=True)
vmhosts = VMHost.objects.filter(status='active')
# 1. Check that all active hosts reported back N seconds ago
# 2. Check that no VM is running on a dead host
# 3. Migrate VMs if necessary
# 4. Check that no VMs have been pending for longer than Y seconds
2020-02-25 21:04:04 +00:00
# If VM snapshots exist without a VM -> notify user (?)
2020-02-25 21:01:55 +00:00
print("Nothing is good, you should implement me")