diff --git a/client.go b/client.go index cd4f4d95..4bd09517 100644 --- a/client.go +++ b/client.go @@ -199,6 +199,7 @@ func (c *Client) registerGofishProvider() { redfish.WithUseBasicAuth(c.providerConfig.gofish.UseBasicAuth), redfish.WithPort(c.providerConfig.gofish.Port), redfish.WithEtagMatchDisabled(c.providerConfig.gofish.DisableEtagMatch), + redfish.WithSystemName(c.providerConfig.gofish.SystemName), } driverGoFish := redfish.New(c.Auth.Host, c.Auth.User, c.Auth.Pass, c.Logger, gofishOpts...) diff --git a/go.sum b/go.sum index 58a0ef34..c7e105fa 100644 --- a/go.sum +++ b/go.sum @@ -88,6 +88,7 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/internal/redfishwrapper/client.go b/internal/redfishwrapper/client.go index 9f7fb078..2172eff6 100644 --- a/internal/redfishwrapper/client.go +++ b/internal/redfishwrapper/client.go @@ -31,6 +31,7 @@ type Client struct { port string user string pass string + systemName string basicAuth bool disableEtagMatch bool versionsNotCompatible []string // a slice of redfish versions to ignore as incompatible @@ -90,6 +91,12 @@ func WithLogger(l *logr.Logger) Option { } } +func WithSystemName(name string) Option { + return func(c *Client) { + c.systemName = name + } +} + // NewClient returns a redfishwrapper client func NewClient(host, port, user, pass string, opts ...Option) *Client { if !strings.HasPrefix(host, "https://") && !strings.HasPrefix(host, "http://") { diff --git a/internal/redfishwrapper/system.go b/internal/redfishwrapper/system.go index 784e5681..4e50e908 100644 --- a/internal/redfishwrapper/system.go +++ b/internal/redfishwrapper/system.go @@ -35,7 +35,12 @@ func (c *Client) Systems() ([]*redfish.ComputerSystem, error) { return nil, err } - return c.client.Service.Systems() + s, err := c.client.Service.Systems() + if err != nil { + return nil, err + } + + return c.matchingSystem(s), nil } // Managers gets the manager instances of this service. @@ -55,3 +60,13 @@ func (c *Client) Chassis(ctx context.Context) ([]*redfish.Chassis, error) { return c.client.Service.Chassis() } + +func (c *Client) matchingSystem(systems []*redfish.ComputerSystem) []*redfish.ComputerSystem { + for _, s := range systems { + if s.Name == c.systemName { + return []*redfish.ComputerSystem{s} + } + } + + return systems +} diff --git a/lint.mk b/lint.mk index d492cc70..09ba98fd 100644 --- a/lint.mk +++ b/lint.mk @@ -20,7 +20,7 @@ LINTERS := FIXERS := GOLANGCI_LINT_CONFIG := $(LINT_ROOT)/.golangci.yml -GOLANGCI_LINT_VERSION ?= v1.53.3 +GOLANGCI_LINT_VERSION ?= v1.61.0 GOLANGCI_LINT_BIN := $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH) $(GOLANGCI_LINT_BIN): mkdir -p $(LINT_ROOT)/out/linters diff --git a/option.go b/option.go index 307024a3..3039cfdc 100644 --- a/option.go +++ b/option.go @@ -118,6 +118,12 @@ func WithRedfishEtagMatchDisabled(d bool) Option { } } +func WithRedfishSystemName(name string) Option { + return func(args *Client) { + args.providerConfig.gofish.SystemName = name + } +} + func WithIntelAMTHostScheme(hostScheme string) Option { return func(args *Client) { args.providerConfig.intelamt.HostScheme = hostScheme diff --git a/providers/redfish/redfish.go b/providers/redfish/redfish.go index 89830272..07caa920 100644 --- a/providers/redfish/redfish.go +++ b/providers/redfish/redfish.go @@ -61,6 +61,7 @@ type Config struct { UseBasicAuth bool // DisableEtagMatch disables the If-Match Etag header from being included by the Gofish driver. DisableEtagMatch bool + SystemName string } // Option for setting optional Client values @@ -96,6 +97,12 @@ func WithUseBasicAuth(useBasicAuth bool) Option { } } +func WithSystemName(name string) Option { + return func(c *Config) { + c.SystemName = name + } +} + // WithEtagMatchDisabled disables the If-Match Etag header from being included by the Gofish driver. // // As of the current implementation this disables the header for POST/PATCH requests to the System entity endpoints. @@ -120,6 +127,8 @@ func New(host, user, pass string, log logr.Logger, opts ...Option) *Conn { redfishwrapper.WithHTTPClient(defaultConfig.HttpClient), redfishwrapper.WithVersionsNotCompatible(defaultConfig.VersionsNotCompatible), redfishwrapper.WithEtagMatchDisabled(defaultConfig.DisableEtagMatch), + redfishwrapper.WithBasicAuthEnabled(defaultConfig.UseBasicAuth), + redfishwrapper.WithSystemName(defaultConfig.SystemName), } if defaultConfig.RootCAs != nil {