mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
DNS view is a generic view and service regen view is a viewset
This commit is contained in:
parent
197475409c
commit
761fad578a
4 changed files with 22 additions and 15 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -43,3 +43,13 @@ Refactored install_re2o.sh script.
|
|||
install_re2o.sh help
|
||||
```
|
||||
* The installation templates (LDIF files and `re2o/settings_locale.example.py`) have been changed to use `example.net` instead of `example.org` (more neutral and generic)
|
||||
|
||||
|
||||
|
||||
## MR XXX: Cleanup and refactor API
|
||||
|
||||
Activate HTTP Authorization passthrough in by adding the following in /etc/apache2/site-available/re2o.conf (example in install_utils/apache2/re2o.conf):
|
||||
```
|
||||
WSGIPassAuthorization On
|
||||
```
|
||||
|
||||
|
|
|
@ -214,8 +214,6 @@ class ServiceSerializer(NamespacedHMSerializer):
|
|||
|
||||
|
||||
class ServiceLinkSerializer(NamespacedHMSerializer):
|
||||
need_regen = serializers.BooleanField()
|
||||
|
||||
class Meta:
|
||||
model = machines.Service_link
|
||||
fields = ('service', 'server', 'last_regen', 'asked_regen',
|
||||
|
@ -466,12 +464,13 @@ class WhitelistSerializer(NamespacedHMSerializer):
|
|||
class ServiceRegenSerializer(NamespacedHMSerializer):
|
||||
hostname = serializers.CharField(source='server.domain.name', read_only=True)
|
||||
service_name = serializers.CharField(source='service.service_type', read_only=True)
|
||||
need_regen = serializers.BooleanField()
|
||||
|
||||
class Meta:
|
||||
model = machines.Service_link
|
||||
fields = ('hostname', 'service_name', 'need_regen', 'api_url')
|
||||
extra_kwargs = {
|
||||
'api_url': {'view_name': 'servicelink-detail'}
|
||||
'api_url': {'view_name': 'serviceregen-detail'}
|
||||
}
|
||||
|
||||
|
||||
|
@ -545,7 +544,7 @@ class ARecordSerializer(serializers.ModelSerializer):
|
|||
|
||||
class AAAARecordSerializer(serializers.ModelSerializer):
|
||||
hostname = serializers.CharField(source='domain.name', read_only=True)
|
||||
ipv6 = serializers.CharField(read_only=True)
|
||||
ipv6 = Ipv6ListSerializer(many=True, read_only=True)
|
||||
|
||||
class Meta:
|
||||
model = machines.Interface
|
||||
|
@ -561,7 +560,7 @@ class CNAMERecordSerializer(serializers.ModelSerializer):
|
|||
fields = ('alias', 'hostname')
|
||||
|
||||
|
||||
class DNSZonesSerializer(NamespacedHMSerializer):
|
||||
class DNSZonesSerializer(serializers.ModelSerializer):
|
||||
soa = SOARecordSerializer()
|
||||
ns_records = NSRecordSerializer(many=True, source='ns_set')
|
||||
originv4 = OriginV4RecordSerializer(source='origin')
|
||||
|
@ -577,7 +576,4 @@ class DNSZonesSerializer(NamespacedHMSerializer):
|
|||
model = machines.Extension
|
||||
fields = ('name', 'soa', 'ns_records', 'originv4', 'originv6',
|
||||
'mx_records', 'txt_records', 'srv_records', 'a_records',
|
||||
'aaaa_records', 'cname_records', 'api_url')
|
||||
extra_kwargs = {
|
||||
'api_url': {'view_name': 'dnszone-detail'}
|
||||
}
|
||||
'aaaa_records', 'cname_records')
|
||||
|
|
|
@ -86,12 +86,13 @@ router.register(r'users/listrights', views.ListRightViewSet)
|
|||
router.register(r'users/shells', views.ShellViewSet, base_name='shell')
|
||||
router.register(r'users/bans', views.BanViewSet)
|
||||
router.register(r'users/whitelists', views.WhitelistViewSet)
|
||||
# DNS
|
||||
router.register(r'dns/zones', views.DNSZonesViewSet, base_name='dnszone')
|
||||
# SERVICES REGEN
|
||||
router.register(r'services/regen', views.ServiceRegenViewSet, base_name='serviceregen')
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^', include(router.urls)),
|
||||
url(r'^dhcp/hostmacip', views.HostMacIpView.as_view()),
|
||||
url(r'^services/regen', views.ServiceRegenView.as_view()),
|
||||
url(r'^dns/zones', views.DNSZonesView.as_view()),
|
||||
url(r'^token-auth', views.ObtainExpiringAuthToken.as_view())
|
||||
]
|
||||
|
|
|
@ -160,7 +160,7 @@ class ServiceViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
serializer_class = serializers.ServiceSerializer
|
||||
|
||||
|
||||
class ServiceLinkViewSet(viewsets.ModelViewSet):
|
||||
class ServiceLinkViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
queryset = machines.Service_link.objects.all()
|
||||
serializer_class = serializers.ServiceLinkSerializer
|
||||
|
||||
|
@ -316,7 +316,7 @@ class WhitelistViewSet(viewsets.ReadOnlyModelViewSet):
|
|||
# Services views
|
||||
|
||||
|
||||
class ServiceRegenView(generics.ListAPIView):
|
||||
class ServiceRegenViewSet(viewsets.ModelViewSet):
|
||||
serializer_class = serializers.ServiceRegenSerializer
|
||||
|
||||
def get_queryset(self):
|
||||
|
@ -340,7 +340,7 @@ class HostMacIpView(generics.ListAPIView):
|
|||
|
||||
# DNS views
|
||||
|
||||
class DNSZonesViewSet(viewsets.ReadOnlyModelViewSet):
|
||||
class DNSZonesView(generics.ListAPIView):
|
||||
queryset = machines.Extension.objects.all()
|
||||
serializer_class = serializers.DNSZonesSerializer
|
||||
|
||||
|
|
Loading…
Reference in a new issue