Skip to content

Commit

Permalink
providers/dell: adds a helper method and implements Inventory(), Powe…
Browse files Browse the repository at this point in the history
…rSet(), PowerStateGet() methods
  • Loading branch information
joelrebel committed Nov 28, 2023
1 parent 37d8981 commit e14321b
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions providers/dell/idrac.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ var (
)

type Config struct {
HttpClient *http.Client
Port string
// VersionsNotCompatible is the list of incompatible redfish versions.
//
// With this option set, The bmclib.Registry.FilterForCompatible(ctx) method will not proceed on
// devices with the given redfish version(s).
HttpClient *http.Client
Port string
VersionsNotCompatible []string
RootCAs *x509.CertPool
UseBasicAuth bool
Expand Down Expand Up @@ -126,19 +122,26 @@ func (c *Conn) Open(ctx context.Context) (err error) {

// because this uses the redfish interface and the redfish interface
// is available across various BMC vendors, we verify the device we're connected to is dell.
manufacturer, err := c.deviceManufacturer(ctx)
if err != nil {
if err := c.deviceSupported(ctx); err != nil {
if er := c.redfishwrapper.Close(ctx); er != nil {
return fmt.Errorf("%v: %w", err, er)
}

return err
}

if !strings.Contains(strings.ToLower(manufacturer), common.VendorDell) {
if er := c.redfishwrapper.Close(ctx); er != nil {
return fmt.Errorf("%v: %w", err, er)
}
return bmclibErrs.ErrIncompatibleProvider
return nil
}

func (c *Conn) deviceSupported(ctx context.Context) error {
manufacturer, err := c.deviceManufacturer(ctx)
if err != nil {
return err
}

m := strings.ToLower(manufacturer)
if !strings.Contains(m, common.VendorDell) {
return errors.Wrap(bmclibErrs.ErrIncompatibleProvider, m)
}

return nil
Expand Down Expand Up @@ -192,6 +195,16 @@ func (c *Conn) PowerStateGet(ctx context.Context) (state string, err error) {
return c.redfishwrapper.SystemPowerStatus(ctx)
}

// PowerSet sets the power state of a server
func (c *Conn) PowerSet(ctx context.Context, state string) (ok bool, err error) {
return c.redfishwrapper.PowerSet(ctx, state)
}

// Inventory collects hardware inventory and install firmware information
func (c *Conn) Inventory(ctx context.Context) (device *common.Device, err error) {
return c.redfishwrapper.Inventory(ctx, false)
}

var errManufacturerUnknown = errors.New("error identifying device manufacturer")

// deviceManufacturer returns the device manufacturer and model attributes
Expand Down

0 comments on commit e14321b

Please sign in to comment.