Commit 3572f870 by Kálmán Viktor

vm: networks as objects and not dicts in Instance create_from_template

parent 4b2c34ea
......@@ -224,11 +224,12 @@ 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}
networks.extend([InterfaceTemplate(vlan=Vlan.objects.get(pk=l),
managed=False)
for l in request.POST.getlist('unmanaged-vlans')
])
......
......@@ -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