Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
64301bda
Commit
64301bda
authored
Dec 30, 2018
by
Gabriel Detraz
Committed by
klafyvel
Jan 03, 2019
Browse files
Export list_modules + return [] if no models for modules
parent
82802de4
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/serializers.py
View file @
64301bda
...
@@ -811,7 +811,8 @@ class SwitchPortSerializer(serializers.ModelSerializer):
...
@@ -811,7 +811,8 @@ class SwitchPortSerializer(serializers.ModelSerializer):
model
=
topologie
.
Switch
model
=
topologie
.
Switch
fields
=
(
'short_name'
,
'model'
,
'switchbay'
,
'ports'
,
'ipv4'
,
'ipv6'
,
fields
=
(
'short_name'
,
'model'
,
'switchbay'
,
'ports'
,
'ipv4'
,
'ipv6'
,
'interfaces_subnet'
,
'interfaces6_subnet'
,
'automatic_provision'
,
'rest_enabled'
,
'interfaces_subnet'
,
'interfaces6_subnet'
,
'automatic_provision'
,
'rest_enabled'
,
'web_management_enabled'
,
'get_radius_key_value'
,
'get_management_cred_value'
)
'web_management_enabled'
,
'get_radius_key_value'
,
'get_management_cred_value'
,
'list_modules'
)
# LOCAL EMAILS
# LOCAL EMAILS
...
...
topologie/models.py
View file @
64301bda
...
@@ -372,7 +372,7 @@ class Switch(AclMixin, Machine):
...
@@ -372,7 +372,7 @@ class Switch(AclMixin, Machine):
def
list_modules
(
self
):
def
list_modules
(
self
):
"""Return modules of that switch, list of dict (rank, reference)"""
"""Return modules of that switch, list of dict (rank, reference)"""
modules
=
[]
modules
=
[]
if
self
.
model
.
is_modular
:
if
getattr
(
self
.
model
,
'
is_modular
'
,
None
)
:
if
self
.
model
.
is_itself_module
:
if
self
.
model
.
is_itself_module
:
modules
.
append
((
1
,
self
.
model
.
reference
))
modules
.
append
((
1
,
self
.
model
.
reference
))
for
module_of_self
in
self
.
moduleonswitch_set
.
all
():
for
module_of_self
in
self
.
moduleonswitch_set
.
all
():
...
...
Write
Preview
Supports
Markdown
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