Skip to content

Commit

Permalink
Merge pull request #1278 from zaneb/profile-to-api-mod
Browse files Browse the repository at this point in the history
Move hardware profile code to the api module
  • Loading branch information
metal3-io-bot committed May 31, 2023
2 parents 21a55b1 + 6c1abd0 commit 3b28ce0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hardware
package profile

import (
"fmt"
Expand Down
12 changes: 6 additions & 6 deletions controllers/metal3.io/baremetalhost_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

metal3v1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/hardware"
"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1/profile"
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
"github.com/metal3-io/baremetal-operator/pkg/imageprovider"
"github.com/metal3-io/baremetal-operator/pkg/provisioner"
Expand Down Expand Up @@ -659,7 +659,7 @@ func getHostArchitecture(host *metal3v1alpha1.BareMetalHost) string {
host.Status.HardwareDetails.CPU.Arch != "" {
return host.Status.HardwareDetails.CPU.Arch
}
if hwprof, err := hardware.GetProfile(host.Status.HardwareProfile); err == nil {
if hwprof, err := profile.GetProfile(host.Status.HardwareProfile); err == nil {
return hwprof.CPUArch
}
return ""
Expand Down Expand Up @@ -882,7 +882,7 @@ func updateRootDeviceHints(host *metal3v1alpha1.BareMetalHost, info *reconcileIn
// precedence. Otherwise use the values from the hardware profile.
hintSource := host.Spec.RootDeviceHints
if hintSource == nil {
hwProf, err := hardware.GetProfile(host.HardwareProfile())
hwProf, err := profile.GetProfile(host.HardwareProfile())
if err != nil {
return false, errors.Wrap(err, "failed to update root device hints")
}
Expand Down Expand Up @@ -1030,14 +1030,14 @@ func getHardwareProfileName(host *metal3v1alpha1.BareMetalHost) string {
if strings.HasPrefix(host.Spec.BMC.Address, "libvirt") {
return "libvirt"
}
return hardware.DefaultProfileName
return profile.DefaultProfileName
}

func (r *BareMetalHostReconciler) matchProfile(info *reconcileInfo) (dirty bool, err error) {
hardwareProfile := getHardwareProfileName(info.host)
info.log.Info("using hardware profile", "profile", hardwareProfile)

_, err = hardware.GetProfile(hardwareProfile)
_, err = profile.GetProfile(hardwareProfile)
if err != nil {
info.log.Info("invalid hardware profile", "profile", hardwareProfile)
return
Expand Down Expand Up @@ -1139,7 +1139,7 @@ func (r *BareMetalHostReconciler) actionProvisioning(prov provisioner.Provisione
}
info.log.Info("provisioning")

hwProf, err := hardware.GetProfile(info.host.HardwareProfile())
hwProf, err := profile.GetProfile(info.host.HardwareProfile())
if err != nil {
return actionError{errors.Wrap(err,
fmt.Sprintf("could not start provisioning with bad hardware profile %s",
Expand Down
4 changes: 2 additions & 2 deletions controllers/metal3.io/host_state_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/hardware"
"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1/profile"
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
"github.com/metal3-io/baremetal-operator/pkg/provisioner"
)
Expand Down Expand Up @@ -1166,7 +1166,7 @@ func host(state metal3v1alpha1.ProvisioningState) *hostBuilder {
RootDeviceHints: &v1alpha1.RootDeviceHints{},
},
Status: metal3v1alpha1.BareMetalHostStatus{
HardwareProfile: hardware.DefaultProfileName,
HardwareProfile: profile.DefaultProfileName,
Provisioning: metal3v1alpha1.ProvisionStatus{
State: state,
BootMode: v1alpha1.DefaultBootMode,
Expand Down
8 changes: 4 additions & 4 deletions pkg/provisioner/ironic/updateopts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"

metal3v1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/hardware"
"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1/profile"
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
"github.com/metal3-io/baremetal-operator/pkg/provisioner"
"github.com/metal3-io/baremetal-operator/pkg/provisioner/ironic/clients"
Expand Down Expand Up @@ -560,7 +560,7 @@ func TestGetUpdateOptsForNodeVirtual(t *testing.T) {
}
ironicNode := &nodes.Node{}

hwProf, _ := hardware.GetProfile("libvirt")
hwProf, _ := profile.GetProfile("libvirt")
provData := provisioner.ProvisionData{
Image: *host.Spec.Image,
BootMode: metal3v1alpha1.DefaultBootMode,
Expand Down Expand Up @@ -667,7 +667,7 @@ func TestGetUpdateOptsForNodeDell(t *testing.T) {
}
ironicNode := &nodes.Node{}

hwProf, _ := hardware.GetProfile("dell")
hwProf, _ := profile.GetProfile("dell")
provData := provisioner.ProvisionData{
Image: *host.Spec.Image,
BootMode: metal3v1alpha1.DefaultBootMode,
Expand Down Expand Up @@ -1185,7 +1185,7 @@ func TestGetUpdateOptsForNodeSecureBoot(t *testing.T) {
}
ironicNode := &nodes.Node{}

hwProf, _ := hardware.GetProfile("libvirt")
hwProf, _ := profile.GetProfile("libvirt")
provData := provisioner.ProvisionData{
Image: *host.Spec.Image,
BootMode: metal3v1alpha1.UEFISecureBoot,
Expand Down
4 changes: 2 additions & 2 deletions pkg/provisioner/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

metal3v1alpha1 "github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1"
"github.com/metal3-io/baremetal-operator/pkg/hardware"
"github.com/metal3-io/baremetal-operator/apis/metal3.io/v1alpha1/profile"
"github.com/metal3-io/baremetal-operator/pkg/hardwareutils/bmc"
"github.com/metal3-io/baremetal-operator/pkg/imageprovider"
)
Expand Down Expand Up @@ -109,7 +109,7 @@ type ProvisionData struct {
Image metal3v1alpha1.Image
HostConfig HostConfigData
BootMode metal3v1alpha1.BootMode
HardwareProfile hardware.Profile
HardwareProfile profile.Profile
RootDeviceHints *metal3v1alpha1.RootDeviceHints
CustomDeploy *metal3v1alpha1.CustomDeploy
}
Expand Down

0 comments on commit 3b28ce0

Please sign in to comment.