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 1 commit
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 IPMI port of the BaseboardManagement.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be HTTP/Redfish, can you make this wording generic? Can you state what a default value is, if any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think default would be 623. I can set a kubebuilder:default

// +kubebuilder:validation:MinLength=1
Port string `json:"port"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be an Int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it as string because bmclib expects port as a string. But we can change it to int if that makes more sense 👍


// 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:
description: Port is the IPMI port of the BaseboardManagement.
minLength: 1
type: string
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
3 changes: 1 addition & 2 deletions controllers/baseboardmanagement_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,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, 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