Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add canonical VM inventory export surface
rcourtmanb0e76b00ae8d
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 1c8186f5e3..cf76445c2f 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -171,6 +171,11 @@ Those timeline reads also accept governed filters for change kind, sourcetype, and source adapter, and the underlying store owns the filtered counts soagent lifecycle routing still stays on canonical fleet-continuity ownershipinstead of re-deriving resource history locally.+That same shared `internal/api/` boundary now also exposes a dedicated VM+inventory export route for reporting. Fleet and install surfaces may coexist+with that export, but `internal/api/reporting_inventory_handlers.go` and+`internal/api/router_routes_licensing.go` remain API-owned reporting transport,+not lifecycle-owned inventory or install behavior.The same API serializer now also refreshes canonical identity and policymetadata through the shared unified-resource helper before it returnsresource payloads, so lifecycle-adjacent links keep the same canonicaldiff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 3126df49d3..50b6f208f1 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -57,6 +57,8 @@ Own canonical runtime payload shapes between backend and frontend.34. `internal/api/router_routes_auth_security.go`35. `internal/api/relay_hosted_runtime.go`36. `internal/api/ai_hosted_runtime.go`+37. `internal/api/router_routes_licensing.go`+38. `internal/api/reporting_inventory_handlers.go`## Shared Boundaries@@ -211,6 +213,15 @@ The same resource contract now also exposes a dedicated`/api/resources/{id}/timeline` history endpoint and bundled facet reads under`/api/resources/{id}/facets`, so operators can inspect change history withoutdepending on a monolithic resource payload.+The reporting API contract now also treats current-state fleet inventory as a+first-class surface separate from historical metrics reports.+`internal/api/reporting_inventory_handlers.go`,+`internal/api/router_routes_licensing.go`, and the settings reporting shell now+own `/api/admin/reports/inventory/vms/export` as the canonical VM inventory CSV+contract. That export is intentionally spreadsheet-shaped rather than comment-+prefixed like the legacy metrics CSV, and it currently omits Proxmox pool+membership until that field exists on the canonical unified VM runtime model+instead of being inferred locally by the frontend or handler.The `/api/resources` serializer now also refreshes canonical identity andpolicy metadata through the shared unified-resource helper before it writesthe payload, so backend and frontend contract tests stay aligned on onediff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.mdindex a1b77a7a21..5aaa2c2b43 100644--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md@@ -67,9 +67,10 @@ work extends shared components instead of creating new local variants.39. `frontend-modern/src/components/Settings/UpdatesSettingsPanel.tsx`40. `frontend-modern/src/components/Settings/ReportingPanel.tsx`41. `frontend-modern/src/components/Settings/reportingPanelModel.ts`-42. `frontend-modern/src/components/Settings/useReportingPanelState.ts`-43. `frontend-modern/src/utils/reportingPresentation.ts`-44. `frontend-modern/src/utils/updatesPresentation.ts`+42. `frontend-modern/src/components/Settings/reportingInventoryExportModel.ts`+43. `frontend-modern/src/components/Settings/useReportingPanelState.ts`+44. `frontend-modern/src/utils/reportingPresentation.ts`+45. `frontend-modern/src/utils/updatesPresentation.ts`44. `frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts`45. `tests/integration/tests/15-settings-shell-consistency.spec.ts`46. `frontend-modern/src/components/shared/PageControls.guardrails.test.ts`@@ -164,6 +165,15 @@ The subsystem registry now also requires explicit proof-policy coverage for allshared runtime files, and shared-component guardrails fail if raw tablecomposition is reintroduced in new shared components outside the canonicalallowlist.+The settings reporting shell now also owns a deliberate split between+historical performance reports and current-state VM inventory export.+`frontend-modern/src/components/Settings/ReportingPanel.tsx`,+`frontend-modern/src/components/Settings/useReportingPanelState.ts`,+`frontend-modern/src/components/Settings/reportingPanelModel.ts`, and+`frontend-modern/src/components/Settings/reportingInventoryExportModel.ts` must+keep those as separate operator jobs with separate request builders and success+copy, rather than collapsing inventory export back into the metrics-report+controls.The shared updates settings owner also defines the user-facing framing forrc-tagged builds. `frontend-modern/src/components/Settings/updatesSettingsModel.ts`and `frontend-modern/src/utils/updatesPresentation.ts` must present thatdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 6e774dc04a..77712df841 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -217,6 +217,11 @@ The same shared API runtime now also exposes dedicated`/api/resources/{id}/facets` surface, but storage and recovery must continueto treat those as adjacent governed API ownership rather than storage/recoverytimeline ownership.+That same adjacent API layer now also exposes a VM inventory CSV export for the+reporting surface. Storage and recovery workflows may consume similar current-+state VM facts, but `internal/api/reporting_inventory_handlers.go` and+`internal/api/router_routes_licensing.go` remain API/reporting transport+ownership rather than storage/recovery contract ownership.Those resource timeline reads now also accept governed kind and source-typefilters plus source-adapter filters, with filtered history counts owned by theunified-resource store so storage and recovery views can consume the samediff --git a/frontend-modern/src/components/Settings/ReportingPanel.tsx b/frontend-modern/src/components/Settings/ReportingPanel.tsxindex 43aec17ac0..a031e15a6d 100644--- a/frontend-modern/src/components/Settings/ReportingPanel.tsx+++ b/frontend-modern/src/components/Settings/ReportingPanel.tsx@@ -2,6 +2,7 @@ import { Show, JSX } from 'solid-js';import FileText from 'lucide-solid/icons/file-text';import Download from 'lucide-solid/icons/download';import BarChart from 'lucide-solid/icons/bar-chart';+import TableProperties from 'lucide-solid/icons/table-properties';import OperationsPanel from '@/components/Settings/OperationsPanel';import { CalloutCard } from '@/components/shared/CalloutCard';import { formField, formLabel, formHelpText, formControl } from '@/components/shared/Form';@@ -18,12 +19,11 @@ import {import { useReportingPanelState } from '@/components/Settings/useReportingPanelState';import { type ReportingRangeValue } from '@/components/Settings/reportingPanelModel';-const REPORTING_RANGE_FILTER_OPTIONS: FilterOption<ReportingRangeValue>[] = REPORTING_RANGE_OPTIONS.map(- (option) => ({+const REPORTING_RANGE_FILTER_OPTIONS: FilterOption<ReportingRangeValue>[] =+ REPORTING_RANGE_OPTIONS.map((option) => ({label: option.label,value: option.value,- }),-);+ }));const REPORTING_FORMAT_FILTER_OPTIONS: FilterOption<'pdf' | 'csv'>[] = [{ value: 'pdf', label: 'PDF Report', icon: FileText },@@ -49,7 +49,9 @@ function FormField(props: FormFieldProps) {export function ReportingPanel() {const {canStartTrial,+ exportingInventory,format,+ handleExportVMInventory,generating,handleGenerate,handleStartTrial,@@ -73,7 +75,7 @@ export function ReportingPanel() {<Show when={isLocked()}><OperationsPaneltitle="Detailed Reporting"- description="Generate reports across infrastructure, workloads, storage, and backup resources."+ description="Generate performance reports and current-state exports across infrastructure and workloads."icon={<BarChart class="w-5 h-5" strokeWidth={2} />}><div class="p-4 sm:p-6">@@ -81,8 +83,8 @@ export function ReportingPanel() {<div class="flex-1 text-center sm:text-left"><h4 class="text-base font-semibold text-base-content">Advanced Reporting (Pro)</h4><p class="text-sm text-muted mt-1">- Generate PDF and CSV reports across infrastructure, workloads, storage, and backup- resources. Includes trend summaries, fleet-wide reporting, and raw data export.+ Generate PDF and CSV performance reports plus current-state VM inventory exports+ across infrastructure and workload resources.</p></div><div class="flex flex-col sm:flex-row items-center gap-2">@@ -116,90 +118,128 @@ export function ReportingPanel() {<Show when={isReportingEnabled()}><OperationsPaneltitle="Detailed Reporting"- description="Generate reports across infrastructure, workloads, storage, and backup resources."+ description="Generate performance reports and current-state exports across infrastructure and workloads."icon={<BarChart class="w-5 h-5" strokeWidth={2} />}><div class="space-y-6 p-4 sm:p-6">- <FormField label="Resources" helpText="Select the resources to include in the report">- <ResourcePicker- selected={selectedResources}- onSelectionChange={setSelectedResources}- />- </FormField>-- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">- <FormField label="Metric Type (Optional)" helpText="Filter by specific metric type">- <input- id="metric-type"- type="text"- class={formControl}- placeholder="e.g. cpu, memory, disk, temperature (leave empty for all)"- value={metricType()}- onInput={(e) => setMetricType(e.currentTarget.value)}- />- </FormField>+ <section class="space-y-6">+ <div class="space-y-2">+ <h4 class="text-base font-semibold text-base-content">Performance Reports</h4>+ <p class="text-sm text-muted">+ Generate PDF summaries or CSV metric exports from historical monitoring data for+ one or more selected resources.+ </p>+ </div>- <FormField label="Report Title" helpText="Custom title for the PDF report">- <input- id="report-title"- type="text"- class={formControl}- placeholder="Auto-generated if empty"- value={title()}- onInput={(e) => setTitle(e.currentTarget.value)}+ <FormField label="Resources" helpText="Select the resources to include in the report">+ <ResourcePicker+ selected={selectedResources}+ onSelectionChange={setSelectedResources}/></FormField>- </div>- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">- <FormField label="Time Range">- <FilterButtonGroup- class="sm:grid-cols-3"- options={REPORTING_RANGE_FILTER_OPTIONS}- value={range()}- onChange={setRange}- variant="prominent"- />- </FormField>+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">+ <FormField label="Metric Type (Optional)" helpText="Filter by specific metric type">+ <input+ id="metric-type"+ type="text"+ class={formControl}+ placeholder="e.g. cpu, memory, disk, temperature (leave empty for all)"+ value={metricType()}+ onInput={(e) => setMetricType(e.currentTarget.value)}+ />+ </FormField>- <FormField label="Export Format">- <FilterButtonGroup- class="sm:grid-cols-2"- options={REPORTING_FORMAT_FILTER_OPTIONS}- value={format()}- onChange={setFormat}- variant="prominent"- />- </FormField>- </div>- </div>+ <FormField label="Report Title" helpText="Custom title for the PDF report">+ <input+ id="report-title"+ type="text"+ class={formControl}+ placeholder="Auto-generated if empty"+ value={title()}+ onInput={(e) => setTitle(e.currentTarget.value)}+ />+ </FormField>+ </div>- <div class="flex justify-end p-4 sm:p-6">- <button- class={`w-full sm:w-auto flex items-center justify-center gap-2 px-6 py-3 rounded-md font-semibold transition-all ${- generating()- ? 'bg-slate-300 text-slate-500 cursor-not-allowed'- : 'bg-blue-600 hover:bg-blue-700 text-white'- }`}- disabled={generating()}- onClick={handleGenerate}- >- <Show when={generating()} fallback={<Download size={20} />}>- <div class="w-5 h-5 border-2 border-white border-t-white rounded-full animate-spin" />- </Show>- {generating()- ? 'Generating...'- : selectedResources().length > 0- ? `Generate Report (${selectedResources().length} resource${selectedResources().length !== 1 ? 's' : ''})`- : 'Generate Report'}- </button>+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">+ <FormField label="Time Range">+ <FilterButtonGroup+ class="sm:grid-cols-3"+ options={REPORTING_RANGE_FILTER_OPTIONS}+ value={range()}+ onChange={setRange}+ variant="prominent"+ />+ </FormField>++ <FormField label="Export Format">+ <FilterButtonGroup+ class="sm:grid-cols-2"+ options={REPORTING_FORMAT_FILTER_OPTIONS}+ value={format()}+ onChange={setFormat}+ variant="prominent"+ />+ </FormField>+ </div>++ <div class="flex justify-end">+ <button+ class={`w-full sm:w-auto flex items-center justify-center gap-2 px-6 py-3 rounded-md font-semibold transition-all ${+ generating()+ ? 'bg-slate-300 text-slate-500 cursor-not-allowed'+ : 'bg-blue-600 hover:bg-blue-700 text-white'+ }`}+ disabled={generating()}+ onClick={handleGenerate}+ >+ <Show when={generating()} fallback={<Download size={20} />}>+ <div class="w-5 h-5 border-2 border-white border-t-white rounded-full animate-spin" />+ </Show>+ {generating()+ ? 'Generating...'+ : selectedResources().length > 0+ ? `Generate Report (${selectedResources().length} resource${selectedResources().length !== 1 ? 's' : ''})`+ : 'Generate Report'}+ </button>+ </div>+ </section>++ <section class="rounded-xl border border-base-300/80 bg-base-200/30 p-4 sm:p-5 space-y-4">+ <div class="space-y-2">+ <h4 class="text-base font-semibold text-base-content">VM Inventory Export</h4>+ <p class="text-sm text-muted">+ Export the current fleet-wide VM inventory as CSV using the canonical runtime+ model. Includes VM identity, placement, CPU, memory allocation, disk allocation,+ and disk usage columns.+ </p>+ </div>++ <div class="flex justify-end">+ <button+ class={`w-full sm:w-auto flex items-center justify-center gap-2 px-6 py-3 rounded-md font-semibold transition-all ${+ exportingInventory()+ ? 'bg-slate-300 text-slate-500 cursor-not-allowed'+ : 'bg-emerald-600 hover:bg-emerald-700 text-white'+ }`}+ disabled={exportingInventory()}+ onClick={handleExportVMInventory}+ >+ <Show when={exportingInventory()} fallback={<TableProperties size={20} />}>+ <div class="w-5 h-5 border-2 border-white border-t-white rounded-full animate-spin" />+ </Show>+ {exportingInventory() ? 'Exporting...' : 'Export VM Inventory'}+ </button>+ </div>+ </section></div></OperationsPanel><CalloutCardicon={<BarChart size={24} />}title="Advanced Insights"- description="Reports are generated directly from the historical metrics store. PDF reports provide summarized trends (average, minimum, and maximum), while CSV exports provide raw time-series data for deeper analysis in spreadsheets or BI tools. Select multiple resources to generate a fleet-wide summary."+ description="Performance reports come from the historical metrics store, while VM inventory export captures the current runtime state for spreadsheet-friendly fleet reviews. Use reports for trends and the inventory export for current allocation and usage snapshots."padding="lg"/></Show>diff --git a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.tsindex f7befc1c4f..c91ad7e1d9 100644--- a/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/monitoredSystemModelGuardrails.test.ts@@ -62,6 +62,7 @@ import aiSettingsStatusAndActionsSource from '../AISettingsStatusAndActions.tsx?import aiSettingsStateSource from '../useAISettingsState.ts?raw';import reportingPanelSource from '../ReportingPanel.tsx?raw';import reportingPanelModelSource from '../reportingPanelModel.ts?raw';+import reportingInventoryExportModelSource from '../reportingInventoryExportModel.ts?raw';import updatesSettingsPanelSource from '../UpdatesSettingsPanel.tsx?raw';import suggestProfileModalSource from '../SuggestProfileModal.tsx?raw';import aiIntelligenceSource from '@/pages/AIIntelligence.tsx?raw';@@ -218,7 +219,7 @@ const recoverySource = [describe('monitored-system model guardrails', () => {it('keeps AgentProfilesPanel on unified resources (not host-only slices)', () => {- expect(agentProfilesPanelSource).toContain("import { useAgentProfilesPanelState }");+ expect(agentProfilesPanelSource).toContain('import { useAgentProfilesPanelState }');expect(agentProfilesPanelSource).toContain('useAgentProfilesPanelState()');expect(agentProfilesPanelSource).toContain('@/utils/agentProfilesPresentation');expect(agentProfilesPanelSource).toContain('getAgentProfilesEmptyState');@@ -249,7 +250,9 @@ describe('monitored-system model guardrails', () => {expect(agentLedgerPanelSource).not.toContain('function statusVariant(');expect(monitoredSystemLedgerApiSource).toContain('@/utils/monitoredSystemPresentation');expect(monitoredSystemLedgerApiSource).toContain('getMonitoredSystemStatusFallbackSummary');- expect(monitoredSystemLedgerApiSource).toContain('getMonitoredSystemExplanationFallbackSummary');+ expect(monitoredSystemLedgerApiSource).toContain(+ 'getMonitoredSystemExplanationFallbackSummary',+ );expect(monitoredSystemLedgerApiSource).toContain('type MonitoredSystemLedgerRawEntry =');expect(monitoredSystemLedgerApiSource).toContain('systems?: MonitoredSystemLedgerRawEntry[];');expect(monitoredSystemLedgerApiSource).toContain('reported_at: string;');@@ -274,7 +277,7 @@ describe('monitored-system model guardrails', () => {});it('keeps APITokenManager runtime usage mapped from unified resources', () => {- expect(apiTokenManagerSource).toContain("import { useAPITokenManagerState }");+ expect(apiTokenManagerSource).toContain('import { useAPITokenManagerState }');expect(apiTokenManagerSource).toContain('useAPITokenManagerState(props)');expect(apiTokenManagerSource).not.toContain('const agentCapableResources = createMemo(() =>');expect(apiTokenManagerSource).not.toContain('@/utils/apiTokenPresentation');@@ -316,9 +319,7 @@ describe('monitored-system model guardrails', () => {expect(infrastructureOperationsStateSource).not.toContain('previousHostTypes');expect(infrastructureOperationsStateSource).not.toContain('const allHosts = createMemo(');expect(infrastructureOperationsSource).toContain('@/utils/unifiedAgentStatusPresentation');- expect(infrastructureOperationsSource).not.toContain(- 'const MONITORING_STOPPED_STATUS_LABEL =',- );+ expect(infrastructureOperationsSource).not.toContain('const MONITORING_STOPPED_STATUS_LABEL =');expect(infrastructureOperationsSource).not.toContain('const ALLOW_RECONNECT_LABEL =');expect(infrastructureOperationsStateSource).toContain('withPrivilegeEscalation');expect(infrastructureOperationsStateSource).toContain('./useInfrastructureInstallState');@@ -339,9 +340,7 @@ describe('monitored-system model guardrails', () => {expect(infrastructureOperationsSource).toContain('@/utils/unifiedAgentStatusPresentation');expect(infrastructureOperationsSource).not.toContain('const statusBadgeClass =');expect(infrastructureOperationsSource).not.toContain('const statusBadgeClasses =');- expect(infrastructureOperationsSource).toContain(- 'getUnifiedAgentLookupStatusPresentation',- );+ expect(infrastructureOperationsSource).toContain('getUnifiedAgentLookupStatusPresentation');expect(unifiedAgentStatusPresentationSource).toContain('export function getUnifiedAgentStatusPresentation',);@@ -397,9 +396,7 @@ describe('monitored-system model guardrails', () => {expect(infrastructureOperationsSource).not.toContain('No host identifiers are available to stop monitoring.',);- expect(infrastructureOperationsSource).not.toContain(- 'Failed to update agent configuration',- );+ expect(infrastructureOperationsSource).not.toContain('Failed to update agent configuration');expect(infrastructureOperationsSource).not.toContain('Uninstall command copied');expect(infrastructureOperationsSource).not.toContain('Upgrade command copied');expect(infrastructureOperationsSource).not.toContain(@@ -425,7 +422,9 @@ describe('monitored-system model guardrails', () => {expect(proxmoxSettingsPanelSource).not.toContain('setPrefillNode(');expect(proxmoxSettingsPanelSource).not.toContain('const renderConfiguredTable = () =>');expect(proxmoxSettingsPanelSource).not.toContain('const renderNodeModal = (type: NodeType)');- expect(proxmoxSettingsPanelSource).not.toContain('No discovery matches for this Proxmox type yet.');+ expect(proxmoxSettingsPanelSource).not.toContain(+ 'No discovery matches for this Proxmox type yet.',+ );expect(proxmoxSettingsPanelSource).not.toContain('What happens next');expect(proxmoxConfiguredNodesTableSource).toContain('PveNodesTable');expect(proxmoxDirectConnectionsCardSource).toContain('getSettingsConfigurationLoadingState');@@ -523,7 +522,9 @@ describe('monitored-system model guardrails', () => {expect(aiSettingsSource).not.toContain("'Failed to update Pulse Assistant setting'");expect(aiSettingsSource).not.toContain('const normalizeControlLevel =');expect(aiSettingsSource).not.toContain('const errorMessages: Record<string, string> =');- expect(aiSettingsShellSource).not.toContain('const [loading, setLoading] = createSignal(false);');+ expect(aiSettingsShellSource).not.toContain(+ 'const [loading, setLoading] = createSignal(false);',+ );expect(aiSettingsShellSource).not.toContain('const handleSave = async (event?: Event) =>');expect(aiSettingsShellSource).not.toContain('Chat Session Maintenance');expect(aiSettingsShellSource).not.toContain('Discovery Settings');@@ -532,7 +533,9 @@ describe('monitored-system model guardrails', () => {expect(aiSettingsStateSource).toContain('export type AISettingsState =');expect(aiSettingsStateSource).toContain('const [loading, setLoading] = createSignal(false);');expect(aiSettingsStateSource).toContain('const handleSave = async (event?: Event) =>');- expect(aiSettingsStateSource).toContain('const handleEnabledToggle = async (newValue: boolean) =>');+ expect(aiSettingsStateSource).toContain(+ 'const handleEnabledToggle = async (newValue: boolean) =>',+ );expect(aiControlLevelPresentationSource).toContain('export function normalizeAIControlLevel');expect(aiControlLevelPresentationSource).toContain('export function getAIControlLevelPanelClass',@@ -602,6 +605,7 @@ describe('monitored-system model guardrails', () => {expect(reportingPanelSource).toContain('@/utils/upgradePresentation');expect(reportingPanelSource).toContain('@/components/Settings/useReportingPanelState');expect(reportingPanelSource).toContain('@/components/Settings/reportingPanelModel');+ expect(reportingPanelSource).toContain('VM Inventory Export');expect(reportingPanelSource).toContain('getUpgradeActionButtonClass');expect(reportingPanelSource).toContain('UPGRADE_ACTION_LABEL');expect(reportingPanelSource).toContain('UPGRADE_TRIAL_LABEL');@@ -613,8 +617,13 @@ describe('monitored-system model guardrails', () => {expect(reportingPanelStateSource).toContain('getReportingGenerateSelectionRequiredMessage');expect(reportingPanelStateSource).toContain('getReportingGenerateSuccessMessage');expect(reportingPanelStateSource).toContain('getReportingGenerateErrorMessage');+ expect(reportingPanelStateSource).toContain('buildVMInventoryExportRequest');+ expect(reportingPanelStateSource).toContain('getReportingInventoryExportSuccessMessage');expect(reportingPanelModelSource).toContain('export function getReportingRangeStart');expect(reportingPanelModelSource).toContain('export function buildReportingRequest');+ expect(reportingInventoryExportModelSource).toContain(+ 'export function buildVMInventoryExportRequest',+ );expect(reportingPresentationSource).toContain('export const REPORTING_RANGE_OPTIONS');expect(reportingPresentationSource).toContain('export function getReportingGenerateSelectionRequiredMessage',@@ -625,13 +634,16 @@ describe('monitored-system model guardrails', () => {expect(reportingPresentationSource).toContain('export function getReportingGenerateErrorMessage',);+ expect(reportingPresentationSource).toContain(+ 'export function getReportingInventoryExportSuccessMessage',+ );expect(reportingPresentationSource).not.toContain('getReportingToggleButtonClass');expect(aiIntelligenceSource).toContain("import { PatrolIntelligenceSurface } from '@/features/patrol/PatrolIntelligenceSurface';",);expect(aiIntelligenceSource).not.toContain('buildPatrolScheduleOptions');expect(aiIntelligenceSource).not.toContain('PATROL_NO_ISSUES_LABEL');- expect(patrolIntelligenceSurfaceSource).toContain("./usePatrolIntelligenceState");+ expect(patrolIntelligenceSurfaceSource).toContain('./usePatrolIntelligenceState');expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceHeader');expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceBanners');expect(patrolIntelligenceSurfaceSource).toContain('./PatrolIntelligenceSummary');@@ -687,9 +699,13 @@ describe('monitored-system model guardrails', () => {it('keeps the infrastructure workspace on router-derived view state', () => {expect(infrastructureWorkspaceSource).toContain('./infrastructureWorkspaceModel');- expect(infrastructureWorkspaceSource).not.toContain('createSignal<InfrastructureWorkspaceView>');+ expect(infrastructureWorkspaceSource).not.toContain(+ 'createSignal<InfrastructureWorkspaceView>',+ );expect(infrastructureWorkspaceSource).not.toContain('setActiveView(');- expect(infrastructureWorkspaceSource).not.toContain("navigate('/settings/infrastructure/proxmox')");+ expect(infrastructureWorkspaceSource).not.toContain(+ "navigate('/settings/infrastructure/proxmox')",+ );expect(infrastructureWorkspaceModelSource).toContain('export function getInfrastructureWorkspaceViewFromPath',);@@ -752,9 +768,7 @@ describe('monitored-system model guardrails', () => {expect(organizationAccessMembersSectionSource).toContain('@/utils/organizationSettingsPresentation',);- expect(organizationAccessManagementSectionSource).toContain(- 'ORGANIZATION_MEMBER_ROLE_OPTIONS',- );+ expect(organizationAccessManagementSectionSource).toContain('ORGANIZATION_MEMBER_ROLE_OPTIONS');expect(organizationAccessMembersSectionSource).toContain('ORGANIZATION_MEMBER_ROLE_OPTIONS');expect(organizationAccessMembersSectionSource).toContain('roleBadgeClass');expect(organizationAccessMembersSectionSource).toContain('formatOrgDate');@@ -777,9 +791,9 @@ describe('monitored-system model guardrails', () => {expect(organizationAccessStateSource).not.toContain("notificationStore.error(error instanceof Error ? error.message : 'Failed to remove member')",);- expect(organizationAccessStateSource).not.toContain("notificationStore.success(`Updated ");- expect(organizationAccessStateSource).not.toContain("notificationStore.success(`Added ");- expect(organizationAccessStateSource).not.toContain("notificationStore.success(`Removed ");+ expect(organizationAccessStateSource).not.toContain('notificationStore.success(`Updated ');+ expect(organizationAccessStateSource).not.toContain('notificationStore.success(`Added ');+ expect(organizationAccessStateSource).not.toContain('notificationStore.success(`Removed ');expect(organizationOverviewPanelSource).toContain('./useOrganizationOverviewPanelState');expect(organizationOverviewPanelSource).toContain('./OrganizationOverviewLoadingState');expect(organizationOverviewPanelSource).toContain('./OrganizationOverviewDetailsSection');@@ -811,7 +825,9 @@ describe('monitored-system model guardrails', () => {expect(organizationOverviewStateSource).not.toContain("notificationStore.success('Organization name updated')",);- expect(organizationSharingCreateSectionSource).toContain('@/utils/organizationRolePresentation');+ expect(organizationSharingCreateSectionSource).toContain(+ '@/utils/organizationRolePresentation',+ );expect(organizationSharingStateSource).toContain('@/utils/organizationSettingsPresentation');expect(organizationSharingCreateSectionSource).toContain('ORGANIZATION_SHARE_ROLE_OPTIONS');expect(organizationOutgoingSharesSectionSource).toContain('normalizeOrganizationShareRole');@@ -885,7 +901,9 @@ describe('monitored-system model guardrails', () => {expect(alertsPageSource).not.toContain('const agentResources = createMemo(');expect(alertsPageSource).not.toContain("resourceType: 'Agent Disk'");expect(alertsConfigurationSurfaceSource).toContain('<ThresholdsTab');- expect(thresholdsTableStateSource).toContain("import { useThresholdsData } from './useThresholdsData';");+ expect(thresholdsTableStateSource).toContain(+ "import { useThresholdsData } from './useThresholdsData';",+ );expect(thresholdsDataHookSource).toContain('useThresholdsHostData');expect(thresholdsHostDataHookSource).toContain("resourceType: 'Agent Disk'");expect(thresholdsHostDataHookSource).not.toContain("resourceType: 'Host Disk'");@@ -914,13 +932,9 @@ describe('monitored-system model guardrails', () => {);expect(infrastructureSelectorSource).not.toContain("resource.type === 'truenas'");expect(infrastructureSelectorStateSource).toContain('useResources');- expect(infrastructureSelectorModelSource).toContain(- 'hasInfrastructureSelectorAgentFacet',- );+ expect(infrastructureSelectorModelSource).toContain('hasInfrastructureSelectorAgentFacet');expect(infrastructureSelectorModelSource).toContain("resource.type === 'truenas'");- expect(infrastructureSelectorModelSource).not.toContain(- 'if (hostLikeResources.length === 0',- );+ expect(infrastructureSelectorModelSource).not.toContain('if (hostLikeResources.length === 0');expect(guestRowCellsSource).toContain('getDashboardGuestBackupStatusPresentation');expect(guestRowCellsSource).toContain('getDashboardGuestBackupTooltip');expect(guestRowCellsSource).toContain('getDashboardGuestNetworkEmptyState');@@ -1269,7 +1283,9 @@ describe('monitored-system model guardrails', () => {expect(thresholdsTableStateSource).toContain('/thresholds/agents');expect(thresholdsHostDataHookSource).toContain("resourceType: 'Agent Disk'");expect(thresholdsTableStateSource).toContain('getAlertThresholdsSectionTitles');- expect(thresholdsTableAgentDisksSectionSource).toContain('title={state.sectionTitles.agentDisks}');+ expect(thresholdsTableAgentDisksSectionSource).toContain(+ 'title={state.sectionTitles.agentDisks}',+ );expect(thresholdsHostDataHookSource).not.toContain("resourceType: 'Host Disk'");expect(thresholdsHostDataHookSource).toContain('props.agentDefaults');expect(thresholdsTableStateSource).not.toContain('props.hostDefaults');@@ -1496,7 +1512,9 @@ describe('monitored-system model guardrails', () => {expect(infrastructureDiscoveryRuntimeStateSource).toContain('@/utils/infrastructureSettingsPresentation',);- expect(infrastructureDiscoveryRuntimeStateSource).toContain('getDiscoveryScanStartErrorMessage');+ expect(infrastructureDiscoveryRuntimeStateSource).toContain(+ 'getDiscoveryScanStartErrorMessage',+ );expect(infrastructureDiscoveryRuntimeStateSource).toContain('getDiscoverySettingUpdateErrorMessage',);diff --git a/frontend-modern/src/components/Settings/__tests__/reportingInventoryExportModel.test.ts b/frontend-modern/src/components/Settings/__tests__/reportingInventoryExportModel.test.tsnew file mode 100644index 0000000000..0bdb549be8--- /dev/null+++ b/frontend-modern/src/components/Settings/__tests__/reportingInventoryExportModel.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from 'vitest';+import {+ buildVMInventoryExportFilename,+ buildVMInventoryExportRequest,+} from '../reportingInventoryExportModel';++describe('reporting inventory export model', () => {+ it('builds a VM inventory export filename', () => {+ const now = new Date('2026-03-20T12:34:56.000Z');+ expect(buildVMInventoryExportFilename(now)).toBe('vm-inventory-2026-03-20.csv');+ });++ it('builds the canonical VM inventory export request', () => {+ const now = new Date('2026-03-20T12:34:56.000Z');+ const request = buildVMInventoryExportRequest(now);++ expect(request.filename).toBe('vm-inventory-2026-03-20.csv');+ expect(request.request.url).toBe('/api/admin/reports/inventory/vms/export?format=csv');+ });+});diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.tsindex 934f44df0e..ca243e3b49 100644--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts@@ -127,6 +127,7 @@ import systemSettingsPresentationSource from '@/utils/systemSettingsPresentationimport updatesPresentationSource from '@/utils/updatesPresentation.ts?raw';import diagnosticsStateSource from '../useDiagnosticsPanelState.ts?raw';import reportingPanelModelSource from '../reportingPanelModel.ts?raw';+import reportingInventoryExportModelSource from '../reportingInventoryExportModel.ts?raw';import reportingPanelSource from '../ReportingPanel.tsx?raw';import reportingPanelStateSource from '../useReportingPanelState.ts?raw';import systemLogsPanelSource from '../SystemLogsPanel.tsx?raw';@@ -206,6 +207,7 @@ const extractedModules = ['../UpdateInstallGuide.tsx','../ReportingPanel.tsx','../reportingPanelModel.ts',+ '../reportingInventoryExportModel.ts','../ProLicensePlanSection.tsx','../RelayPairingSection.tsx','../OrganizationOverviewLoadingState.tsx',@@ -468,7 +470,9 @@ describe('Settings architecture guardrails', () => {expect(settingsPanelRegistryHookSource).not.toContain('backupPollingEnabled: params.');expect(settingsInfrastructurePanelPropsSource).toContain('pbsInstanceFromResource');expect(settingsInfrastructurePanelPropsSource).toContain('pmgInstanceFromResource');- expect(settingsInfrastructurePanelPropsSource).toContain('const agentStateResources = createMemo');+ expect(settingsInfrastructurePanelPropsSource).toContain(+ 'const agentStateResources = createMemo',+ );expect(settingsInfrastructurePanelPropsSource).toContain('getInfrastructurePanelProps');expect(settingsNavigationModelSource).toContain('export type SettingsTab =');expect(settingsNavigationModelSource).toContain('export const DEFAULT_SETTINGS_TAB');@@ -511,7 +515,9 @@ describe('Settings architecture guardrails', () => {expect(proLicensePanelSource).not.toContain('useLocation()');expect(monitoredSystemLedgerPanelSource).toContain('@/utils/monitoredSystemPresentation');expect(monitoredSystemLedgerPanelSource).toContain('getMonitoredSystemLedgerPresentation');- expect(monitoredSystemLedgerPanelSource).toContain('getMonitoredSystemCountingDetailsToggleLabel');+ expect(monitoredSystemLedgerPanelSource).toContain(+ 'getMonitoredSystemCountingDetailsToggleLabel',+ );expect(monitoredSystemLedgerPanelSource).not.toContain('No monitored systems counted.');expect(monitoredSystemLedgerPanelSource).not.toContain('Current status');expect(monitoredSystemLedgerPanelSource).toContain('getMonitoredSystemLedgerDescription');@@ -520,9 +526,7 @@ describe('Settings architecture guardrails', () => {expect(monitoredSystemDefinitionDisclosureSource).toContain('@/utils/monitoredSystemPresentation',);- expect(monitoredSystemDefinitionDisclosureSource).toContain(- 'getMonitoredSystemBriefSummary',- );+ expect(monitoredSystemDefinitionDisclosureSource).toContain('getMonitoredSystemBriefSummary');expect(monitoredSystemDefinitionDisclosureSource).toContain('getMonitoredSystemDisclosureToggleLabel',);@@ -534,7 +538,9 @@ describe('Settings architecture guardrails', () => {expect(proLicensePanelStateSource).not.toContain('startProTrial()');expect(proLicensePlanSectionSource).toContain('CommercialStatGrid');expect(proLicensePlanSectionSource).toContain('getLicenseStatusLoadingState');- expect(monitoredSystemPresentationSource).toContain('export function getMonitoredSystemLedgerPresentation');+ expect(monitoredSystemPresentationSource).toContain(+ 'export function getMonitoredSystemLedgerPresentation',+ );expect(monitoredSystemPresentationSource).toContain('export function getMonitoredSystemCountingDetailsToggleLabel',);@@ -568,7 +574,9 @@ describe('Settings architecture guardrails', () => {expect(relaySettingsPanelSource).toContain('./RelayPairingSection');expect(relaySettingsPanelSource).not.toContain('createSignal(');expect(relaySettingsPanelSource).not.toContain('QRCode.toDataURL(');- expect(relaySettingsPanelStateSource).toContain("trackPaywallViewed('relay', 'settings_relay_panel')");+ expect(relaySettingsPanelStateSource).toContain(+ "trackPaywallViewed('relay', 'settings_relay_panel')",+ );expect(relaySettingsPanelStateSource).toContain('setInterval(() => void loadStatus(), 5000)');expect(relaySettingsPanelStateSource).toContain('QRCode.toDataURL(payload.deep_link');expect(relaySettingsPanelStateSource).toContain('runStartProTrialAction({');@@ -659,7 +667,9 @@ describe('Settings architecture guardrails', () => {expect(proxmoxDirectWorkspaceSource).toContain('./ProxmoxNodeModalStack');expect(proxmoxSettingsPanelSource).not.toContain('const renderConfiguredTable = () =>');expect(proxmoxSettingsPanelSource).not.toContain('const renderNodeModal = (type: NodeType)');- expect(proxmoxSettingsPanelSource).not.toContain('No discovery matches for this Proxmox type yet.');+ expect(proxmoxSettingsPanelSource).not.toContain(+ 'No discovery matches for this Proxmox type yet.',+ );expect(proxmoxSettingsPanelSource).not.toContain('What happens next');expect(proxmoxConfiguredNodesTableSource).toContain('PveNodesTable');expect(proxmoxConfiguredNodesTableSource).toContain('PbsNodesTable');@@ -718,12 +728,8 @@ describe('Settings architecture guardrails', () => {expect(organizationAccessManagementSectionSource).toContain('getOrganizationAccessManageRequiredMessage',);- expect(organizationAccessManagementSectionSource).toContain(- 'ORGANIZATION_MEMBER_ROLE_OPTIONS',- );- expect(organizationAccessMembersSectionSource).toContain(- 'getOrganizationAccessEmptyState',- );+ expect(organizationAccessManagementSectionSource).toContain('ORGANIZATION_MEMBER_ROLE_OPTIONS');+ expect(organizationAccessMembersSectionSource).toContain('getOrganizationAccessEmptyState');expect(organizationAccessMembersSectionSource).toContain('formatOrgDate');expect(organizationAccessLoadingStateSource).toContain('animate-pulse');});@@ -802,7 +808,9 @@ describe('Settings architecture guardrails', () => {expect(infrastructureWorkspaceSource).not.toContain('Add and manage infrastructure');expect(infrastructureWorkspaceSource).not.toContain('tracking-[0.22em]');expect(infrastructureWorkspaceSource).toContain('./infrastructureWorkspaceModel');- expect(infrastructureWorkspaceSource).not.toContain('createSignal<InfrastructureWorkspaceView>');+ expect(infrastructureWorkspaceSource).not.toContain(+ 'createSignal<InfrastructureWorkspaceView>',+ );expect(infrastructureWorkspaceSource).not.toContain('createEffect(() =>');expect(infrastructureWorkspaceSource).toContain('InfrastructureInstallPanel');expect(infrastructureWorkspaceSource).toContain('InfrastructureReportingPanel');@@ -816,10 +824,14 @@ describe('Settings architecture guardrails', () => {);expect(infrastructureReportingPanelSource).not.toContain('Direct Proxmox connections');expect(infrastructureReportingPanelSource).not.toContain('Manage direct connections');- expect(infrastructureOperationsControllerSource).toContain('InfrastructureOperationsStateProvider');+ expect(infrastructureOperationsControllerSource).toContain(+ 'InfrastructureOperationsStateProvider',+ );expect(infrastructureOperationsControllerSource).toContain('InfrastructureInstallerSection');expect(infrastructureOperationsControllerSource).toContain('InfrastructureInventorySection');- expect(infrastructureOperationsControllerSource).toContain('InfrastructureStopMonitoringDialog');+ expect(infrastructureOperationsControllerSource).toContain(+ 'InfrastructureStopMonitoringDialog',+ );expect(infrastructureOperationsStateSource).toContain('export const useInfrastructureOperationsState',);@@ -834,13 +846,17 @@ describe('Settings architecture guardrails', () => {expect(infrastructureOperationsStateSource).not.toContain('const renderInstallerSection =');expect(infrastructureOperationsStateSource).not.toContain('const renderInventorySection =');expect(infrastructureOperationsStateSource).not.toContain('const renderStopMonitoringDialog =');- expect(infrastructureInstallStateSource).toContain('export const useInfrastructureInstallState');+ expect(infrastructureInstallStateSource).toContain(+ 'export const useInfrastructureInstallState',+ );expect(infrastructureReportingStateSource).toContain('export const useInfrastructureReportingState',);expect(infrastructureInstallerSectionSource).toContain('useInfrastructureOperationsContext');expect(infrastructureInventorySectionSource).toContain('useInfrastructureOperationsContext');- expect(infrastructureStopMonitoringDialogSource).toContain('useInfrastructureOperationsContext');+ expect(infrastructureStopMonitoringDialogSource).toContain(+ 'useInfrastructureOperationsContext',+ );expect(infrastructureActiveRowDetailsSource).toContain('useInfrastructureOperationsContext');expect(infrastructureIgnoredRowDetailsSource).toContain('useInfrastructureOperationsContext');expect(infrastructureWorkspaceModelSource).toContain(@@ -855,9 +871,7 @@ describe('Settings architecture guardrails', () => {expect(infrastructureDirectConnectionsSummaryCardSource).toContain('Direct Proxmox connections',);- expect(infrastructureDirectConnectionsSummaryCardSource).toContain(- 'Manage direct connections',- );+ expect(infrastructureDirectConnectionsSummaryCardSource).toContain('Manage direct connections');expect(infrastructureInstallPanelSource).not.toContain('<PageHeader');expect(infrastructureReportingPanelSource).not.toContain('<PageHeader');});@@ -882,17 +896,23 @@ describe('Settings architecture guardrails', () => {expect(infrastructureSettingsStateSource).toContain("from './infrastructureSettingsModel'");expect(infrastructureSettingsStateSource).not.toContain('NodesAPI.getNodes');expect(infrastructureSettingsStateSource).not.toContain('SettingsAPI.updateSystemSettings');- expect(infrastructureSettingsStateSource).not.toContain("const [nodes, setNodes] = createSignal");expect(infrastructureSettingsStateSource).not.toContain(- "const [discoveredNodes, setDiscoveredNodes] = createSignal",+ 'const [nodes, setNodes] = createSignal',+ );+ expect(infrastructureSettingsStateSource).not.toContain(+ 'const [discoveredNodes, setDiscoveredNodes] = createSignal',+ );+ expect(infrastructureConfiguredNodesStateSource).toContain(+ 'export const useInfrastructureConfiguredNodesState',);- expect(infrastructureConfiguredNodesStateSource).toContain('export const useInfrastructureConfiguredNodesState');expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.getNodes');expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.updateNode');expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.deleteNode');expect(infrastructureConfiguredNodesStateSource).toContain('NodesAPI.refreshClusterNodes');expect(infrastructureConfiguredNodesStateSource).not.toContain("apiFetch('/api/discover'");- expect(infrastructureConfiguredNodesStateSource).not.toContain('SettingsAPI.updateSystemSettings');+ expect(infrastructureConfiguredNodesStateSource).not.toContain(+ 'SettingsAPI.updateSystemSettings',+ );expect(infrastructureDiscoveryRuntimeStateSource).toContain('export const useInfrastructureDiscoveryRuntimeState',);@@ -909,19 +929,29 @@ describe('Settings architecture guardrails', () => {it('keeps the API token manager shell behind extracted state and model owners', () => {expect(apiTokenManagerSource).toContain('./useAPITokenManagerState');- expect(apiTokenManagerSource).not.toContain('const [tokens, setTokens] = createSignal<APITokenRecord[]>([])');+ expect(apiTokenManagerSource).not.toContain(+ 'const [tokens, setTokens] = createSignal<APITokenRecord[]>([])',+ );expect(apiTokenManagerSource).not.toContain('const loadTokens = async () =>');- expect(apiTokenManagerSource).not.toContain('const hasAgentScopeResource = (resource: Resource)');+ expect(apiTokenManagerSource).not.toContain(+ 'const hasAgentScopeResource = (resource: Resource)',+ );expect(apiTokenManagerStateSource).toContain('export const useAPITokenManagerState =');- expect(apiTokenManagerStateSource).toContain('const [tokens, setTokens] = createSignal<APITokenRecord[]>([])');+ expect(apiTokenManagerStateSource).toContain(+ 'const [tokens, setTokens] = createSignal<APITokenRecord[]>([])',+ );expect(apiTokenManagerStateSource).toContain('const loadTokens = async () =>');expect(apiTokenManagerStateSource).toContain('SecurityAPI.listTokens()');expect(apiTokenManagerStateSource).toContain('const scopePresets = getAPITokenScopePresets();');- expect(apiTokenManagerStateSource).not.toContain('const scopePresets = API_TOKEN_SCOPE_PRESETS;');+ expect(apiTokenManagerStateSource).not.toContain(+ 'const scopePresets = API_TOKEN_SCOPE_PRESETS;',+ );expect(apiTokenManagerModelSource).toContain('export const hasAgentScopeResource =');expect(apiTokenManagerModelSource).toContain('export const buildDockerTokenUsage =');expect(apiTokenManagerModelSource).toContain('export const buildAgentTokenUsage =');- expect(apiTokenManagerModelSource).toContain('export const getAPITokenScopePresets = (): APITokenPreset[] => [');+ expect(apiTokenManagerModelSource).toContain(+ 'export const getAPITokenScopePresets = (): APITokenPreset[] => [',+ );expect(apiTokenManagerModelSource).not.toContain('export const API_TOKEN_SCOPE_PRESETS = [');});@@ -950,10 +980,14 @@ describe('Settings architecture guardrails', () => {expect(nodeModalModelSource).toContain('export const deriveNameFromHost =');expect(nodeModalModelSource).toContain('export const PVE_MANUAL_PERMISSION_COMMAND = `');expect(nodeModalStateSource).toContain('export const useNodeModalState =');- expect(nodeModalStateSource).toContain('export type NodeModalState = ReturnType<typeof useNodeModalState>;');+ expect(nodeModalStateSource).toContain(+ 'export type NodeModalState = ReturnType<typeof useNodeModalState>;',+ );expect(nodeModalStateSource).toContain('const [quickSetupBootstrap, setQuickSetupBootstrap] =');expect(nodeModalStateSource).toContain('const handleTestConnection = async () =>');- expect(nodeModalStateSource).toContain("const PROXMOX_SETUP_HOST_REQUIRED_MESSAGE = 'Proxmox setup host is required';");+ expect(nodeModalStateSource).toContain(+ "const PROXMOX_SETUP_HOST_REQUIRED_MESSAGE = 'Proxmox setup host is required';",+ );expect(nodeModalStateSource).toContain('runStartProTrialAction({');expect(nodeModalStateSource).not.toContain('startProTrial()');});@@ -965,13 +999,17 @@ describe('Settings architecture guardrails', () => {expect(aiSettingsPanelSource).toContain('@/components/Settings/AISettingsStatusAndActions');expect(aiSettingsPanelSource).toContain('@/components/Settings/AISettingsDialogs');expect(aiSettingsPanelSource).toContain('@/components/Settings/useAISettingsState');- expect(aiSettingsPanelSource).not.toContain('const [loading, setLoading] = createSignal(false);');+ expect(aiSettingsPanelSource).not.toContain(+ 'const [loading, setLoading] = createSignal(false);',+ );expect(aiSettingsPanelSource).not.toContain('const handleSave = async (event?: Event) =>');expect(aiSettingsPanelSource).not.toContain('AIAPI.getSettings()');expect(aiSettingsPanelSource).not.toContain('Chat Session Maintenance');expect(aiSettingsPanelSource).not.toContain('Discovery Settings');expect(aiSettingsPanelSource).not.toContain('Pulse Permission Level');- expect(aiModelSelectionSectionSource).toContain('@/components/Settings/AIProviderConfigurationSection');+ expect(aiModelSelectionSectionSource).toContain(+ '@/components/Settings/AIProviderConfigurationSection',+ );expect(aiModelSelectionSectionSource).toContain('@/components/Settings/aiSettingsModel');expect(aiModelSelectionSectionSource).toContain('Advanced Model Selection');expect(aiRuntimeControlsSectionSource).toContain('Discovery Settings');@@ -986,7 +1024,9 @@ describe('Settings architecture guardrails', () => {expect(aiSettingsStateSource).toContain('export const useAISettingsState =');expect(aiSettingsStateSource).toContain('const [loading, setLoading] = createSignal(false);');expect(aiSettingsStateSource).toContain('const handleSave = async (event?: Event) =>');- expect(aiSettingsStateSource).toContain('const handleEnabledToggle = async (newValue: boolean) =>');+ expect(aiSettingsStateSource).toContain(+ 'const handleEnabledToggle = async (newValue: boolean) =>',+ );expect(aiSettingsStateSource).toContain('AIAPI.getSettings()');expect(aiSettingsStateSource).toContain('runStartProTrialAction({');expect(aiSettingsStateSource).not.toContain('startProTrial()');@@ -1007,12 +1047,14 @@ describe('Settings architecture guardrails', () => {expect(updateInstallGuideSource).toContain('@/components/Settings/CopyCommandBlock');expect(updateInstallGuideSource).toContain('buildUpdateInstallGuide');expect(copyCommandBlockSource).toContain('export function CopyCommandBlock');- expect(copyCommandBlockSource).toContain("aria-label=\"Copy to clipboard\"");+ expect(copyCommandBlockSource).toContain('aria-label="Copy to clipboard"');expect(updatesSettingsModelSource).toContain('export function getUpdateChannelCardOptions');expect(updatesSettingsModelSource).toContain('export function buildUpdateInstallGuide');expect(updatesSettingsModelSource).toContain("title: 'Pre-release'");expect(updatesSettingsModelSource).not.toContain('Release Candidate');- expect(updatesPresentationSource).toContain('Pre-release builds stay on a manual preview channel.');+ expect(updatesPresentationSource).toContain(+ 'Pre-release builds stay on a manual preview channel.',+ );expect(updatesPresentationSource).not.toContain('RC is a manual preview channel.');});@@ -1041,6 +1083,7 @@ describe('Settings architecture guardrails', () => {expect(reportingPanelSource).toContain('@/components/Settings/OperationsPanel');expect(reportingPanelSource).toContain('@/components/Settings/useReportingPanelState');expect(reportingPanelSource).toContain('@/components/Settings/reportingPanelModel');+ expect(reportingPanelSource).toContain('VM Inventory Export');expect(reportingPanelSource).not.toContain('loadLicenseStatus()');expect(reportingPanelSource).not.toContain('startProTrial()');expect(reportingPanelSource).not.toContain("apiFetch('/api/admin/reports/generate");@@ -1050,11 +1093,15 @@ describe('Settings architecture guardrails', () => {expect(reportingPanelStateSource).toContain('runStartProTrialAction({');expect(reportingPanelStateSource).not.toContain('startProTrial()');expect(reportingPanelStateSource).toContain('buildReportingRequest');+ expect(reportingPanelStateSource).toContain('buildVMInventoryExportRequest');expect(reportingPanelStateSource).toContain('getReportingGenerateSuccessMessage');expect(reportingPanelStateSource).not.toContain('getTrialAlreadyUsedMessage()');expect(reportingPanelModelSource).toContain('export function getReportingRangeStart');expect(reportingPanelModelSource).toContain('export function buildReportingRequest');expect(reportingPanelModelSource).toContain('export function buildReportingFilename');+ expect(reportingInventoryExportModelSource).toContain(+ 'export function buildVMInventoryExportFilename',+ );});it('keeps the shared operations wrapper rooted at SettingsPanel', () => {@@ -1116,8 +1163,12 @@ describe('Settings architecture guardrails', () => {expect(ssoProvidersModelSource).toContain('export const mapProviderDetailsToForm =');expect(ssoProvidersModelSource).toContain('export const buildProviderPayload =');expect(ssoProvidersModelSource).toContain('export const buildProviderTestPayload =');- expect(ssoProviderPresentationSource).toContain('export function getSSOProviderEmptyStateTitle');- expect(ssoProviderPresentationSource).toContain('export function getSSOProvidersLoadErrorMessage');+ expect(ssoProviderPresentationSource).toContain(+ 'export function getSSOProviderEmptyStateTitle',+ );+ expect(ssoProviderPresentationSource).toContain(+ 'export function getSSOProvidersLoadErrorMessage',+ );});it('keeps shared system settings presentation extracted from panel and state owners', () => {diff --git a/frontend-modern/src/components/Settings/reportingInventoryExportModel.ts b/frontend-modern/src/components/Settings/reportingInventoryExportModel.tsnew file mode 100644index 0000000000..6aeb0d22f6--- /dev/null+++ b/frontend-modern/src/components/Settings/reportingInventoryExportModel.ts@@ -0,0 +1,23 @@+export interface ReportingInventoryExportRequestDefinition {+ filename: string;+ request: {+ url: string;+ };+}++export function buildVMInventoryExportFilename(now: Date): string {+ const date = now.toISOString().split('T')[0];+ return `vm-inventory-${date}.csv`;+}++export function buildVMInventoryExportRequest(+ now: Date,+): ReportingInventoryExportRequestDefinition {+ const params = new URLSearchParams({ format: 'csv' });+ return {+ filename: buildVMInventoryExportFilename(now),+ request: {+ url: `/api/admin/reports/inventory/vms/export?${params.toString()}`,+ },+ };+}diff --git a/frontend-modern/src/components/Settings/useReportingPanelState.ts b/frontend-modern/src/components/Settings/useReportingPanelState.tsindex d7b4647c0c..f39c7d5e39 100644--- a/frontend-modern/src/components/Settings/useReportingPanelState.ts+++ b/frontend-modern/src/components/Settings/useReportingPanelState.ts@@ -14,6 +14,8 @@ import {getReportingGenerateErrorMessage,getReportingGenerateSelectionRequiredMessage,getReportingGenerateSuccessMessage,+ getReportingInventoryExportErrorMessage,+ getReportingInventoryExportSuccessMessage,} from '@/utils/reportingPresentation';import { runStartProTrialAction } from '@/utils/trialStartAction';import {@@ -22,6 +24,7 @@ import {type ReportingFormat,type ReportingRangeValue,} from '@/components/Settings/reportingPanelModel';+import { buildVMInventoryExportRequest } from '@/components/Settings/reportingInventoryExportModel';export const useReportingPanelState = () => {const [selectedResources, setSelectedResources] = createSignal<SelectedResource[]>([]);@@ -29,6 +32,7 @@ export const useReportingPanelState = () => {const [format, setFormat] = createSignal<ReportingFormat>('pdf');const [range, setRange] = createSignal<ReportingRangeValue>('24h');const [generating, setGenerating] = createSignal(false);+ const [exportingInventory, setExportingInventory] = createSignal(false);const [title, setTitle] = createSignal('');const [startingTrial, setStartingTrial] = createSignal(false);@@ -62,6 +66,18 @@ export const useReportingPanelState = () => {}};+ const downloadResponseBlob = async (filename: string, response: Response) => {+ const blob = await response.blob();+ const url = window.URL.createObjectURL(blob);+ const anchor = document.createElement('a');+ anchor.href = url;+ anchor.download = filename;+ document.body.appendChild(anchor);+ anchor.click();+ window.URL.revokeObjectURL(url);+ document.body.removeChild(anchor);+ };+const handleGenerate = async () => {const resources = selectedResources();if (resources.length === 0) {@@ -89,15 +105,7 @@ export const useReportingPanelState = () => {throw new Error(text || getReportingGenerateErrorMessage());}- const blob = await response.blob();- const url = window.URL.createObjectURL(blob);- const anchor = document.createElement('a');- anchor.href = url;- anchor.download = request.filename;- document.body.appendChild(anchor);- anchor.click();- window.URL.revokeObjectURL(url);- document.body.removeChild(anchor);+ await downloadResponseBlob(request.filename, response);showSuccess(getReportingGenerateSuccessMessage());} catch (error) {@@ -108,9 +116,35 @@ export const useReportingPanelState = () => {}};+ const handleExportVMInventory = async () => {+ if (exportingInventory()) return;++ setExportingInventory(true);+ try {+ const request = buildVMInventoryExportRequest(new Date());+ const response = await apiFetch(request.request.url);+ if (!response.ok) {+ const text = await response.text();+ throw new Error(text || getReportingInventoryExportErrorMessage());+ }++ await downloadResponseBlob(request.filename, response);+ showSuccess(getReportingInventoryExportSuccessMessage());+ } catch (error) {+ console.error('VM inventory export error:', error);+ showWarning(+ error instanceof Error ? error.message : getReportingInventoryExportErrorMessage(),+ );+ } finally {+ setExportingInventory(false);+ }+ };+return {canStartTrial,+ exportingInventory,format,+ handleExportVMInventory,generating,handleGenerate,handleStartTrial,diff --git a/frontend-modern/src/utils/reportingPresentation.ts b/frontend-modern/src/utils/reportingPresentation.tsindex 210098bef2..84b9f9795a 100644--- a/frontend-modern/src/utils/reportingPresentation.ts+++ b/frontend-modern/src/utils/reportingPresentation.ts@@ -20,3 +20,11 @@ export function getReportingGenerateSuccessMessage(): string {export function getReportingGenerateErrorMessage(): string {return 'Failed to generate report';}++export function getReportingInventoryExportSuccessMessage(): string {+ return 'VM inventory export generated successfully';+}++export function getReportingInventoryExportErrorMessage(): string {+ return 'Failed to generate VM inventory export';+}diff --git a/internal/api/audit_reporting_scope_test.go b/internal/api/audit_reporting_scope_test.goindex 9bff291b98..de1f00453e 100644--- a/internal/api/audit_reporting_scope_test.go+++ b/internal/api/audit_reporting_scope_test.go@@ -49,6 +49,7 @@ func TestReportingEndpointsRequireSettingsReadScope(t *testing.T) {paths := []string{"/api/admin/reports/generate","/api/admin/reports/generate-multi",+ "/api/admin/reports/inventory/vms/export",}for _, path := range paths {diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex ac0a8e1311..340e708f3a 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -306,6 +306,29 @@ func TestContract_HostedAISettingsAutoBootstrapJSONSnapshot(t *testing.T) {assertJSONSnapshot(t, rec.Body.Bytes(), want)}+func TestContract_VMInventoryExportCSVHeaders(t *testing.T) {+ handler := NewReportingHandlers(nil, nil)+ req := httptest.NewRequest(http.MethodGet, "/api/admin/reports/inventory/vms/export?format=csv", nil)+ rec := httptest.NewRecorder()++ handler.HandleExportVMInventory(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("expected 200, got %d body=%s", rec.Code, rec.Body.String())+ }+ if got := rec.Header().Get("Content-Type"); got != "text/csv; charset=utf-8" {+ t.Fatalf("expected csv content type, got %q", got)+ }+ if got := rec.Header().Get("Content-Disposition"); !strings.HasPrefix(got, "attachment; filename=\"vm-inventory-") {+ t.Fatalf("expected VM inventory attachment filename, got %q", got)+ }++ const want = "Resource ID,Instance,Node,VMID,VM Name,Status,CPU Cores,Memory Allocated Bytes,Disk Allocated Bytes,Disk Used Bytes,Disk Status Reason\n"+ if got := rec.Body.String(); got != want {+ t.Fatalf("unexpected VM inventory CSV header row:\nwant %q\ngot %q", want, got)+ }+}+func TestContract_HostedTenantAISettingsFallbackJSONSnapshot(t *testing.T) {t.Setenv("PULSE_HOSTED_MODE", "true")diff --git a/internal/api/enterprise_extension_reporting_admin_test.go b/internal/api/enterprise_extension_reporting_admin_test.goindex e7f0d11c74..f2ea123364 100644--- a/internal/api/enterprise_extension_reporting_admin_test.go+++ b/internal/api/enterprise_extension_reporting_admin_test.go@@ -9,7 +9,8 @@ import ()type testReportingAdminEndpoints struct {- generateCalls int+ generateCalls int+ exportInventoryCalls int}func (t *testReportingAdminEndpoints) HandleGenerateReport(http.ResponseWriter, *http.Request) {@@ -18,6 +19,10 @@ func (t *testReportingAdminEndpoints) HandleGenerateReport(http.ResponseWriter,func (t *testReportingAdminEndpoints) HandleGenerateMultiReport(http.ResponseWriter, *http.Request) {}+func (t *testReportingAdminEndpoints) HandleExportVMInventory(http.ResponseWriter, *http.Request) {+ t.exportInventoryCalls+++}+func TestResolveReportingAdminEndpoints_DefaultWhenBinderNil(t *testing.T) {SetReportingAdminEndpointsBinder(nil)t.Cleanup(func() {@@ -58,3 +63,19 @@ func TestResolveReportingAdminEndpoints_UsesBinderOverride(t *testing.T) {t.Fatalf("expected override reporting handler call, got %d", override.generateCalls)}}++func TestResolveReportingAdminEndpoints_UsesDefaultInventoryHandler(t *testing.T) {+ SetReportingAdminEndpointsBinder(nil)+ t.Cleanup(func() {+ SetReportingAdminEndpointsBinder(nil)+ })++ defaults := &testReportingAdminEndpoints{}+ resolved := resolveReportingAdminEndpoints(defaults, extensions.ReportingAdminRuntime{})+ req := httptest.NewRequest(http.MethodGet, "/api/admin/reports/inventory/vms/export", nil)+ rec := httptest.NewRecorder()+ resolved.HandleExportVMInventory(rec, req)+ if defaults.exportInventoryCalls != 1 {+ t.Fatalf("expected default VM inventory handler call, got %d", defaults.exportInventoryCalls)+ }+}diff --git a/internal/api/rbac_reporting_auth_test.go b/internal/api/rbac_reporting_auth_test.goindex 87ff8d69aa..e8ab8cd32f 100644--- a/internal/api/rbac_reporting_auth_test.go+++ b/internal/api/rbac_reporting_auth_test.go@@ -39,6 +39,7 @@ func TestReportingEndpointsRequireAuthInAPIMode(t *testing.T) {}{{method: http.MethodGet, path: "/api/admin/reports/generate", body: ""},{method: http.MethodPost, path: "/api/admin/reports/generate-multi", body: `{}`},+ {method: http.MethodGet, path: "/api/admin/reports/inventory/vms/export", body: ""},}for _, tc := range cases {diff --git a/internal/api/reporting_handlers_test.go b/internal/api/reporting_handlers_test.goindex d7078bd3d0..ffbf2e0895 100644--- a/internal/api/reporting_handlers_test.go+++ b/internal/api/reporting_handlers_test.go@@ -9,6 +9,7 @@ import ("testing""time"+ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources""github.com/rcourtman/pulse-go-rewrite/pkg/reporting")@@ -223,3 +224,94 @@ func TestSanitizeFilename(t *testing.T) {t.Fatalf("sanitizeFilename did not remove unsafe characters: %q", got)}}++func TestReportingHandlers_ExportVMInventory_MethodNotAllowed(t *testing.T) {+ handler := NewReportingHandlers(nil, nil)+ req := httptest.NewRequest(http.MethodPost, "/api/admin/reports/inventory/vms/export", nil)+ rr := httptest.NewRecorder()++ handler.HandleExportVMInventory(rr, req)++ if rr.Code != http.StatusMethodNotAllowed {+ t.Fatalf("expected status %d, got %d", http.StatusMethodNotAllowed, rr.Code)+ }+}++func TestReportingHandlers_ExportVMInventory_InvalidFormat(t *testing.T) {+ handler := NewReportingHandlers(nil, nil)+ req := httptest.NewRequest(http.MethodGet, "/api/admin/reports/inventory/vms/export?format=pdf", nil)+ rr := httptest.NewRecorder()++ handler.HandleExportVMInventory(rr, req)++ if rr.Code != http.StatusBadRequest {+ t.Fatalf("expected status %d, got %d body=%s", http.StatusBadRequest, rr.Code, rr.Body.String())+ }+}++func TestReportingHandlers_ExportVMInventory_EmptySnapshotStillReturnsCSVHeader(t *testing.T) {+ handler := NewReportingHandlers(nil, nil)+ req := httptest.NewRequest(http.MethodGet, "/api/admin/reports/inventory/vms/export", nil)+ rr := httptest.NewRecorder()++ handler.HandleExportVMInventory(rr, req)++ if rr.Code != http.StatusOK {+ t.Fatalf("expected status %d, got %d body=%s", http.StatusOK, rr.Code, rr.Body.String())+ }+ if contentType := rr.Header().Get("Content-Type"); !strings.Contains(contentType, "text/csv") {+ t.Fatalf("expected CSV content type, got %q", contentType)+ }+ if !strings.Contains(rr.Body.String(), "Resource ID,Instance,Node,VMID,VM Name") {+ t.Fatalf("expected CSV header row, got %q", rr.Body.String())+ }+}++func TestBuildVMInventoryRows_UsesCanonicalFieldsAndDiskFallback(t *testing.T) {+ total := int64(16 * 1024)+ resources := []unifiedresources.Resource{+ {+ ID: "vm-101",+ Type: unifiedresources.ResourceTypeVM,+ Name: "app-vm",+ Status: unifiedresources.StatusWarning,+ Metrics: &unifiedresources.ResourceMetrics{+ Memory: &unifiedresources.MetricValue{Total: &total},+ },+ Proxmox: &unifiedresources.ProxmoxData{+ Instance: "lab",+ NodeName: "pve-a",+ VMID: 101,+ CPUs: 4,+ DiskStatusReason: "guest agent offline",+ Disks: []unifiedresources.DiskInfo{+ {Device: "scsi0", Total: 100 * 1024, Used: 40 * 1024},+ {Device: "scsi1", Total: 50 * 1024, Used: 10 * 1024},+ },+ },+ },+ {+ ID: "node-1",+ Type: unifiedresources.ResourceTypeAgent,+ Name: "node-a",+ },+ }++ rows := buildVMInventoryRows(resources)+ if len(rows) != 1 {+ t.Fatalf("expected one VM row, got %d", len(rows))+ }+ row := rows[0]+ if row.ResourceID != "vm-101" || row.Name != "app-vm" || row.Instance != "lab" || row.Node != "pve-a" {+ t.Fatalf("unexpected inventory row identity: %+v", row)+ }+ if row.CPUCores != 4 || row.MemoryAllocatedBytes != total {+ t.Fatalf("expected CPU and memory totals from canonical model, got %+v", row)+ }+ if row.DiskAllocatedBytes != 150*1024 || row.DiskUsedBytes != 50*1024 {+ t.Fatalf("expected disk totals to fall back to per-disk sums, got %+v", row)+ }+ if row.DiskStatusReason != "guest agent offline" {+ t.Fatalf("expected disk status reason to be preserved, got %+v", row)+ }+}diff --git a/internal/api/reporting_inventory_handlers.go b/internal/api/reporting_inventory_handlers.gonew file mode 100644index 0000000000..c735c27697--- /dev/null+++ b/internal/api/reporting_inventory_handlers.go@@ -0,0 +1,88 @@+package api++import (+ "fmt"+ "net/http"+ "time"++ "github.com/rcourtman/pulse-go-rewrite/internal/unifiedresources"+ "github.com/rcourtman/pulse-go-rewrite/pkg/reporting"+)++// HandleExportVMInventory exports the current VM inventory as spreadsheet-friendly CSV.+func (h *ReportingHandlers) HandleExportVMInventory(w http.ResponseWriter, r *http.Request) {+ if r.Method != http.MethodGet {+ http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)+ return+ }++ format := reporting.ReportFormat(r.URL.Query().Get("format"))+ if format == "" {+ format = reporting.FormatCSV+ }+ if format != reporting.FormatCSV {+ writeErrorResponse(w, http.StatusBadRequest, "invalid_format", "Format must be 'csv'", nil)+ return+ }++ snapshot := emptyReportingEnrichmentSnapshot()+ if h != nil {+ if liveSnapshot, ok := h.getReportingEnrichmentSnapshot(r.Context(), GetOrgID(r.Context())); ok {+ snapshot = liveSnapshot+ }+ }++ data, err := reporting.GenerateVMInventoryCSV(reporting.VMInventoryData{+ GeneratedAt: time.Now().UTC(),+ Rows: buildVMInventoryRows(snapshot.Resources),+ })+ if err != nil {+ writeErrorResponse(w, http.StatusInternalServerError, "generation_failed", "Failed to generate VM inventory export", nil)+ return+ }++ w.Header().Set("Content-Type", "text/csv; charset=utf-8")+ filename := fmt.Sprintf("vm-inventory-%s.csv", time.Now().Format("20060102"))+ w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))+ _, _ = w.Write(data)+}++func buildVMInventoryRows(resources []unifiedresources.Resource) []reporting.VMInventoryRow {+ rows := make([]reporting.VMInventoryRow, 0, len(resources))+ for i := range resources {+ resource := &resources[i]+ if resource.Type != unifiedresources.ResourceTypeVM {+ continue+ }+ view := unifiedresources.NewVMView(resource)+ diskAllocated, diskUsed := resolveVMInventoryDiskUsage(view)+ rows = append(rows, reporting.VMInventoryRow{+ ResourceID: view.ID(),+ Instance: view.Instance(),+ Node: view.Node(),+ VMID: view.VMID(),+ Name: view.Name(),+ Status: string(view.Status()),+ CPUCores: view.CPUs(),+ MemoryAllocatedBytes: view.MemoryTotal(),+ DiskAllocatedBytes: diskAllocated,+ DiskUsedBytes: diskUsed,+ DiskStatusReason: view.DiskStatusReason(),+ })+ }+ return rows+}++func resolveVMInventoryDiskUsage(view unifiedresources.VMView) (allocated int64, used int64) {+ allocated = view.DiskTotal()+ used = view.DiskUsed()+ if allocated > 0 || used > 0 {+ return allocated, used+ }++ for _, disk := range view.Disks() {+ allocated += disk.Total+ used += disk.Used+ }+ return allocated, used+}diff --git a/internal/api/route_inventory_test.go b/internal/api/route_inventory_test.goindex 92bbe3ce8a..af10d8ef55 100644--- a/internal/api/route_inventory_test.go+++ b/internal/api/route_inventory_test.go@@ -449,6 +449,7 @@ var allRouteAllowlist = []string{"POST /api/admin/rbac/reset-admin","/api/admin/reports/generate","/api/admin/reports/generate-multi",+ "/api/admin/reports/inventory/vms/export","/api/admin/webhooks/audit","/api/security/change-password","/api/security/dev/reset-first-run",diff --git a/internal/api/router_routes_licensing.go b/internal/api/router_routes_licensing.goindex 6849f0367c..098dc798b2 100644--- a/internal/api/router_routes_licensing.go+++ b/internal/api/router_routes_licensing.go@@ -189,6 +189,12 @@ func (r *Router) registerOrgLicenseRoutesGroup(orgHandlers *OrgHandlers, rbacHan}RequireLicenseFeature(r.licenseHandlers, featureAdvancedReportingValue, RequireScope(config.ScopeSettingsRead, reportingAdminEndpoints.HandleGenerateMultiReport))(w, req)}))+ r.mux.HandleFunc("/api/admin/reports/inventory/vms/export", RequirePermission(r.config, r.authorizer, auth.ActionRead, auth.ResourceNodes, func(w http.ResponseWriter, req *http.Request) {+ if !ensureAdminSession(r.config, w, req) {+ return+ }+ RequireLicenseFeature(r.licenseHandlers, featureAdvancedReportingValue, RequireScope(config.ScopeSettingsRead, reportingAdminEndpoints.HandleExportVMInventory))(w, req)+ }))// Audit Webhook routesr.mux.HandleFunc("/api/admin/webhooks/audit", RequirePermission(r.config, r.authorizer, auth.ActionAdmin, auth.ResourceAuditLogs, func(w http.ResponseWriter, req *http.Request) {@@ -303,6 +309,14 @@ func (a reportingAdminEndpointAdapter) HandleGenerateMultiReport(w http.Responsea.handlers.HandleGenerateMultiReport(w, req)}+func (a reportingAdminEndpointAdapter) HandleExportVMInventory(w http.ResponseWriter, req *http.Request) {+ if a.handlers == nil {+ writeErrorResponse(w, http.StatusNotImplemented, "reporting_unavailable", "Reporting is not available", nil)+ return+ }+ a.handlers.HandleExportVMInventory(w, req)+}+func newRBACAdminRuntime(handlers *RBACHandlers) extensions.RBACAdminRuntime {return extensions.RBACAdminRuntime{GetRequestOrgID: GetOrgID,diff --git a/pkg/extensions/reporting_admin.go b/pkg/extensions/reporting_admin.goindex 58febf2de1..8967542381 100644--- a/pkg/extensions/reporting_admin.go+++ b/pkg/extensions/reporting_admin.go@@ -12,6 +12,7 @@ import (type ReportingAdminEndpoints interface {HandleGenerateReport(http.ResponseWriter, *http.Request)HandleGenerateMultiReport(http.ResponseWriter, *http.Request)+ HandleExportVMInventory(http.ResponseWriter, *http.Request)}// WriteReportingErrorFunc writes a structured reporting error response.diff --git a/pkg/reporting/vm_inventory.go b/pkg/reporting/vm_inventory.gonew file mode 100644index 0000000000..9ea5db9f4a--- /dev/null+++ b/pkg/reporting/vm_inventory.go@@ -0,0 +1,100 @@+package reporting++import (+ "bytes"+ "encoding/csv"+ "fmt"+ "sort"+ "strconv"+ "time"+)++// VMInventoryData captures the current-state VM inventory export payload.+type VMInventoryData struct {+ GeneratedAt time.Time+ Rows []VMInventoryRow+}++// VMInventoryRow captures a single VM's current inventory state.+type VMInventoryRow struct {+ ResourceID string+ Instance string+ Node string+ VMID int+ Name string+ Status string+ CPUCores int+ MemoryAllocatedBytes int64+ DiskAllocatedBytes int64+ DiskUsedBytes int64+ DiskStatusReason string+}++var vmInventoryCSVHeaders = []string{+ "Resource ID",+ "Instance",+ "Node",+ "VMID",+ "VM Name",+ "Status",+ "CPU Cores",+ "Memory Allocated Bytes",+ "Disk Allocated Bytes",+ "Disk Used Bytes",+ "Disk Status Reason",+}++// GenerateVMInventoryCSV renders a spreadsheet-friendly CSV export for the+// current VM inventory state.+func GenerateVMInventoryCSV(data VMInventoryData) ([]byte, error) {+ var buf bytes.Buffer+ w := csv.NewWriter(&buf)++ if err := w.Write(vmInventoryCSVHeaders); err != nil {+ return nil, fmt.Errorf("write VM inventory CSV header: %w", err)+ }++ rows := append([]VMInventoryRow(nil), data.Rows...)+ sort.SliceStable(rows, func(i, j int) bool {+ left := rows[i]+ right := rows[j]+ switch {+ case left.Instance != right.Instance:+ return left.Instance < right.Instance+ case left.Node != right.Node:+ return left.Node < right.Node+ case left.Name != right.Name:+ return left.Name < right.Name+ case left.VMID != right.VMID:+ return left.VMID < right.VMID+ default:+ return left.ResourceID < right.ResourceID+ }+ })++ for _, row := range rows {+ record := []string{+ row.ResourceID,+ row.Instance,+ row.Node,+ strconv.Itoa(row.VMID),+ row.Name,+ row.Status,+ strconv.Itoa(row.CPUCores),+ strconv.FormatInt(row.MemoryAllocatedBytes, 10),+ strconv.FormatInt(row.DiskAllocatedBytes, 10),+ strconv.FormatInt(row.DiskUsedBytes, 10),+ row.DiskStatusReason,+ }+ if err := w.Write(record); err != nil {+ return nil, fmt.Errorf("write VM inventory CSV row for %q: %w", row.ResourceID, err)+ }+ }++ w.Flush()+ if err := w.Error(); err != nil {+ return nil, fmt.Errorf("flush VM inventory CSV: %w", err)+ }++ return buf.Bytes(), nil+}diff --git a/pkg/reporting/vm_inventory_test.go b/pkg/reporting/vm_inventory_test.gonew file mode 100644index 0000000000..4186cac5c9--- /dev/null+++ b/pkg/reporting/vm_inventory_test.go@@ -0,0 +1,57 @@+package reporting++import (+ "strings"+ "testing"+)++func TestGenerateVMInventoryCSV_SortsRowsAndWritesHeader(t *testing.T) {+ data := VMInventoryData{+ Rows: []VMInventoryRow{+ {+ ResourceID: "vm-20",+ Instance: "lab-b",+ Node: "node-2",+ VMID: 20,+ Name: "beta",+ Status: "online",+ CPUCores: 4,+ MemoryAllocatedBytes: 8192,+ DiskAllocatedBytes: 20000,+ DiskUsedBytes: 15000,+ },+ {+ ResourceID: "vm-10",+ Instance: "lab-a",+ Node: "node-1",+ VMID: 10,+ Name: "alpha",+ Status: "warning",+ CPUCores: 2,+ MemoryAllocatedBytes: 4096,+ DiskAllocatedBytes: 10000,+ DiskUsedBytes: 5000,+ DiskStatusReason: "guest agent offline",+ },+ },+ }++ got, err := GenerateVMInventoryCSV(data)+ if err != nil {+ t.Fatalf("GenerateVMInventoryCSV returned error: %v", err)+ }++ lines := strings.Split(strings.TrimSpace(string(got)), "\n")+ if len(lines) != 3 {+ t.Fatalf("expected header plus two rows, got %d lines: %q", len(lines), string(got))+ }+ if !strings.Contains(lines[0], "Resource ID,Instance,Node,VMID,VM Name") {+ t.Fatalf("expected spreadsheet-friendly header row, got %q", lines[0])+ }+ if !strings.Contains(lines[1], "vm-10,lab-a,node-1,10,alpha,warning,2,4096,10000,5000,guest agent offline") {+ t.Fatalf("expected rows sorted by instance/node/name, got first data row %q", lines[1])+ }+ if !strings.Contains(lines[2], "vm-20,lab-b,node-2,20,beta,online,4,8192,20000,15000,") {+ t.Fatalf("expected second data row for vm-20, got %q", lines[2])+ }+}