# cray-hpe/metal-init architecture

> Architecture diagram of the GitHub repository cray-hpe/metal-init, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cray-hpe/metal-init
- Repository: https://github.com/cray-hpe/metal-init

## Overview

##### Project type & purpose (what you’re diagramming)
This is **not a typical service/app**; it’s an **operations/tooling repository**: a **Pre-Install Toolkit (PIT) automation bundle** made of **shell scripts + config artifacts** intended to run inside (or emulate) a **Cray Pre-Install Toolkit environment**.

- **Execution environment(s)** (PIT live image / emulated PIT)
- **Operator entrypoints**
- **Script modules** grouped by function (BIOS, networking, NTP, image/SQFS handling, initialization)
- **External systems/devices** the scripts control (BMC/IPMI, NICs/bonds/VLANs, time sources)
- **Artifacts** (INI/JSON configs, spec file, Makefile) and **CI automation** (GitHub workflows, Jenkinsfile)

A good mental model: **a toolkit pipeline that configures bare-metal nodes pre-install**.

##### File structure analysis → architectural modules
Top-level structure is flat, but the **`bin/` directory is the product**.

##### Core modules (by file grouping)
**A. BIOS / hardware baseline**
- `bin/bios-baseline.sh`
- `bin/bios-hpe-baseline.ini` (baseline settings)
- `bin/bios-hpe-enable-ipmitool.json` (likely vendor/tool-specific config/commands)

**B. Network bring-up / CSI (node) setup**
- `bin/csi-pxe-bond0.sh`
- `bin/csi-pxe-hmn.sh`
- `bin/csi-set-hostname.sh`
- `bin/csi-setup-bond0.sh`
- `bin/csi-setup-hmn.sh`
- `bin/csi-setup-lan0.sh`

These suggest a **sequence**: PXE context scripts vs post-boot setup scripts; configuring interfaces like **bond0**, **HMN**, **lan0**, and setting hostname.

**C. Time configuration**
- `bin/configure-ntp.sh`

**D. PIT initialization / identity**
- `bin/pit-init.sh`
- `bin/metalid.sh` (likely generates/reads a “metal ID”, serial, MAC-based identifier, etc.)

**E. Image / filesystem artifacts (SQFS)**
- `bin/get-sqfs.sh`
- `bin/set-sqfs-links.sh`

This implies interactions with a **remote artifact store** or local cache; the PIT environment may mount or link **squashfs** images.

##### Packaging / build / CI artifacts
- `Makefile` (local build/test/lint/package tasks)
- `metal-init.spec` (RPM spec packaging)
- `.github/workflows/*` (labeling, merge strategy, shellcheck, stale issues)
- `Jenkinsfile.github` (CI pipeline, likely for enterprise Jenkins mirroring GitHub)

##### README insights
README is minimal but confirms the key: “scripts and config files for running on a Cray Pre-Install Toolkit, or emulating such an environment.”

##### Initialization & Identity
- `pit-init.sh`
- `metalid.sh`
- Outputs: machine identity facts, initialization state, maybe local files under `/etc` or `/var`

##### BIOS Baseline
- `bios-baseline.sh`
- Inputs: `bios-hpe-baseline.ini`, `bios-hpe-enable-ipmitool.json`
- External: BMC/IPMI / vendor BIOS interface
- Outputs: BIOS settings applied, logs

##### Networking (CSI Setup)
- `csi-setup-bond0.sh`, `csi-pxe-bond0.sh`
- `csi-setup-hmn.sh`, `csi-pxe-hmn.sh`
- `csi-setup-lan0.sh`
- `csi-set-hostname.sh`
- External: NICs, OS network stack, potentially DHCP/PXE environment
- Outputs: interface configs, routes, hostname, link state

##### Time Sync
- `configure-ntp.sh`
- External: NTP servers
- Outputs: NTP client config / service state

##### Image/Artifact Handling
- `get-sqfs.sh`
- `set-sqfs-links.sh`
- External: artifact store
- Outputs: downloaded SQFS, symlinks/mount points

**“Packaging & Delivery”** as a separate lane (not inside runtime):
- `metal-init.spec` → RPM build artifact
- `Makefile` → build/lint/package entrypoints
- GitHub Workflows / Jenkinsfile → CI gates (ShellCheck, labeling)

- BIOS baseline may be independent or early; if it requires network/BMC access, show that dependency.

- Lane 1: Operator / Orchestrator
- Lane 2: PIT Environment
- Lane 3: Target Node / OS config
- Lane 4: BMC/IPMI
- Lane 5: Artifact repo / NTP servers

##### Result: node is baseline-ready for subsequent install stages

Make it explicit which steps are **idempotent** (likely intended) and which require reboots (BIOS changes often do).

##### Important architectural patterns/design principles to highlight

- **Config-driven operations**: INI/JSON files parameterize behavior (BIOS baseline).
- **Environment-dependent execution**: PIT vs emulated PIT.
- **Imperative orchestration**: scripts act as runbooks encoded as code.
- **Separation by concerns**: BIOS vs network vs NTP vs artifact retrieval.
- **Packaging for distribution**: RPM spec indicates this is meant to be installed as a package, not just cloned.

##### Technologies/frameworks to include (what matters here)
- **Shell scripts (bash/sh)** as primary runtime
- **IPMI / vendor BIOS tooling** (implied by “ipmitool” config and BIOS scripts)
- **NTP** (client config + NTP servers)
- **PXE** context (explicit in script names)
- **SquashFS (SQFS)** artifact handling
- **CI**: GitHub Actions (ShellCheck), Jenkins pipeline
- **Packaging**: RPM (`metal-init.spec`), Makefile build targets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% =========================
    %% Actors / Triggers
    %% =========================
    Operator["Operator / Orchestrator"]:::actor
    DocsRoot["Documentation (README.md)"]:::doc
    DocsBin["Documentation (bin/README.md)"]:::doc

    %% =========================
    %% Execution Environments
    %% =========================
    subgraph "Execution Environments"
        PITEnv["PIT Live Image (target runtime)"]:::env
        EmuPIT["Emulated PIT (dev/test VM or container)"]:::env
    end

    %% =========================
    %% PIT Toolkit Boundary (this repo)
    %% =========================
    subgraph "PIT Toolkit (shell-script automation bundle)"
        BinDir["bin/ (toolkit scripts bundle)"]:::boundary

        subgraph "Initialization & Identity"
            PitInit["pit-init.sh\n(PIT bootstrap / init)"]:::script
            MetalId["metalid.sh\n(hardware identity facts)"]:::script
        end

        subgraph "Networking (CSI setup / PXE context)"
            PxEBond0["csi-pxe-bond0.sh\n(PXE bond0 context)"]:::script
            PxEHMN["csi-pxe-hmn.sh\n(PXE HMN context)"]:::script
            SetupBond0["csi-setup-bond0.sh\n(configure bond0)"]:::script
            SetupHMN["csi-setup-hmn.sh\n(configure HMN)"]:::script
            SetupLan0["csi-setup-lan0.sh\n(configure lan0)"]:::script
            SetHostname["csi-set-hostname.sh\n(set hostname)"]:::script
        end

        subgraph "Time Sync"
            NTPConf["configure-ntp.sh\n(configure NTP client)"]:::script
        end

        subgraph "BIOS / Hardware Baseline"
            BiosBaseline["bios-baseline.sh\n(apply BIOS baseline)"]:::script
            HpeIni["bios-hpe-baseline.ini\n(baseline settings)"]:::config
            IpmiJson["bios-hpe-enable-ipmitool.json\n(vendor/tool cmds)"]:::config
        end

        subgraph "Image / Artifact Handling (SQFS)"
            GetSqfs["get-sqfs.sh\n(fetch SQFS image)"]:::script
            SetSqfsLinks["set-sqfs-links.sh\n(wire links/mountpoints)"]:::script
        end
    end

    %% =========================
    %% External Systems / Controlled Assets
    %% =========================
    subgraph "External Systems / Dependencies"
        TargetNode["Target bare-metal node(s)\n(OS config: hostname, net, time)"]:::external
        BMC["BMC / IPMI interface\n(BIOS control)"]:::external
        NetInfra["Network Infrastructure\n(DHCP/PXE, switches, VLANs)"]:::external
        NTPServers["NTP Server(s)"]:::external
        ArtifactRepo[("Artifact Repository / Web Server\n(SQFS storage)")]:::db
    end

    %% =========================
    %% Delivery Pipeline (CI / Packaging)
    %% =========================
    subgraph "Delivery Pipeline (build, CI, packaging)"
        MakefileNode["Makefile\n(build/lint/package entrypoints)"]:::ci
        SpecNode["metal-init.spec\n(RPM packaging spec)"]:::ci
        subgraph "CI Automation"
            GHAWorkflows["GitHub Actions Workflows\n(labeling/merge/shellcheck/stale)"]:::ci
            ShellcheckWF["shellcheck.yml\n(ShellCheck gate)"]:::ci
            Jenkins["Jenkinsfile.github\n(enterprise CI pipeline)"]:::ci
        end
        RPMArtifact["RPM package\n(distributable PIT toolkit)"]:::artifact
        PITInstall["Installed onto PIT image/environment"]:::env
    end

    %% =========================
    %% Control Flow / Typical Runtime Sequence (vertical)
    %% =========================
    Operator -->|"boots_or_enters"| PITEnv
    Operator -->|"runs_scripts_in"| EmuPIT

    Operator -->|"reads"| DocsRoot
    Operator -->|"reads"| DocsBin
    DocsRoot -->|"guides_usage_of"| BinDir
    DocsBin -->|"details_scripts_in"| BinDir

    PITEnv -->|"executes"| PitInit
    EmuPIT -->|"executes"| PitInit

    PitInit -->|"invokes"| MetalId
    MetalId -->|"feeds_identity"| SetHostname

    PitInit -->|"runs_after_init"| SetupBond0
    PitInit -->|"runs_after_init"| SetupHMN
    PitInit -->|"runs_after_init"| SetupLan0

    PxEBond0 -->|"PXE_context_for"| SetupBond0
    PxEHMN -->|"PXE_context_for"| SetupHMN

    SetupBond0 -->|"configures"| TargetNode
    SetupHMN -->|"configures"| TargetNode
    SetupLan0 -->|"configures"| TargetNode
    SetHostname -->|"writes_hostname"| TargetNode

    SetupBond0 -->|"depends_on"| NetInfra
    SetupHMN -->|"depends_on"| NetInfra
    SetupLan0 -->|"depends_on"| NetInfra
    PxEBond0 -->|"requires"| NetInfra
    PxEHMN -->|"requires"| NetInfra

    SetupBond0 -->|"enables_network_for"| GetSqfs
    SetupHMN -->|"enables_network_for"| GetSqfs
    SetupLan0 -->|"enables_network_for"| GetSqfs

    PitInit -->|"runs_after_init"| NTPConf
    NTPConf -->|"syncs_time_with"| NTPServers
    NTPConf -->|"writes_time_config"| TargetNode

    PitInit -->|"runs_after_init"| BiosBaseline
    BiosBaseline -->|"reads_config"| HpeIni
    BiosBaseline -->|"reads_config"| IpmiJson
    BiosBaseline -->|"issues_ipmi_commands"| BMC
    BiosBaseline -->|"applies_baseline_to"| TargetNode

    GetSqfs -->|"downloads_from"| ArtifactRepo
    GetSqfs -->|"stores_artifact_for"| SetSqfsLinks
    SetSqfsLinks -->|"creates_links_or_mounts_on"| TargetNode

    %% =========================
    %% CI / Packaging Relationships
    %% =========================
    GHAWorkflows -->|"runs"| ShellcheckWF
    MakefileNode -->|"drives"| GHAWorkflows
    MakefileNode -->|"drives"| Jenkins
    MakefileNode -->|"packages_using"| SpecNode
    SpecNode -->|"builds"| RPMArtifact
    Jenkins -->|"publishes"| RPMArtifact
    RPMArtifact -->|"installed_into"| PITInstall
    PITInstall -->|"provides_runtime_for"| BinDir
    PITInstall -->|"used_by"| PITEnv

    %% =========================
    %% Click Events (from component_mapping)
    %% =========================
    click BinDir "https://github.com/cray-hpe/metal-init/tree/main/bin/"
    click DocsRoot "https://github.com/cray-hpe/metal-init/blob/main/README.md"
    click DocsBin "https://github.com/cray-hpe/metal-init/blob/main/bin/README.md"
    click PitInit "https://github.com/cray-hpe/metal-init/blob/main/bin/pit-init.sh"
    click MetalId "https://github.com/cray-hpe/metal-init/blob/main/bin/metalid.sh"
    click BiosBaseline "https://github.com/cray-hpe/metal-init/blob/main/bin/bios-baseline.sh"
    click HpeIni "https://github.com/cray-hpe/metal-init/blob/main/bin/bios-hpe-baseline.ini"
    click IpmiJson "https://github.com/cray-hpe/metal-init/blob/main/bin/bios-hpe-enable-ipmitool.json"
    click PxEBond0 "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-pxe-bond0.sh"
    click PxEHMN "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-pxe-hmn.sh"
    click SetupBond0 "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-setup-bond0.sh"
    click SetupHMN "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-setup-hmn.sh"
    click SetupLan0 "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-setup-lan0.sh"
    click SetHostname "https://github.com/cray-hpe/metal-init/blob/main/bin/csi-set-hostname.sh"
    click NTPConf "https://github.com/cray-hpe/metal-init/blob/main/bin/configure-ntp.sh"
    click GetSqfs "https://github.com/cray-hpe/metal-init/blob/main/bin/get-sqfs.sh"
    click SetSqfsLinks "https://github.com/cray-hpe/metal-init/blob/main/bin/set-sqfs-links.sh"
    click MakefileNode "https://github.com/cray-hpe/metal-init/tree/main/Makefile"
    click SpecNode "https://github.com/cray-hpe/metal-init/blob/main/metal-init.spec"
    click GHAWorkflows "https://github.com/cray-hpe/metal-init/tree/main/.github/workflows/"
    click ShellcheckWF "https://github.com/cray-hpe/metal-init/blob/main/.github/workflows/shellcheck.yml"
    click Jenkins "https://github.com/cray-hpe/metal-init/blob/main/Jenkinsfile.github"

    %% =========================
    %% Styles (color required)
    %% =========================
    classDef actor fill:#E3F2FD,stroke:#1565C0,stroke-width:1px,color:#0D47A1
    classDef doc fill:#FFFDE7,stroke:#F9A825,stroke-width:1px,color:#5D4037
    classDef env fill:#E8F5E9,stroke:#2E7D32,stroke-width:1px,color:#1B5E20
    classDef boundary fill:#F3E5F5,stroke:#6A1B9A,stroke-width:1px,color:#4A148C
    classDef script fill:#FFF8E1,stroke:#FF8F00,stroke-width:1px,color:#5D4037
    classDef config fill:#FFF3E0,stroke:#EF6C00,stroke-width:1px,color:#4E342E
    classDef external fill:#FFEBEE,stroke:#C62828,stroke-width:1px,color:#B71C1C
    classDef db fill:#E0F7FA,stroke:#00838F,stroke-width:1px,color:#004D40
    classDef ci fill:#ECEFF1,stroke:#455A64,stroke-width:1px,color:#263238
    classDef artifact fill:#F1F8E9,stroke:#558B2F,stroke-width:1px,color:#33691E
```
