Commit 9f1fb1e0 by Máhonfai Bálint

Add custom django command for mass creating VMs for users

parent 8996b587
Pipeline #1149 failed with stage
in 0 seconds
from django.core.management.base import BaseCommand
from vm.models import Instance, InstanceTemplate
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('template_id', type=int)
parser.add_argument('users_path')
def handle(self, *args, **options):
template = InstanceTemplate.objects.get(id=options['template_id'])
with open(options['users_path']) as f:
users = f.read().splitlines()
missing_users = Instance.mass_create_for_users(template, users)
if len(missing_users) > 0:
self.stdout.write('These users do not exist:')
for user in missing_users:
self.stdout.write(user)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment