Documentation
¶
Index ¶
- func CanUpdateVirtualMachine(vm *armcompute.VirtualMachine) bool
- func CheckAndDeleteLeftoverNICsAndDisks(ctx context.Context, factory access.Factory, vmName string, ...) error
- func ConstructCreateMachineResponse(location string, vmName string) *driver.CreateMachineResponse
- func ConstructGetMachineStatusResponse(location string, vmName string) *driver.GetMachineStatusResponse
- func ConstructMachineListResponse(location string, vmNames []string) *driver.ListMachinesResponse
- func CreateDisksWithImageRef(ctx context.Context, factory access.Factory, ...) (map[DataDiskLun]DiskID, error)
- func CreateNICIfNotExists(ctx context.Context, factory access.Factory, ...) (string, error)
- func CreateVM(ctx context.Context, factory access.Factory, ...) (*armcompute.VirtualMachine, error)
- func DecodeAndValidateMachineClassProviderSpec(mcc *v1alpha1.MachineClass) (api.AzureProviderSpec, error)
- func DeleteVirtualMachine(ctx context.Context, vmAccess *armcompute.VirtualMachinesClient, ...) error
- func DeriveInstanceID(location, vmName string) string
- func DetermineAzureCloudConfiguration(cloudConfiguration *api.CloudConfiguration) cloud.Configuration
- func ExtractCredentialsFromData(data map[string][]byte, keys ...string) string
- func ExtractProviderSpecAndConnectConfig(mcc *v1alpha1.MachineClass, secret *corev1.Secret) (api.AzureProviderSpec, access.ConnectConfig, error)
- func ExtractVMNamesFromVMsNICsDisks(ctx context.Context, factory access.Factory, ...) ([]string, error)
- func GetDiskNames(providerSpec api.AzureProviderSpec, vmName string) []string
- func GetSubnet(ctx context.Context, factory access.Factory, ...) (*armnetwork.Subnet, error)
- func IsVirtualMachineInTerminalState(vm *armcompute.VirtualMachine) bool
- func LogVMCreation(location, resourceGroup string, vm *armcompute.VirtualMachine)
- func ProcessVMImageConfiguration(ctx context.Context, factory access.Factory, ...) (imgRef armcompute.ImageReference, plan *armcompute.Plan, err error)
- func SkipDeleteMachine(ctx context.Context, factory access.Factory, ...) (bool, error)
- func UpdateCascadeDeleteOptions(ctx context.Context, providerSpec api.AzureProviderSpec, ...) error
- func ValidateSecretAndCreateConnectConfig(secret *corev1.Secret, cloudConfiguration *api.CloudConfiguration) (access.ConnectConfig, error)
- type DataDiskLun
- type DiskID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanUpdateVirtualMachine ¶
func CanUpdateVirtualMachine(vm *armcompute.VirtualMachine) bool
CanUpdateVirtualMachine checks if the VM is not in terminal state and if there are no data disks marked for detachment.
func CheckAndDeleteLeftoverNICsAndDisks ¶
func CheckAndDeleteLeftoverNICsAndDisks(ctx context.Context, factory access.Factory, vmName string, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec) error
CheckAndDeleteLeftoverNICsAndDisks creates tasks for NIC and DISK deletion and runs them concurrently. It waits for them to complete and then returns a consolidated error if there is any. This method will be called when these resources are left without an associated VM.
func ConstructCreateMachineResponse ¶
func ConstructCreateMachineResponse(location string, vmName string) *driver.CreateMachineResponse
ConstructCreateMachineResponse constructs response for driver.CreateMachine method.
func ConstructGetMachineStatusResponse ¶
func ConstructGetMachineStatusResponse(location string, vmName string) *driver.GetMachineStatusResponse
ConstructGetMachineStatusResponse constructs response for driver.GetMachineStatus method.
func ConstructMachineListResponse ¶
func ConstructMachineListResponse(location string, vmNames []string) *driver.ListMachinesResponse
ConstructMachineListResponse constructs response for driver.ListMachines method.
func CreateDisksWithImageRef ¶ added in v0.14.0
func CreateDisksWithImageRef(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, vmName string) (map[DataDiskLun]DiskID, error)
CreateDisksWithImageRef creates a disk with CreationData (e.g. ImageReference or GalleryImageReference)
func CreateNICIfNotExists ¶
func CreateNICIfNotExists(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, subnet *armnetwork.Subnet, nicName string) (string, error)
CreateNICIfNotExists creates a NIC if it does not exist.
func CreateVM ¶
func CreateVM(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, vmImageRef armcompute.ImageReference, plan *armcompute.Plan, secret *corev1.Secret, nicID string, vmName string, imageRefDiskIDs map[DataDiskLun]DiskID) (*armcompute.VirtualMachine, error)
CreateVM gathers the VM creation parameters and invokes a call to create or update the VM.
func DecodeAndValidateMachineClassProviderSpec ¶
func DecodeAndValidateMachineClassProviderSpec(mcc *v1alpha1.MachineClass) (api.AzureProviderSpec, error)
DecodeAndValidateMachineClassProviderSpec decodes v1alpha1.MachineClass.ProviderSpec.Raw into api.AzureProviderSpec. It also handles deprecated fields and ensures that the replacement fields are populated. A validated api.AzureProviderSpec is returned. In case there is an error during unmarshalling or validation an error will be returned.
func DeleteVirtualMachine ¶
func DeleteVirtualMachine(ctx context.Context, vmAccess *armcompute.VirtualMachinesClient, resourceGroup string, vmName string) error
DeleteVirtualMachine deletes the VirtualMachine, if there is any error it will wrap it into a status.Status error.
func DeriveInstanceID ¶
DeriveInstanceID creates an instance ID from location and VM name.
func DetermineAzureCloudConfiguration ¶
func DetermineAzureCloudConfiguration(cloudConfiguration *api.CloudConfiguration) cloud.Configuration
DetermineAzureCloudConfiguration returns the Azure cloud.Configuration corresponding to the instance given by the provided api.Configuration.
func ExtractCredentialsFromData ¶
ExtractCredentialsFromData extracts and trims a value from the given data map. The first key that exists is being returned, otherwise, the next key is tried, etc. If no key exists then an empty string is returned.
func ExtractProviderSpecAndConnectConfig ¶
func ExtractProviderSpecAndConnectConfig(mcc *v1alpha1.MachineClass, secret *corev1.Secret) (api.AzureProviderSpec, access.ConnectConfig, error)
ExtractProviderSpecAndConnectConfig extracts api.AzureProviderSpec from mcc and access.ConnectConfig from secret.
func ExtractVMNamesFromVMsNICsDisks ¶
func ExtractVMNamesFromVMsNICsDisks(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, resourceGroup string, providerSpec api.AzureProviderSpec) ([]string, error)
ExtractVMNamesFromVMsNICsDisks leverages resource graph to extract names from VMs, NICs and Disks (OS and Data disks).
func GetDiskNames ¶
func GetDiskNames(providerSpec api.AzureProviderSpec, vmName string) []string
GetDiskNames creates disk names for all configured OSDisk and DataDisk in the provider spec.
func GetSubnet ¶
func GetSubnet(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec) (*armnetwork.Subnet, error)
GetSubnet gets the subnet for the subnet configuration in the provider config.
func IsVirtualMachineInTerminalState ¶
func IsVirtualMachineInTerminalState(vm *armcompute.VirtualMachine) bool
IsVirtualMachineInTerminalState checks if the provisioningState of the VM is set to Failed.
func LogVMCreation ¶
func LogVMCreation(location, resourceGroup string, vm *armcompute.VirtualMachine)
LogVMCreation is a convenience method which helps to extract relevant details from the created virtual machine and logs it. Today the azure create VM call is atomic only w.r.t creation of VM, OSDisk, DataDisk(s). NIC still has to be created prior to creation of the VM. Therefore, this method produces a log which also prints the OSDisk, DataDisks that are created (which helps in traceability). For completeness it also prints the NIC that now gets associated to this VM.
func ProcessVMImageConfiguration ¶
func ProcessVMImageConfiguration(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, vmName string) (imgRef armcompute.ImageReference, plan *armcompute.Plan, err error)
ProcessVMImageConfiguration gets the image configuration from provider spec. If the VM image configured is a marketplace image then it will additionally do the following: 1. Gets the VM image. If the image does not exist then it will return an error. 2. From the VM Image it checks if there is a plan. 3. If there is a plan then it will check if there is an existing agreement for this plan. If an agreement does not exist then it will return an error. 4. If the agreement has not been accepted yet then it will accept the agreement and update the agreement. If that fails then it will return an error.
func SkipDeleteMachine ¶
func SkipDeleteMachine(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, resourceGroup string) (bool, error)
SkipDeleteMachine checks if ResourceGroup exists. If it does not exist then there is no need to delete any resource as it is assumed that none would exist.
func UpdateCascadeDeleteOptions ¶
func UpdateCascadeDeleteOptions(ctx context.Context, providerSpec api.AzureProviderSpec, vmAccess *armcompute.VirtualMachinesClient, resourceGroup string, vm *armcompute.VirtualMachine) error
UpdateCascadeDeleteOptions updates the VirtualMachine properties and sets cascade delete options for NIC and DISKs if it is not already set. Once that is set then it deletes the VM. This will ensure that no separate calls to delete each NIC and DISK are made as they will get deleted along with the VM in one single atomic call.
func ValidateSecretAndCreateConnectConfig ¶
func ValidateSecretAndCreateConnectConfig(secret *corev1.Secret, cloudConfiguration *api.CloudConfiguration) (access.ConnectConfig, error)
ValidateSecretAndCreateConnectConfig validates the secret and creates an instance of azure.ConnectConfig out of it.
Types ¶
type DataDiskLun ¶ added in v0.14.0
type DataDiskLun int32
DataDiskLun is a type alias for int32 which semantically represents a dataDisk lun