Skip to content

Commit

Permalink
Adding ipmi port to BaseboardManagement type (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored May 17, 2022
2 parents 0732a9c + 26f3ea5 commit 4a1c506
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/v1alpha1/baseboardmanagement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ type Connection struct {
// +kubebuilder:validation:MinLength=1
Host string `json:"host"`

// Port is the port number for connecting with the BaseboardManagement.
// +kubebuilder:default:=623
Port int `json:"port"`

// AuthSecretRef is the SecretReference that contains authentication information of the BaseboardManagement.
// The Secret must contain username and password keys.
AuthSecretRef corev1.SecretReference `json:"authSecretRef"`
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/bmc.tinkerbell.org_baseboardmanagements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ spec:
insecureTLS:
description: InsecureTLS specifies trusted TLS connections.
type: boolean
port:
default: 623
description: Port is the port number for connecting with the BaseboardManagement.
type: integer
required:
- authSecretRef
- host
- insecureTLS
- port
type: object
power:
description: Power is the desired power state of the BaseboardManagement.
Expand Down
1 change: 1 addition & 0 deletions config/samples/bmc_v1alpha1_baseboardmanagement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
spec:
connection:
host: 0.0.0.0
port: 623
authSecretRef:
name: bm-auth
namespace: sample
Expand Down
4 changes: 2 additions & 2 deletions controllers/baseboardmanagement_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"strconv"
"strings"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -114,9 +115,8 @@ func (r *BaseboardManagementReconciler) reconcile(ctx context.Context, bm *bmcv1
return ctrl.Result{Requeue: true}, fmt.Errorf("resolving BaseboardManagement %s/%s SecretReference: %v", bm.Namespace, bm.Name, err)
}

// TODO (pokearu): Remove port hardcoding
// Initializing BMC Client
bmcClient, err := r.bmcClientFactory(ctx, bm.Spec.Connection.Host, "623", username, password)
bmcClient, err := r.bmcClientFactory(ctx, bm.Spec.Connection.Host, strconv.Itoa(bm.Spec.Connection.Port), username, password)
if err != nil {
logger.Error(err, "BMC connection failed", "host", bm.Spec.Connection.Host)
result, setConditionErr := r.setCondition(ctx, bm, bmPatch, bmcv1alpha1.ConnectionError, err.Error())
Expand Down
1 change: 1 addition & 0 deletions controllers/baseboardmanagement_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func getBaseboardManagement() *bmcv1alpha1.BaseboardManagement {
Spec: bmcv1alpha1.BaseboardManagementSpec{
Connection: bmcv1alpha1.Connection{
Host: "0.0.0.0",
Port: 623,
AuthSecretRef: corev1.SecretReference{
Name: "test-bm-auth",
Namespace: "test-namespace",
Expand Down

0 comments on commit 4a1c506

Please sign in to comment.