Add template for creating VMs

This commit is contained in:
Nico Schottelius 2020-03-22 18:52:31 +01:00
parent 08fe3e689e
commit 105142f76a
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
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 VMSnapshotProduct
from datetime import datetime
class Command(BaseCommand):
help = 'Select VM Host for VMs'
def add_arguments(self, parser):
parser.add_argument('--this-hostname', required=True)
# parser.add_argument('--start-vms-here', action='store_true')
# parser.add_argument('--check-health', action='store_true')
# parser.add_argument('--vmhostname')
# print(parser)
def handle(self, *args, **options):
for snapshot in VMSnapshotProduct.objects.filter(status='PENDING'):
if not snapshot.extra_data:
snapshot.extra_data = {}
# TODO: implement locking here
if 'creating_hostname' in snapshot.extra_data:
pass
snapshot.extra_data['creating_hostname'] = options['this_hostname']
snapshot.extra_data['creating_start'] = str(datetime.now())
snapshot.save()
print(snapshot)