VirtualMachineBuilder

Fluent builder for a VirtualMachineSettings. Every property is set through a With... call, so one description of a machine can be inserted into ANY environment.

Note
The same built record goes to Hyper-V and to Proxmox unchanged - the provider decide how to realise it. That is the whole point of treating a machine as a row: you write the row once.
public sealed class VirtualMachineBuilder : IBuilder<VirtualMachineSettings>

1. Constructors

1.1. VirtualMachineBuilder()

Initialises a new instance of the VirtualMachineBuilder class.

public VirtualMachineBuilder()

1.2. VirtualMachineBuilder(VirtualMachineSettings)

Initialises a new instance of the VirtualMachineBuilder class from a record.

public VirtualMachineBuilder(VirtualMachineSettings record)
Table 1. Parameters
Name Type Description

record

VirtualMachineSettings

Record to copy.

2. Methods

2.1. Build()

Build the record.

public VirtualMachineSettings Build()

Returns: VirtualMachineSettings — The record.

2.2. Create()

Start a new builder.

public static VirtualMachineBuilder Create()

Returns: VirtualMachineBuilder — The builder.

2.3. From(VirtualMachineSettings)

Start a builder pre-filled from an existing record.

public static VirtualMachineBuilder From(VirtualMachineSettings record)
Table 2. Parameters
Name Type Description

record

VirtualMachineSettings

Record to copy.

Returns: VirtualMachineBuilder — The builder.

2.4. WithAutoStart(bool)

public VirtualMachineBuilder WithAutoStart(bool autoStart = true)
Table 3. Parameters
Name Type Description

autoStart

bool

Returns: VirtualMachineBuilder

2.5. WithCores(int)

Set the processor core count.

public VirtualMachineBuilder WithCores(int cores)
Table 4. Parameters
Name Type Description

cores

int

Core count.

Returns: VirtualMachineBuilder — This builder.

2.6. WithDisk(DataSize)

Set the primary disk size.

public VirtualMachineBuilder WithDisk(DataSize disk)
Table 5. Parameters
Name Type Description

disk

DataSize

Disk size, built with DataSize.Parse.

Returns: VirtualMachineBuilder — This builder.

2.7. WithIsVirtualMachine(bool)

Set whether the machine start right after insert. Set whether this row describe a REAL virtual machine.

public VirtualMachineBuilder WithIsVirtualMachine(bool isVirtualMachine)
Table 6. Parameters
Name Type Description

isVirtualMachine

bool

False for a physical machine no hypervisor can create.

Returns: VirtualMachineBuilder — This builder.

2.8. WithIso(ISubPath)

Set the boot image NAME. Never a rooted path - the provider resolve it.

public VirtualMachineBuilder WithIso(ISubPath iso)
Table 7. Parameters
Name Type Description

iso

ISubPath

Boot image name below the provider image root.

Returns: VirtualMachineBuilder — This builder.

2.9. WithIsoStorage(StorageName)

Set the storage the boot image live on.

public VirtualMachineBuilder WithIsoStorage(StorageName isoStorage)
Table 8. Parameters
Name Type Description

isoStorage

StorageName

Storage name.

Returns: VirtualMachineBuilder — This builder.

2.10. WithKey(VirtualMachineKey)

Set the primary key.

public VirtualMachineBuilder WithKey(VirtualMachineKey key)
Table 9. Parameters
Name Type Description

key

VirtualMachineKey

Key value.

Returns: VirtualMachineBuilder — This builder.

2.11. WithMacAddress(MAC?)

Set the NIC MAC address the guest is created with.

public VirtualMachineBuilder WithMacAddress(MAC? macAddress)
Table 10. Parameters
Name Type Description

macAddress

MAC?

MAC the guest NIC carry. Null let the environment pick one.

Returns: VirtualMachineBuilder — This builder.

2.12. WithMemory(DataSize)

Set the memory.

public VirtualMachineBuilder WithMemory(DataSize memory)
Table 11. Parameters
Name Type Description

memory

DataSize

Memory, built with DataSize.Parse.

Returns: VirtualMachineBuilder — This builder.

2.13. WithName(MachineName)

Set the machine name.

public VirtualMachineBuilder WithName(MachineName name)
Table 12. Parameters
Name Type Description

name

MachineName

Machine name.

Returns: VirtualMachineBuilder — This builder.

2.14. WithNetwork(VirtualSwitchName)

Set the virtual switch or bridge to attach.

public VirtualMachineBuilder WithNetwork(VirtualSwitchName networkName)
Table 13. Parameters
Name Type Description

networkName

VirtualSwitchName

Switch or bridge name.

Returns: VirtualMachineBuilder — This builder.

2.15. WithOperatingSystem(SystemManagement.Contracts.Elements.OperatingSystem)

Set the operating system.

public VirtualMachineBuilder WithOperatingSystem(SystemManagement.Contracts.Elements.OperatingSystem operatingSystem)
Table 14. Parameters
Name Type Description

operatingSystem

SystemManagement.Contracts.Elements.OperatingSystem

Operating system.

Returns: VirtualMachineBuilder — This builder.

2.16. WithPowerState(VirtualMachinePowerState)

Set the expected power state of the record.

public VirtualMachineBuilder WithPowerState(VirtualMachinePowerState powerState)
Table 15. Parameters
Name Type Description

powerState

VirtualMachinePowerState

Power state.

Returns: VirtualMachineBuilder — This builder.

2.17. WithSerialNumber(SerialNumber)

Set the BIOS serial number the guest is created with.

public VirtualMachineBuilder WithSerialNumber(SerialNumber serialNumber)
Table 16. Parameters
Name Type Description

serialNumber

SerialNumber

Serial the guest report. Empty let the environment pick one.

Returns: VirtualMachineBuilder — This builder.

2.18. WithStorage(StorageName)

Set the storage the disk is created on.

public VirtualMachineBuilder WithStorage(StorageName storage)
Table 17. Parameters
Name Type Description

storage

StorageName

Storage name.

Returns: VirtualMachineBuilder — This builder.

2.19. WithVmId(VmId)

Set the numeric id within the environment.

public VirtualMachineBuilder WithVmId(VmId vmId)
Table 18. Parameters
Name Type Description

vmId

VmId

Numeric id. VmId.None let the provider pick.

Returns: VirtualMachineBuilder — This builder.