netbox-device-view 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -92,10 +92,6 @@
92
92
  <input onChange="this.form.submit()" type="checkbox" name="cable_colors" class="form-check-input" {% if cable_colors == "on" %}checked{% endif %} />
93
93
  <label for="cable_colors" class="form-check-label">Cable Colors</label>
94
94
  </div>
95
- <div class="form-check">
96
- <input onChange="this.form.submit()" type="checkbox" name="something_else" class="form-check-input" {% if something_else == "on" %}checked{% endif %} />
97
- <label for="something_else" class="form-check-label">something_else</label>
98
- </div>
99
95
  </form>
100
96
  </div>
101
97
  </div>
@@ -5,10 +5,12 @@ from django.core.exceptions import ObjectDoesNotExist
5
5
  import re
6
6
 
7
7
 
8
- def process_interfaces(interfaces, ports_chassis, dev=1):
8
+ def process_interfaces(interfaces, ports_chassis, dev):
9
9
  if interfaces is not None:
10
10
  for itf in interfaces:
11
- regex = r"^(?P<type>([a-z]+))((?P<dev>[0-9]+)\/)?((?P<module>[0-9]+)\/)?((?P<port>[0-9]+))$"
11
+ if itf.type == "virtual" or itf.type == "lag":
12
+ continue
13
+ regex = r"^(?P<type>([a-zA-Z\-_]*))(\/|(?P<dev>[0-9]+).|\s)?((?P<module>[0-9]+).|\s)?((?P<port>[0-9]+))$"
12
14
  matches = re.search(regex, itf.name.lower())
13
15
  if matches:
14
16
  itf.stylename = (
@@ -17,37 +19,28 @@ def process_interfaces(interfaces, ports_chassis, dev=1):
17
19
  + "-"
18
20
  + matches["port"]
19
21
  )
20
- sw = int(matches["dev"] or 999)
21
- if (
22
- hasattr(itf, "mgmt_only")
23
- and itf.mgmt_only
24
- and itf.type != "virtual"
25
- ) or hasattr(itf, "mgmt_only") == False:
26
- sw = dev
27
- if sw not in ports_chassis and sw != 999:
28
- ports_chassis[sw] = []
29
- if sw != 999:
30
- ports_chassis[sw].append(itf)
22
+ else:
23
+ itf.stylename = re.sub(r"[^.a-zA-Z\d]", "-", itf.name.lower())
24
+ if itf.stylename.isdigit():
25
+ itf.stylename = f"p{itf.stylename}"
26
+ if dev not in ports_chassis:
27
+ ports_chassis[dev] = []
28
+ ports_chassis[dev].append(itf)
31
29
  return ports_chassis
32
30
 
33
31
 
34
- def process_ports(ports, ports_chassis, where):
32
+ def process_ports(ports, ports_chassis, dev):
35
33
  if ports is not None:
36
34
  for port in ports:
37
- regex = r"^(?P<type>([A-Za-z]+))[\s]?((?P<port>[0-9]+))$"
38
- matches = re.search(regex, port.name.lower())
39
- port.is_port = True
40
- if matches:
41
- port.stylename = (matches["type"] or "") + "-" + matches["port"]
42
- else:
43
- port.stylename = re.sub(r"[^.a-zA-Z\d]", "-", port.name.lower())
44
- sw = where
45
35
  if port.type == "virtual":
46
- sw = 999
47
- if sw not in ports_chassis and sw != 999:
48
- ports_chassis[sw] = []
49
- if sw != 999:
50
- ports_chassis[sw].append(port)
36
+ continue
37
+ port.is_port = True
38
+ port.stylename = re.sub(r"[^.a-zA-Z\d]", "-", port.name.lower())
39
+ if port.stylename.isdigit():
40
+ port.stylename = f"p{port.stylename}"
41
+ if dev not in ports_chassis:
42
+ ports_chassis[dev] = []
43
+ ports_chassis[dev].append(port)
51
44
  return ports_chassis
52
45
 
53
46
 
@@ -62,7 +55,7 @@ def prepare(obj):
62
55
  device_type=obj.device_type
63
56
  ).grid_template_area
64
57
  modules[1] = obj.modules.all()
65
- ports_chassis = process_interfaces(obj.interfaces.all(), ports_chassis)
58
+ ports_chassis = process_interfaces(obj.interfaces.all(), ports_chassis, 1)
66
59
  ports_chassis = process_ports(obj.frontports.all(), ports_chassis, "Front")
67
60
  ports_chassis = process_ports(obj.rearports.all(), ports_chassis, "Rear")
68
61
  ports_chassis = process_ports(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: netbox-device-view
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: NetBox Device View plugin
5
5
  Home-page: https://github.com/peterbaumert/netbox-device-view
6
6
  Author: Peter Baumert
@@ -54,10 +54,12 @@ For each Device Type you need to add a DeviceView.
54
54
 
55
55
  It is based on a CSS grid view with 32 columns and 2 rows.
56
56
  You need to specify the grid-template-areas.
57
- - Interface positions will use the following format: {interfacename}{module}-{port}
57
+ - Interface positions will use the following format: {interfacename}{module}-{port}
58
+ or fallback to all lower case + [^.a-zA-Z\d] changed to "-"
58
59
  - leading "empties" can be specified as x
59
60
  - trailing "empties" can be specified as z
60
61
  - between "empties" can be named s{0-99}
62
+ - numeric only ports have to be prefixed with "p" e.g. "p1"
61
63
 
62
64
  Example for Cisco C9300-24T with 8x 10G module ( more in [examples](https://github.com/peterbaumert/netbox-device-view/blob/main/examples/) folder )
63
65
 
@@ -6,7 +6,7 @@ netbox_device_view/navigation.py,sha256=FYzQyTOz8xzLs559KeI0nbY2nPlKipsfPeiV5y1n
6
6
  netbox_device_view/tables.py,sha256=ejhKjD5fGo_tLUhTExqBhDL_TbYVe9TPnzF-ZWHqujY,351
7
7
  netbox_device_view/template_content.py,sha256=gK7KNUcangjNl4janloXjGqs1jBSKllvYLhyf2_LaEA,1072
8
8
  netbox_device_view/urls.py,sha256=UhLOmfj0v4ofRnHM-bxisTnIPQ2viS8I47AyHiA20LU,839
9
- netbox_device_view/utils.py,sha256=gkBv2LpmeHkiI9Gpvf8VeoMNIo1jb-vhkW9EmVUDymQ,3472
9
+ netbox_device_view/utils.py,sha256=uUPJnwYfEpM6H61Z-BkyNeQwmWm3xJY5Z9-Xe9Jp7f8,3191
10
10
  netbox_device_view/views.py,sha256=8OQQE-BZPM_ZXXopiRGJStdXq6eAE_tndfRVvHLkA2U,1778
11
11
  netbox_device_view/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  netbox_device_view/api/serializers.py,sha256=IQEFuIh7X22MWO4jxv4MctZQxln-DgH2eo-0IbdvBl4,456
@@ -15,9 +15,9 @@ netbox_device_view/api/views.py,sha256=4sID0Rad-OVBnTD4MTpMpMYg-FnOLQlsyIhfcNsg2
15
15
  netbox_device_view/migrations/0001_initial.py,sha256=2maF1lEro3LuqdQqKwrBs1ABpw7KsTdTqLxiSlrU_SI,1783
16
16
  netbox_device_view/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  netbox_device_view/static/netbox_device_view/css/device_view.css,sha256=VnvjTMPrEnUkpb_odDe6-VJKhBXZ6RuII4Ce3EnPDCc,833
18
- netbox_device_view/templates/netbox_device_view/deviceview.html,sha256=fMQ7p1qi-v_Rdl39TOIgZz3XGKxNxjNUSVhHJ1YXhbk,3168
18
+ netbox_device_view/templates/netbox_device_view/deviceview.html,sha256=iYfqjTO_tvp0c7_0s7AxKmzHC_6JRxxbRahPxoTi3NQ,2893
19
19
  netbox_device_view/templates/netbox_device_view/ports.html,sha256=H-OVDZfpa-s3NB5a3ZJmrNbir001wfYfKJss8bppBgk,1716
20
- netbox_device_view-0.1.2.dist-info/METADATA,sha256=2bbaFhnN2EE1sd1mY5a6M_MGtmrgtLhBWpl6dvtlTBY,3630
21
- netbox_device_view-0.1.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
22
- netbox_device_view-0.1.2.dist-info/top_level.txt,sha256=Cj7X6_XpLT0jnyTyX5DMqttqc8_z3uhRYCmvnXLfWOs,19
23
- netbox_device_view-0.1.2.dist-info/RECORD,,
20
+ netbox_device_view-0.1.4.dist-info/METADATA,sha256=7V-rw6KG23oeodAYd_z02M7Z9VORPlL3-mXI4mk65U8,3753
21
+ netbox_device_view-0.1.4.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
22
+ netbox_device_view-0.1.4.dist-info/top_level.txt,sha256=Cj7X6_XpLT0jnyTyX5DMqttqc8_z3uhRYCmvnXLfWOs,19
23
+ netbox_device_view-0.1.4.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.40.0)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5