Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
1a46f311
Commit
1a46f311
authored
Jul 14, 2018
by
Charlie Jacomme
Committed by
Gabriel Detraz
Aug 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serializers for reverse DNS
parent
cd5d0f56
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
0 deletions
+39
-0
api/serializers.py
api/serializers.py
+18
-0
api/urls.py
api/urls.py
+1
-0
api/views.py
api/views.py
+9
-0
machines/models.py
machines/models.py
+11
-0
No files found.
api/serializers.py
View file @
1a46f311
...
...
@@ -817,6 +817,24 @@ class DNSZonesSerializer(serializers.ModelSerializer):
'aaaa_records'
,
'cname_records'
,
'sshfp_records'
)
class
DNSReverseZonesSerializer
(
serializers
.
ModelSerializer
):
"""Serialize the data about DNS Zones.
"""
soa
=
SOARecordSerializer
(
source
=
'extension.soa'
)
extension
=
serializers
.
CharField
(
source
=
'extension.name'
,
read_only
=
True
)
cidrs
=
serializers
.
CharField
(
source
=
'ip_set_cidrs_as_str'
,
read_only
=
True
)
ns_records
=
NSRecordSerializer
(
many
=
True
,
source
=
'extension.ns_set'
)
mx_records
=
MXRecordSerializer
(
many
=
True
,
source
=
'extension.mx_set'
)
txt_records
=
TXTRecordSerializer
(
many
=
True
,
source
=
'extension.txt_set'
)
ptr_records
=
ARecordSerializer
(
many
=
True
,
source
=
'get_associated_ptr_records'
)
ptr_v6_records
=
AAAARecordSerializer
(
many
=
True
,
source
=
'get_associated_ptr_v6_records'
)
class
Meta
:
model
=
machines
.
IpType
fields
=
(
'type'
,
'extension'
,
'soa'
,
'ns_records'
,
'mx_records'
,
'txt_records'
,
'ptr_records'
,
'ptr_v6_records'
,
'cidrs'
)
# MAILING
...
...
api/urls.py
View file @
1a46f311
...
...
@@ -104,6 +104,7 @@ router.register_view(r'localemail/users', views.LocalEmailUsersView),
router
.
register_view
(
r
'firewall/subnet-ports'
,
views
.
SubnetPortsOpenView
),
# DNS
router
.
register_view
(
r
'dns/zones'
,
views
.
DNSZonesView
),
router
.
register_view
(
r
'dns/reverse-zones'
,
views
.
DNSReverseZonesView
),
# MAILING
router
.
register_view
(
r
'mailing/standard'
,
views
.
StandardMailingView
),
router
.
register_view
(
r
'mailing/club'
,
views
.
ClubMailingView
),
...
...
api/views.py
View file @
1a46f311
...
...
@@ -555,6 +555,15 @@ class DNSZonesView(generics.ListAPIView):
.
all
())
serializer_class
=
serializers
.
DNSZonesSerializer
class
DNSReverseZonesView
(
generics
.
ListAPIView
):
"""Exposes the detailed information about each extension (hostnames,
IPs, DNS records, etc.) in order to build the DNS zone files.
"""
queryset
=
(
machines
.
IpType
.
objects
.
all
())
serializer_class
=
serializers
.
DNSReverseZonesSerializer
# MAILING
...
...
machines/models.py
View file @
1a46f311
...
...
@@ -353,6 +353,17 @@ class IpType(RevMixin, AclMixin, models.Model):
):
ipv6
.
check_and_replace_prefix
(
prefix
=
self
.
prefix_v6
)
def
get_associated_ptr_records
(
self
):
from
re2o.utils
import
all_active_assigned_interfaces
return
(
all_active_assigned_interfaces
()
.
filter
(
type__ip_type
=
self
)
.
filter
(
ipv4__isnull
=
False
))
def
get_associated_ptr_v6_records
(
self
):
from
re2o.utils
import
all_active_interfaces
return
(
all_active_interfaces
(
full
=
True
)
.
filter
(
type__ip_type
=
self
))
def
clean
(
self
):
""" Nettoyage. Vérifie :
- Que ip_stop est après ip_start
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment