Commit 4ef2a8a8 by Karsa Zoltán István

filter ci disk

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