in pkg/providers/instance/instance.go [381:449]
func newVMObject(opts *createVMOptions) *armcompute.VirtualMachine {
if opts.LaunchTemplate.IsWindows {
return &armcompute.VirtualMachine{} // TODO(Windows)
}
vm := &armcompute.VirtualMachine{
Name: lo.ToPtr(opts.VMName), // TODO: I think it's safe to set this, even though it's read only
Location: lo.ToPtr(opts.Location),
Identity: ConvertToVirtualMachineIdentity(opts.NodeIdentities),
Properties: &armcompute.VirtualMachineProperties{
HardwareProfile: &armcompute.HardwareProfile{
VMSize: lo.ToPtr(armcompute.VirtualMachineSizeTypes(opts.InstanceType.Name)),
},
StorageProfile: &armcompute.StorageProfile{
OSDisk: &armcompute.OSDisk{
Name: lo.ToPtr(opts.VMName),
DiskSizeGB: opts.NodeClass.Spec.OSDiskSizeGB,
CreateOption: lo.ToPtr(armcompute.DiskCreateOptionTypesFromImage),
DeleteOption: lo.ToPtr(armcompute.DiskDeleteOptionTypesDelete),
},
},
NetworkProfile: &armcompute.NetworkProfile{
NetworkInterfaces: []*armcompute.NetworkInterfaceReference{
{
ID: &opts.NicReference,
Properties: &armcompute.NetworkInterfaceReferenceProperties{
Primary: lo.ToPtr(true),
DeleteOption: lo.ToPtr(armcompute.DeleteOptionsDelete),
},
},
},
},
OSProfile: &armcompute.OSProfile{
AdminUsername: lo.ToPtr("azureuser"),
ComputerName: &opts.VMName,
LinuxConfiguration: &armcompute.LinuxConfiguration{
DisablePasswordAuthentication: lo.ToPtr(true),
SSH: &armcompute.SSHConfiguration{
PublicKeys: []*armcompute.SSHPublicKey{
{
KeyData: lo.ToPtr(opts.SSHPublicKey),
Path: lo.ToPtr("/home/" + "azureuser" + "/.ssh/authorized_keys"),
},
},
},
},
},
Priority: lo.ToPtr(armcompute.VirtualMachinePriorityTypes(
CapacityTypeToPriority[opts.CapacityType]),
),
},
Zones: utils.MakeVMZone(opts.Zone),
Tags: opts.LaunchTemplate.Tags,
}
setVMPropertiesOSDiskType(vm.Properties, opts.LaunchTemplate.StorageProfile)
setImageReference(vm.Properties, opts.LaunchTemplate.ImageID, opts.UseSIG)
setVMPropertiesBillingProfile(vm.Properties, opts.CapacityType)
if opts.ProvisionMode == consts.ProvisionModeBootstrappingClient {
vm.Properties.OSProfile.CustomData = lo.ToPtr(opts.LaunchTemplate.CustomScriptsCustomData)
} else {
vm.Properties.OSProfile.CustomData = lo.ToPtr(opts.LaunchTemplate.ScriptlessCustomData)
}
return vm
}