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 import BaseCommand
from vm.models import Instance, InstanceTemplate
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('template_id', type=int)
def handle(self, *args, **options):
template = InstanceTemplate.objects.get(id=options['template_id'])
with open(options['users_path']) as f:
users =
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:
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