IVirtualMachineOperations
The six primitive operations a virtualisation environment must offer for virtual machines to behave like database records. One implementation per environment; everything above this seam is provider neutral, which is what let one test base span Hyper-V and Proxmox.
|
Note
|
StopAsync(VirtualMachineSettings, CancellationToken), ChangeAsync(VirtualMachineSettings, CancellationToken) and StartAsync(VirtualMachineSettings, CancellationToken) are separate on purpose: an update of a running machine is stop → change → restart, and a single "reboot" verb would collapse the first and third step and hide the second.
|
public interface IVirtualMachineOperations
1. Properties
1.1. CanApplyChanges
Gets a value indicating whether ChangeAsync(VirtualMachineSettings, CancellationToken) actually APPLIES field changes.
bool CanApplyChanges { get; }
1.2. CanSoftDelete
Gets a value indicating whether this environment can MARK a machine as deleted rather than destroy it.
bool CanSoftDelete { get; }
1.3. EnvironmentName
Gets the name of the environment, used for diagnostics and fallback keys.
MachineName EnvironmentName { get; }
2. Methods
2.1. ChangeAsync(VirtualMachineSettings, CancellationToken)
Apply the changed fields of an existing virtual machine.
Task ChangeAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record carrying the desired field values. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.
2.2. DeleteAsync(VirtualMachineSettings, CancellationToken)
Remove a virtual machine, for real. Its disks go with it.
Task DeleteAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to remove. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.
2.3. Exists()
Gets a value indicating whether the environment is reachable.
bool Exists()
Returns: bool — when the environment answer.
2.4. InsertAsync(VirtualMachineSettings, CancellationToken)
Create a virtual machine.
Task InsertAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to create. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.
2.5. ReadAsync(CancellationToken)
Read every virtual machine currently in the environment.
Task<IReadOnlyList<VirtualMachineSettings>> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task<IReadOnlyList<VirtualMachineSettings>> — The live record set.
2.6. SoftDeleteAsync(VirtualMachineSettings, CancellationToken)
Mark a virtual machine as deleted: stop it and rename it with the marker prefix.
Task SoftDeleteAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to mark. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.
2.7. StartAsync(VirtualMachineSettings, CancellationToken)
Start a stopped virtual machine.
Task StartAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to start. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.
2.8. StopAsync(VirtualMachineSettings, CancellationToken)
Stop a running virtual machine.
Task StopAsync(VirtualMachineSettings record, CancellationToken cancellationToken = default(CancellationToken))
| Name | Type | Description |
|---|---|---|
record |
VirtualMachineSettings |
Record to stop. |
cancellationToken |
CancellationToken |
Cancellation token. |
Returns: Task — A task.