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>
This commit is contained in:
2026-11-11 00:12:07 -05:00
co-authored by Claude Opus 5.5
parent 6530433d9c
commit a9de175d90
12 changed files with 281 additions and 56 deletions
+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'}]
+20
View File
@@ -369,3 +369,23 @@ 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)
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)]