forked from uncloud/uncloud
vmhosts, restructure urls, etc.
This commit is contained in:
parent
d4b170f813
commit
c7ded96658
9 changed files with 134 additions and 47 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
|
||||
24
uncloud/uncloud_vm/management/commands/vmhealth.py
Normal file
24
uncloud/uncloud_vm/management/commands/vmhealth.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
|
||||
|
||||
print("Nothing is good, you should implement me")
|
||||
Loading…
Add table
Add a link
Reference in a new issue