diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f4f099..db5fe62 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,10 @@ publish a tag that has no section here.
installs the NVIDIA driver on GPU nodes) and extra overlays for stateless nodes.
- `rollcall tag`, `rollcall tags`, `rollcall list -tag`, `deploy tag:NAME` / `power tag:NAME`
fan-out; tags column, editor and definitions panel in the web UI; `?tag=` filter on the API.
+- Web UI redesigned for fleets: sidebar navigation (Overview, Machines, Jobs, Tags, Profiles,
+ OS images), state/tag filter chips, search, sorting and paging, multi-select with bulk
+ power/deploy/assign/tag/re-commission/release, machine detail with tabs, dialog-driven
+ actions, fleet-wide `/api/v1/events` and `/api/v1/jobs`, `?token=` sign-in for bookmarks.
- `rollcall version`; CD-built binary carries `git describe`.
- Release notes from `CHANGELOG.md`.
diff --git a/cmd/rollcall/deploy.go b/cmd/rollcall/deploy.go
index 1a86fd7..6fcf7f7 100644
--- a/cmd/rollcall/deploy.go
+++ b/cmd/rollcall/deploy.go
@@ -131,6 +131,24 @@ func (s *Store) Jobs(ctx context.Context, machineID string, limit int) ([]*Job,
return out, rows.Err()
}
+// RecentJobs lists jobs across all machines, newest first (active ones first when activeFirst).
+func (s *Store) RecentJobs(ctx context.Context, limit int) ([]*Job, error) {
+ rows, err := s.pool.Query(ctx, `SELECT `+jobCols+` FROM jobs ORDER BY (state IN ('pending','running')) DESC, created DESC LIMIT $1`, limit)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ out := []*Job{}
+ for rows.Next() {
+ j, err := scanJob(rows)
+ if err != nil {
+ return nil, err
+ }
+ out = append(out, j)
+ }
+ return out, rows.Err()
+}
+
func (s *Store) JobProgress(ctx context.Context, id string, progress []byte) error {
_, err := s.pool.Exec(ctx, `UPDATE jobs SET state='running', started=coalesce(started, now()), progress=$2 WHERE id=$1 AND state IN ('pending','running')`, id, progress)
return err
diff --git a/cmd/rollcall/osimages.go b/cmd/rollcall/osimages.go
index 590ec98..361d84f 100644
--- a/cmd/rollcall/osimages.go
+++ b/cmd/rollcall/osimages.go
@@ -146,7 +146,7 @@ func osCatalog(dir, sourcesFile string) ([]OSImage, error) {
}
if ents, err := os.ReadDir(dir); err == nil {
for _, e := range ents {
- if e.IsDir() {
+ if e.IsDir() && !strings.HasPrefix(e.Name(), ".") {
names[e.Name()] = true
}
}
diff --git a/cmd/rollcall/server.go b/cmd/rollcall/server.go
index 58953aa..9fa5aa5 100644
--- a/cmd/rollcall/server.go
+++ b/cmd/rollcall/server.go
@@ -129,6 +129,23 @@ func (a *App) routes() http.Handler {
mux.HandleFunc("GET /api/v1/jobs/self", a.handleJobSelf) // job token auth inside
mux.HandleFunc("POST /api/v1/jobs/self/progress", a.handleJobProgress) // job token auth inside
mux.HandleFunc("POST /api/v1/phone-home/{token}", a.handlePhoneHome)
+ // fleet-wide views for the UI
+ mux.HandleFunc("GET /api/v1/events", a.adminAuth(func(w http.ResponseWriter, r *http.Request) {
+ evs, err := a.store.RecentEvents(r.Context(), 100)
+ if err != nil {
+ fail(w, 500, err)
+ return
+ }
+ writeJSON(w, 200, evs)
+ }))
+ mux.HandleFunc("GET /api/v1/jobs", a.adminAuth(func(w http.ResponseWriter, r *http.Request) {
+ jobs, err := a.store.RecentJobs(r.Context(), 100)
+ if err != nil {
+ fail(w, 500, err)
+ return
+ }
+ writeJSON(w, 200, jobs)
+ }))
// tags
mux.HandleFunc("GET /api/v1/tags", a.adminAuth(a.handleTags))
mux.HandleFunc("POST /api/v1/tags", a.adminAuth(a.handleTags))
@@ -262,7 +279,7 @@ func summarize(m *Machine) Summary {
CPU: str(dig(inv, "cpu", "Model name")), CPUs: str(dig(inv, "cpu", "CPU(s)")),
MemoryBytes: num(dig(inv, "memory", "total_bytes")), Disks: num(dig(inv, "storage", "disk_count")),
StorageBytes: num(dig(inv, "storage", "total_bytes")), NICs: listLen(inv["network"]),
- IBHCAs: listLen(dig(inv, "infiniband", "hcas")), GPUs: listLen(inv["gpus"]),
+ IBHCAs: listLen(dig(inv, "infiniband", "hcas")), GPUs: nodeCtx(m).GPUs, // real accelerators only
Profile: m.Profile, NodeName: m.NodeName, MgmtIP: m.MgmtIP, IBIP: m.IBIP, BootedAt: m.BootedAt,
OS: m.OS, OSVersion: m.OSVersion, DeployedAt: m.DeployedAt,
Tags: effectiveTags(m), ManualTags: m.Tags, AutoTags: m.AutoTags}
diff --git a/cmd/rollcall/store.go b/cmd/rollcall/store.go
index 943ff33..03d2a52 100644
--- a/cmd/rollcall/store.go
+++ b/cmd/rollcall/store.go
@@ -212,6 +212,29 @@ func (s *Store) Events(ctx context.Context, id string) ([]Event, error) {
return evs, rows.Err()
}
+type MachineEvent struct {
+ Event
+ MachineID string `json:"machine_id"`
+}
+
+// RecentEvents lists the newest events across all machines.
+func (s *Store) RecentEvents(ctx context.Context, limit int) ([]MachineEvent, error) {
+ rows, err := s.pool.Query(ctx, `SELECT ts, machine_id, event, coalesce(detail,'') FROM events ORDER BY ts DESC LIMIT $1`, limit)
+ if err != nil {
+ return nil, err
+ }
+ defer rows.Close()
+ evs := []MachineEvent{}
+ for rows.Next() {
+ var e MachineEvent
+ if err := rows.Scan(&e.TS, &e.MachineID, &e.Event.Event, &e.Detail); err != nil {
+ return nil, err
+ }
+ evs = append(evs, e)
+ }
+ return evs, rows.Err()
+}
+
func (s *Store) AddEvent(ctx context.Context, id, event, detail string) error {
_, err := s.pool.Exec(ctx, `INSERT INTO events(machine_id, event, detail) VALUES ($1,$2,$3)`, id, event, detail)
return err
diff --git a/cmd/rollcall/web/app.js b/cmd/rollcall/web/app.js
index 28bd3e2..36b8f5e 100644
--- a/cmd/rollcall/web/app.js
+++ b/cmd/rollcall/web/app.js
@@ -1,13 +1,20 @@
'use strict';
+// Rollcall web UI: a fleet view first (filters, selection, bulk actions), machine detail second.
const $ = (s, el = document) => el.querySelector(s);
-const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
-const human = n => { n = Number(n || 0); const u = ['B','K','M','G','T','P']; let i = 0; while (n >= 1024 && i < u.length - 1) { n /= 1024; i++; } return (i <= 2 ? n.toFixed(0) : n.toFixed(1)) + u[i]; };
-const ago = ts => { if (!ts) return '-'; const s = (Date.now() - new Date(ts)) / 1000; if (s < 90) return `${s | 0}s ago`; if (s < 5400) return `${(s / 60) | 0}m ago`; if (s < 172800) return `${(s / 3600) | 0}h ago`; return `${(s / 86400) | 0}d ago`; };
+const $$ = (s, el = document) => Array.from(el.querySelectorAll(s));
+const esc = s => String(s ?? '').replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
+const human = n => { n = Number(n || 0); const u = ['B', 'K', 'M', 'G', 'T', 'P']; let i = 0; while (n >= 1024 && i < u.length - 1) { n /= 1024; i++; } return (i <= 2 ? n.toFixed(0) : n.toFixed(1)) + u[i]; };
+const ago = ts => { if (!ts) return '-'; const s = (Date.now() - new Date(ts)) / 1000; if (s < 90) return `${s | 0}s`; if (s < 5400) return `${(s / 60) | 0}m`; if (s < 172800) return `${(s / 3600) | 0}h`; return `${(s / 86400) | 0}d`; };
+const when = ts => ts ? new Date(ts).toLocaleString() : '';
+const pill = (s, extra = '') => `${esc(s)}${extra} `;
+const nameOf = m => m.node_name || m.hostname || m.id;
+// ---------------------------------------------------------------- state
let token = '';
try { token = localStorage.getItem('rollcall.token') || ''; } catch (e) { /* storage unavailable */ }
-let machines = [];
-let current = null;
+// ?token=… on the URL signs in once and is removed from the address bar (for bookmarks/kiosks)
+{ const u = new URL(location.href); const t = u.searchParams.get('token'); if (t) { token = t; try { localStorage.setItem('rollcall.token', t); } catch (e) { /* ignore */ } u.searchParams.delete('token'); history.replaceState(null, '', u.pathname + u.search + u.hash); } }
+const S = { machines: [], tags: [], profiles: [], os: [], jobs: [], events: [], sel: new Set(), q: '', states: new Set(), tagf: new Set(), page: 0, per: 50, sort: 'name', dir: 1, loaded: false };
let timer = null;
async function api(method, path, body) {
@@ -17,251 +24,426 @@ async function api(method, path, body) {
if (!r.ok) throw new Error(data.error || r.statusText);
return data;
}
-
-function askToken() {
- const dlg = $('#login');
- if (!dlg.open) dlg.showModal();
-}
-$('#login form').addEventListener('submit', () => {
- token = $('#token').value.trim();
- try { localStorage.setItem('rollcall.token', token); } catch (e) { /* ignore */ }
- $('#token').value = '';
- loadList();
-});
+function askToken() { const d = $('#login'); if (!d.open) d.showModal(); }
+$('#login form').addEventListener('submit', () => { token = $('#token').value.trim(); try { localStorage.setItem('rollcall.token', token); } catch (e) { /* ignore */ } $('#token').value = ''; refresh(true); });
$('#logout').onclick = () => { token = ''; try { localStorage.removeItem('rollcall.token'); } catch (e) { /* ignore */ } askToken(); };
-$('#refresh').onclick = () => current ? loadDetail(current) : loadList();
-$('#filter').oninput = renderList;
-$('#back').onclick = () => { current = null; $('#detail').hidden = true; $('#list').hidden = false; loadList(); };
-function setStatus(msg, bad) { const el = $('#status'); el.textContent = msg; el.className = bad ? 'bad' : 'muted'; }
+let toastTimer = null;
+function toast(msg, bad) { const t = $('#toast'); t.textContent = msg; t.className = bad ? 'bad' : ''; t.hidden = false; clearTimeout(toastTimer); toastTimer = setTimeout(() => { t.hidden = true; }, bad ? 9000 : 5000); }
-let profiles = [];
-let osImages = [];
-let tagDefs = [];
-const tagPills = (m, editable) => (m.tags || []).map(t => { const auto = (m.auto_tags || []).includes(t) && !(m.manual_tags || []).includes(t); return `${esc(t)}${editable && !auto ? ` × ` : ''} `; }).join(' ');
-async function loadList() {
+// dialog(title, [{name,label,type:'select'|'text'|'checkbox'|'textarea', options:[[v,label]], value, placeholder}], note) -> values | null
+function dialog(title, fields, note, okLabel = 'OK') {
+ return new Promise(resolve => {
+ const d = $('#dlg');
+ $('#dlg-title').textContent = title; $('#dlg-note').textContent = note || ''; $('#dlg-ok').textContent = okLabel;
+ $('#dlg-body').innerHTML = fields.map(f => {
+ let input;
+ if (f.type === 'select') input = `${(f.options || []).map(([v, l]) => `${esc(l)} `).join('')} `;
+ else if (f.type === 'checkbox') input = ` `;
+ else if (f.type === 'textarea') input = ``;
+ else input = ` `;
+ return `${esc(f.label)}
${input}${f.help ? `
${esc(f.help)}
` : ''}
`;
+ }).join('');
+ const form = $('#dlg-form');
+ const done = ok => { d.close(); form.onsubmit = null; $('#dlg-cancel').onclick = null; if (!ok) return resolve(null); const fd = new FormData(form); const out = {}; for (const f of fields) out[f.name] = f.type === 'checkbox' ? form.elements[f.name].checked : (fd.get(f.name) ?? ''); resolve(out); };
+ form.onsubmit = ev => { ev.preventDefault(); done(true); };
+ $('#dlg-cancel').onclick = () => done(false);
+ d.oncancel = () => done(false);
+ d.showModal();
+ const first = $('#dlg-body input, #dlg-body select, #dlg-body textarea'); if (first) first.focus();
+ });
+}
+
+// ---------------------------------------------------------------- data
+async function refresh(full) {
if (!token) return askToken();
try {
- machines = await api('GET', '/api/v1/machines');
- setStatus(`updated ${new Date().toLocaleTimeString()}`);
- renderList();
- loadProfiles();
- } catch (e) { if (e.message !== 'unauthorized') setStatus(e.message, true); }
+ const [machines, tags, profiles, os] = await Promise.all([api('GET', '/api/v1/machines'), api('GET', '/api/v1/tags'), api('GET', '/api/v1/profiles'), api('GET', '/api/v1/os')]);
+ Object.assign(S, { machines, tags, profiles, os, loaded: true });
+ const page = route().page;
+ if (full || page === 'overview' || page === 'jobs') S.jobs = await api('GET', '/api/v1/jobs');
+ if (full || page === 'overview') S.events = await api('GET', '/api/v1/events');
+ $('#n-machines').textContent = machines.length;
+ const active = S.jobs.filter(j => j.state === 'pending' || j.state === 'running').length;
+ $('#n-jobs').textContent = active ? `${active} active` : '';
+ $('#status').textContent = `updated ${new Date().toLocaleTimeString()}`;
+ render();
+ } catch (e) { if (e.message !== 'unauthorized') { $('#status').textContent = e.message; $('#status').className = 'bad'; } }
}
-
-async function loadProfiles() {
- try {
- profiles = await api('GET', '/api/v1/profiles');
- const images = await api('GET', '/api/v1/images');
- $('#profiles').innerHTML = table(['Profile', 'Image', 'Overlays', 'Names', 'Nodes', ''], profiles.map(p => [esc(p.name), esc(p.image), esc((p.overlays || []).join(', ')), esc(p.name_format), machines.filter(m => m.profile === p.name).length, `rm `]));
- $('#images').innerHTML = table(['Image', 'Complete', 'Squashfs', 'Built'], images.map(i => [esc(i.name), i.complete ? 'yes ' : 'no ', human(i['filesystem.squashfs']), esc(i.built ? new Date(i.built).toLocaleString() : '')]));
- document.querySelectorAll('[data-rmprofile]').forEach(b => b.onclick = async () => { if (confirm(`Delete profile ${b.dataset.rmprofile}?`)) { try { await api('DELETE', '/api/v1/profiles/' + b.dataset.rmprofile); } catch (e) { alert(e.message); } loadProfiles(); } });
- const sel = $('#assign-profile'); const cur = sel.value;
- sel.innerHTML = 'profile… ' + profiles.map(p => `${esc(p.name)} (${esc(p.image)}) `).join('');
- sel.value = cur;
- tagDefs = await api('GET', '/api/v1/tags');
- $('#tags').innerHTML = table(['Tag', 'Machines', 'Match', 'Overlays', 'Cloud-config', 'Comment', ''], tagDefs.map(t => [`${esc(t.name)} `, t.machines || 0, `${esc(t.match || '')} `, esc((t.overlays || []).join(', ')), t.cloud_config ? `${t.cloud_config.length} B` : '', esc(t.comment || ''), `edit rm `]));
- document.querySelectorAll('[data-rmtag]').forEach(b => b.onclick = async () => { if (confirm(`Delete tag ${b.dataset.rmtag}? It is removed from every machine.`)) { try { await api('DELETE', '/api/v1/tags/' + b.dataset.rmtag); } catch (e) { alert(e.message); } loadProfiles(); } });
- document.querySelectorAll('[data-edittag]').forEach(b => b.onclick = () => { const t = tagDefs.find(x => x.name === b.dataset.edittag); const f = $('#tag-form'); f.name.value = t.name; f.comment.value = t.comment || ''; f.match.value = t.match || ''; f.overlays.value = (t.overlays || []).join(','); f.cloud_config.value = t.cloud_config || ''; f.scrollIntoView(); });
- $('#tag-names').innerHTML = tagDefs.map(t => ``).join('');
- osImages = await api('GET', '/api/v1/os');
- $('#osimages').innerHTML = table(['OS', 'Current version', 'Family', 'Compressed', 'Disk needed', 'Imported', 'Track', 'Versions', 'Status'],
- osImages.map(i => { const c = i.current || {}; const s = i.source || {}; return [esc(i.name), `${esc(c.version || '-')} `, esc(s.family || c.family), c.size ? human(c.size) : '', c.raw_size ? human(c.raw_size) : '', c.imported ? esc(new Date(c.imported).toLocaleString()) : '', esc(s.track || ''), (i.versions || []).length, i.warning ? `${esc(i.warning)} ` : 'ok ']; }));
- const os = $('#deploy-os'); const curOS = os.value;
- os.innerHTML = ' OS image… ' + osImages.filter(i => i.current).map(i => `${esc(i.name)} (${esc(i.current.version)}, ${human(i.current.raw_size)}) `).join('');
- os.value = curOS;
- } catch (e) { /* non-fatal */ }
-}
-$('#profile-form').onsubmit = async ev => {
- ev.preventDefault();
- const f = new FormData(ev.target);
- let vars = {};
- try { vars = JSON.parse(f.get('vars') || '{}'); } catch (e) { $('#profile-out').textContent = 'vars: invalid JSON'; return; }
- const body = { name: f.get('name'), image: f.get('image'), append: f.get('append'), name_format: f.get('name_format'), vars, overlays: (f.get('overlays') || '').split(',').map(s => s.trim()).filter(Boolean) };
- try { await api('POST', '/api/v1/profiles', body); $('#profile-out').textContent = 'saved'; loadProfiles(); } catch (e) { $('#profile-out').textContent = e.message; }
-};
-
-function renderList() {
- const q = $('#filter').value.toLowerCase();
- const rows = machines.filter(m => !q || JSON.stringify([m.id, m.state, m.manufacturer, m.product, m.serial, m.macs, m.hostname, m.node_name, m.os, m.profile, m.tags]).toLowerCase().includes(q));
- $('#count').textContent = `${rows.length} / ${machines.length}`;
- $('#empty').hidden = machines.length > 0;
- $('#machines tbody').innerHTML = rows.map(m => {
- const b = m.bmc;
- const bmc = b ? `${esc(b.address || '-')} ${esc(b.source)} ` : '- ';
- const prog = m.job && m.job.progress ? m.job.progress : null;
- const state = m.job ? `${esc(m.state)} ${prog ? Math.round(prog.pct || 0) + '%' : ''}` : esc(m.state);
- const what = m.profile ? esc(m.profile) : m.os ? `${esc(m.os)}${esc(m.os_version || '')} ` : '';
- return `
- ${esc(m.id)} ${state}
- ${esc(m.node_name || '')}${m.mgmt_ip ? `${esc(m.mgmt_ip)} ` : ''} ${what} ${tagPills(m, false)}
- ${esc((m.manufacturer || '') + ' ' + (m.product || ''))} ${esc(m.serial || '')}
- ${esc(m.cpus)} ${human(m.memory_bytes)} ${m.disks | 0}
- ${human(m.storage_bytes)} ${m.nics} ${m.ib_hcas} ${m.gpus}
- ${bmc} ${ago(m.last_seen)} `;
- }).join('');
- for (const tr of $('#machines tbody').children) tr.onclick = () => loadDetail(tr.dataset.id);
-}
-
-function card(title, inner, wide) { return `
${esc(title)} ${inner}`; }
-function kv(pairs) { return '' + pairs.filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => `${esc(k)} ${v} `).join('') + ' '; }
-function table(cols, rows) { return rows.length ? `${cols.map(c => `${esc(c)} `).join('')} ${rows.map(r => `${r.map(c => `${c ?? ''} `).join('')} `).join('')}
` : 'none '; }
-
-async function loadDetail(id) {
- try {
- const d = await api('GET', '/api/v1/machines/' + encodeURIComponent(id));
- current = id;
- renderDetail(d);
- $('#list').hidden = true; $('#detail').hidden = false;
- } catch (e) { if (e.message !== 'unauthorized') setStatus(e.message, true); }
-}
-
-function renderDetail(d) {
- const s = d.summary, inv = d.inventory || {}, sys = inv.system || {}, cpu = inv.cpu || {}, mem = inv.memory || {}, st = inv.storage || {}, b = d.bmc || {};
- $('#d-title').textContent = `${s.node_name ? s.node_name + ' · ' : ''}${s.id} ${sys['system-manufacturer'] || ''} ${sys['system-product-name'] || ''}`;
- $('#d-state').textContent = s.state; $('#d-state').className = 'pill ' + s.state;
- $('#action-out').textContent = '';
- if (s.profile) $('#assign-profile').value = s.profile;
- $('#assign-name').value = s.node_name || '';
- const diskSel = $('#deploy-disk'); const curDisk = diskSel.value;
- diskSel.innerHTML = 'disk: auto (smallest that fits) ' + ((st.disks || []).map(x => `${esc(x.name)} ${human(x.size)} ${esc(x.model || '')} `).join(''));
- diskSel.value = curDisk;
- $('#job-cancel').hidden = !s.job;
- $('#d-tags').innerHTML = tagPills(s, true) || 'none ';
- document.querySelectorAll('[data-rmmtag]').forEach(a => a.onclick = ev => { ev.preventDefault(); action(async () => { const r = await api('POST', `/api/v1/machines/${current}/tags`, { remove: [a.dataset.rmmtag] }); await loadDetail(current); return 'tags: ' + r.effective.join(' '); }, 'untag'); });
- const cards = [];
- const job = s.job || (d.jobs || [])[0];
- if (s.os || job) {
- const p = (job && job.progress) || {}; const sp = (job && job.spec) || {};
- const active = job && (job.state === 'pending' || job.state === 'running');
- cards.push(card('Deployment', kv([
- ['OS', s.os ? `${esc(s.os)} ${esc(s.os_version || '')} ` : ''],
- ['Deployed', esc(s.deployed_at ? new Date(s.deployed_at).toLocaleString() : '')],
- ['Phoned home', s.deployed_at ? (s.booted_at ? `${esc(new Date(s.booted_at).toLocaleString())} ` : 'not yet ') : ''],
- ['Hostname', esc(s.node_name)], ['Management IP', s.mgmt_ip ? `${esc(s.mgmt_ip)} ` : ''],
- ['Job', job ? `${esc(job.id)} ${esc(job.kind)} ${esc(job.state)} ${esc(ago(job.created))}` : ''],
- ['Target', sp.disk ? `${esc(sp.disk)} ← ${esc(sp.os || '')}/${esc(sp.version || '')}` : ''],
- ['Progress', active ? `
${esc(p.phase || '')} ${Math.round(p.pct || 0)}% ${esc(p.msg || '')} ` : ''],
- ['Result', p.details && Object.keys(p.details).length ? `${esc(JSON.stringify(p.details))} ` : ''],
- ['Error', job && job.error ? `${esc(job.error)} ` : ''],
- ]) + ((d.jobs || []).length > 1 ? 'History
' + table(['Job', 'Kind', 'State', 'Created', 'OS', 'Error'], d.jobs.map(j => [`${esc(j.id)} `, esc(j.kind), `${esc(j.state)} `, esc(new Date(j.created).toLocaleString()), esc(((j.spec || {}).os || '') + '/' + ((j.spec || {}).version || '')), esc(j.error || '')])) : ''), true));
- }
- if (s.profile) cards.push(card('Stateless node', kv([
- ['Node name', esc(s.node_name)], ['Profile', esc(s.profile)], ['Management IP', `${esc(s.mgmt_ip)} `],
- ['InfiniBand IP', s.ib_ip ? `${esc(s.ib_ip)} ` : ''], ['Booted', esc(s.booted_at ? new Date(s.booted_at).toLocaleString() : 'not yet')],
- ['Last heartbeat', esc(s.last_seen ? ago(s.last_seen) : '')],
- ])));
- cards.push(card('System', kv([
- ['Manufacturer', esc(sys['system-manufacturer'])], ['Product', esc(sys['system-product-name'])], ['Serial', esc(sys['system-serial-number'])],
- ['UUID', `${esc(sys['system-uuid'])} `], ['SKU', esc(sys['system-sku-number'])],
- ['Board', esc([sys['baseboard-manufacturer'], sys['baseboard-product-name'], sys['baseboard-serial-number']].filter(Boolean).join(' / '))],
- ['Chassis', esc([sys['chassis-type'], sys['chassis-serial-number'], sys['chassis-asset-tag']].filter(Boolean).join(' / '))],
- ['BIOS', esc([sys['bios-vendor'], sys['bios-version'], sys['bios-release-date']].filter(Boolean).join(' '))],
- ['Kernel', esc((inv.kernel || '').split(' (')[0])], ['TPM', esc((inv.tpm || []).join(', ') || 'none')],
- ['Hostname', esc(s.hostname)], ['First seen', esc(new Date(s.first_seen).toLocaleString())], ['Last seen', esc(s.last_seen ? new Date(s.last_seen).toLocaleString() : '')],
- ['Agent run', esc(inv.duration_s ? inv.duration_s + ' s' : '')],
- ])));
- cards.push(card('CPU', kv([
- ['Model', esc(cpu['Model name'])], ['Sockets', esc(cpu['Socket(s)'])], ['Cores / socket', esc(cpu['Core(s) per socket'])],
- ['Threads / core', esc(cpu['Thread(s) per core'])], ['Logical CPUs', esc(cpu['CPU(s)'])], ['NUMA nodes', esc(cpu['NUMA node(s)'])],
- ['Max MHz', esc(cpu['CPU max MHz'])], ['L3', esc(cpu['L3 cache'])], ['Virtualization', esc(cpu['Virtualization'])],
- ['Features', esc((cpu.features || []).join(' '))],
- ])));
- cards.push(card(`Memory ${human(mem.total_bytes)} · ${mem.dimms_populated ?? '?'}/${mem.dimm_slots ?? '?'} DIMMs`,
- table(['Slot', 'Size', 'Type', 'Speed', 'Vendor', 'Part', 'Serial'],
- (mem.dimms || []).filter(x => x.populated).map(x => [esc(x.locator), esc(x.size), esc(x.type), esc(x.configured_speed || x.speed), esc(x.manufacturer), `${esc(x.part_number)} `, `${esc(x.serial)} `]))));
- cards.push(card(`Storage · ${st.disk_count ?? 0} disks · ${human(st.total_bytes)}`,
- table(['Dev', 'Size', 'Bus', 'Kind', 'Model', 'Serial', 'FW', 'Health'],
- (st.disks || []).map(x => { const sm = (st.smart || {})[x.name] || {}; return [esc(x.name), human(x.size), esc(x.tran), x.rota === false ? 'ssd' : 'hdd', esc(x.model), `${esc(x.serial)} `, esc(sm.firmware), sm.healthy === true ? 'ok ' : sm.healthy === false ? 'FAIL ' : '']; }))
- + (st.controllers && st.controllers.length ? 'Controllers
' + table(['PCI', 'Vendor', 'Device', 'Driver'], st.controllers.map(c => [`${esc(c.slot)} `, esc(c.vendor), esc(c.device), esc(c.driver)])) : ''), true));
- cards.push(card(`Network · ${(inv.network || []).length} NICs`,
- table(['If', 'MAC', 'Driver', 'FW', 'Speed', 'Link', 'PCI', 'NUMA', 'VFs', 'IPv4'],
- (inv.network || []).map(n => [esc(n.name), `${esc(n.mac)} `, esc(n.driver), esc(n.firmware_version), esc(n.speed), n.link === true ? 'up ' : n.link === false ? 'down ' : '', `${esc(n.pci)} `, esc(n.numa_node), esc(n.sriov_totalvfs), esc((n.ipv4 || []).join(' '))])), true));
- const hcas = (inv.infiniband || {}).hcas || [];
- if (hcas.length) cards.push(card(`InfiniBand · ${hcas.length} HCAs`,
- table(['HCA', 'Port', 'Layer', 'State', 'Rate', 'LID', 'Node GUID', 'FW', 'Board', 'PCI'],
- hcas.flatMap(h => (h.ports || []).map(p => [esc(h.name), esc(p.port), esc(p.link_layer), esc(p.state), esc(p.rate), esc(p.lid), `${esc(h.node_guid)} `, esc(h.fw_ver), esc(h.board_id), `${esc(h.pci)} `]))), true));
- if ((inv.gpus || []).length) cards.push(card('GPUs / accelerators', table(['PCI', 'Vendor', 'Device', 'Driver'], inv.gpus.map(g => [`${esc(g.slot)} `, esc(g.vendor), esc(g.device), esc(g.driver)]))));
- if (inv.lldp && Object.keys(inv.lldp).length) {
- const rows = [];
- for (const [ifn, ents] of Object.entries(inv.lldp)) for (const e of (Array.isArray(ents) ? ents : [ents])) {
- const ch = e.chassis || {}; const name = Object.keys(ch)[0] || '?'; const c = ch[name] || {};
- rows.push([esc(ifn), esc(name), esc((c.descr || '').slice(0, 60)), esc((e.port || {}).id && (e.port.id.value || e.port.id)), esc((e.port || {}).descr), esc((e.vlan || {})['vlan-id'] || (e.vlan || {}).value)]);
- }
- cards.push(card('LLDP neighbors (switch ports)', table(['If', 'Switch', 'Descr', 'Port', 'Port descr', 'VLAN'], rows), true));
- }
- cards.push(card('BMC', kv([
- ['Source', esc(b.source)], ['Address', `${esc(b.address)}${b.port && b.port !== 623 ? ':' + esc(b.port) : ''} `], ['MAC', `${esc(b.mac)} `],
- ['User', esc(b.user)], ['Password', d.has_bmc_secret ? 'stored encrypted on server ' : 'none '],
- ['Configured', b.configured ? 'yes ' : 'no '], ['Verified OOB', b.verified_oob === true ? 'yes ' : b.verified_oob === false ? 'no ' : ''],
- ['Channel', esc(b.channel)], ['LAN', b.lan ? `${esc(JSON.stringify(b.lan))} ` : ''],
- ['Firmware', esc((b.mc_info || {})['Firmware Revision'])], ['Manufacturer', esc((b.mc_info || {})['Manufacturer Name'])],
- ['Errors', (b.errors || []).length ? `${esc(b.errors.join('; '))} ` : ''],
- ]) + ((b.users_before || []).length ? 'User table before commissioning
' + table(['ID', 'Name', 'Priv', 'IPMI'], b.users_before.map(u => [u.id, esc(u.name), esc(u.priv), u.ipmi_msg ? 'yes' : 'no'])) : '')));
- cards.push(card('Events', table(['Time', 'Event', 'Detail'], (d.events || []).slice().reverse().map(e => [esc(new Date(e.ts).toLocaleString()), esc(e.event), `${esc(e.detail)} `]))));
- if ((inv.pci || []).length) cards.push(card(`PCI devices · ${inv.pci.length}`, table(['Slot', 'Class', 'Vendor', 'Device', 'Driver'], inv.pci.map(p => [`${esc(p.slot)} `, esc(p.class), esc(p.vendor), esc(p.device), esc(p.driver)])), true));
- if ((inv.errors || []).length) cards.push(card('Agent errors', `${esc(inv.errors.join('\n'))} `, true));
- $('#d-body').innerHTML = cards.join('');
- $('#d-json').textContent = JSON.stringify(d, null, 1);
-}
-
-async function action(fn, label) {
- const btns = document.querySelectorAll('.actions button');
- btns.forEach(b => b.disabled = true);
- $('#action-out').textContent = label + ' …';
- try { const r = await fn(); $('#action-out').textContent = r; }
- catch (e) { $('#action-out').textContent = 'error: ' + e.message; }
- finally { btns.forEach(b => b.disabled = false); }
-}
-document.querySelectorAll('[data-power]').forEach(b => b.onclick = () => action(async () => {
- const r = await api('POST', `/api/v1/machines/${current}/power`, { action: b.dataset.power }); return r.output || (r.ok ? 'ok' : 'failed');
-}, 'power ' + b.dataset.power));
-document.querySelectorAll('[data-bootdev]').forEach(b => b.onclick = () => action(async () => {
- const r = await api('POST', `/api/v1/machines/${current}/bootdev`, { device: b.dataset.bootdev }); return r.output || (r.ok ? 'ok' : 'failed');
-}, 'bootdev ' + b.dataset.bootdev));
-const doAssign = boot => action(async () => {
- const profile = $('#assign-profile').value; if (!profile) throw new Error('pick a profile');
- const r = await api('POST', `/api/v1/machines/${current}/assign`, { profile, name: $('#assign-name').value.trim(), boot });
- await loadDetail(current); return `${r.name} (${r.mgmt_ip || 'no pool'})${r.ipmi ? ' · ' + r.ipmi : ''}`;
-}, boot ? 'assign + boot' : 'assign');
-$('#assign').onclick = () => doAssign(false);
-$('#assign-boot').onclick = () => { if (confirm('Assign and power-cycle this machine into the stateless image?')) doAssign(true); };
-$('#unassign').onclick = () => { if (confirm('Remove the profile? The node name and IP are released.')) action(async () => { const r = await api('POST', `/api/v1/machines/${current}/unassign`); await loadDetail(current); return 'state ' + r.state; }, 'unassign'); };
-$('#tag-add').onkeydown = ev => {
- if (ev.key !== 'Enter') return;
- ev.preventDefault();
- const t = $('#tag-add').value.trim().replace(/^\+/, ''); if (!t) return;
- action(async () => { const r = await api('POST', `/api/v1/machines/${current}/tags`, { add: [t] }); $('#tag-add').value = ''; await loadDetail(current); loadProfiles(); return 'tags: ' + r.effective.join(' '); }, 'tag');
-};
-$('#tag-form').onsubmit = async ev => {
- ev.preventDefault();
- const f = new FormData(ev.target);
- const body = { name: f.get('name'), comment: f.get('comment'), match: f.get('match'), cloud_config: f.get('cloud_config'), overlays: (f.get('overlays') || '').split(',').map(s => s.trim()).filter(Boolean) };
- try { await api('POST', '/api/v1/tags', body); $('#tag-out').textContent = 'saved (auto tags re-evaluated)'; loadList(); } catch (e) { $('#tag-out').textContent = e.message; }
-};
-$('#deploy').onclick = () => {
- const os = $('#deploy-os').value; if (!os) { $('#action-out').textContent = 'pick an OS image'; return; }
- const disk = $('#deploy-disk').value;
- if (!confirm(`Deploy ${os} to ${disk || 'the auto-selected disk'} of ${current}?\nThe disk is wiped and the machine is power-cycled.`)) return;
- action(async () => {
- const r = await api('POST', `/api/v1/machines/${current}/deploy`, { os, disk, hostname: $('#deploy-host').value.trim(), package_upgrade: $('#deploy-upgrade').checked, boot: true });
- await loadDetail(current); return `job ${r.job}: ${r.os}/${r.version} → ${r.disk} as ${r.hostname}${r.ipmi ? ' · ' + r.ipmi : ''}`;
- }, 'deploy');
-};
-$('#release').onclick = () => { if (confirm(`Release ${current}? The OS disk is wiped (signatures + first/last 64 MiB) and the machine returns to ready.`)) action(async () => { const r = await api('POST', `/api/v1/machines/${current}/release`, { boot: true }); await loadDetail(current); return `job ${r.job} (wipe ${r.disk})${r.ipmi ? ' · ' + r.ipmi : ''}`; }, 'release'); };
-$('#job-cancel').onclick = () => { if (confirm('Cancel the active job? A running write is not interrupted on the machine; it just stops being tracked.')) action(async () => { const r = await api('POST', `/api/v1/machines/${current}/jobs/cancel`); await loadDetail(current); return `job ${r.job} cancelled`; }, 'cancel job'); };
-$('#recommission').onclick = () => action(async () => { const r = await api('POST', `/api/v1/machines/${current}/recommission`); await loadDetail(current); return `state ${r.state}: next PXE boot runs commissioning`; }, 'recommission');
-$('#recommission-now').onclick = () => { if (confirm('Remove PXE override, set bootdev=pxe and power-cycle this machine via its BMC?')) action(async () => { const r = await api('POST', `/api/v1/machines/${current}/recommission?now=1`); await loadDetail(current); return r.ipmi || r.state; }, 'recommission now'); };
-$('#delete').onclick = () => { if (confirm(`Delete ${current}? It will be commissioned again as a new machine on next PXE boot.`)) action(async () => { await api('DELETE', `/api/v1/machines/${current}`); $('#back').click(); return 'deleted'; }, 'delete'); };
-
function schedule() {
clearInterval(timer);
timer = setInterval(() => {
- if (document.visibilityState !== 'visible') return;
- if (!current) return loadList();
- const m = machines.find(x => x.id === current);
- if (m && (m.job || m.state === 'deploying' || m.state === 'releasing')) { loadDetail(current); loadList(); }
- }, 4000);
+ if (document.visibilityState !== 'visible' || $('#dlg').open) return;
+ const r = route();
+ const busy = S.machines.some(m => m.job);
+ if (r.page === 'machine') { const m = S.machines.find(x => x.id === r.id); if (m && m.job) loadDetail(r.id); else if (Date.now() % 20000 < 5000) loadDetail(r.id); return; }
+ if (r.page === 'overview' || r.page === 'jobs' || busy) refresh(); else if (Date.now() % 20000 < 5000) refresh();
+ }, 5000);
}
+
+// ---------------------------------------------------------------- routing
+function route() {
+ const h = location.hash.replace(/^#\/?/, '').split('/');
+ if (h[0] === 'machine' && h[1]) return { page: 'machine', id: h[1], tab: h[2] || 'overview' };
+ return { page: h[0] || 'overview', arg: h[1] };
+}
+window.addEventListener('hashchange', () => { S.sel.clear(); render(); });
+function nav(page) { location.hash = '#/' + page; }
+
+const detailCache = {};
+async function loadDetail(id) {
+ try { detailCache[id] = await api('GET', '/api/v1/machines/' + encodeURIComponent(id)); if (route().page === 'machine' && route().id === id) render(); } catch (e) { if (e.message !== 'unauthorized') toast(e.message, true); }
+}
+
+function render() {
+ if (!S.loaded) return;
+ const r = route();
+ $$('.side a[data-nav]').forEach(a => a.classList.toggle('active', a.dataset.nav === r.page || (r.page === 'machine' && a.dataset.nav === 'machines')));
+ const main = $('#main');
+ switch (r.page) {
+ case 'machines': main.innerHTML = pageMachines(); wireMachines(); break;
+ case 'machine': if (!detailCache[r.id]) { main.innerHTML = 'loading…
'; loadDetail(r.id); } else { main.innerHTML = pageMachine(detailCache[r.id], r.tab); wireMachine(detailCache[r.id]); } break;
+ case 'jobs': main.innerHTML = pageJobs(); wireJobs(); break;
+ case 'tags': main.innerHTML = pageTags(); wireTags(); break;
+ case 'profiles': main.innerHTML = pageProfiles(); wireProfiles(); break;
+ case 'images': main.innerHTML = pageImages(); break;
+ default: main.innerHTML = pageOverview(); wireOverview();
+ }
+}
+
+// ---------------------------------------------------------------- overview
+function pageOverview() {
+ const by = {}; for (const m of S.machines) by[m.state] = (by[m.state] || 0) + 1;
+ const order = ['ready', 'deployed', 'booted', 'stateless', 'deploying', 'releasing', 'recommission', 'new', 'deploy-failed', 'release-failed'];
+ const states = Object.keys(by).sort((a, b) => (order.indexOf(a) + 1 || 99) - (order.indexOf(b) + 1 || 99));
+ const active = S.jobs.filter(j => j.state === 'pending' || j.state === 'running');
+ const bmcBad = S.machines.filter(m => !m.bmc || !m.bmc.configured).length;
+ const stale = S.machines.filter(m => (m.state === 'booted' || m.state === 'stateless') && m.last_seen && Date.now() - new Date(m.last_seen) > 15 * 60e3).length;
+ const warnImgs = S.os.filter(i => i.warning);
+ return `
+
Overview ${S.machines.length} machines
+
+
${S.machines.length}
machines
+ ${states.map(s => `
`).join('')}
+
${active.length}
active jobs
+
+
+
Active jobs ${jobsTable(active, true)}
+
Attention ${kv([
+ ['BMC not configured', bmcBad ? `
${bmcBad} show ` : '
none '],
+ ['Stateless nodes silent > 15 min', stale ? `
${stale} ` : '
none '],
+ ['Failed jobs (last 100)', (() => { const n = S.jobs.filter(j => j.state === 'failed').length; return n ? `
${n} show ` : '
none '; })()],
+ ['OS images', warnImgs.length ? warnImgs.map(i => `
${esc(i.name)}: ${esc(i.warning)} `).join('
') : `
${S.os.length} ok `],
+ ['Profiles', S.profiles.length ? S.profiles.map(p => `${esc(p.name)} (${S.machines.filter(m => m.profile === p.name).length})`).join(', ') : '
none '],
+ ])}
+
Recent events ${table(['When', 'Machine', 'Event', 'Detail'], S.events.slice(0, 25).map(e => { const m = S.machines.find(x => x.id === e.machine_id); return [`
${ago(e.ts)} `, `
${esc(m ? nameOf(m) : e.machine_id)} `, esc(e.event), `
${esc(e.detail.slice(0, 80))} `]; }))}
+
`;
+}
+function wireOverview() { $$('[data-go]').forEach(el => el.onclick = () => { const [p, st] = el.dataset.go.split('/'); S.states.clear(); if (st) S.states.add(st); nav(p); }); }
+
+// ---------------------------------------------------------------- machines list
+function filtered() {
+ const q = S.q.toLowerCase();
+ let ms = S.machines.filter(m => (!S.states.size || S.states.has(m.state)) && (!S.tagf.size || [...S.tagf].every(t => (m.tags || []).includes(t)))
+ && (!q || JSON.stringify([m.id, m.state, m.manufacturer, m.product, m.serial, m.macs, m.hostname, m.node_name, m.os, m.profile, m.tags, m.mgmt_ip, m.bmc && m.bmc.address]).toLowerCase().includes(q)));
+ const key = { name: m => nameOf(m), state: m => m.state, role: m => m.profile || m.os || '', model: m => (m.manufacturer || '') + (m.product || ''), cpu: m => Number(m.cpus) || 0, ram: m => m.memory_bytes, seen: m => m.last_seen || '' }[S.sort] || (m => nameOf(m));
+ ms.sort((a, b) => { const x = key(a), y = key(b); return (x > y ? 1 : x < y ? -1 : 0) * S.dir; });
+ return ms;
+}
+function hwSummary(m) {
+ const parts = [`${esc(m.cpus || '?')} c`, `${human(m.memory_bytes)} `];
+ if (m.disks) parts.push(`${m.disks | 0} ×disk ${human(m.storage_bytes)}`);
+ if (m.gpus) parts.push(`${m.gpus} GPU`);
+ if (m.ib_hcas) parts.push(`${m.ib_hcas} IB`);
+ return `${parts.join(' · ')} `;
+}
+function tagPills(m, editable) {
+ return (m.tags || []).map(t => { const auto = (m.auto_tags || []).includes(t) && !(m.manual_tags || []).includes(t); return `${esc(t)}${editable && !auto ? `× ` : ''} `; }).join(' ');
+}
+function stateCell(m) {
+ if (m.job) { const p = m.job.progress || {}; return `${pill(m.state)}
`; }
+ return pill(m.state);
+}
+function pageMachines() {
+ const r = route(); if (r.arg && !S.states.size) S.states.add(r.arg);
+ const ms = filtered();
+ const by = {}; for (const m of S.machines) by[m.state] = (by[m.state] || 0) + 1;
+ const tagCount = {}; for (const m of S.machines) for (const t of m.tags || []) tagCount[t] = (tagCount[t] || 0) + 1;
+ const pages = Math.max(1, Math.ceil(ms.length / S.per)); if (S.page >= pages) S.page = pages - 1;
+ const slice = ms.slice(S.page * S.per, (S.page + 1) * S.per);
+ const allSel = slice.length && slice.every(m => S.sel.has(m.id));
+ const th = (k, l, cls = '') => `${l}${S.sort === k ? (S.dir > 0 ? ' ▲' : ' ▼') : ''} `;
+ return `
+
+ State: ${Object.keys(by).sort().map(s => `${esc(s)}${by[s]} `).join('')}
+ ${Object.keys(tagCount).length ? `Tag: ${Object.keys(tagCount).sort().map(t => `${esc(t)}${tagCount[t]} `).join('')}` : ''}
+ ${(S.states.size || S.tagf.size || S.q) ? 'clear ' : ''}
+ ${S.sel.size ? bulkBar() : ''}
+ ${S.machines.length ? '' : 'No machines yet. PXE-boot an unknown server: it commissions itself and appears here.
'}
+
+ `;
+}
+function bulkBar() {
+ const n = S.sel.size;
+ return `${n} selected
+ ${menuBtn('Power', [['status', 'Status'], ['on', 'Power on'], ['off', 'Power off'], ['soft', 'Soft off'], ['cycle', 'Power cycle'], ['reset', 'Reset']], 'bpower')}
+ Deploy OS…
+ Assign profile…
+ Tag…
+ ${menuBtn('More', [['recommission', 'Re-commission (next boot)'], ['recommission-now', 'Re-commission now (BMC)'], ['release', 'Release (wipe disk)…'], ['unassign', 'Unassign profile'], ['hr'], ['bootdev-pxe', 'Boot device: PXE'], ['bootdev-disk', 'Boot device: disk']], 'bmore')}
+ Clear selection
`;
+}
+function menuBtn(label, items, id) { return ``; }
+function wireMenus(root = document) {
+ $$('[data-menu]', root).forEach(b => b.onclick = ev => { ev.stopPropagation(); const m = b.parentElement; const was = m.classList.contains('open'); $$('.menu.open').forEach(x => x.classList.remove('open')); if (!was) m.classList.add('open'); });
+ document.onclick = () => $$('.menu.open').forEach(x => x.classList.remove('open'));
+}
+function wireMachines() {
+ $('#q').oninput = ev => { S.q = ev.target.value; S.page = 0; render(); $('#q').focus(); const v = $('#q').value; $('#q').setSelectionRange(v.length, v.length); };
+ $('#refresh').onclick = () => refresh(true);
+ $$('[data-state]').forEach(c => c.onclick = () => { const s = c.dataset.state; S.states.has(s) ? S.states.delete(s) : S.states.add(s); S.page = 0; location.hash = '#/machines'; render(); });
+ $$('[data-tag]').forEach(c => c.onclick = () => { const t = c.dataset.tag; S.tagf.has(t) ? S.tagf.delete(t) : S.tagf.add(t); S.page = 0; render(); });
+ const clr = $('#clear'); if (clr) clr.onclick = () => { S.states.clear(); S.tagf.clear(); S.q = ''; location.hash = '#/machines'; render(); };
+ $$('th.sort').forEach(h => h.onclick = () => { if (S.sort === h.dataset.sort) S.dir = -S.dir; else { S.sort = h.dataset.sort; S.dir = 1; } render(); });
+ $$('tr.row').forEach(tr => tr.onclick = ev => { if (ev.target.closest('input,a')) return; location.hash = '#/machine/' + tr.dataset.id; });
+ $$('[data-sel]').forEach(cb => cb.onchange = () => { cb.checked ? S.sel.add(cb.dataset.sel) : S.sel.delete(cb.dataset.sel); render(); });
+ $('#selall').onchange = ev => { const ids = filtered().slice(S.page * S.per, (S.page + 1) * S.per).map(m => m.id); ids.forEach(id => ev.target.checked ? S.sel.add(id) : S.sel.delete(id)); render(); };
+ const prev = $('#prev'), next = $('#next'); if (prev) prev.onclick = () => { S.page--; render(); }; if (next) next.onclick = () => { S.page++; render(); };
+ $('#per').onchange = ev => { S.per = Number(ev.target.value); S.page = 0; render(); };
+ if (S.sel.size) {
+ wireMenus();
+ const ids = () => [...S.sel];
+ $$('#bpower [data-item]').forEach(b => b.onclick = () => act.power(ids(), b.dataset.item));
+ $('#bdeploy').onclick = () => act.deploy(ids());
+ $('#bassign').onclick = () => act.assign(ids());
+ $('#btag').onclick = () => act.tag(ids());
+ $$('#bmore [data-item]').forEach(b => b.onclick = () => act.more(ids(), b.dataset.item));
+ $('#bclear').onclick = () => { S.sel.clear(); render(); };
+ }
+}
+
+// ---------------------------------------------------------------- actions (single or many machines)
+async function each(ids, label, fn) {
+ const out = [];
+ for (const id of ids) {
+ const m = S.machines.find(x => x.id === id);
+ try { const r = await fn(id, m); out.push(`${m ? nameOf(m) : id}: ${r}`); } catch (e) { out.push(`${m ? nameOf(m) : id}: ERROR ${e.message}`); }
+ }
+ toast(`${label}\n${out.join('\n')}`, out.some(l => l.includes('ERROR')));
+ const r = route(); if (r.page === 'machine') await loadDetail(r.id);
+ await refresh(true);
+}
+const act = {
+ power: (ids, action) => each(ids, `power ${action}`, async id => { const r = await api('POST', `/api/v1/machines/${id}/power`, { action }); return r.output || (r.ok ? 'ok' : 'failed'); }),
+ bootdev: (ids, device) => each(ids, `bootdev ${device}`, async id => { const r = await api('POST', `/api/v1/machines/${id}/bootdev`, { device }); return r.output || (r.ok ? 'ok' : 'failed'); }),
+ async deploy(ids) {
+ const one = ids.length === 1 ? S.machines.find(m => m.id === ids[0]) : null;
+ const detail = one ? (detailCache[one.id] || await api('GET', '/api/v1/machines/' + one.id)) : null;
+ const disks = detail ? (((detail.inventory || {}).storage || {}).disks || []) : [];
+ const imgs = S.os.filter(i => i.current);
+ if (!imgs.length) return toast('No OS image has a current version. Import or sync one first (OS images).', true);
+ const fields = [{ name: 'os', label: 'OS image', type: 'select', options: imgs.map(i => [i.name, `${i.name} (${i.current.version}, needs ${human(i.current.raw_size)})`]) }];
+ if (one) fields.push({ name: 'disk', label: 'Target disk', type: 'select', options: [['', 'auto: smallest disk that fits'], ...disks.map(d => [d.path || '/dev/' + d.name, `${d.name} ${human(d.size)} ${d.model || ''}`])] },
+ { name: 'hostname', label: 'Hostname', value: one.node_name || '', placeholder: 'auto (next free name)' });
+ fields.push({ name: 'upgrade', label: 'Upgrade packages on first boot', type: 'checkbox' }, { name: 'boot', label: 'Power-cycle via BMC now', type: 'checkbox', value: true });
+ const v = await dialog(`Deploy OS to ${one ? nameOf(one) : ids.length + ' machines'}`, fields, 'The target disk is wiped. Tags with cloud-config fragments are applied automatically.', 'Deploy');
+ if (!v) return;
+ await each(ids, `deploy ${v.os}`, async id => { const r = await api('POST', `/api/v1/machines/${id}/deploy`, { os: v.os, disk: v.disk || '', hostname: v.hostname || '', package_upgrade: v.upgrade, boot: v.boot }); return `job ${r.job} → ${r.disk} as ${r.hostname}${r.ipmi ? ' · ' + r.ipmi.split('\n').pop() : ''}`; });
+ },
+ async assign(ids) {
+ if (!S.profiles.length) return toast('No profiles defined yet (Profiles page).', true);
+ const one = ids.length === 1 ? S.machines.find(m => m.id === ids[0]) : null;
+ const fields = [{ name: 'profile', label: 'Profile', type: 'select', options: S.profiles.map(p => [p.name, `${p.name} (${p.image})`]), value: one && one.profile }];
+ if (one) fields.push({ name: 'name', label: 'Node name', value: one.node_name || '', placeholder: 'auto' });
+ fields.push({ name: 'boot', label: 'PXE boot via BMC now', type: 'checkbox', value: true });
+ const v = await dialog(`Assign stateless profile to ${one ? nameOf(one) : ids.length + ' machines'}`, fields, 'The node boots the profile image from RAM; the disk is not touched.', 'Assign');
+ if (!v) return;
+ await each(ids, `assign ${v.profile}`, async id => { const r = await api('POST', `/api/v1/machines/${id}/assign`, { profile: v.profile, name: v.name || '', boot: v.boot }); return `${r.name} (${r.mgmt_ip || 'no pool'})`; });
+ },
+ async tag(ids) {
+ const v = await dialog(`Tags for ${ids.length} machine${ids.length > 1 ? 's' : ''}`, [{ name: 'add', label: 'Add', placeholder: 'gpu rack-3', help: 'space separated; new names create a manual tag' }, { name: 'remove', label: 'Remove', placeholder: 'staging' }], 'Auto tags (from match rules) cannot be removed here.', 'Apply');
+ if (!v) return;
+ const add = v.add.trim().split(/\s+/).filter(Boolean), remove = v.remove.trim().split(/\s+/).filter(Boolean);
+ await each(ids, 'tags', async id => { const r = await api('POST', `/api/v1/machines/${id}/tags`, { add, remove }); return r.effective.join(' ') || 'none'; });
+ },
+ async more(ids, item) {
+ const n = ids.length;
+ switch (item) {
+ case 'recommission': if (confirm(`Re-commission ${n} machine(s) on their next PXE boot?`)) await each(ids, 'recommission', async id => (await api('POST', `/api/v1/machines/${id}/recommission`)).state); break;
+ case 'recommission-now': if (confirm(`Re-commission ${n} machine(s) NOW: bootdev pxe + power cycle through the BMC?`)) await each(ids, 'recommission now', async id => { const r = await api('POST', `/api/v1/machines/${id}/recommission?now=1`); return r.ipmi || r.state; }); break;
+ case 'release': { const v = await dialog(`Release ${n} machine(s)`, [{ name: 'wipe', label: 'Wipe', type: 'select', options: [['quick', 'quick: signatures + first/last 64 MiB'], ['full', 'full: discard or zero the whole disk']] }, { name: 'boot', label: 'Power-cycle via BMC now', type: 'checkbox', value: true }], 'The OS disk is wiped and the machine returns to ready.', 'Release'); if (v) await each(ids, 'release', async id => `job ${(await api('POST', `/api/v1/machines/${id}/release`, { wipe: v.wipe, boot: v.boot })).job}`); break; }
+ case 'unassign': if (confirm(`Remove the stateless profile from ${n} machine(s)? Names and IPs are released.`)) await each(ids, 'unassign', async id => (await api('POST', `/api/v1/machines/${id}/unassign`)).state); break;
+ case 'bootdev-pxe': await act.bootdev(ids, 'pxe'); break;
+ case 'bootdev-disk': await act.bootdev(ids, 'disk'); break;
+ case 'cancel-job': await each(ids, 'cancel job', async id => `job ${(await api('POST', `/api/v1/machines/${id}/jobs/cancel`)).job} cancelled`); break;
+ case 'delete': if (confirm(`Delete ${n} machine record(s)? They are commissioned again as new machines on their next PXE boot.`)) { await each(ids, 'delete', async id => { await api('DELETE', `/api/v1/machines/${id}`); delete detailCache[id]; return 'deleted'; }); S.sel.clear(); nav('machines'); } break;
+ }
+ },
+};
+
+// ---------------------------------------------------------------- machine detail
+function card(title, inner, wide) { return `
${title} ${inner}`; }
+function kv(pairs) { return '' + pairs.filter(([, v]) => v !== undefined && v !== null && v !== '').map(([k, v]) => `${k} ${v} `).join('') + ' '; }
+function table(cols, rows) { return rows.length ? `${cols.map(c => `${esc(c)} `).join('')} ${rows.map(r => `${r.map(c => `${c ?? ''} `).join('')} `).join('')}
` : 'none '; }
+function jobsTable(jobs, withMachine) {
+ return table([...(withMachine ? ['Machine'] : []), 'Job', 'Kind', 'State', 'Target', 'Progress', 'Started', 'Finished', 'Error'], jobs.map(j => {
+ const sp = j.spec || {}, p = j.progress || {}; const m = S.machines.find(x => x.id === j.machine_id);
+ const prog = (j.state === 'running' || j.state === 'pending') ? `
${esc(p.phase || '')} ${Math.round(p.pct || 0)}% ${esc((p.msg || '').slice(0, 60))} ` : (p.details && p.details.seconds ? `${p.details.seconds}s ` : '');
+ return [...(withMachine ? [`${esc(m ? nameOf(m) : j.machine_id)} `] : []), `${esc(j.id)} `, esc(j.kind), pill(j.state), `${esc(sp.os || '')}${sp.version ? ' ' + esc(sp.version) + ' ' : ''}${sp.disk ? ' → ' + esc(sp.disk) + ' ' : ''}`, prog, `${ago(j.started || j.created)} `, `${esc(when(j.finished))} `, j.error ? `${esc(j.error)} ` : ''];
+ }));
+}
+function pageMachine(d, tab) {
+ const s = d.summary, inv = d.inventory || {}, sys = inv.system || {}, cpu = inv.cpu || {}, mem = inv.memory || {}, st = inv.storage || {}, b = d.bmc || {};
+ const m = S.machines.find(x => x.id === s.id) || s;
+ const tabs = ['overview', 'hardware', 'network', 'bmc', 'jobs', 'events', 'raw'];
+ let body = '';
+ if (tab === 'overview') {
+ const job = s.job || (d.jobs || [])[0]; const p = (job && job.progress) || {}; const active = job && (job.state === 'pending' || job.state === 'running');
+ body = `
+ ${card('Identity', kv([['Machine id', `
${esc(s.id)} `], ['Model', esc([sys['system-manufacturer'], sys['system-product-name']].filter(Boolean).join(' '))], ['Serial', `
${esc(sys['system-serial-number'])} `], ['UUID', `
${esc(sys['system-uuid'])} `], ['BIOS', esc([sys['bios-vendor'], sys['bios-version'], sys['bios-release-date']].filter(Boolean).join(' '))], ['Chassis / asset', esc([sys['chassis-type'], sys['chassis-asset-tag']].filter(Boolean).join(' / '))], ['First seen', esc(when(s.first_seen))], ['Last seen', esc(when(s.last_seen))], ['Hardware', `${esc(cpu['Model name'])}
${hwSummary(m)}`]]))}
+ ${card('Role', kv([
+ ['State', pill(s.state)],
+ ['Node name', esc(s.node_name)], ['Management IP', s.mgmt_ip ? `
${esc(s.mgmt_ip)} ` : ''], ['IB IP', s.ib_ip ? `
${esc(s.ib_ip)} ` : ''],
+ ['Stateless profile', s.profile ? `${esc(s.profile)} · booted ${esc(s.booted_at ? when(s.booted_at) : 'not yet')}` : ''],
+ ['OS on disk', s.os ? `${esc(s.os)}
${esc(s.os_version || '')} · deployed ${esc(when(s.deployed_at))}` : ''],
+ ['Phoned home', s.deployed_at ? (s.booted_at ? `
${esc(when(s.booted_at))} ` : '
not yet ') : ''],
+ ['Tags', `
${tagPills(s, true) || 'none '} edit `],
+ ['BMC', b.address ? `
${esc(b.address)} ${esc(b.user || '')} · ${d.has_bmc_secret ? '
credentials stored ' : '
no credentials '}` : '
none '],
+ ['Current job', job ? `
${esc(job.id)} ${esc(job.kind)} ${pill(job.state)}${active ? `
${esc(p.phase || '')} ${Math.round(p.pct || 0)}% ${esc(p.msg || '')} ` : ''}${job.error ? `
${esc(job.error)} ` : ''}` : ''],
+ ]))}
+ ${card(`Storage · ${st.disk_count ?? 0} disks · ${human(st.total_bytes)}`, table(['Dev', 'Size', 'Bus', 'Kind', 'Model', 'Serial', 'Health'], (st.disks || []).map(x => { const sm = (st.smart || {})[x.name] || {}; return [esc(x.name), human(x.size), esc(x.tran), x.rota === false ? 'ssd' : 'hdd', esc(x.model), `
${esc(x.serial)} `, sm.healthy === true ? '
ok ' : sm.healthy === false ? '
FAIL ' : '']; })))}
+ ${card(`Network · ${(inv.network || []).length} NICs`, table(['If', 'MAC', 'Speed', 'Link', 'Switch port'], (inv.network || []).map(n => { const l = ((inv.lldp || {})[n.name]); const e = l ? (Array.isArray(l) ? l[0] : l) : null; const sw = e ? `${Object.keys(e.chassis || {})[0] || ''} ${((e.port || {}).id || {}).value || ''}` : ''; return [esc(n.name), `
${esc(n.mac)} `, esc(n.speed), n.link === true ? '
up ' : n.link === false ? '
down ' : '', esc(sw)]; })))}
+ ${card('Recent events', table(['When', 'Event', 'Detail'], (d.events || []).slice(-8).reverse().map(e => [`
${ago(e.ts)} `, esc(e.event), `
${esc(e.detail.slice(0, 90))} `])), true)}
+
`;
+ } else if (tab === 'hardware') {
+ body = `
+ ${card('CPU', kv([['Model', esc(cpu['Model name'])], ['Sockets × cores × threads', `${esc(cpu['Socket(s)'])} × ${esc(cpu['Core(s) per socket'])} × ${esc(cpu['Thread(s) per core'])} = ${esc(cpu['CPU(s)'])}`], ['NUMA nodes', esc(cpu['NUMA node(s)'])], ['Max MHz', esc(cpu['CPU max MHz'])], ['L3', esc(cpu['L3 cache'])], ['Virtualization', esc(cpu['Virtualization'])], ['Features', esc((cpu.features || []).join(' '))]]))}
+ ${card(`Memory ${human(mem.total_bytes)} · ${mem.dimms_populated ?? '?'}/${mem.dimm_slots ?? '?'} DIMMs`, table(['Slot', 'Size', 'Type', 'Speed', 'Vendor', 'Part', 'Serial'], (mem.dimms || []).filter(x => x.populated).map(x => [esc(x.locator), esc(x.size), esc(x.type), esc(x.configured_speed || x.speed), esc(x.manufacturer), `
${esc(x.part_number)} `, `
${esc(x.serial)} `])))}
+ ${card(`Storage · ${st.disk_count ?? 0} disks · ${human(st.total_bytes)}`, table(['Dev', 'Size', 'Bus', 'Kind', 'Model', 'Serial', 'FW', 'Hours', 'Health'], (st.disks || []).map(x => { const sm = (st.smart || {})[x.name] || {}; return [esc(x.name), human(x.size), esc(x.tran), x.rota === false ? 'ssd' : 'hdd', esc(x.model), `
${esc(x.serial)} `, esc(sm.firmware), esc(sm.power_on_hours), sm.healthy === true ? '
ok ' : sm.healthy === false ? '
FAIL ' : '']; })) + ((st.controllers || []).length ? '
Controllers
' + table(['PCI', 'Vendor', 'Device', 'Driver'], st.controllers.map(c => [`
${esc(c.slot)} `, esc(c.vendor), esc(c.device), esc(c.driver)])) : ''), true)}
+ ${(inv.gpus || []).length ? card('GPUs / accelerators', table(['PCI', 'Vendor', 'Device', 'Driver'], inv.gpus.map(g => [`
${esc(g.slot)} `, esc(g.vendor), esc(g.device), esc(g.driver)])), true) : ''}
+ ${card('System', kv([['Board', esc([sys['baseboard-manufacturer'], sys['baseboard-product-name'], sys['baseboard-serial-number']].filter(Boolean).join(' / '))], ['SKU', esc(sys['system-sku-number'])], ['Chassis', esc([sys['chassis-type'], sys['chassis-serial-number'], sys['chassis-asset-tag']].filter(Boolean).join(' / '))], ['TPM', esc((inv.tpm || []).join(', ') || 'none')], ['Kernel (commissioning)', esc((inv.kernel || '').split(' (')[0])], ['Agent run', esc(inv.duration_s ? inv.duration_s + ' s' : '')]]))}
+ ${(inv.pci || []).length ? card(`PCI devices · ${inv.pci.length}`, table(['Slot', 'Class', 'Vendor', 'Device', 'Driver'], inv.pci.map(p => [`
${esc(p.slot)} `, esc(p.class), esc(p.vendor), esc(p.device), esc(p.driver)])), true) : ''}
+ ${(inv.errors || []).length ? card('Agent errors', `
${esc(inv.errors.join('\n'))} `, true) : ''}
+
`;
+ } else if (tab === 'network') {
+ const hcas = (inv.infiniband || {}).hcas || [];
+ const lldpRows = []; for (const [ifn, ents] of Object.entries(inv.lldp || {})) for (const e of (Array.isArray(ents) ? ents : [ents])) { const ch = e.chassis || {}; const name = Object.keys(ch)[0] || '?'; const c = ch[name] || {}; lldpRows.push([esc(ifn), esc(name), esc((c.descr || '').slice(0, 60)), esc((e.port || {}).id && (e.port.id.value || e.port.id)), esc((e.port || {}).descr), esc((e.vlan || {})['vlan-id'] || (e.vlan || {}).value)]); }
+ body = `
+ ${card(`NICs · ${(inv.network || []).length}`, table(['If', 'MAC', 'Driver', 'FW', 'Speed', 'Link', 'PCI', 'NUMA', 'VFs', 'IPv4'], (inv.network || []).map(n => [esc(n.name), `${esc(n.mac)} `, esc(n.driver), esc(n.firmware_version), esc(n.speed), n.link === true ? 'up ' : n.link === false ? 'down ' : '', `${esc(n.pci)} `, esc(n.numa_node), esc(n.sriov_totalvfs), esc((n.ipv4 || []).join(' '))])), true)}
+ ${card(`InfiniBand · ${hcas.length} HCAs`, hcas.length ? table(['HCA', 'Port', 'Layer', 'State', 'Rate', 'LID', 'Node GUID', 'FW', 'Board'], hcas.flatMap(h => (h.ports || []).map(p => [esc(h.name), esc(p.port), esc(p.link_layer), esc(p.state), esc(p.rate), esc(p.lid), `${esc(h.node_guid)} `, esc(h.fw_ver), esc(h.board_id)]))) : 'none ', true)}
+ ${card('LLDP neighbours (switch ports)', table(['If', 'Switch', 'Descr', 'Port', 'Port descr', 'VLAN'], lldpRows), true)}
+
`;
+ } else if (tab === 'bmc') {
+ body = `${card('BMC', kv([['Source', esc(b.source)], ['Address', `
${esc(b.address)}${b.port && b.port !== 623 ? ':' + esc(b.port) : ''} `], ['MAC', `
${esc(b.mac)} `], ['User', esc(b.user)], ['Password', d.has_bmc_secret ? '
stored encrypted on the server ' : '
none '], ['Configured', b.configured ? '
yes ' : '
no '], ['Verified out-of-band', b.verified_oob === true ? '
yes ' : b.verified_oob === false ? '
no ' : ''], ['Channel', esc(b.channel)], ['LAN', b.lan ? `
${esc(JSON.stringify(b.lan))} ` : ''], ['Firmware', esc((b.mc_info || {})['Firmware Revision'])], ['Manufacturer', esc((b.mc_info || {})['Manufacturer Name'])], ['Errors', (b.errors || []).length ? `
${esc(b.errors.join('; '))} ` : '']]))}
+ ${(b.users_before || []).length ? card('User table before commissioning', table(['ID', 'Name', 'Priv', 'IPMI'], b.users_before.map(u => [u.id, esc(u.name), esc(u.priv), u.ipmi_msg ? 'yes' : 'no']))) : ''}
+ ${b.fru ? card('FRU', `
${esc(JSON.stringify(b.fru, null, 1))} `) : ''}
`;
+ } else if (tab === 'jobs') body = jobsTable(d.jobs || [], false);
+ else if (tab === 'events') body = table(['Time', 'Event', 'Detail'], (d.events || []).slice().reverse().map(e => [esc(when(e.ts)), esc(e.event), `${esc(e.detail)} `]));
+ else body = `${esc(JSON.stringify(d, null, 1))} `;
+
+ const hasJob = !!s.job;
+ return `
+ ← Machines ${esc(nameOf(s))} ${pill(s.state)}
${esc(s.id)}
+
+ ${menuBtn('Power', [['status', 'Status'], ['on', 'Power on'], ['off', 'Power off'], ['soft', 'Soft off'], ['cycle', 'Power cycle'], ['reset', 'Reset']], 'dpower')}
+ ${menuBtn('Boot device', [['pxe', 'PXE'], ['disk', 'Disk'], ['bios', 'BIOS setup'], ['cdrom', 'CD-ROM']], 'dboot')}
+ Deploy OS…
+ Assign profile…
+ ${menuBtn('More', [['recommission', 'Re-commission (next boot)'], ['recommission-now', 'Re-commission now (BMC)'], ['release', 'Release (wipe disk)…'], ['unassign', 'Unassign profile'], ...(hasJob ? [['cancel-job', 'Cancel active job']] : []), ['hr'], ['delete', 'Delete record']], 'dmore')}
+
+ ${esc([sys['system-manufacturer'], sys['system-product-name']].filter(Boolean).join(' '))} S/N ${esc(s.serial || '')} ${hwSummary(m)} ${s.mgmt_ip ? `${esc(s.mgmt_ip)} ` : ''}seen ${ago(s.last_seen)} ago
+
+ ${body}`;
+}
+function wireMachine(d) {
+ const id = d.summary.id, ids = [id];
+ wireMenus();
+ $$('#dpower [data-item]').forEach(b => b.onclick = () => act.power(ids, b.dataset.item));
+ $$('#dboot [data-item]').forEach(b => b.onclick = () => act.bootdev(ids, b.dataset.item));
+ $('#ddeploy').onclick = () => act.deploy(ids);
+ $('#dassign').onclick = () => act.assign(ids);
+ $$('#dmore [data-item]').forEach(b => b.onclick = () => act.more(ids, b.dataset.item));
+ const t = $('#d-tag'); if (t) t.onclick = () => act.tag(ids);
+ $$('[data-untag]').forEach(a => a.onclick = ev => { ev.preventDefault(); each(ids, 'untag', async () => (await api('POST', `/api/v1/machines/${id}/tags`, { remove: [a.dataset.untag] })).effective.join(' ')); });
+}
+
+// ---------------------------------------------------------------- jobs
+function pageJobs() {
+ const active = S.jobs.filter(j => j.state === 'pending' || j.state === 'running'), rest = S.jobs.filter(j => !(j.state === 'pending' || j.state === 'running'));
+ return `Jobs ${active.length} active · last ${rest.length} finished Refresh
+
Active ${jobsTable(active, true)}
+
History ${jobsTable(rest, true)}`;
+}
+function wireJobs() { $('#refresh').onclick = () => refresh(true); }
+
+// ---------------------------------------------------------------- tags
+function pageTags() {
+ return `Tags single out machines for special treatment: auto rules from the inventory, cloud-init fragments at deployment, overlays for stateless nodes New tag…
+ ${table(['Tag', 'Machines', 'Match rule', 'Cloud-config', 'Overlays', 'Comment', ''], S.tags.map(t => [`${esc(t.name)} `, `${t.machines || 0} `, `${esc(t.match || '')} `, t.cloud_config ? `${t.cloud_config.split('\n').length} lines ` : '', esc((t.overlays || []).join(', ')), esc(t.comment || ''), `edit delete `]))}
+ Match rules are Go templates over .Node (GPUs, IBGUIDs, CPUs, Sockets, MemMB, Disks, NVMe, PCIVendors, Manufacturer, Product, OS, Tags), e.g. {{ gt .Node.GPUs 0 }}, {{ has .Node.PCIVendors "15b3" }}, {{ matches "(?i)PowerEdge R7" .Node.Product }}. Rules run at commissioning and whenever a tag is saved.
`;
+}
+async function editTag(t) {
+ const v = await dialog(t ? `Edit tag ${t.name}` : 'New tag', [
+ { name: 'name', label: 'Name', value: t ? t.name : '', placeholder: 'gpu' },
+ { name: 'comment', label: 'Comment', value: t ? t.comment : '' },
+ { name: 'match', label: 'Match rule', value: t ? t.match : '', placeholder: '{{ gt .Node.GPUs 0 }} (empty = manual only)' },
+ { name: 'overlays', label: 'Overlays', value: t ? (t.overlays || []).join(',') : '', placeholder: 'gpu-slurm', help: 'extra overlays for stateless nodes with this tag' },
+ { name: 'cloud_config', label: 'Cloud-config', type: 'textarea', value: t ? t.cloud_config : '', placeholder: '#cloud-config\npackages: [nvidia-driver]\nruncmd:\n - [ sh, -c, "..." ]' },
+ ], 'The cloud-config fragment is merged into the user-data of every deployment of a tagged machine. A fragment starting with #! runs as a script.', 'Save');
+ if (!v) return;
+ try { await api('POST', '/api/v1/tags', { name: v.name.trim(), comment: v.comment, match: v.match, overlays: v.overlays.split(',').map(s => s.trim()).filter(Boolean), cloud_config: v.cloud_config }); toast(`tag ${v.name} saved; auto tags re-evaluated`); refresh(true); } catch (e) { toast(e.message, true); }
+}
+function wireTags() {
+ $('#newtag').onclick = () => editTag(null);
+ $$('[data-edit]').forEach(b => b.onclick = () => editTag(S.tags.find(t => t.name === b.dataset.edit)));
+ $$('[data-rm]').forEach(b => b.onclick = async () => { if (confirm(`Delete tag ${b.dataset.rm}? It is removed from every machine.`)) { try { await api('DELETE', '/api/v1/tags/' + b.dataset.rm); refresh(true); } catch (e) { toast(e.message, true); } } });
+ $$('[data-filtertag]').forEach(a => a.onclick = () => { S.tagf.clear(); S.tagf.add(a.dataset.filtertag); S.states.clear(); });
+}
+
+// ---------------------------------------------------------------- profiles / images
+function pageProfiles() {
+ const imgs = (S._images || []);
+ return `Profiles stateless (RAM-booted) node definitions New profile…
+ ${table(['Profile', 'Root image', 'Overlays', 'Name format', 'Kernel append', 'Nodes', ''], S.profiles.map(p => [esc(p.name), esc(p.image), esc((p.overlays || []).join(', ')), `${esc(p.name_format)} `, `${esc(p.append || '')} `, S.machines.filter(m => m.profile === p.name).length, `edit delete `]))}
+ Stateless root images loading…
`;
+}
+async function editProfile(p) {
+ const v = await dialog(p ? `Edit profile ${p.name}` : 'New profile', [
+ { name: 'name', label: 'Name', value: p ? p.name : '', placeholder: 'compute' },
+ { name: 'image', label: 'Root image', value: p ? p.image : '', placeholder: 'compute-debian13', help: 'directory under images_dir with vmlinuz, initrd.img, filesystem.squashfs' },
+ { name: 'overlays', label: 'Overlays', value: p ? (p.overlays || []).join(',') : '', placeholder: 'compute' },
+ { name: 'name_format', label: 'Name format', value: p ? p.name_format : 'node%03d' },
+ { name: 'append', label: 'Kernel append', value: p ? p.append : '' },
+ { name: 'vars', label: 'Vars (JSON)', type: 'textarea', rows: 4, value: p ? JSON.stringify(p.vars || {}, null, 1) : '{}' },
+ ], '', 'Save');
+ if (!v) return;
+ let vars; try { vars = JSON.parse(v.vars || '{}'); } catch (e) { return toast('vars: invalid JSON', true); }
+ try { await api('POST', '/api/v1/profiles', { name: v.name.trim(), image: v.image.trim(), overlays: v.overlays.split(',').map(s => s.trim()).filter(Boolean), name_format: v.name_format, append: v.append, vars }); toast(`profile ${v.name} saved`); refresh(true); } catch (e) { toast(e.message, true); }
+}
+function wireProfiles() {
+ $('#newprofile').onclick = () => editProfile(null);
+ $$('[data-edit]').forEach(b => b.onclick = () => editProfile(S.profiles.find(p => p.name === b.dataset.edit)));
+ $$('[data-rm]').forEach(b => b.onclick = async () => { if (confirm(`Delete profile ${b.dataset.rm}?`)) { try { await api('DELETE', '/api/v1/profiles/' + b.dataset.rm); refresh(true); } catch (e) { toast(e.message, true); } } });
+ api('GET', '/api/v1/images').then(imgs => { const el = $('#rootimgs'); if (el) el.innerHTML = table(['Image', 'Complete', 'Squashfs', 'Built'], imgs.map(i => [esc(i.name), i.complete ? 'yes ' : 'no ', human(i['filesystem.squashfs']), esc(when(i.built))])); }).catch(() => { });
+}
+function pageImages() {
+ return `
OS images disk images for deployment · refreshed nightly by rollcall os sync from the vendors' checksum files
+ ${table(['OS', 'Current version', 'Family', 'Compressed', 'Disk needed', 'Imported', 'Track', 'Keep', 'Versions', 'Status'], S.os.map(i => { const c = i.current || {}; const s = i.source || {}; return [`${esc(i.name)} ${s.description ? `${esc(s.description)} ` : ''}`, `${esc(c.version || '—')} `, esc(s.family || c.family), c.size ? human(c.size) : '', c.raw_size ? human(c.raw_size) : '', c.imported ? `${esc(when(c.imported))} (${ago(c.imported)}) ` : '', esc(s.track || ''), s.keep || '', (i.versions || []).map(v => `${esc(v.version)} `).join(' '), i.warning ? `${esc(i.warning)} ` : 'ok ']; }))}
+ Pinned sources keep current until rollcall os promote NAME VERSION; a deployment always uses the exact version it started with. Import a local file with rollcall os import NAME FILE.
`;
+}
+
+// ---------------------------------------------------------------- go
schedule();
-loadList();
+refresh(true);
diff --git a/cmd/rollcall/web/index.html b/cmd/rollcall/web/index.html
index b9eadfd..7f097e3 100644
--- a/cmd/rollcall/web/index.html
+++ b/cmd/rollcall/web/index.html
@@ -3,124 +3,48 @@
-rollcall
+Rollcall
-
- rollcall hardware commissioning
-
-
- Refresh
- Token
-
-
+
-
-
-
-
-
+