Hyper-V
Edition: PROPro ENTERPRISEEnterprise
What it does
The Hyper-V connector reads a Microsoft Hyper-V host and keeps NetBox in step with it. Each run reads the host, its virtual switches and its virtual machines with their network adapters, VLANs and disks, then makes a plan of what would change in NetBox. Nothing is written until an operator applies the plan (see Collect, review and approve).
cinqstack reads the host over SSH (OpenSSH Server, built into Windows Server 2019 and later) and runs only read commands. Nothing is installed, changed or written on the host. Every command it runs is listed on What each connector reads.
When a plan is applied, cinqstack writes:
| In NetBox | What is written |
|---|---|
| Clusters | The host's cluster, with the cluster type set on the job: the Windows failover cluster the host belongs to, by its name; a host that is in none is its own cluster, named after the host. |
| Virtual machines | Name, status, site, cluster, host device, vCPUs, memory (the VM's startup memory), platform (the guest OS), tenant, tag, and the first line of the VM's notes as its description. |
| VM interfaces | One per network adapter, numbered in order (Network Adapter 1, Network Adapter 2), with its MAC address, connected or not, the virtual switch in the description, and the adapter's access VLAN as its untagged VLAN. |
| IP addresses | The addresses the guest reports, with their prefix length, and the guest's DNS name. The first IPv4 address becomes the VM's primary IP. |
| Virtual disks | One per virtual hard disk, named by its controller slot (for example SCSI 0:0), with its size. |
| The Hyper-V host | Only when it already exists as a NetBox device: serial, cluster, platform (the Windows edition) and the management IP, on an interface named after the host's virtual Ethernet adapter, for example vEthernet (OT-EXT). |
Power state maps to NetBox status: Running is Active; Off, Saved and Paused are Offline.
Guest data. The guest OS, the DNS name and the IP addresses come from the guest itself, through the Hyper-V Data Exchange (KVP) integration service. Windows guests report them out of the box. Linux guests need the Hyper-V daemons (hv_kvp_daemon, in the linux-cloud-tools or hyperv-daemons package). Appliances often report nothing: their VMs are still synced, without guest OS, DNS name or addresses.
Identity. Every object the sync owns carries the hyperv_id custom field: the host's hardware ID and the VM's own ID. A renamed VM is therefore an update, never a duplicate. Objects already in NetBox without the field are adopted on first match: a VM by name within its site, the host by serial and then by short name, a cluster by name within its site.
Changes between runs. Each run compares the host with the previous run of the same job and records every VM that was added, removed or changed. Guest details that disappear because the guest stopped reporting (VM off, integration services stopped) are left out. Each change gets risk labels and waits for someone to acknowledge it (see VM changes).
What it needs in NetBox
- The
hyperv_idcustom field on virtual machines, clusters and devices. It is part of the schema pack: create it under Settings › NetBox schema. See The NetBox schema. - Sites whose slugs match the scope rules. A rule that names a site NetBox lacks syncs nothing.
- The Hyper-V host as a device, at the site its scope rule maps to, for host details to be written. The sync never creates host devices.
- Tenants named on scope rules must already exist. A tag slug NetBox does not know is created when the plan is applied.
- VLANs at the site, for VM interfaces to get their VLAN. If no VLAN with that ID is available at the site, the interface is written without one.
- A NetBox write token, for apply only.
Created on demand, if missing: the cluster type, platforms (one per guest OS and Windows edition) and the hyperv-orphan tag.
If the optional last_synced and sync_source fields exist, each written VM and host gets the time and cinqstack Hyper-V sync.
Setting up
1. Prepare the host
On the Hyper-V host:
- Turn on OpenSSH Server (Windows Server 2019 and later: Settings › Apps › Optional features, or
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0) and allow TCP 22 from the cinqstack server. - Create an account for cinqstack and add it to the local Hyper-V Administrators group. That group can read every VM and can also change them: Windows has no read-only role for Hyper-V. cinqstack only reads, but protect the account as a privileged one. To read virtual disk sizes, the account also needs read access to the disk files; without it, disks are left out with a warning and the rest of the run is complete.
2. Add a connection
An admin opens Connectors › Hyper-V and clicks Connections. Each connection is one Hyper-V host.
| Field | What to enter |
|---|---|
| Name | A name for the list, for example "Halden Hyper-V 01". Blank uses the host. |
| Host | The host name or IP address, for example hv01.halden.example. |
| SSH port | 22 by default. |
| Username | The cinqstack account, for example svc-cinqstack or HALDEN\svc-cinqstack. |
| Password | The account's password, or the passphrase of the private key. Stored encrypted. |
| Private key | Optional: an OpenSSH private key (Ed25519, ECDSA or RSA) instead of a password. Stored encrypted. |
Then choose:
- Test connects and shows
Connected to <host>:<port>: <host name>, <Windows edition>, <n> VMs (account: <rights>). Host key <key type>. The connection works; save it when ready.The rights arelocal administrator,Hyper-V Administratorsorlimited rights. Nothing is saved. - Test and save saves the connection if the test passes, and pins the host's SSH key. If the host later presents a different key, runs stop until the connection is tested and saved again.
A connection that a job uses cannot be deleted: That connection is used by a job.
3. Create a job
An operator or admin clicks New job on the Connectors › Hyper-V page.
| Field | Default | What it does |
|---|---|---|
| Name | A name for the job. | |
| Hyper-V host | The connection to read. | |
| NetBox cluster type | Microsoft Hyper-V | The cluster type for new clusters. Created if missing. |
| VM names | * | Which VMs to read, as a pattern such as PLANT-*. The filter runs on the host: other VMs are never read. |
| Guest OS, DNS name and IP addresses from the guests | on | Reads the KVP data. Turn it off if the host is slow to answer it. |
| Time limit per step (s) | 60 | Each part of the read (VMs, adapters, disks) stops after this long; the rest of the run goes on. Guest data has its own limit: it stops after 30 seconds. |
| Time limit for the whole read (s) | 240 | The read on the host ends after this long, whatever is still running. |
| The Hyper-V host (serial, cluster, Windows version, management IP) when it exists in NetBox | on | Writes host details to the matching device. |
| VM network adapters, MAC addresses and access VLANs | on | Writes VM interfaces. |
| Guest IP addresses, DNS names and primary IP | on | Writes the addresses the guests report. Needs interfaces on. |
| Skip IPs of powered-off VMs | off | Leaves addresses alone for VMs that are not running. |
| Virtual disks | on | Writes virtual disks. |
| VMs that disappear from Hyper-V | Mark offline and tag hyperv-orphan | Or Leave them alone. VMs are never deleted. |
| Enabled | on | A disabled job is not run by its schedule. |
Schedule, What happens after a run and Safety limit work as for every sync job (see vCenter).
4. Add scope rules
Scope rules decide which VMs go to which NetBox site. Rules run top to bottom (lowest Order first) and the first match wins. A rule with no site excludes what it matches. Anything no rule matches is left out.
| When | Matches on |
|---|---|
| Host name matches (regex) | The Hyper-V host name. Also places the host's own cluster. |
| Cluster name matches (regex; a standalone host is its own cluster) | The failover cluster's name, or for a standalone host its own name. |
| VM name matches (regex) | The VM name. |
| Everything else | Anything still unmatched. |
For a host whose VMs all belong to one site, one Host name rule is enough. Patterns ignore upper and lower case.
5. Run it
On the Connectors › Hyper-V page, click Run now beside the job, or use the arrow next to it and choose Run with debug log. Scheduled runs start on their own.
To collect through a Relay edge ENTERPRISEEnterprise, route the job under Connectors › Relay › Routes. The edge then connects to the host over SSH; the password and key travel sealed.
Problems with SSH, rights or slow hosts are covered in Hyper-V troubleshooting.
Reading the results
The run page
Each run has a page at /hyperv/runs/<run id>, with the same status, tiles, report, plan and apply result as a vCenter run.
The report has one group of its own: Some details could not be read from the host. It lists each part of the read that timed out or was refused, and VMs whose guests report no KVP data. The rest of the inventory is complete.
A run with nothing to write ends as analysed rather than waiting for review. When the host's answer looks incomplete (no VMs where the last run had some, or far fewer), nothing is retired: the report shows Looked gone, kept this run, the run waits for review whatever the automation level, and the next complete run decides again. When the connection now reaches a different host, that run is a fresh baseline and no VM is reported as removed.
VM changes
Each recorded VM change appears under Review › Changes (filter on Virtual machines) with the device and vCenter changes; the Connectors › Hyper-V page shows how many wait, with a link there. Each opens a page with what changed (before and after), the VM's power, vCPUs, memory and disk, its host, site and addresses, its network adapters, and earlier changes to the same VM.
An operator or admin acknowledges a change with an optional Ticket and Note, then Acknowledge, or several at once on Review › Changes. cinqstack then writes a journal entry on the VM in NetBox naming who acknowledged it, the ticket and the note (unless journal entries are turned off). A VM removed before it ever reached NetBox gets no entry.
Findings it raises
Findings appear in the Findings inbox PROPro.
From the Hyper-V connector:
| Finding | Severity |
|---|---|
Hyper-V host <name> is not in NetBox | Low |
<VM>: <risk labels>, one per VM change not yet acknowledged | The change's highest risk, below |
The Virtual view of the topology draws Hyper-V hosts and VMs next to vCenter's, and raises the same checks on them (zone mixing on a host, VMs with adapters in OT and IT networks, VLANs a host's switch port does not carry). Each vSwitch and VLAN pair is drawn as one network.
Risk labels on a VM change. A VM counts as part of the control system when its name, NetBox role, notes or guest DNS name contain words such as SCADA, HMI, historian, EWS, PLC, OPC, DCS, MES or safety.
| Label | Severity |
|---|---|
| Control-system VM removed from Hyper-V, Control-system VM powered off, stopped (saved) or stopped (paused) | High |
| VM removed from Hyper-V, VM powered off, stopped (saved) or stopped (paused) | Medium |
| New VM on OT VLAN … (a VLAN classified level 0 to 3) | High |
| New VM | Low |
| Moved off an OT network, from VLAN … to VLAN …, Moved onto an OT network, from VLAN … to VLAN … | High |
| VLAN changed, from VLAN … to VLAN …, vSwitch changed (same VLAN) | High for a control-system VM or an OT VLAN, otherwise medium |
| Network adapter disconnected | High for a control-system VM, otherwise medium |
| Network adapter added, removed or reconnected, IP address changed | Medium |
| Resources changed, Renamed, Guest OS changed | Low |
Limits
- Read-only towards Hyper-V. Only read commands run on the host; nothing is changed or written there.
- One host per connection. When the host belongs to a Windows failover cluster, cinqstack reads the cluster's name from that host and files the host and its VMs under it; it does not read the cluster's other nodes or their VMs, its roles or shared volumes, Live Migration between hosts, or System Center VMM.
- SSH only. WinRM is not supported yet.
- Least privilege. The rights above are those Microsoft documents for reading Hyper-V.
- Guest data needs integration services in the guest. Without them a VM has no guest OS, DNS name or addresses. Only addresses with a prefix length are written, and only an IPv4 address becomes the primary IP.
- Only access VLANs are written. An adapter in trunk mode gets no VLAN; its allowed VLANs are in the interface description.
- Disks whose size cannot be read are left out (the account needs read access to the disk files).
- Apply deletes VM interfaces and virtual disks that are gone from the host, and only those the plan lists: the run page shows each one before you apply, and the count is part of the run summary. A VM the host could not read in full keeps all of its adapters and disks. Nothing else is deleted in NetBox. VMs that leave the host are marked offline (and give up their primary IP), and only at sites this job's rules sync to.
- Addresses. An address already in NetBox is adopted whatever its prefix length. An address on a VM this connector retired moves to the live VM; an address on anything else is left alone, and the run names the holder.
- Duplicate Hyper-V ids. When two NetBox VMs carry the same Hyper-V id, one is synced and the run warns about the other.
- Hosts are never created. Add the Hyper-V host to NetBox yourself.
- Change tracking starts with the second run of a job, and compares only with that job's previous run.