Commit d692c2f4 by Kálmán Viktor

dashboard: create vms with disks and networks

parent 1bc7ae27
...@@ -221,14 +221,23 @@ class VmCreate(TemplateView): ...@@ -221,14 +221,23 @@ class VmCreate(TemplateView):
'num_cores': int(request.POST.get('cpu-count')), 'num_cores': int(request.POST.get('cpu-count')),
'ram_size': int(request.POST.get('ram-size')), 'ram_size': int(request.POST.get('ram-size')),
'priority': int(request.POST.get('cpu-priority')), 'priority': int(request.POST.get('cpu-priority')),
'disks': Disk.objects.filter(
pk__in=request.POST.getlist('disks'))
} }
networks = [{'vlan': Vlan.objects.get(pk=l), 'managed': True}
for l in request.POST.getlist('managed-vlans')
]
networks.extend([{'vlan': Vlan.objects.get(pk=l),
'managed': False}
for l in request.POST.getlist('unmanaged-vlans')
])
disks = Disk.objects.filter(pk__in=request.POST.getlist('disks'))
template = InstanceTemplate.objects.get( template = InstanceTemplate.objects.get(
pk=request.POST.get('template-pk')) pk=request.POST.get('template-pk'))
inst = Instance.create_from_template(template=template, inst = Instance.create_from_template(template=template,
owner=user, **ikwargs) owner=user, networks=networks,
disks=disks, **ikwargs)
inst.deploy_async() inst.deploy_async()
resp['pk'] = inst.pk resp['pk'] = inst.pk
......
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