forked from uncloud/uncloud
fix migrations the ugly way
Signed-off-by: Nico Schottelius <nico@nico-notebook.schottelius.org>
This commit is contained in:
parent
d658b9635d
commit
0c7ca1147a
28 changed files with 524 additions and 432 deletions
21
uncloud/uncloud_vm/management/commands/schedulevms.py
Normal file
21
uncloud/uncloud_vm/management/commands/schedulevms.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import json
|
||||
|
||||
import uncloud.secrets as secrets
|
||||
|
||||
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 = 'Select VM Host for VMs'
|
||||
|
||||
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')
|
||||
for vm in pending_vms:
|
||||
print(vm)
|
||||
# FIXME: implement smart placement
|
||||
26
uncloud/uncloud_vm/management/commands/vmhealth.py
Normal file
26
uncloud/uncloud_vm/management/commands/vmhealth.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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")
|
||||
Loading…
Add table
Add a link
Reference in a new issue