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
4662df73
Commit
4662df73
authored
Mar 27, 2018
by
Gabriel Detraz
Committed by
root
Mar 27, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unifi_ap_names dans re2o-tools
parent
708d897e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
47 deletions
+45
-47
api/urls.py
api/urls.py
+3
-0
api/views.py
api/views.py
+30
-0
topologie/management/commands/sync_unifi_ap.py
topologie/management/commands/sync_unifi_ap.py
+0
-47
topologie/models.py
topologie/models.py
+12
-0
No files found.
api/urls.py
View file @
4662df73
...
...
@@ -45,6 +45,9 @@ urlpatterns = [
url
(
r
'^dns/srv/$'
,
views
.
dns_srv
),
url
(
r
'^dns/zones/$'
,
views
.
dns_zones
),
# Unifi controler AP names
url
(
r
'^unifi/ap_names/$'
,
views
.
accesspoint_ip_dns
),
# Firewall
url
(
r
'^firewall/ouverture_ports/$'
,
views
.
firewall_ouverture_ports
),
...
...
api/views.py
View file @
4662df73
...
...
@@ -163,6 +163,36 @@ def dns_alias(request):
return
JSONSuccess
(
seria
.
data
)
@
csrf_exempt
@
login_required
@
permission_required
(
'machines.serveur'
)
@
accept_method
([
'GET'
])
def
accesspoint_ip_dns
(
request
):
"""The list of all active interfaces with all the associated infos
(MAC, IP, IpType, DNS name and associated zone extension)
Only display access points. Use to gen unifi controler names
Returns:
GET:
A JSON Success response with a field `data` containing:
* a list of dictionnaries (one for each interface) containing:
* a field `ipv4` containing:
* a field `ipv4`: the ip for this interface
* a field `ip_type`: the name of the IpType of this interface
* a field `ipv6` containing `null` if ipv6 is deactivated else:
* a field `ipv6`: the ip for this interface
* a field `ip_type`: the name of the IpType of this interface
* a field `mac_address`: the MAC of this interface
* a field `domain`: the DNS name for this interface
* a field `extension`: the extension for the DNS zone of this interface
"""
interfaces
=
all_active_assigned_interfaces
(
full
=
True
)
\
.
filter
(
machine__accesspoint__isnull
=
False
)
seria
=
FullInterfaceSerializer
(
interfaces
,
many
=
True
)
return
JSONSuccess
(
seria
.
data
)
@
csrf_exempt
@
login_required
@
permission_required
(
'machines.serveur'
)
...
...
topologie/management/commands/sync_unifi_ap.py
deleted
100644 → 0
View file @
708d897e
# ⁻*- mode: python; coding: utf-8 -*-
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
# se veut agnostique au réseau considéré, de manière à être installable en
# quelques clics.
#
# Copyright © 2018 Gabriel Detraz
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
from
django.core.management.base
import
BaseCommand
,
CommandError
from
pymongo
import
MongoClient
from
topologie.models
import
Borne
class
Command
(
BaseCommand
):
help
=
'Ce script donne un nom aux bornes dans le controleur unifi.
A lancer sur le serveur en local où se trouve le controleur'
def
handle
(
self
,
*
args
,
**
options
):
# Connexion mongodb
client
=
MongoClient
(
"mongodb://localhost:27117"
)
db
=
client
.
ace
device
=
db
[
'device'
]
bornes
=
Borne
.
objects
.
all
()
def
set_bornes_names
(
liste_bornes
):
"""Met à jour les noms des bornes dans la bdd du controleur"""
for
borne
in
liste_bornes
:
if
borne
.
ipv4
and
borne
.
domain
:
device
.
find_one_and_update
({
'ip'
:
str
(
borne
.
ipv4
)},
{
'$set'
:
{
'name'
:
str
(
borne
.
domain
.
name
)}})
return
set_bornes_names
(
bornes
)
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
'Mise à jour de la base de donnée unifi avec succès'
))
topologie/models.py
View file @
4662df73
...
...
@@ -538,6 +538,18 @@ class Room(models.Model):
return
self
.
name
@
receiver
(
post_save
,
sender
=
AccessPoint
)
def
ap_post_save
(
sender
,
**
kwargs
):
"""Regeneration des noms des bornes vers le controleur"""
regen
(
'unifi-ap-names'
)
@
receiver
(
post_delete
,
sender
=
AccessPoint
)
def
ap_post_delete
(
sender
,
**
kwargs
):
"""Regeneration des noms des bornes vers le controleur"""
regen
(
'unifi-ap-names'
)
@
receiver
(
post_delete
,
sender
=
Stack
)
def
stack_post_delete
(
sender
,
**
kwargs
):
"""Vide les id des switches membres d'une stack supprimée"""
...
...
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