Commit 4ef2a8a8 by Karsa Zoltán István

filter ci disk

parent 20af2315
......@@ -82,8 +82,12 @@ class InstanceSerializer(serializers.ModelSerializer):
macaddr = serializers.SerializerMethodField('get_mac')
sshportipv4 = serializers.SerializerMethodField('get_sshportipv4')
hostipv4 = serializers.SerializerMethodField('get_hostipv4')
disks = serializers.SerializerMethodField('get_disks')
#interfaces = serializers.SerializerMethodField('get_interfaces')
def get_disks(self, i):
return list(disk.id for disk in i.disks.filter(ci_disk=False).all())
def get_ipv4(self, i):
return str(i.ipv4)
......
......@@ -260,10 +260,16 @@ class InstanceREST(APIView):
serializer = InstanceSerializer(data=data)
if serializer.is_valid():
inst = serializer.save()
if 'disks' in data:
for d in data['disks']:
d = Disk.objects.get(id=d)
inst.disks.add(d)
inst.save()
networks = []
if 'vlans' in data:
for v in data['vlans']:
v = Vlan.objects.filter(vid=v).get()
v = Vlan.objects.get(id=v)
if not v.has_level(request.user, "user"):
raise PermissionDenied()
networks.append(InterfaceTemplate(vlan=v, managed=v.managed))
......
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