From 4dbbb00cf7fc4867ce1ef0c2258600d54b150cf0 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Sun, 30 Dec 2018 17:16:30 +0100 Subject: [PATCH] Export of modules of a switch --- topologie/models.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/topologie/models.py b/topologie/models.py index a4f5f3bc..53e9ffe6 100644 --- a/topologie/models.py +++ b/topologie/models.py @@ -368,6 +368,17 @@ class Switch(AclMixin, Machine): """Return dict ip6:subnet for all ipv6 of the switch""" return dict((str(interface.ipv6().first()), interface.type.ip_type.ip6_set_full_info) for interface in self.interface_set.all()) + @cached_property + def list_modules(self): + """Return modules of that switch, list of dict (rank, reference)""" + modules = [] + if self.model.is_modular: + if self.model.is_itself_module: + modules.append((1, self.model.reference)) + for module_of_self in self.moduleonswitch_set.all(): + modules.append((module_of_self.slot, module_of_self.module.reference)) + return modules + def __str__(self): return str(self.get_name)