Commit 3572f870 by Kálmán Viktor

vm: networks as objects and not dicts in Instance create_from_template

parent 4b2c34ea
......@@ -224,12 +224,13 @@ class VmCreate(TemplateView):
'priority': int(request.POST.get('cpu-priority')),
}
networks = [{'vlan': Vlan.objects.get(pk=l), 'managed': True}
networks = [InterfaceTemplate(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')
networks.extend([InterfaceTemplate(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'))
......
......@@ -429,8 +429,8 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
inst.disks.add(*[disk.get_exclusive() for disk in disks])
for net in networks:
i = Interface.create(instance=inst, vlan=net['vlan'], owner=owner,
managed=net['managed'])
i = Interface.create(instance=inst, vlan=net.vlan, owner=owner,
managed=net.managed)
if i.host:
i.host.enable_net()
port, proto = ACCESS_PROTOCOLS[i.instance.access_method][1:3]
......
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