diff --git a/api/serializers.py b/api/serializers.py index 05075606..9c0531ca 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -675,6 +675,15 @@ class SubnetPortsOpenSerializer(serializers.ModelSerializer): model = machines.IpType fields = ('type', 'domaine_ip_start', 'domaine_ip_stop', 'complete_prefixv6', 'ouverture_ports') +class InterfacePortsOpenSerializer(serializers.ModelSerializer): + port_lists = FirewallOuverturePortListSerializer(read_only=True, many=True) + ipv4 = serializers.CharField(source='ipv4.ipv4', read_only=True) + ipv6 = Ipv6ListSerializer(many=True, read_only=True) + + class Meta: + model = machines.Interface + fields = ('port_lists', 'ipv4', 'ipv6') + # DHCP diff --git a/api/urls.py b/api/urls.py index 3bcaee0e..19757c1d 100644 --- a/api/urls.py +++ b/api/urls.py @@ -103,6 +103,7 @@ router.register_view(r'dhcp/hostmacip', views.HostMacIpView), router.register_view(r'localemail/users', views.LocalEmailUsersView), # Firewall router.register_view(r'firewall/subnet-ports', views.SubnetPortsOpenView), +router.register_view(r'firewall/interface-ports', views.InterfacePortsOpenView), # DNS router.register_view(r'dns/zones', views.DNSZonesView), router.register_view(r'dns/reverse-zones', views.DNSReverseZonesView), diff --git a/api/views.py b/api/views.py index f284abbe..fae55d1e 100644 --- a/api/views.py +++ b/api/views.py @@ -544,6 +544,10 @@ class SubnetPortsOpenView(generics.ListAPIView): queryset = machines.IpType.objects.all() serializer_class = serializers.SubnetPortsOpenSerializer +class InterfacePortsOpenView(generics.ListAPIView): + queryset = machines.Interface.objects.filter(port_lists__isnull=False).distinct() + serializer_class = serializers.InterfacePortsOpenSerializer + # DNS