forked from uncloud/uncloud
26 lines
816 B
Python
26 lines
816 B
Python
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
|
|
|
|
# If VM snapshots exist without a VM -> notify user (?)
|
|
|
|
|
|
print("Nothing is good, you should implement me")
|