-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: provide a way to configure IPMI PXE method
Fixes #274 Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com> (cherry picked from commit 4cfdeda)
- Loading branch information
Showing
9 changed files
with
105 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package power provides common interface to manage power state. | ||
package power | ||
|
||
import ( | ||
"context" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/talos-systems/sidero/app/sidero-controller-manager/api/v1alpha1" | ||
"github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/api" | ||
"github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/ipmi" | ||
"github.com/talos-systems/sidero/app/sidero-controller-manager/internal/power/metal" | ||
"github.com/talos-systems/sidero/app/sidero-controller-manager/pkg/constants" | ||
) | ||
|
||
// NewManagementClient builds ManagementClient from the server spec. | ||
func NewManagementClient(ctx context.Context, client client.Client, spec *v1alpha1.ServerSpec) (metal.ManagementClient, error) { | ||
switch { | ||
case spec.BMC != nil: | ||
var err error | ||
|
||
bmcSpec := *spec.BMC | ||
|
||
if bmcSpec.User == "" { | ||
bmcSpec.User, err = bmcSpec.UserFrom.Resolve(ctx, client) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
if bmcSpec.Pass == "" { | ||
bmcSpec.Pass, err = bmcSpec.PassFrom.Resolve(ctx, client) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
if bmcSpec.Interface == "" { | ||
bmcSpec.Interface = "lanplus" | ||
} | ||
|
||
if bmcSpec.Port == 0 { | ||
bmcSpec.Port = constants.DefaultBMCPort | ||
} | ||
|
||
return ipmi.NewClient(bmcSpec) | ||
case spec.ManagementAPI != nil: | ||
return api.NewClient(*spec.ManagementAPI) | ||
default: | ||
return fakeClient{}, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters