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)
| 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)
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to copy. |
Returns: VirtualMachineBuilder — The builder.
2.4. WithAutoStart(bool)
public VirtualMachineBuilder WithAutoStart(bool autoStart = true)
| Name | Type | Description |
|---|---|---|
autoStart |
bool |
Returns: VirtualMachineBuilder
2.5. WithCores(int)
Set the processor core count.
public VirtualMachineBuilder WithCores(int cores)
| 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)
| Name | Type | Description |
|---|---|---|
disk |
DataSize |
Disk size, built with |
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)
| 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)
| 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)
| Name | Type | Description |
|---|---|---|
isoStorage |
StorageName |
Storage name. |
Returns: VirtualMachineBuilder — This builder.
2.10. WithKey(VirtualMachineKey)
Set the primary key.
public VirtualMachineBuilder WithKey(VirtualMachineKey key)
| 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)
| 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)
| Name | Type | Description |
|---|---|---|
memory |
DataSize |
Memory, built with |
Returns: VirtualMachineBuilder — This builder.
2.13. WithName(MachineName)
Set the machine name.
public VirtualMachineBuilder WithName(MachineName name)
| 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)
| 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)
| 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)
| 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)
| 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)
| 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)
| Name | Type | Description |
|---|---|---|
vmId |
VmId |
Numeric id. |
Returns: VirtualMachineBuilder — This builder.