Rack: ports-facing separate from posts, three views, ZimaBoard 832 shelves to scale
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m0s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m9s
Lint / Python (flake8) (pull_request) Successful in 57s
Test / Python Tests (pytest) (push) Successful in 1m14s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 56s
Test / Python Tests (pytest) (pull_request) Successful in 1m5s
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m0s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m9s
Lint / Python (flake8) (pull_request) Successful in 57s
Test / Python Tests (pytest) (push) Successful in 1m14s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 56s
Test / Python Tests (pytest) (pull_request) Successful in 1m5s
Gear on the rear posts usually still faces the front (the StarTech's RPDU and ZimaBoard shelf), so "which posts" and "which way the ports face" are now separate fields (mount, facing). The page has three views: Front (front posts), Rear posts (rear-post gear seen from the front, i.e. what is behind the front gear) and Rear (from behind). An item seen from the side it doesn't face shows its back. Facing defaults to front, so existing items keep their meaning. Shelves are drawn at true scale with their contents ordered by a new "Position on shelf". The IceWhale ZimaBoard 832 is traced from IceWhale's labelled photo of its port end (ZimaDocs): Mini-DP, two RJ45-over-USB 3.0 stacks with link/activity LEDs, DC jack, gunmetal case, gold PCB edge and black base. Its RJ45 link lights follow the host's physical NICs and the status glow follows the host. New cutsheet_items columns facing and slot, added on first use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1105,6 +1105,19 @@ def _racks(items: list) -> list:
|
||||
return racks
|
||||
|
||||
|
||||
_VIRTUAL_IFACE = ('lo', 'vmbr', 'bond', 'docker', 'veth', 'tap', 'fwbr', 'fwpr', 'fwln', 'br-', 'virbr', 'wg', 'tun')
|
||||
|
||||
|
||||
def _physical_interfaces(name: str, snapshot: dict) -> list:
|
||||
"""A host's physical NICs in name order, with their state: [{'name', 'up'}].
|
||||
|
||||
Drawn fronts light one RJ45 per NIC in this order (first NIC on the leftmost jack).
|
||||
"""
|
||||
ifaces = ((snapshot.get('hosts') or {}).get(name) or {}).get('interfaces') or {}
|
||||
return [{'name': n, 'up': str(state).lower() == 'up'} for n, state in sorted(ifaces.items())
|
||||
if not n.startswith(_VIRTUAL_IFACE)]
|
||||
|
||||
|
||||
def _device_status(name: str, snapshot: dict) -> str:
|
||||
host = (snapshot.get('hosts') or {}).get(name)
|
||||
if host:
|
||||
@@ -1123,8 +1136,8 @@ def api_rack():
|
||||
Query: rack (name; default the first rack), face (front|rear).
|
||||
"""
|
||||
face = request.args.get('face', 'front')
|
||||
if face not in ('front', 'rear'):
|
||||
return jsonify({'error': 'face must be front or rear'}), 400
|
||||
if face not in cutsheet.RACK_VIEWS:
|
||||
return jsonify({'error': f'face must be one of {", ".join(cutsheet.RACK_VIEWS)}'}), 400
|
||||
view = _cutsheet_view()
|
||||
link_stats = _state_json('link_stats')
|
||||
switches = link_stats.get('unifi_switches') or {}
|
||||
@@ -1145,7 +1158,9 @@ def api_rack():
|
||||
for r in racks:
|
||||
racked = [i for i in view['items'] if not i.get('shelf') and i.get('rack_u') and rack_of(i) == r['name']]
|
||||
r['count'] = len(racked)
|
||||
# How many items each view shows: rear-post gear is what "behind" and "rear" add
|
||||
r['rear'] = sum(1 for i in racked if i.get('mount') in ('rear', 'full'))
|
||||
r['behind'] = sum(1 for i in racked if i.get('mount') == 'rear')
|
||||
for cable in view['cables']:
|
||||
cable['run'] = [h['cable_id'] for h in cable['path'] if 'cable_id' in h]
|
||||
marks = cutsheet.port_marks(view['cables'])
|
||||
@@ -1189,12 +1204,14 @@ def api_rack():
|
||||
'outlets': (unifi_info.get(device) or {}).get('outlets') or [],
|
||||
'online': online.get(device, True)}
|
||||
if item['kind'] == 'shelf':
|
||||
# Left to right: by position on the shelf, then by name
|
||||
entry['contents'] = [
|
||||
{'id': c['id'], 'name': c['name'], 'kind': c['kind'], 'url': url(c),
|
||||
'status': _device_status(dev(c), snapshot) if dev(c) in known else '',
|
||||
'model': next((u.get('model') for u in snapshot.get('unifi') or [] if u.get('name') == dev(c)), '')
|
||||
or '', 'notes': c.get('notes') or ''}
|
||||
for c in sorted(on_shelf.get(name, []), key=lambda c: c['name'].lower())
|
||||
or '', 'notes': c.get('notes') or '', 'chassis': c.get('chassis') or '',
|
||||
'slot': c.get('slot'), 'interfaces': _physical_interfaces(dev(c), snapshot)}
|
||||
for c in sorted(on_shelf.get(name, []), key=lambda c: (c.get('slot') or 999, c['name'].lower()))
|
||||
]
|
||||
out.append(entry)
|
||||
return jsonify({
|
||||
|
||||
Reference in New Issue
Block a user