github.com/openshift/installer@v1.4.17/pkg/asset/machines/machineconfig/powersmt.go (about) 1 package machineconfig 2 3 import ( 4 "fmt" 5 6 ignutil "github.com/coreos/ignition/v2/config/util" 7 igntypes "github.com/coreos/ignition/v2/config/v3_2/types" 8 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 9 10 mcfgv1 "github.com/openshift/api/machineconfiguration/v1" 11 "github.com/openshift/installer/pkg/asset/ignition" 12 ) 13 14 // ForPowerSMT sets the SMT level for Power machines. 15 func ForPowerSMT(role string, smtLevel string) (*mcfgv1.MachineConfig, error) { 16 powerSMTUnit, err := createPowerSMTUnit(smtLevel) 17 if err != nil { 18 return nil, err 19 } 20 21 ignConfig := igntypes.Config{ 22 Ignition: igntypes.Ignition{ 23 Version: igntypes.MaxVersion.String(), 24 }, 25 Systemd: igntypes.Systemd{ 26 Units: []igntypes.Unit{ 27 { 28 Contents: &powerSMTUnit, 29 Name: fmt.Sprintf("99-%s-powersmt.service", role), 30 Enabled: ignutil.BoolToPtr(true), 31 }, 32 }, 33 }, 34 } 35 36 rawExt, err := ignition.ConvertToRawExtension(ignConfig) 37 if err != nil { 38 return nil, err 39 } 40 41 return &mcfgv1.MachineConfig{ 42 TypeMeta: metav1.TypeMeta{ 43 APIVersion: "machineconfiguration.openshift.io/v1", 44 Kind: "MachineConfig", 45 }, 46 ObjectMeta: metav1.ObjectMeta{ 47 Name: fmt.Sprintf("99-%s-powersmt", role), 48 Labels: map[string]string{ 49 "machineconfiguration.openshift.io/role": role, 50 }, 51 }, 52 Spec: mcfgv1.MachineConfigSpec{ 53 Config: rawExt, 54 }, 55 }, nil 56 } 57 58 func createPowerSMTUnit(smtLevel string) (string, error) { 59 unit := `[Unit] 60 Description=Set SMT 61 After=network-online.target 62 Before= crio.service 63 [Service] 64 Type=oneshot 65 RemainAfterExit=yes 66 ExecStart=/usr/sbin/ppc64_cpu --smt=%s 67 [Install] 68 WantedBy=multi-user.target` 69 return fmt.Sprintf(unit, smtLevel), nil 70 }