Commit 234b2dc3 authored by chapeau's avatar chapeau Committed by root

Add ip_type in dhcp api serializer

parent 706b309a
Pipeline #2372 canceled with stage
......@@ -1168,11 +1168,12 @@ class HostMacIpSerializer(serializers.ModelSerializer):
hostname = serializers.CharField(source="domain.name", read_only=True)
extension = serializers.CharField(source="domain.extension.name", read_only=True)
mac_address = serializers.CharField(read_only=True)
ip_type = serializers.CharField(source="machine_type.ip_type", read_only=True)
ipv4 = serializers.CharField(source="ipv4.ipv4", read_only=True)
class Meta:
model = machines.Interface
fields = ("hostname", "extension", "mac_address", "ipv4")
fields = ("hostname", "extension", "mac_address", "ipv4", "ip_type")
# DNS
......
......@@ -81,10 +81,12 @@ class InterfaceSerializer(serializers.ModelSerializer):
mac_address = serializers.SerializerMethodField("get_macaddress")
domain = serializers.SerializerMethodField("get_dns")
extension = serializers.SerializerMethodField("get_interface_extension")
machine_type = serializers.SerializerMethodField("get_machinetype")
class Meta:
model = Interface
fields = ("ipv4", "mac_address", "domain", "extension")
fields = ("ipv4", "mac_address", "domain", "extension", "machinetype")
@staticmethod
def get_dns(obj):
......@@ -101,6 +103,10 @@ class InterfaceSerializer(serializers.ModelSerializer):
""" The string representation of the associated MAC address """
return str(obj.mac_address)
@staticmethod
def get_machine(obj):
""" The name of the associated machine type """
return str(obj.machinetype)
class FullInterfaceSerializer(serializers.ModelSerializer):
""" Serializer for an Interface obejct. Use SerializerMethodField
......
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 to comment