Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ipmi port to BaseboardManagement type #4

Merged
merged 2 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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