github.com/openshift/installer@v1.4.17/pkg/types/ovirt/machinepool.go (about) 1 package ovirt 2 3 import "fmt" 4 5 // MachinePool stores the configuration for a machine pool installed 6 // on ovirt. 7 type MachinePool struct { 8 // InstanceTypeID defines the VM instance type and overrides 9 // the hardware parameters of the created VM, including cpu and memory. 10 // If InstanceTypeID is passed, all memory and cpu variables will be ignored. 11 InstanceTypeID string `json:"instanceTypeID,omitempty"` 12 13 // CPU defines the VM CPU. 14 // +optional 15 CPU *CPU `json:"cpu,omitempty"` 16 17 // MemoryMB is the size of a VM's memory in MiBs. 18 // +optional 19 MemoryMB int32 `json:"memoryMB,omitempty"` 20 21 // OSDisk is the the root disk of the node. 22 // +optional 23 OSDisk *Disk `json:"osDisk,omitempty"` 24 25 // VMType defines the workload type of the VM. 26 // +kubebuilder:validation:Enum="";desktop;server;high_performance 27 // +optional 28 VMType VMType `json:"vmType,omitempty"` 29 30 // AffinityGroupsNames contains a list of oVirt affinity group names that the newly created machines will join. 31 // The affinity groups should exist on the oVirt cluster or created by the OpenShift installer. 32 // +optional 33 AffinityGroupsNames []string `json:"affinityGroupsNames"` 34 35 // AutoPinningPolicy defines the policy to automatically set the CPU 36 // and NUMA including pinning to the host for the instance. 37 // When the field is omitted the default will be "none". 38 // +optional 39 AutoPinningPolicy AutoPinningPolicy `json:"autoPinningPolicy,omitempty"` 40 41 // Hugepages is the size of a VM's hugepages to use in KiBs. 42 // +optional 43 Hugepages Hugepages `json:"hugepages,omitempty"` 44 45 // Clone makes sure that the disks are cloned from the template and are not linked. 46 // Defaults to true for high performance and server VM types, false for desktop types. 47 // 48 // Note: this option is not documented in the OpenShift documentation. This is intentional as it has sane defaults 49 // that shouldn't be changed unless needed for debugging or resolving issues in cooperation with Red Hat support. 50 // 51 // +optional 52 Clone *bool `json:"clone,omitempty"` 53 54 // Sparse indicates that sparse provisioning should be used and disks should be not preallocated. 55 // +optional 56 Sparse *bool `json:"sparse,omitempty"` 57 58 // Format is the disk format that the disks are in. Can be "cow" or "raw". "raw" disables several features that 59 // may be needed, such as incremental backups. 60 // +kubebuilder:validation:Enum="";raw;cow 61 // +optional 62 Format string `json:"format,omitempty"` 63 } 64 65 // Disk defines a VM disk 66 type Disk struct { 67 // SizeGB size of the bootable disk in GiB. 68 SizeGB int64 `json:"sizeGB"` 69 } 70 71 // CPU defines the VM cpu, made of (Sockets * Cores). 72 type CPU struct { 73 // Sockets is the number of sockets for a VM. 74 // Total CPUs is (Sockets * Cores) 75 Sockets int32 `json:"sockets"` 76 77 // Cores is the number of cores per socket. 78 // Total CPUs is (Sockets * Cores) 79 Cores int32 `json:"cores"` 80 81 // Threads is the number of CPU threads. 82 Threads int32 `json:"threads"` 83 } 84 85 // VMType defines the type of the VM, which will change the VM configuration, 86 // like including or excluding devices (like excluding sound-card), 87 // device configuration (like using multi-queues for vNic), and several other 88 // configuration tweaks. This doesn't effect properties like CPU count and amount of memory. 89 type VMType string 90 91 const ( 92 // VMTypeDesktop set the VM type to desktop. Virtual machines optimized to act 93 // as desktop machines do have a sound card, use an image (thin allocation), 94 // and are stateless. 95 VMTypeDesktop VMType = "desktop" 96 // VMTypeServer sets the VM type to server. Virtual machines optimized to act 97 // as servers have no sound card, use a cloned disk image, and are not stateless. 98 VMTypeServer VMType = "server" 99 // VMTypeHighPerformance sets a VM type to high_performance which sets various 100 // properties of a VM to optimize for performance, like enabling headless mode, 101 // disabling usb, smart-card, and sound devices, enabling host cpu pass-through, 102 // multi-queues for vNics and several more items. 103 // See https://www.ovirt.org/develop/release-management/features/virt/high-performance-vm.html. 104 VMTypeHighPerformance VMType = "high_performance" 105 ) 106 107 // AutoPinningPolicy defines the policy to automatically set the CPU 108 // and NUMA including pinning to the host for the instance. 109 // +kubebuilder:validation:Enum=none;resize_and_pin 110 type AutoPinningPolicy string 111 112 const ( 113 // AutoPinningNone - will mean to do nothing, leaving the VM configuration 114 // as is. 115 AutoPinningNone AutoPinningPolicy = "none" 116 // AutoPinningResizeAndPin - will override the CPU and NUMA topology to fit the host, 117 // including pinning them to get maximal performance. 118 AutoPinningResizeAndPin AutoPinningPolicy = "resize_and_pin" 119 ) 120 121 // Hugepages is the size of a VM's hugepages to use in KiBs. 122 // The VM will consume its memory from the host using the host 123 // hugepages. 124 // In order to run the VM, the host should have enough hugepages 125 // with the specific size. 126 // +kubebuilder:validation:Enum=2048;1048576 127 type Hugepages int32 128 129 func (h Hugepages) String() string { 130 return fmt.Sprintf("%d", h) 131 } 132 133 const ( 134 // Hugepages2MB for using 2MB hugepages. 135 Hugepages2MB Hugepages = 2048 136 // Hugepages1GB for using 1GB hugepages. 137 Hugepages1GB Hugepages = 1048576 138 ) 139 140 // Set sets the values from `required` to `p`. 141 func (p *MachinePool) Set(required *MachinePool) { 142 if required == nil || p == nil { 143 return 144 } 145 146 if required.InstanceTypeID != "" { 147 p.InstanceTypeID = required.InstanceTypeID 148 } 149 150 if required.VMType != "" { 151 p.VMType = required.VMType 152 } 153 154 if required.CPU != nil { 155 p.CPU = required.CPU 156 } 157 158 if required.MemoryMB != 0 { 159 p.MemoryMB = required.MemoryMB 160 } 161 162 if required.OSDisk != nil { 163 p.OSDisk = required.OSDisk 164 } 165 166 if len(required.AffinityGroupsNames) > 0 { 167 p.AffinityGroupsNames = required.AffinityGroupsNames 168 } 169 170 if required.AutoPinningPolicy != "" { 171 p.AutoPinningPolicy = required.AutoPinningPolicy 172 } 173 174 if required.Hugepages > 0 { 175 p.Hugepages = required.Hugepages 176 } 177 178 p.Clone = required.Clone 179 p.Format = required.Format 180 p.Sparse = required.Sparse 181 }