Compare commits

...
Author SHA1 Message Date
jared 9bdf5d9eed Merge pull request 'Tickets: don't adopt a Closed ticket Tinker couldn't reopen' (#34) from tinker-create-action into main
Lint / Python (flake8) (push) Successful in 47s
Lint / JS (eslint) (push) Successful in 9s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m39s
Test / Python Tests (pytest) (push) Successful in 1m49s
Lint / Deploy (push) Successful in 24s
2026-11-11 02:01:10 -05:00
jaredandClaude Opus 5.5 d234e36e3f Tickets: don't adopt a Closed ticket Tinker couldn't reopen
Lint / JS (eslint) (push) Successful in 14s
Lint / Python (flake8) (push) Successful in 57s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 55s
Lint / Python (flake8) (pull_request) Successful in 1m31s
Test / Python Tests (pytest) (push) Successful in 1m51s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m22s
Test / Python Tests (pytest) (pull_request) Successful in 1m46s
Tinker's create response says what it did (action). For recurrence_noted it
matched a Closed ticket it could not reopen unattended: that ticket isn't
tracking the alert (this is what hid micro1 enp3s0 behind an old reboot
ticket), so Gandalf now logs it and keeps no ticket for the alert. Each such
create adds a "recurred" comment to the closed ticket, so the same title is
retried once a day rather than every poll. Other actions are logged.

See tinker_tickets#116 and #115.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 01:52:53 -05:00
jared fde1d01f27 Merge pull request 'Revert #31: revived glitch alerts opened tickets' (#33) from revert-31 into main
Lint / Python (flake8) (push) Successful in 57s
Lint / JS (eslint) (push) Successful in 7s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m50s
Test / Python Tests (pytest) (push) Successful in 1m59s
Lint / Deploy (push) Successful in 7s
2026-11-11 01:17:47 -05:00
jaredandClaude Opus 5.5 8edaa78ad7 Revert #31: open link-down alerts from a monitor glitch were revived and ticketed
Lint / JS (eslint) (push) Successful in 12s
Lint / Python (flake8) (push) Successful in 1m47s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m15s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Python (flake8) (pull_request) Successful in 48s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Test / Python Tests (pytest) (push) Successful in 1m41s
Security / Python Security (bandit) (pull_request) Successful in 1m32s
Test / Python Tests (pytest) (pull_request) Successful in 1m6s
#31 treated any open interface_down alert as previously up. Production had
six such alerts all created in the same second on 2026-03-02 (a monitor
glitch, on ports that were never in use: large1 enp36s0 and a USB adapter,
compute-storage-01 nic1-3, micro1 enp3s0). Reviving them opened per-host
tickets and a P1 cluster-wide ticket. Back to the previous behaviour while a
safer fix is worked out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 01:11:00 -05:00
jared a0e062493d Merge pull request 'Monitor: keep checking interfaces whose link-down alert is still open' (#31) from stale-interface-alerts into main
Lint / JS (eslint) (push) Successful in 21s
Lint / Python (flake8) (push) Successful in 1m44s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m25s
Lint / Deploy (push) Successful in 5s
Test / Python Tests (pytest) (push) Successful in 1m2s
2026-11-11 01:06:37 -05:00
jaredandClaude Opus 5.5 d07787ee38 Monitor: keep checking interfaces whose link-down alert is still open
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 49s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 53s
Test / Python Tests (pytest) (push) Successful in 1m3s
Lint / Python (flake8) (pull_request) Successful in 55s
Lint / JS (eslint) (pull_request) Successful in 6s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m22s
Test / Python Tests (pytest) (pull_request) Successful in 1m27s
After the interface baseline is reset, a port that is already down reads as
"first seen down", which neither alerts nor resolves. An alert opened before
the reset was then stuck open without updates: micro1's enp3s0 had sat at
one failed check since March with no ticket. An interface with an open
interface_down alert is now treated as previously up, so the alert keeps
counting, tickets and resolves as normal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 01:02:53 -05:00
jared 7e75ba8b3c Merge pull request 'Rack: posts vs facing, three views, ZimaBoard 832 shelves to scale' (#30) from zimaboard-and-facing into main
Lint / JS (eslint) (push) Successful in 8s
Lint / Python (flake8) (push) Successful in 1m31s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m47s
Lint / Deploy (push) Successful in 8s
Test / Python Tests (pytest) (push) Successful in 49s
2026-11-11 00:53:41 -05:00
jared 0243b23732 Merge remote-tracking branch 'origin/main' into zimaboard-and-facing
Lint / Python (flake8) (push) Successful in 58s
Lint / JS (eslint) (push) Successful in 8s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 13s
Security / Python Security (bandit) (push) Successful in 1m11s
Test / Python Tests (pytest) (push) Successful in 1m14s
Security / Python Security (bandit) (pull_request) Successful in 1m44s
Test / Python Tests (pytest) (pull_request) Successful in 1m40s
Lint / Python (flake8) (pull_request) Successful in 48s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
# Conflicts:
#	static/style.css
#	tests/test_cutsheet.py
2026-11-11 00:46:13 -05:00
jared 90e051dc22 Merge pull request 'Faceplates: USW Pro Max 24 PoE and 48 PoE' (#29) from pro-max-faceplates into main
Lint / JS (eslint) (push) Successful in 17s
Lint / Python (flake8) (push) Successful in 1m28s
Security / Python Security (bandit) (push) Successful in 1m5s
Lint / Notify on failure (push) Skipped
Test / Python Tests (pytest) (push) Successful in 1m8s
Lint / Deploy (push) Successful in 5s
2026-11-11 00:45:49 -05:00
jaredandClaude Opus 5.5 486a93c5a0 Rack: ConnectX-3 SFP+ cards in the ZimaBoards' PCIe slots; correct NIC mapping
Lint / JS (eslint) (push) Successful in 10s
Lint / Python (flake8) (push) Successful in 51s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / Python (flake8) (pull_request) Successful in 50s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m7s
Security / Python Security (bandit) (push) Successful in 1m8s
Test / Python Tests (pytest) (push) Successful in 1m38s
Test / Python Tests (pytest) (pull_request) Successful in 1m38s
From the rack photo, each ZimaBoard has a single-port ConnectX-3 lying flat
in its side PCIe slot with a DAC attached. Front drawing "ZimaBoard 832 +
ConnectX-3" draws the card beside the board at scale: PCB at board height,
heatsink, SFP+ cage with the DAC and pull tab, and a Gandalf link mark for
the card's interface.

The jacks were lit in NIC name order, which put the ConnectX-3 (enp1s0, PCI
bus 1) on the left RJ45. The onboard ports are enp2s0 (left) and enp3s0
(right); the PCIe card is enp1s0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 00:35:25 -05:00
jaredandClaude Opus 5.5 a9de175d90 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
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>
2026-11-11 00:12:07 -05:00
jaredandClaude Opus 5.5 ce12dede5f Faceplates: USW Pro Max 24 PoE and 48 PoE
Lint / JS (eslint) (push) Successful in 12s
Lint / Python (flake8) (push) Successful in 1m10s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m11s
Test / Python Tests (pytest) (push) Successful in 1m42s
Lint / Python (flake8) (pull_request) Successful in 2m28s
Lint / JS (eslint) (pull_request) Successful in 14s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m10s
Test / Python Tests (pytest) (pull_request) Successful in 1m16s
Both laid out from the CC0 NetBox devicetype-library images, with jack
centres measured from them: the 24 has one row of 24 RJ45 in groups of 8
(17-24 at 2.5G) and 2 SFP+; the 48 has two rows, odd ports on top, in
groups of 16 (33-48 at 2.5G) and 4 SFP+ (49-52). The "2.5G" and "10G" bars
under the faster ports are drawn too (fpSpeedBar).

Registered as USPM24P/USPM48P with USPM24/USPM48 aliases, and as Front
drawing options so the new switch draws on the rack before it is adopted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 00:01:12 -05:00
15 changed files with 480 additions and 59 deletions

No files matched your search

+25 -5
View File
@@ -141,10 +141,20 @@ The rack front, drawn from the rack units set on cutsheet items, top first.
drawings live in `static/fronts.js`.
- **Shelves**: an item can sit on a shelf item instead of having a rack unit. The shelf draws what is on
it side by side (mini PCs, desk switches), each with its status and a link to its page.
- **Front and rear**: each item is mounted from the front, the rear, or full depth (both sides). On a
4-post rack a front and a rear item can share a unit; a full-depth item (a server) takes it on both
sides, and the rear view shows its back. Items on a shelf take the shelf's side. The Front / Rear switch
flips the drawing (`?face=rear`).
- **Posts, facing and views**: each item hangs on the front posts, the rear posts, or both (full
depth), and its ports face the front or the rear. On a 4-post rack a front-post and a rear-post item
can share a unit; a full-depth item takes it on both. The page has three views: **Front** (the front
posts), **Rear posts** (gear on the rear posts seen from the front, i.e. what sits behind the front
gear, such as a PDU or a shelf mounted from the rear but facing forward) and **Rear** (from behind).
An item seen from the side it doesn't face shows its back. Items on a shelf take the shelf's posts
and facing.
- **Shelves to scale**: a shelf draws its contents left to right by **Position on shelf**, at true scale
(a 19" panel is 482.6 mm). Gear with a drawing, such as the IceWhale ZimaBoard 832 (traced from
IceWhale's labelled photo of its port end), shows its real ports: the onboard RJ45 link lights follow
enp2s0 (left) and enp3s0 (right), and the status glow follows the host. The "ZimaBoard 832 +
ConnectX-3" drawing adds the single-port SFP+ card lying flat in the side PCIe slot, as in the rack,
with a DAC attached; its round dot is Gandalf's link mark for enp1s0 (the slot is PCI bus 1), not an
LED on the card. Anything else is a labelled box.
- **Racks**: admins name a rack and set its height with **Rack settings** on the page, and add more with
**+ Rack** (a tab per rack). Renaming a rack moves its items; an empty rack can be deleted. Each item
has a rack (empty means the first). Until a rack is saved, racks come from config:
@@ -704,6 +714,16 @@ gandalf/
4. Restart monitor: `systemctl restart gandalf-monitor`
5. For SFP DOM / ethtool: ensure the host is SSH-accessible from the Pulse worker
### Faceplates included
UniFi gear drawn with live ports: UDM Pro (`UDMPRO`), USW Pro 24 PoE (`US24PRO`), USW Aggregation
(`USL8A`), USW Flex (`USF5P`), USW Flex Mini (`USMINI`), USP PDU Pro (`USPPDUP`), UPS 2U Pro (`USPDA2B`),
USW Pro Max 24 PoE (`USPM24P`, also `USPM24`) and USW Pro Max 48 PoE (`USPM48P`, also `USPM48`), plus the
UniFi NVR Pro (`UNVRPRO`), which UniFi Network doesn't report and so is picked by Front drawing. The Pro
Max switches also have Front drawing options, so a new switch draws correctly on the rack before it is
adopted. If UniFi reports a Pro Max under a different model code, add it as another alias at the end of
`static/faceplates.js`.
### Adding a New Device Faceplate
Find the UniFi model code on the device page, then add an entry to `FACEPLATES` in `static/faceplates.js`.
@@ -724,7 +744,7 @@ Take LED colors from the model's quick start guide. See the comment at the top o
### Database Schema Notes
- `cutsheet_items` gained `rack`, `shelf`, `device`, `mount` and `chassis` columns; they are added automatically on first use
- `cutsheet_items` gained `rack`, `shelf`, `device`, `mount`, `chassis`, `facing` and `slot` columns; they are added automatically on first use
- `cutsheet_racks`: racks saved on the rack page (name, height, notes)
- `device_links`: each device's inventory URL, by device name; created with the cutsheet tables
- `network_events`: one row per active event; `resolved_at` is set when recovered, and
+21 -4
View File
@@ -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({
+29 -8
View File
@@ -25,13 +25,22 @@ ITEM_KINDS = ('patch_panel', 'wall_jack', 'device', 'shelf', 'other')
# Which side of a 4-post rack an item is mounted from. A front and a rear item can share
# a unit; a full-depth one (a server) takes the unit on both sides.
MOUNTS = ('front', 'rear', 'full')
# Which way an item's ports face. Gear on the rear posts usually still faces the front.
FACINGS = ('front', 'rear')
# Rack views: the front posts seen from the front, the rear posts seen from the front
# (what is behind the front gear), and the rack seen from behind
RACK_VIEWS = ('front', 'behind', 'rear')
RACK_UNITS_MAX = 60
# Drawn fronts for gear without a live faceplate (keys of RACK_FRONTS in static/fronts.js)
CHASSIS = {
'unvr-pro': 'UniFi NVR Pro (UNVR Pro)',
'uacc-patch-24': 'UniFi Patch Panel Blank 24 (UACC-Rack-Panel-Patch-Blank-24)',
'usw-pro-max-24-poe': 'UniFi Switch Pro Max 24 PoE (until UniFi reports it)',
'usw-pro-max-48-poe': 'UniFi Switch Pro Max 48 PoE (until UniFi reports it)',
'sliger-cx4712': 'Sliger CX4712 4U (10-bay)',
'rosewill-rsv-l4500u': 'Rosewill RSV-L4500U 4U (15-bay)',
'zimaboard-832': 'IceWhale ZimaBoard 832 (shelf gear)',
'zimaboard-832-cx3': 'IceWhale ZimaBoard 832 + ConnectX-3 SFP+ in PCIe (shelf gear)',
'server-1u': 'Generic 1U server',
'server-2u': 'Generic 2U server',
'server-4u': 'Generic 4U server',
@@ -110,11 +119,17 @@ def validate_item(data: dict, items: Optional[Dict[str, dict]] = None) -> dict:
'device': _text(data, 'device'),
'mount': _text(data, 'mount', 10) or 'front',
'chassis': _text(data, 'chassis', 40),
'facing': _text(data, 'facing', 10) or 'front',
'slot': _int(data, 'slot', 1, 99, 'Position on the shelf'),
'shelf': _text(data, 'shelf', NAME_MAX),
'notes': _text(data, 'notes', NOTES_MAX),
}
if item['chassis'] and item['chassis'] not in CHASSIS:
raise ValidationError(f'Unknown front drawing {item["chassis"]}')
if item['facing'] not in FACINGS:
raise ValidationError(f'facing must be one of {", ".join(FACINGS)}')
if item['slot'] and not item['shelf']:
raise ValidationError('A position applies only to an item on a shelf')
if item['mount'] not in MOUNTS:
raise ValidationError(f'mount must be one of {", ".join(MOUNTS)}')
if item['shelf']:
@@ -127,6 +142,7 @@ def validate_item(data: dict, items: Optional[Dict[str, dict]] = None) -> dict:
raise ValidationError('An item on a shelf takes its rack position from the shelf; clear the rack unit')
item['rack'] = '' # the shelf's rack and side
item['mount'] = 'front'
item['facing'] = 'front'
if item['rack_height'] and not item['rack_u']:
raise ValidationError('Set a rack unit to go with the height')
if item['rack_u'] and not item['rack_height']:
@@ -602,15 +618,20 @@ def _sides(item: dict) -> Tuple[str, ...]:
def rack_layout(items: List[dict], units: int, face: str = 'front') -> dict:
"""Place items that have a rack unit, top of the rack first, as seen from one face.
"""Place items that have a rack unit, top of the rack first, for one view.
Front and rear items may share a unit; full-depth items take it on both sides.
An item that would share a unit and side with one already placed, or runs past the
top of the rack, is reported (whichever face is asked for) rather than drawn over another.
Front-post and rear-post items may share a unit; full-depth items take it on both.
Views (RACK_VIEWS): 'front' shows the front posts from the front; 'behind' shows the
rear posts from the front (what sits behind the front gear); 'rear' shows the rear posts
from behind. Full-depth items appear in all three.
An item that would share a unit and post with one already placed, or runs past the
top of the rack, is reported (whatever the view) rather than drawn over another.
Returns {'placed': [item + 'rack_top' + 'through'], 'overlaps': [{'name', 'units', 'with'}],
'outside': [name]}, where 'through' marks a full-depth item seen from the side it isn't faced to
(its back, for the rear view).
'outside': [name]}, where 'through' marks an item seen from the side it doesn't face
(its back, rather than its ports).
"""
side = 'front' if face == 'front' else 'rear'
looking = 'rear' if face == 'rear' else 'front'
taken: Dict[tuple, str] = {}
placed, overlaps, outside = [], [], []
racked = [i for i in items if i.get('rack_u')]
@@ -630,8 +651,8 @@ def rack_layout(items: List[dict], units: int, face: str = 'front') -> dict:
continue
for c in cells:
taken[c] = item['name']
if face in sides:
placed.append(dict(item, rack_top=high, through=item.get('mount') == 'full' and face == 'rear'))
if side in sides:
placed.append(dict(item, rack_top=high, through=(item.get('facing') or 'front') != looking))
return {'placed': placed, 'overlaps': overlaps, 'outside': outside}
+7 -1
View File
@@ -679,6 +679,8 @@ _CUTSHEET_SCHEMA = (
device VARCHAR(255) NOT NULL DEFAULT '',
mount VARCHAR(10) NOT NULL DEFAULT 'front',
chassis VARCHAR(40) NOT NULL DEFAULT '',
facing VARCHAR(10) NOT NULL DEFAULT 'front',
slot SMALLINT NULL,
notes TEXT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -769,7 +771,7 @@ def set_device_link(name: str, inventory_url: str, user: str) -> None:
)
_ITEM_FIELDS = ('name', 'kind', 'port_count', 'location', 'rack_u', 'rack_height', 'rack', 'shelf', 'device',
'mount', 'chassis', 'notes')
'mount', 'chassis', 'facing', 'slot', 'notes')
# Columns added to cutsheet_items after its first release: (name, definition)
_ITEM_COLUMNS_ADDED = (
('rack', "VARCHAR(100) NOT NULL DEFAULT ''"),
@@ -778,6 +780,10 @@ _ITEM_COLUMNS_ADDED = (
('device', "VARCHAR(255) NOT NULL DEFAULT ''"),
('mount', "VARCHAR(10) NOT NULL DEFAULT 'front'"),
('chassis', "VARCHAR(40) NOT NULL DEFAULT ''"),
# Which way the ports face, independent of which posts it hangs on
('facing', "VARCHAR(10) NOT NULL DEFAULT 'front'"),
# Left-to-right position on a shelf
('slot', 'SMALLINT NULL'),
)
_CABLE_FIELDS = ('label', 'a_device', 'a_port', 'a_side', 'b_device', 'b_port', 'b_side',
'cable_type', 'length_m', 'color', 'status', 'label_applied', 'notes')
+25 -1
View File
@@ -393,6 +393,8 @@ class TicketClient:
self.comment_url = cfg.get('comment_url') or (
urljoin(self.url, 'api/ticket_comment_api.php') if self.url else '')
self.comments_denied = False
# Titles whose create matched a Closed ticket Tinker couldn't reopen: {title: (ticket_id, when)}
self._closed_matches: Dict[str, tuple] = {}
def comment(self, ticket_id: str, text: str) -> bool:
"""Add a Markdown comment to a ticket. Never raises; False means try again later."""
@@ -425,10 +427,23 @@ class TicketClient:
logger.error(f'Ticket comment failed for #{ticket_id}: {e}')
return False
# How long to wait before asking again after a create matched an unreopenable Closed ticket.
# Each ask adds a "recurred" comment to that ticket, so once a poll would pile them up.
CLOSED_MATCH_RETRY_S = 24 * 3600
def create(self, title: str, description: str, priority: str = '2') -> Optional[str]:
"""Open a ticket. Returns its ID, or None if there is no ticket to track.
Tinker deduplicates: the response's `action` says what happened (new, deduplicated,
updated, reopened, recurrence_noted). recurrence_noted means it matched a Closed ticket
it could not reopen unattended; that ticket isn't tracking this alert, so it isn't used.
"""
if not self.api_key or not self.url:
logger.warning('Ticket API not configured: skipping ticket creation')
return None
seen = self._closed_matches.get(title)
if seen and time.time() - seen[1] < self.CLOSED_MATCH_RETRY_S:
return None
try:
resp = requests.post(
self.url,
@@ -450,7 +465,16 @@ class TicketClient:
if not tid:
logger.warning(f'Ticket API success but no ticket_id in response: {data}')
return None
logger.info(f'Created ticket #{tid}: {title}')
action = data.get('action') or 'created'
if action == 'recurrence_noted':
self._closed_matches[title] = (tid, time.time())
logger.warning(
f'Ticket API matched Closed ticket #{tid}, which it could not reopen; not using it '
f'for this alert. Reopen #{tid} in Tinker to track it there. Retrying in 24 h: {title}'
)
return None
self._closed_matches.pop(title, None)
logger.info(f'Ticket #{tid} ({action}): {title}')
return tid
if data.get('existing_ticket_id'):
logger.info(f'Duplicate suppressed by API: existing #{data["existing_ticket_id"]}')
+7 -7
View File
@@ -258,9 +258,9 @@ function renderRack() {
}
function rackText(i) {
if (i.shelf) return `on ${esc(i.shelf)}`;
if (i.shelf) return `on ${esc(i.shelf)}${i.slot ? `, position ${esc(i.slot)}` : ''}`;
if (!i.rack_u) return '-';
const side = { rear: ' rear', full: ' full depth' }[i.mount] || '';
const side = ({ rear: ' rear posts', full: ' full depth' }[i.mount] || '') + (i.facing === 'rear' ? ', faces rear' : '');
const where = `U${esc(i.rack_u)}${i.rack_height > 1 ? ` (${esc(i.rack_height)}U)` : ''}${side}`;
return (_cs.racks || []).length > 1 ? `${where} · ${esc(i.rack || _cs.racks[0])}` : where;
}
@@ -389,7 +389,7 @@ function openCable(cable, prefill) {
function openItem(item) {
const form = document.getElementById('cs-item-form');
form.reset();
const data = Object.assign({ kind: 'patch_panel', mount: 'front' }, item || {});
const data = Object.assign({ kind: 'patch_panel', mount: 'front', facing: 'front' }, item || {});
document.getElementById('cs-rack-list').innerHTML = (_cs.racks || []).map(r => `<option value="${esc(r)}">`).join('');
document.getElementById('cs-known-devices').innerHTML = (_cs.devices || []).map(d => `<option value="${esc(d)}">`).join('');
form.chassis.innerHTML = '<option value="">Automatic (faceplate or plain plate)</option>' +
@@ -397,8 +397,8 @@ function openItem(item) {
const shelves = _cs.items.filter(i => i.kind === 'shelf' && (!item || i.id !== item.id));
form.shelf.innerHTML = '<option value="">Not on a shelf</option>' +
shelves.map(i => `<option value="${esc(i.name)}">${esc(i.name)}</option>`).join('');
for (const key of ['id', 'name', 'device', 'kind', 'port_count', 'rack_u', 'rack_height', 'rack', 'mount', 'shelf',
'chassis', 'location', 'notes']) {
for (const key of ['id', 'name', 'device', 'kind', 'port_count', 'rack_u', 'rack_height', 'rack', 'mount', 'facing',
'shelf', 'slot', 'chassis', 'location', 'notes']) {
form[key].value = data[key] == null ? '' : data[key];
}
if (!item) form.port_count.value = 24;
@@ -451,8 +451,8 @@ async function saveCable(e) {
async function saveItem(e) {
e.preventDefault();
const form = e.target;
const body = formData(form, ['name', 'device', 'kind', 'port_count', 'rack_u', 'rack_height', 'rack', 'mount', 'shelf',
'chassis', 'location', 'notes']);
const body = formData(form, ['name', 'device', 'kind', 'port_count', 'rack_u', 'rack_height', 'rack', 'mount', 'facing',
'shelf', 'slot', 'chassis', 'location', 'notes']);
const id = form.id.value;
await save(() => id ? lt.api.put(`/api/cutsheet/items/${encodeURIComponent(id)}`, body)
: lt.api.post('/api/cutsheet/items', body), 'Saved', 'cs-item-modal');
+58
View File
@@ -225,6 +225,12 @@ function fpQuadScreen(x, y, s) {
</g>`;
}
// The bar UniFi prints under a group of faster ports, with its speed ("2.5G", "10G")
function fpSpeedBar(x0, x1, y, text) {
return `<rect class="fp-speedbar" x="${x0}" y="${y - 3}" width="${x1 - x0}" height="3" rx="1.5"/>
<text class="fp-label fp-label-sm" x="${(x0 + x1) / 2}" y="${y + 6}" text-anchor="middle">${text}</text>`;
}
// The model name printed under a UniFi screen: centred on the screen, first word bold and
// second word light ("USW Pro", "NVR Pro"), as on the real units. `bolt` adds the PoE mark.
function fpModel(cx, y, bold, light = '', { size = 7.5, bolt = false } = {}) {
@@ -350,6 +356,53 @@ const FACEPLATES = {
},
},
// USW Pro Max 24 PoE, laid out from the CC0 NetBox devicetype-library image
// (ubiquiti-unifi-switch-pro-max-24-poe.front.png; jack centres measured from it):
// one row of 24 RJ45 in three groups of 8 (17-24 are 2.5G), then 2 SFP+.
USPM24P: {
width: 1167, height: 117, frameClass: 'fp-scroll', scrollX: 560,
label: 'USW Pro Max 24 PoE',
legend: [...LEGEND_RJ45, ['white', '10G'], ['poe', 'PoE in use']],
roles: { ...roleRange(1, 16, 'RJ45 1G'), ...roleRange(17, 24, 'RJ45 2.5G'), 25: 'SFP+', 26: 'SFP+' },
ports: [
...[118.5, 427, 734.5].flatMap((x0, g) => Array.from({ length: 8 }, (_, i) => {
const x = x0 + i * 37.35;
return { idx: g * 8 + i + 1, type: 'rj45', x, y: 74, scale: 1.1, label: [x, 100] };
})),
...[1030, 1071].map((x, i) => ({ idx: 25 + i, type: 'sfp', x, y: 62, w: 38, h: 27,
led: [x + 19, 54], label: [x + 19, 100] })),
],
decor() {
return `${fpVents([[97, 293], [301, 498], [506, 703], [710, 906], [914, 1110]], 9, 3)}
${fpQuadScreen(14, 27, 60)}${fpModel(44, 103, 'USW', 'Pro Max', { bolt: true })}
${[98, 407, 714].map(x => `<rect class="fp-block" x="${x}" y="53" width="303" height="36" rx="1"/>`).join('')}
${fpSpeedBar(714, 1017, 107, '2.5G')}${fpSpeedBar(1030, 1109, 107, '10G')}
${fpReset(1128, 101)}`;
},
},
// USW Pro Max 48 PoE, from ubiquiti-unifi-switch-pro-max-48-poe.front.png (CC0, NetBox):
// two rows, odd ports on top, three groups of 16 (33-48 are 2.5G), then 4 SFP+ (49-52).
USPM48P: {
width: 1169, height: 114, frameClass: 'fp-scroll', scrollX: 560,
label: 'USW Pro Max 48 PoE',
legend: [...LEGEND_RJ45, ['white', '10G'], ['poe', 'PoE in use']],
roles: { ...roleRange(1, 32, 'RJ45 1G'), ...roleRange(33, 48, 'RJ45 2.5G'), ...roleRange(49, 52, 'SFP+') },
ports: [
...rj45Pairs([122, 425.5, 731].flatMap(x0 => Array.from({ length: 8 }, (_, i) => x0 + i * 36.8)),
{ top: 38, bottom: 68, topLabel: 15, bottomLabel: 97 }),
...sfpPairs([1033, 1075], { first: 49, top: 23, bottom: 60, w: 37, h: 27, ledY: 56, ledGap: 9,
topLabel: 15, bottomLabel: 97 }),
],
decor() {
return `${fpVents([[97, 293], [301, 498], [506, 703], [710, 906], [914, 1110]], 7, 3)}
${fpQuadScreen(14, 25, 60)}${fpModel(44, 101, 'USW', 'Pro Max', { bolt: true })}
${[101, 405, 711].map(x => `<rect class="fp-block" x="${x}" y="19" width="298" height="70" rx="1"/>`).join('')}
${fpSpeedBar(711, 1009, 104, '2.5G')}${fpSpeedBar(1033, 1112, 104, '10G')}
${fpReset(1130, 99)}`;
},
},
// No quick start guide was available: layout from a reference image. LED colors
// are taken from the SFP+ ports of the USW Pro 24 guide.
USL8A: {
@@ -585,3 +638,8 @@ function faceplateScrollLeft(model, frame) {
const spec = FACEPLATES[model];
return spec.scrollX ? (frame.scrollWidth / spec.width) * spec.scrollX : 0;
}
// Same fronts under the other model codes UniFi uses for these switches (non-PoE variants
// draw the same; PoE marks simply never show)
FACEPLATES.USPM24 = FACEPLATES.USPM24P;
FACEPLATES.USPM48 = FACEPLATES.USPM48P;
+151 -2
View File
@@ -1,5 +1,5 @@
'use strict';
/* exported RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg */
/* exported RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg, shelfSvg, SHELF_GEAR */
// Drawn fronts for rack gear Gandalf can't read a faceplate from: custom-built servers. Chosen per cutsheet item ("Front drawing"). Each one
// shows the device's live status on its power light when the item is linked to a device.
//
@@ -134,7 +134,12 @@ function genericServer(units, bays) {
}
// Front drawings that are full faceplates in faceplates.js (same parts as the UniFi gear)
const CHASSIS_FACEPLATES = { 'unvr-pro': 'UNVRPRO' };
const CHASSIS_FACEPLATES = {
'unvr-pro': 'UNVRPRO',
// For a new switch before UniFi reports it (or under a model code not mapped yet)
'usw-pro-max-24-poe': 'USPM24P',
'usw-pro-max-48-poe': 'USPM48P',
};
// The markup for one item's drawn front, or '' when the key is unknown
function rackFrontSvg(key, ctx) {
@@ -146,3 +151,147 @@ function rackFrontSvg(key, ctx) {
${spec.draw(ctx)}
</svg>`;
}
// ── IceWhale ZimaBoard 832 (shelf gear) ─────────────────────────────────
// The port end, traced from IceWhale's labelled photo in ZimaDocs
// (source/images/Hardware-Interface-Introduction-/hardware-interface-introduction.webp),
// in that photo's pixel coordinates (the port end spans 862 x 415 px; 81.4 mm wide).
// Left to right: Mini-DisplayPort 1.2, two stacks of GbE RJ45 over USB 3.0, DC 12V 5.5x2.5mm,
// on a gunmetal case over a thin gold PCB edge and the black polycarbonate base.
const ZIMA = { width: 862, height: 415, mm: 81.4 };
function zimaRj45(x, y, link) {
const contacts = Array.from({ length: 8 }, (_, i) => `<rect class="zb-contact" x="${x + 52 + i * 14}" y="${y + 34}" width="5" height="22"/>`).join('');
return `<rect class="zb-shield" x="${x}" y="${y}" width="207" height="143" rx="5"/>
<rect class="zb-hole" x="${x + 22}" y="${y + 30}" width="163" height="102" rx="2"/>
<rect class="zb-hole-key" x="${x + 70}" y="${y + 120}" width="67" height="16" rx="1"/>
${contacts}
<rect class="zb-led" x="${x + 16}" y="${y + 9}" width="30" height="15" rx="2" style="fill:${link ? '#3ad16b' : '#8f8f8a'}"/>
<rect class="zb-led" x="${x + 161}" y="${y + 9}" width="30" height="15" rx="2" style="fill:${link ? '#f2d13a' : '#77714a'}"/>`;
}
function zimaUsb(x, y) {
return `<rect class="zb-shield" x="${x}" y="${y}" width="204" height="100" rx="5"/>
<rect class="zb-hole" x="${x + 26}" y="${y + 20}" width="152" height="62" rx="2"/>
<rect class="zb-usb-tongue" x="${x + 38}" y="${y + 28}" width="128" height="22" rx="2"/>
${Array.from({ length: 5 }, (_, i) => `<rect class="zb-usb-pin" x="${x + 50 + i * 24}" y="${y + 46}" width="10" height="4"/>`).join('')}`;
}
// Which NIC is which on a ZimaBoard: the onboard Realtek GbE ports enumerate on PCI buses 2 and 3
// (enp2s0 left jack, enp3s0 right), and a card in the PCIe slot on bus 1 (enp1s0, enp1s0d1).
const ZIMA_NICS = { rj45: ['enp2s0', 'enp3s0'], slot: /^enp1s0/ };
function zimaNic(ctx, name) {
const n = (ctx.interfaces || []).find(i => i.name === name);
return n ? n.up : ctx.status === 'up';
}
function zimaFront(ctx) {
// ctx: { status, interfaces: [{name, up}] }
const link = i => zimaNic(ctx, ZIMA_NICS.rj45[i]);
const on = ctx.status === 'up' || ctx.status === 'degraded';
const pads = [60, 105, 420, 470, 640, 700, 790, 835]
.map(x => `<rect class="zb-pad" x="${x}" y="309" width="12" height="7"/>`).join('');
return `
<rect class="zb-base" x="0" y="300" width="862" height="115" rx="10"/>
<rect class="zb-base-sheen" x="6" y="330" width="850" height="6" rx="3"/>
${on ? '<ellipse class="zb-glow" cx="34" cy="404" rx="34" ry="9"/>' : ''}
<rect class="zb-pcb" x="2" y="306" width="858" height="12"/>${pads}
<path class="zb-case" d="M0 14 Q0 0 14 0 H848 Q862 0 862 14 V308 H0 Z"/>
<rect class="zb-case-edge" x="0" y="6" width="18" height="300"/>
<rect class="zb-case-top" x="14" y="0" width="834" height="5"/>
<rect class="zb-shield" x="63" y="225" width="127" height="80" rx="6"/>
<path class="zb-hole" d="M75 243 H178 V280 L163 293 H90 L75 280 Z"/>
<rect class="zb-dp-pins" x="92" y="262" width="69" height="9" rx="1"/>
${zimaRj45(213, 47, link(0))}${zimaRj45(443, 47, link(1))}
${zimaUsb(216, 205)}${zimaUsb(443, 205)}
<rect class="zb-dc" x="678" y="177" width="132" height="130" rx="8"/>
<rect class="zb-dc-face" x="690" y="189" width="108" height="106" rx="6"/>
<circle class="zb-dc-ring" cx="744" cy="242" r="36"/>
<circle class="zb-hole" cx="744" cy="242" r="27"/>
<circle class="zb-dc-pin" cx="744" cy="242" r="8"/>`;
}
// A Mellanox ConnectX-3 single-port SFP+ card (MCX311A) in the ZimaBoard's side PCIe slot, lying flat
// beside the board as in the rack photo (wiki.lotusguild.org/zimaboards.jpg): its front edge is about
// 54 mm (572 px at the ZimaBoard photo's 10.59 px/mm), PCB at the board's PCB height, heatsink on the
// chip, and the SFP+ cage toward the board with a DAC plugged in and its pull tab hanging down.
// The round dot on the cage is Gandalf's link mark (like the cutsheet marks), not an LED on the card.
const CX3_PX = 572;
function cx3Card(up) {
return `
<rect class="cx-part" x="40" y="314" width="70" height="22" rx="2"/>
<rect class="cx-part" x="150" y="314" width="40" height="16" rx="2"/>
<rect class="cx-part" x="250" y="314" width="90" height="26" rx="2"/>
<rect class="cx-pcb" x="0" y="296" width="${CX3_PX}" height="18" rx="2"/>
<rect class="cx-pcb-edge" x="0" y="296" width="${CX3_PX}" height="4"/>
<rect class="cx-heatsink" x="110" y="232" width="210" height="64" rx="3"/>
${Array.from({ length: 9 }, (_, i) => `<rect class="cx-fin" x="${120 + i * 22}" y="232" width="9" height="64"/>`).join('')}
<rect class="cx-cage" x="380" y="190" width="150" height="106" rx="4"/>
<rect class="cx-cage-lip" x="380" y="190" width="150" height="10" rx="3"/>
<rect class="cx-plug" x="392" y="206" width="126" height="80" rx="5"/>
<rect class="cx-boot" x="410" y="220" width="90" height="52" rx="10"/>
<circle class="cx-cable" cx="455" cy="246" r="20"/>
<path class="cx-tab" d="M441 286 V392 Q441 404 455 404 Q469 404 469 392 V286"/>
<circle class="cx-link" cx="520" cy="200" r="13" style="fill:${up ? '#3ad16b' : '#e0312b'}"><title>Gandalf: SFP+ link ${up ? 'up' : 'down'}</title></circle>`;
}
function zimaCx3Front(ctx) {
return `${cx3Card(zimaNic(ctx, (ctx.interfaces || []).map(i => i.name).find(n => ZIMA_NICS.slot.test(n)) || 'enp1s0'))}
<g transform="translate(${CX3_PX} 0)">${zimaFront(ctx)}</g>`;
}
const ZIMA_SPECS = 'Intel Celeron N3450, 8GB LPDDR4, 32GB eMMC, 2x GbE, 2x USB 3.0, 2x SATA, PCIe 2.0 x4, 6W';
const SHELF_GEAR = {
'zimaboard-832': {
label: 'IceWhale ZimaBoard 832', mm: ZIMA.mm, width: ZIMA.width, height: ZIMA.height, draw: zimaFront,
specs: ZIMA_SPECS,
},
'zimaboard-832-cx3': {
label: 'IceWhale ZimaBoard 832 + ConnectX-3 SFP+', mm: ZIMA.mm * (ZIMA.width + CX3_PX) / ZIMA.width,
width: ZIMA.width + CX3_PX, height: ZIMA.height, draw: zimaCx3Front,
specs: `${ZIMA_SPECS}; Mellanox ConnectX-3 10G SFP+ (enp1s0) in the PCIe slot, DAC attached`,
},
};
// A shelf at true scale (1100 units = 482.6 mm, a 19" panel) with what sits on it, left to right.
// Gear with a SHELF_GEAR drawing is drawn to its real width; anything else is a labelled box.
function shelfSvg(item, esc) {
const units = item.rack_height || 1;
const W = 1100, H = 105 * units, perMm = W / 482.6;
const floor = H - 20;
let x = 64;
const things = (item.contents || []).map(c => {
const gear = SHELF_GEAR[c.chassis];
const w = gear ? gear.mm * perMm : 150;
const k = gear ? w / gear.width : 1;
const h = gear ? gear.height * k : 58;
const top = floor - h;
const nics = (c.interfaces || []).map(n => `${n.name} ${n.up ? 'up' : 'down'}`).join(', ');
const tip = [c.name, gear ? gear.label : c.kind, c.status, nics, gear && gear.specs].filter(Boolean).join(' · ');
const body = gear
? `<g transform="translate(${x} ${top}) scale(${k})">${gear.draw(c)}</g>`
: `<rect class="sh-box" x="${x}" y="${top}" width="${w}" height="${h}" rx="4"/>
<text class="sh-box-name" x="${x + w / 2}" y="${top + h / 2 + 5}" text-anchor="middle">${esc(c.name)}</text>`;
const out = `<a class="sh-thing" href="${esc(c.url)}"><title>${esc(tip)}</title>
${body}
<rect class="sh-hit" x="${x - 4}" y="${top - 4}" width="${w + 8}" height="${h + 8}" rx="4"/>
<rect class="sh-tag" x="${x + w / 2 - 46}" y="${floor + 5}" width="92" height="12" rx="2"/>
<text class="sh-tag-text" x="${x + w / 2}" y="${floor + 14}" text-anchor="middle">${esc(c.name)}</text>
</a>`;
x += w + 26;
return out;
}).join('');
return `<svg class="rack-svg rack-shelf-svg" viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" role="group"
aria-label="${esc(item.name)}">
<title>${esc(item.name)}</title>
${ears(W, H, 'rf-ear-dark')}
<rect class="sh-back" x="36" y="6" width="${W - 72}" height="${floor - 6}"/>
<rect class="sh-floor" x="30" y="${floor}" width="${W - 60}" height="${H - floor - 2}" rx="2"/>
<rect class="sh-lip" x="30" y="${floor}" width="${W - 60}" height="3"/>
${things || `<text class="sh-empty" x="${W / 2}" y="${floor - 12}" text-anchor="middle">empty shelf</text>`}
<text class="sh-name" x="46" y="18">${esc(item.name)}</text>
</svg>`;
}
+11 -20
View File
@@ -1,5 +1,5 @@
'use strict';
/* global FACEPLATES, renderFaceplate, RACK_CAN_EDIT, RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg */
/* global FACEPLATES, renderFaceplate, RACK_CAN_EDIT, RACK_FRONTS, CHASSIS_FACEPLATES, rackFrontSvg, shelfSvg */
// Rack page: draws the rack front from /api/rack. Switches use their real faceplates,
// patch panels a generic panel; hovering a port lights up every port on the same cable run.
@@ -93,18 +93,6 @@ function statusDot(status) {
return status ? `<span class="${STATUS_CLASS[status] || 'dot-unknown'}" title="${esc(status)}"></span>` : '';
}
function shelfHtml(item) {
const contents = item.contents || [];
const things = contents.map(c => `
<a class="rack-shelf-thing" href="${esc(c.url)}" title="${esc([c.name, c.model, c.status].filter(Boolean).join(' · '))}">
${statusDot(c.status)}<span class="rack-shelf-name">${esc(c.name)}</span>
</a>`).join('');
return `<div class="rack-plate rack-shelf">
<span class="rack-shelf-label">${esc(item.name)}</span>
<div class="rack-shelf-things">${things || '<span class="rack-plate-sub">empty shelf</span>'}</div>
</div>`;
}
// Ubiquiti UACC-Rack-Panel-Patch-Blank-24, laid out from the CC0 NetBox devicetype-library image
// (elevation-images/Ubiquiti/ubiquiti-uacc-rack-panel-patch-blank-24.front.png): a grey steel face,
// darker ears with oval holes, 24 square keystone openings in one row with the cable-support bar
@@ -173,7 +161,7 @@ function itemHtml(item) {
else if (item.chassis && RACK_FRONTS[item.chassis]) body = rackFrontSvg(item.chassis, item);
else if (item.kind === 'patch_panel' && item.chassis === 'uacc-patch-24') body = uaccPanelSvg(item);
else if (item.kind === 'patch_panel') body = panelSvg(item);
else if (item.kind === 'shelf') body = shelfHtml(item);
else if (item.kind === 'shelf') body = shelfSvg(item, esc);
else body = plateHtml(item);
return `<div class="rack-item rack-kind-${esc(item.kind)}" data-item="${esc(item.id)}">${body}</div>`;
}
@@ -216,14 +204,16 @@ function renderTabs(data) {
return `<button type="button" class="rack-tab${on ? ' active' : ''}" role="tab" aria-selected="${on}"
data-rack="${esc(r.name)}">${esc(r.name)} <span class="rack-tab-count">${r.count}</span></button>`;
}).join('');
document.getElementById('rack-title').textContent = `${data.rack} · ${data.face}`;
const VIEW_TITLE = { front: 'front', behind: 'rear posts, from the front', rear: 'rear' };
document.getElementById('rack-title').textContent = `${data.rack} · ${VIEW_TITLE[data.face] || data.face}`;
document.querySelectorAll('.rack-face-btn').forEach(b => {
const on = b.dataset.face === data.face;
b.classList.toggle('active', on);
b.setAttribute('aria-pressed', on);
});
const rear = (data.racks.find(r => r.name === data.rack) || {}).rear || 0;
document.querySelector('.rack-face-btn[data-face="rear"]').textContent = rear ? `Rear (${rear})` : 'Rear';
const r = data.racks.find(x => x.name === data.rack) || {};
document.querySelector('.rack-face-btn[data-face="behind"]').textContent = r.behind ? `Rear posts (${r.behind})` : 'Rear posts';
document.querySelector('.rack-face-btn[data-face="rear"]').textContent = r.rear ? `Rear (${r.rear})` : 'Rear';
}
function render(data) {
@@ -362,7 +352,8 @@ function currentRack() {
}
function currentFace() {
return new URLSearchParams(location.search).get('face') === 'rear' ? 'rear' : 'front';
const face = new URLSearchParams(location.search).get('face');
return ['behind', 'rear'].includes(face) ? face : 'front';
}
function setView(changes) {
@@ -383,14 +374,14 @@ document.getElementById('rack-tabs').addEventListener('click', e => {
document.querySelector('.rack-face').addEventListener('click', e => {
const btn = e.target.closest('[data-face]');
if (btn) setView({ face: btn.dataset.face === 'rear' ? 'rear' : '' });
if (btn) setView({ face: btn.dataset.face === 'front' ? '' : btn.dataset.face });
});
async function load() {
try {
const q = new URLSearchParams();
if (currentRack()) q.set('rack', currentRack());
if (currentFace() === 'rear') q.set('face', 'rear');
if (currentFace() !== 'front') q.set('face', currentFace());
render(await lt.api.get(`/api/rack${q.toString() ? `?${q}` : ''}`));
} catch (err) {
if (_rack) return; // keep the last drawing on a failed refresh
+46
View File
@@ -1584,3 +1584,49 @@ body.fp-marks-off .fp-svg .fp-mark { display: none; }
.rack-pp-bad .ua-mark { stroke: #e0312b; stroke-width: 3; }
.rack-pp-doc .ua-mark { stroke: #4c5662; stroke-width: 2; }
.rack-pp-port.rack-hl .ua-mark { fill: rgba(0,212,255,.25); stroke: #00b8e6; stroke-width: 3.5; }
/* ── Shelves drawn to scale, and the ZimaBoard 832 (static/fronts.js) ─ */
.sh-back { fill: #0f1215; }
.sh-floor { fill: #3a414b; }
.sh-lip { fill: #59636f; }
.sh-name { fill: var(--rk-muted, #8b97a5); font-size: 11px; font-family: Helvetica, Arial, sans-serif; }
.sh-empty { fill: var(--rk-muted, #8b97a5); font-size: 13px; }
.sh-box { fill: #d4d7dc; stroke: #8a929c; }
.sh-box-name { fill: #15191e; font-size: 13px; font-weight: 700; font-family: Helvetica, Arial, sans-serif; }
.sh-tag { fill: #111; stroke: #3a3f45; }
.sh-tag-text { fill: #e9edf1; font-size: 9px; font-weight: 700; font-family: Helvetica, Arial, sans-serif; }
.sh-hit { fill: transparent; stroke: transparent; stroke-width: 2.5; }
.sh-thing:hover .sh-hit, .sh-thing:focus-visible .sh-hit { stroke: #00b8e6; }
.zb-case { fill: #66625b; }
.zb-case-edge { fill: #807c74; }
.zb-case-top { fill: #8b877f; }
.zb-pcb { fill: #a48f55; }
.zb-pad { fill: #d3bd73; }
.zb-base { fill: #121212; }
.zb-base-sheen { fill: #2b2b2b; }
.zb-glow { fill: #ff9a2e; opacity: .85; filter: blur(4px); }
.zb-shield { fill: #cfcfca; stroke: #8f8f8a; stroke-width: 3; }
.zb-hole { fill: #0b0b0b; }
.zb-hole-key { fill: #0b0b0b; }
.zb-contact { fill: #b89545; }
.zb-led { stroke: #5c5c58; stroke-width: 1.5; }
.zb-usb-tongue { fill: #2f7fe0; }
.zb-usb-pin { fill: #c7a64b; }
.zb-dp-pins { fill: #b89545; }
.zb-dc { fill: #3a3a3a; stroke: #222; stroke-width: 2; }
.zb-dc-face { fill: #2b2b2b; }
.zb-dc-ring { fill: #4b4b4b; }
.zb-dc-pin { fill: #c9a43a; }
.cx-pcb { fill: #1d6b43; }
.cx-pcb-edge { fill: #2f8a5a; }
.cx-part { fill: #26292d; }
.cx-heatsink { fill: #18191b; }
.cx-fin { fill: #2c2e31; }
.cx-cage { fill: #c8cbcf; stroke: #85898f; stroke-width: 3; }
.cx-cage-lip { fill: #dde0e3; }
.cx-plug { fill: #2b2e33; }
.cx-boot { fill: #1b1d20; }
.cx-cable { fill: #0e0f10; }
.cx-tab { fill: none; stroke: #c9ccd0; stroke-width: 9; stroke-linejoin: round; }
.cx-link { stroke: #101418; stroke-width: 3; }
.fp-speedbar { fill: #b3b5ba; }
+13 -2
View File
@@ -275,11 +275,18 @@
<datalist id="cs-rack-list"></datalist>
</div>
<div class="lt-form-group">
<label class="lt-label" for="cs-item-mount">Mounted</label>
<label class="lt-label" for="cs-item-mount">Mounted on</label>
<select class="lt-select" id="cs-item-mount" name="mount">
<option value="front">Front posts</option>
<option value="rear">Rear posts</option>
<option value="full">Both (full depth)</option>
</select>
</div>
<div class="lt-form-group">
<label class="lt-label" for="cs-item-facing">Ports face</label>
<select class="lt-select" id="cs-item-facing" name="facing">
<option value="front">Front</option>
<option value="rear">Rear</option>
<option value="full">Full depth (both sides)</option>
</select>
</div>
</div>
@@ -288,6 +295,10 @@
<label class="lt-label" for="cs-item-shelf">On shelf</label>
<select class="lt-select" id="cs-item-shelf" name="shelf"><option value="">Not on a shelf</option></select>
</div>
<div class="lt-form-group">
<label class="lt-label" for="cs-item-slot">Position on shelf</label>
<input class="lt-input" id="cs-item-slot" name="slot" type="number" min="1" max="99" placeholder="1 = leftmost">
</div>
</div>
<div class="lt-field-hint cs-shelf-hint">Gear on a shelf (mini PCs, desk switches) takes its place and side from the shelf: leave its rack unit empty. On a 4-post rack a front and a rear item can share a unit; a full-depth one (a server) takes it on both sides.</div>
<div class="lt-form-group">
+6 -2
View File
@@ -21,8 +21,12 @@
<div class="rack-bar">
<div class="rack-tabs" id="rack-tabs" role="tablist" aria-label="Racks" hidden></div>
<div class="rack-face" role="group" aria-label="Rack side">
<button type="button" class="rack-face-btn active" data-face="front" aria-pressed="true">Front</button>
<button type="button" class="rack-face-btn" data-face="rear" aria-pressed="false">Rear</button>
<button type="button" class="rack-face-btn active" data-face="front" aria-pressed="true"
title="The front posts, seen from the front">Front</button>
<button type="button" class="rack-face-btn" data-face="behind" aria-pressed="false"
title="Gear on the rear posts, seen from the front (what is behind the front gear)">Rear posts</button>
<button type="button" class="rack-face-btn" data-face="rear" aria-pressed="false"
title="The rack seen from behind">Rear</button>
</div>
</div>
+24 -6
View File
@@ -524,17 +524,35 @@ class TestRackFacesAndSettings:
gandalf.db.cutsheet_load.return_value = {
'items': [dict(base, id=n, **i) for n, i in enumerate(items, 1)], 'cables': [], 'port_labels': []}
def test_rear_face(self, client):
def test_three_views(self, client):
# A server through both posts, a PDU on the rear posts facing the front (as in the StarTech),
# a fan tray on the rear posts facing the rear, and a switch on the front posts
self._items({'name': 'Server', 'kind': 'device', 'rack_u': 5, 'rack_height': 4, 'mount': 'full'},
{'name': 'PDU', 'kind': 'device', 'rack_u': 12, 'rack_height': 1, 'mount': 'rear'},
{'name': 'Fans', 'kind': 'device', 'rack_u': 14, 'rack_height': 1, 'mount': 'rear',
'facing': 'rear'},
{'name': 'Switch', 'kind': 'device', 'rack_u': 12, 'rack_height': 1})
front = client.get('/api/rack', headers=AUTH).get_json()
rear = client.get('/api/rack?face=rear', headers=AUTH).get_json()
assert [(i['name'], i['through']) for i in front['items']] == [('Switch', False), ('Server', False)]
assert [(i['name'], i['through']) for i in rear['items']] == [('PDU', False), ('Server', True)]
assert rear['face'] == 'rear' and rear['racks'][0]['rear'] == 2 and rear['racks'][0]['count'] == 3
def view(face):
return [(i['name'], i['through']) for i in
client.get(f'/api/rack?face={face}', headers=AUTH).get_json()['items']]
assert view('front') == [('Switch', False), ('Server', False)]
assert view('behind') == [('Fans', True), ('PDU', False), ('Server', False)]
assert view('rear') == [('Fans', False), ('PDU', True), ('Server', True)]
racks = client.get('/api/rack', headers=AUTH).get_json()['racks'][0]
assert (racks['count'], racks['rear'], racks['behind']) == (4, 3, 2)
assert client.get('/api/rack?face=side', headers=AUTH).status_code == 400
def test_shelf_contents_ordered_with_nics(self, client):
self._items({'name': 'Shelf', 'kind': 'shelf', 'rack_u': 3, 'rack_height': 2, 'mount': 'rear'},
{'name': 'b-box', 'kind': 'device', 'shelf': 'Shelf', 'slot': 1, 'chassis': 'zimaboard-832'},
{'name': 'large1', 'kind': 'device', 'shelf': 'Shelf', 'slot': 2})
data = client.get('/api/rack?face=behind', headers=AUTH).get_json()
things = data['items'][0]['contents']
assert [(c['name'], c['slot'], c['chassis']) for c in things] == [('b-box', 1, 'zimaboard-832'),
('large1', 2, '')]
assert things[1]['interfaces'] == [{'name': 'eth0', 'up': True}]
def test_saved_racks_replace_config(self, client):
self._items()
gandalf.db.cutsheet_racks.return_value = [{'id': 4, 'name': 'StarTech 25U', 'units': 25, 'notes': 'open frame'}]
+22 -1
View File
@@ -368,4 +368,25 @@ class TestChassis:
def test_every_drawing_has_a_label(self):
assert all(cs.CHASSIS.values())
assert {'sliger-cx4712', 'rosewill-rsv-l4500u', 'unvr-pro', 'uacc-patch-24'} <= set(cs.CHASSIS)
assert {'sliger-cx4712', 'rosewill-rsv-l4500u', 'unvr-pro', 'uacc-patch-24',
'usw-pro-max-24-poe', 'usw-pro-max-48-poe', 'zimaboard-832', 'zimaboard-832-cx3'} <= set(cs.CHASSIS)
class TestFacingAndSlots:
def test_facing_and_slot_validation(self):
shelf = {'S': {'name': 'S', 'kind': 'shelf'}}
assert cs.validate_item({'name': 'p', 'facing': 'rear'})['facing'] == 'rear'
assert cs.validate_item({'name': 'p'})['facing'] == 'front'
assert cs.validate_item({'name': 'z', 'shelf': 'S', 'slot': '2'}, shelf)['slot'] == 2
with pytest.raises(cs.ValidationError):
cs.validate_item({'name': 'p', 'facing': 'up'})
with pytest.raises(cs.ValidationError):
cs.validate_item({'name': 'p', 'slot': 1}) # a position needs a shelf
def test_rear_posts_facing_front_are_seen_from_the_front(self):
items = [{'id': 1, 'name': 'pdu', 'kind': 'device', 'rack_u': 24, 'rack_height': 2, 'mount': 'rear'},
{'id': 2, 'name': 'udm', 'kind': 'device', 'rack_u': 24, 'rack_height': 1}]
assert [i['name'] for i in cs.rack_layout(items, 25, 'front')['placed']] == ['udm']
behind = cs.rack_layout(items, 25, 'behind')['placed']
assert [(i['name'], i['through']) for i in behind] == [('pdu', False)]
assert [(i['name'], i['through']) for i in cs.rack_layout(items, 25, 'rear')['placed']] == [('pdu', True)]
+35
View File
@@ -748,3 +748,38 @@ class TestTicketClientComment:
with patch.object(monitor.requests, 'post', side_effect=OSError('down')):
assert c.comment('42', 'hi') is False
assert not c.comments_denied
class TestTicketClientCreate:
def _client(self):
return monitor.TicketClient({'url': 'http://t.test/create_ticket_api.php', 'api_key': 'k'})
def _post(self, body):
resp = MagicMock(status_code=200)
resp.json.return_value = body
return patch.object(monitor.requests, 'post', return_value=resp)
def test_new_and_deduplicated_tickets_are_used(self):
c = self._client()
with self._post({'success': True, 'ticket_id': '5', 'action': 'deduplicated'}):
assert c.create('t', 'd') == '5'
with self._post({'success': True, 'ticket_id': '6'}):
assert c.create('u', 'd') == '6'
def test_recurrence_on_a_closed_ticket_is_not_used_and_not_retried_each_poll(self):
c = self._client()
with self._post({'success': True, 'ticket_id': '993', 'action': 'recurrence_noted'}) as post:
assert c.create('t', 'd') is None
assert c.create('t', 'd') is None
assert post.call_count == 1 # the second poll doesn't add another comment to the closed ticket
with self._post({'success': True, 'ticket_id': '7', 'action': 'none'}) as post:
assert c.create('other', 'd') == '7' # other alerts are unaffected
def test_retry_after_a_day(self):
c = self._client()
with self._post({'success': True, 'ticket_id': '993', 'action': 'recurrence_noted'}):
c.create('t', 'd')
c._closed_matches['t'] = ('993', time.time() - c.CLOSED_MATCH_RETRY_S - 1)
with self._post({'success': True, 'ticket_id': '8', 'action': 'none'}):
assert c.create('t', 'd') == '8'
assert 't' not in c._closed_matches