Documentation
¶
Overview ¶
Package complexity provides pure, stateless functions for scoring VM migration complexity. It has no dependency on the HTTP layer or database and is designed to be unit-tested in isolation.
Two independent scoring dimensions are supported:
OS complexity (scores 0–4): derived by substring-matching the VM's OS name against OSDifficultyScores. Score 1 is the least complex; score 0 means the OS is unknown and complexity can not be assessed.
Disk complexity (scores 1–4): derived from the pre-computed disk-size tier labels stored in the inventory by the agent. Score 1 is the least complex; score 4 is the most complex.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DiskScores = []Score{1, 2, 3, 4}
DiskScores lists all valid disk complexity scores in canonical order.
var DiskSizeScores = map[string]Score{
"Easy (0-10TB)": 1,
"Medium (10-20TB)": 2,
"Hard (20-50TB)": 3,
"White Glove (>50TB)": 4,
}
DiskSizeScores maps the pre-computed inventory tier label strings (produced by the agent) to numeric complexity scores. The thresholds follow complexity.md:
Score 1 — provisioned disk ≤ 10 TB Score 2 — provisioned disk ≤ 20 TB Score 3 — provisioned disk ≤ 50 TB Score 4 — provisioned disk > 50 TB
Edit this map to adjust disk complexity scoring.
var OSDifficultyScores = map[string]Score{
"Red Hat Enterprise Linux 4": 2,
"Red Hat Enterprise Linux 5": 2,
"Red Hat Enterprise Linux 6": 1,
"Red Hat Enterprise Linux 7": 1,
"Red Hat Enterprise Linux 8": 1,
"Red Hat Enterprise Linux 9": 1,
"Red Hat Enterprise Linux 10": 1,
"Red Hat Fedora": 1,
"CentOS 4": 2,
"CentOS 5": 2,
"CentOS 6": 1,
"CentOS 7": 1,
"CentOS 8": 1,
"CentOS 9": 1,
"Oracle Linux 4": 2,
"Oracle Linux 5": 2,
"Oracle Linux 6": 1,
"Oracle Linux 7": 1,
"Oracle Linux 8": 1,
"Oracle Linux 9": 1,
"Rocky Linux 8": 1,
"Rocky Linux 9": 1,
"AlmaLinux 8": 3,
"AlmaLinux 9": 3,
"SUSE Linux Enterprise 8": 3,
"SUSE Linux Enterprise 9": 3,
"SUSE Linux Enterprise 10": 3,
"SUSE Linux Enterprise 11": 3,
"SUSE Linux Enterprise 12": 2,
"SUSE Linux Enterprise 15": 2,
"SUSE openSUSE": 3,
"Ubuntu Linux 18.04": 3,
"Ubuntu Linux 20.04": 3,
"Ubuntu Linux 22.04": 3,
"Ubuntu Linux 24.04": 3,
"Ubuntu Linux": 3,
"Debian GNU/Linux 5": 3,
"Debian GNU/Linux 6": 3,
"Debian GNU/Linux 7": 3,
"Debian GNU/Linux 8": 3,
"Debian GNU/Linux 9": 3,
"Debian GNU/Linux 10": 3,
"Debian GNU/Linux 11": 3,
"Debian GNU/Linux 12": 3,
"Microsoft Windows Server 2000": 3,
"Microsoft Windows Server 2003": 3,
"Microsoft Windows Server 2008 R2": 3,
"Microsoft Windows Server 2008": 3,
"Microsoft Windows Server 2012 R2": 3,
"Microsoft Windows Server 2012": 3,
"Microsoft Windows Server 2016": 2,
"Microsoft Windows Server 2019": 2,
"Microsoft Windows Server 2022": 2,
"Microsoft Windows Server 2025": 2,
"Microsoft Windows XP": 3,
"Microsoft Windows Vista": 3,
"Microsoft Windows 7": 3,
"Microsoft Windows 8": 3,
"Microsoft Windows 10": 2,
"Microsoft Windows 11": 2,
"Oracle Solaris 10": 3,
"Oracle Solaris 11": 3,
"FreeBSD": 3,
"VMware Photon OS": 3,
"Amazon Linux 2": 3,
"CoreOS Linux": 3,
"Apple macOS": 3,
"Microsoft SQL": 4,
}
OSDifficultyScores maps OS name substrings to numeric complexity scores. ClassifyOS checks whether each key is a case-insensitive substring of the VM's OS name.
When multiple keys match the same OS name, all matching keys carry the same score, so non-deterministic map iteration order does not affect the result.
Score semantics:
0 = unknown (no key matched) 1 = score 1 easiest 2 = score 2 3 = score 3 4 = score 4 hardest
var OSScores = []Score{0, 1, 2, 3, 4}
OSScores lists all valid OS complexity scores in canonical order.
Functions ¶
func DiskSizeRangeRatings ¶
DiskSizeRangeRatings returns the DiskSizeScores map with keys reformatted to contain only the numeric range portion of each tier label (e.g. "Easy (0-10TB)" becomes "0-10TB"). Use this when exposing the lookup table in API responses so that UI-level label words ("Easy", "Hard", etc.) do not bleed into the data layer.
Types ¶
type DiskComplexityEntry ¶
DiskComplexityEntry is one row in the disk complexity breakdown.
func DiskBreakdown ¶
func DiskBreakdown(tiers []DiskTierInput) []DiskComplexityEntry
DiskBreakdown maps pre-computed inventory tier labels to numeric scores and returns a slice of DiskComplexityEntry in canonical score order (1–4). All four scores are always present; absent scores carry VMCount == 0 and TotalSizeTB == 0.
type DiskTierInput ¶
type DiskTierInput struct {
Label string // Tier label as stored in the inventory (key in vms.diskSizeTier)
VMCount int
TotalSizeTB float64
}
DiskTierInput represents a pre-computed disk size tier from the inventory.
type OSDifficultyEntry ¶
OSDifficultyEntry is one row in the OS complexity breakdown.
func OSBreakdown ¶
func OSBreakdown(osEntries []VMOsEntry) []OSDifficultyEntry
OSBreakdown classifies each OS entry by numeric score and returns a slice of OSDifficultyEntry in canonical score order (0–4). All five scores are always present; absent scores carry VMCount == 0.
type OSNameEntry ¶ added in v0.8.0
OSNameEntry is one row in the per-OS-name complexity breakdown.
func OSNameBreakdown ¶ added in v0.8.0
func OSNameBreakdown(osEntries []VMOsEntry) []OSNameEntry
OSNameBreakdown returns one OSNameEntry per distinct OS name in osEntries.
type Score ¶
type Score = int
Score is a numeric complexity level. Lower values indicate simpler migrations. OS scores run 0–4; disk scores run 1–4.
func ClassifyOS ¶
ClassifyOS returns the numeric complexity score for the given OS name by checking whether each key in OSDifficultyScores appears as a case-insensitive substring of osName. Returns 0 if no key matches (unknown).
func ScoreDiskTierLabel ¶
ScoreDiskTierLabel returns the numeric score for an inventory disk tier label. Returns 0 if the label is not in DiskSizeScores.