Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions ansible/roles/site/files/pib/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
VENV := .venv
UV := uv
PYTHON := $(UV) run python
MANAGE := $(PYTHON) manage.py
PORT := 8000

APPS := -e pibfpgas -e pibup -e pistat -e snmp_switch
DEPS := 'channels[daphne]' channels_redis

FIXTURE ?= pibfpgas/fixtures/fpgas.online.json

.PHONY: serve setup migrate fixtures clean help

help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " make %-12s %s\n", $$1, $$2}'

serve: setup ## Start the local dev server (default: port 8000)
$(MANAGE) runserver 0.0.0.0:$(PORT)

setup: $(VENV)/pyvenv.cfg pib/local_settings.py | migrate fixtures ## Full setup: venv, deps, settings, migrate, fixtures

$(VENV)/pyvenv.cfg:
$(UV) venv $(VENV)
$(UV) pip install $(APPS) $(DEPS)

pib/local_settings.py:
@echo "Creating pib/local_settings.py for local dev..."
@printf '%s\n' \
'# Local development settings' \
'# Auto-generated by Makefile. Edit freely; .gitignored.' \
'' \
"ALLOWED_HOSTS = ['*']" \
'' \
"DOMAIN_NAME = 'localhost:$(PORT)'" \
"PI_PW = 'dev-password'" \
'' \
'# In-memory channel layer (no Redis needed for local dev)' \
'CHANNEL_LAYERS = {' \
' "default": {' \
' "BACKEND": "channels.layers.InMemoryChannelLayer",' \
' },' \
'}' > pib/local_settings.py

migrate: $(VENV)/pyvenv.cfg ## Run Django migrations
$(MANAGE) migrate

fixtures: $(VENV)/pyvenv.cfg ## Load fixture data (override: FIXTURE=path/to/file.json)
$(MANAGE) loaddata $(FIXTURE)

clean: ## Remove venv, database, and local_settings.py
rm -rf $(VENV)
rm -f db.sqlite3
rm -f pib/local_settings.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"model": "pibfpgas.pi", "pk": 1, "fields": {"port": 34, "mac": "b8:27:eb:6d:27:f6", "cable_color": "white", "location": "", "serial_no": "7a6d27f6"}}, {"model": "pibfpgas.pi", "pk": 2, "fields": {"port": 36, "mac": "b8:27:eb:86:39:63", "cable_color": "blue", "location": "", "serial_no": "80863963"}}, {"model": "pibfpgas.pi", "pk": 3, "fields": {"port": 40, "mac": "e4:5f:01:97:1f:7e", "cable_color": "gray", "location": "", "serial_no": "613a4524"}}, {"model": "pibfpgas.pi", "pk": 4, "fields": {"port": 42, "mac": "e4:5f:01:8d:f7:17", "model": "Raspberry_Pi_4_Model_B_Rev_1", "cable_color": "yellow", "location": "", "serial_no": "f77b8415"}}, {"model": "pibfpgas.pi", "pk": 5, "fields": {"port": 46, "mac": "e4:5f:01:97:32:d2", "cable_color": "gray/white", "location": "", "serial_no": "8483b266"}}, {"model": "pibfpgas.pi", "pk": 6, "fields": {"port": 48, "mac": "e4:5f:01:96:f8:a5", "cable_color": "blue", "location": "", "serial_no": "ce8e3593"}}]
[{"model": "pibfpgas.pi", "pk": 1, "fields": {"port": 34, "mac": "b8:27:eb:6d:27:f6", "cable_color": "white", "location": "", "serial_no": "7a6d27f6", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 2, "fields": {"port": 36, "mac": "b8:27:eb:86:39:63", "cable_color": "blue", "location": "", "serial_no": "80863963", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 3, "fields": {"port": 40, "mac": "e4:5f:01:97:1f:7e", "cable_color": "gray", "location": "", "serial_no": "613a4524", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 4, "fields": {"port": 42, "mac": "e4:5f:01:8d:f7:17", "model": "Raspberry_Pi_4_Model_B_Rev_1", "cable_color": "yellow", "location": "", "serial_no": "f77b8415", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 5, "fields": {"port": 46, "mac": "e4:5f:01:97:32:d2", "cable_color": "gray/white", "location": "", "serial_no": "8483b266", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 6, "fields": {"port": 48, "mac": "e4:5f:01:96:f8:a5", "cable_color": "blue", "location": "", "serial_no": "ce8e3593", "board_type": "arty_a7"}}]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"model": "pibfpgas.pi", "pk": 1, "fields": {"port": 2, "mac": "b8:27:eb:2f:5d:08", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "grey", "location": "front 1", "serial_no": "042f5d08"}}, {"model": "pibfpgas.pi", "pk": 2, "fields": {"port": 3, "mac": "dc:a6:32:05:32:45", "model": "Raspberry_Pi_4_Model_B_Rev_1", "cable_color": "white", "location": "front 2", "serial_no": "f1b7bb5a"}}, {"model": "pibfpgas.pi", "pk": 3, "fields": {"port": 5, "mac": "b8:27:eb:d4:f1:74", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "white", "location": "front 4", "serial_no": "9ed4f174"}}, {"model": "pibfpgas.pi", "pk": 4, "fields": {"port": 7, "mac": "b8:27:eb:33:51:27", "model": "Raspberry_Pi_3_Model_B_Plus_Rev_1", "cable_color": "blue", "location": "front 5", "serial_no": 48335127}}, {"model": "pibfpgas.pi", "pk": 5, "fields": {"port": 9, "mac": "b8:27:eb:a3:51:b4", "model": "Raspberry_Pi_3_Model_B_Plus_Rev_1", "cable_color": "blue", "location": "front 6", "serial_no": "8da351b4"}}, {"model": "pibfpgas.pi", "pk": 6, "fields": {"port": 11, "mac": "b8:27:eb:51:01:df", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "blue", "location": "front 7", "serial_no": "265101df"}}, {"model": "pibfpgas.pi", "pk": 7, "fields": {"port": 13, "mac": "b8:27:eb:68:fc:e7", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "white", "location": "front 8", "serial_no": "f168fce7"}}, {"model": "pibfpgas.pi", "pk": 8, "fields": {"port": 21, "mac": "b8:27:eb:5f:de:85", "model": "", "cable_color": "blue", "location": "back 7", "serial_no": "7d5fde85"}}, {"model": "pibfpgas.pi", "pk": 9, "fields": {"port": 23, "mac": "b8:27:eb:0c:f8:43", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "grey", "location": "back 8", "serial_no": "9b0cf843"}}]
[{"model": "pibfpgas.pi", "pk": 1, "fields": {"port": 2, "mac": "b8:27:eb:2f:5d:08", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "grey", "location": "front 1", "serial_no": "042f5d08", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 2, "fields": {"port": 3, "mac": "dc:a6:32:05:32:45", "model": "Raspberry_Pi_4_Model_B_Rev_1", "cable_color": "white", "location": "front 2", "serial_no": "f1b7bb5a", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 3, "fields": {"port": 5, "mac": "b8:27:eb:d4:f1:74", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "white", "location": "front 4", "serial_no": "9ed4f174", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 4, "fields": {"port": 7, "mac": "b8:27:eb:33:51:27", "model": "Raspberry_Pi_3_Model_B_Plus_Rev_1", "cable_color": "blue", "location": "front 5", "serial_no": "48335127", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 5, "fields": {"port": 9, "mac": "b8:27:eb:a3:51:b4", "model": "Raspberry_Pi_3_Model_B_Plus_Rev_1", "cable_color": "blue", "location": "front 6", "serial_no": "8da351b4", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 6, "fields": {"port": 11, "mac": "b8:27:eb:51:01:df", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "blue", "location": "front 7", "serial_no": "265101df", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 7, "fields": {"port": 13, "mac": "b8:27:eb:68:fc:e7", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "white", "location": "front 8", "serial_no": "f168fce7", "board_type": "arty_a7"}}, {"model": "pibfpgas.pi", "pk": 8, "fields": {"port": 21, "mac": "b8:27:eb:5f:de:85", "model": "", "cable_color": "blue", "location": "back 7", "serial_no": "7d5fde85", "board_type": "tt_asic"}}, {"model": "pibfpgas.pi", "pk": 9, "fields": {"port": 23, "mac": "b8:27:eb:0c:f8:43", "model": "Raspberry_Pi_3_Model_B_Rev_1", "cable_color": "grey", "location": "back 8", "serial_no": "9b0cf843", "board_type": "arty_a7"}}]
5 changes: 3 additions & 2 deletions ansible/roles/site/files/pib/pibfpgas/src/pibfpgas/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.contrib import admin
from .models import *
from .models import Pi

class PiAdmin(admin.ModelAdmin):
pass
list_display = ('port', 'board_type', 'location', 'model', 'cable_color')
list_filter = ('board_type',)

admin.site.register(Pi, PiAdmin)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 6.0.2 on 2026-02-28 05:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("pibfpgas", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="pi",
name="board_type",
field=models.CharField(
blank=True,
choices=[
("arty_a7", "Arty A7"),
("netv2", "NeTV2"),
("ulx3s", "ULX3S"),
("fomu", "Fomu"),
("tt_asic", "Tiny Tapeout ASIC"),
("tt_fpga", "Tiny Tapeout FPGA Emulation"),
],
default="arty_a7",
max_length=20,
),
),
]
10 changes: 10 additions & 0 deletions ansible/roles/site/files/pib/pibfpgas/src/pibfpgas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

from django.db import models

BOARD_TYPES = [
('arty_a7', 'Arty A7'),
('netv2', 'NeTV2'),
('ulx3s', 'ULX3S'),
('fomu', 'Fomu'),
('tt_asic', 'Tiny Tapeout ASIC'),
('tt_fpga', 'Tiny Tapeout FPGA Emulation'),
]

class Pi(models.Model):
port = models.IntegerField()
mac = models.CharField(max_length=17, blank=True)
serial_no = models.CharField(max_length=8, blank=True)
location = models.CharField(max_length=30, blank=True)
model = models.CharField(max_length=30, blank=True)
cable_color = models.CharField(max_length=10, blank=True)
board_type = models.CharField(max_length=20, choices=BOARD_TYPES, default='arty_a7', blank=True)
Loading