diff --git a/discover/probe.go b/discover/probe.go index 863c0550..65d7cc23 100644 --- a/discover/probe.go +++ b/discover/probe.go @@ -24,7 +24,7 @@ import ( var ( idrac8SysDesc = []string{"PowerEdge M630", "PowerEdge R630"} - idrac9SysDesc = []string{"PowerEdge M640", "PowerEdge R640"} + idrac9SysDesc = []string{"PowerEdge M640", "PowerEdge R640", "PowerEdge R6415", "PowerEdge R6515"} m1000eSysDesc = []string{"PowerEdge M1000e"} ) diff --git a/examples/main.go b/examples/main.go index 1470eebb..43b7c64d 100644 --- a/examples/main.go +++ b/examples/main.go @@ -46,11 +46,8 @@ func main() { func withUserDefinedLogger(ip, user, pass string, logger *logrus.Logger) (interface{}, error) { myLog := logrusr.NewLogger(logger) - opts := func(o *discover.Options) { - o.Logger = myLog - } - return discover.ScanAndConnect(ip, user, pass, opts) + return discover.ScanAndConnect(ip, user, pass, discover.WithLogger(myLog)) } func withDefaultBuiltinLogger(ip, user, pass string) (interface{}, error) { @@ -58,9 +55,9 @@ func withDefaultBuiltinLogger(ip, user, pass string) (interface{}, error) { } func printStatus(connection interface{}, logger *logrus.Logger) { - switch connection.(type) { + switch con := connection.(type) { case devices.Bmc: - conn := connection.(devices.Bmc) + conn := con defer conn.Close() sr, err := conn.Serial() @@ -97,7 +94,8 @@ func printStatus(connection interface{}, logger *logrus.Logger) { logger.WithFields(logrus.Fields{"state": state}).Info("state") case devices.Cmc: - cmc := connection.(devices.Cmc) + cmc := con + defer cmc.Close() sts, err := cmc.Status() if err != nil { logger.Fatal(err) diff --git a/providers/dell/idrac9/idrac9.go b/providers/dell/idrac9/idrac9.go index 01d7732f..1f0b60e1 100644 --- a/providers/dell/idrac9/idrac9.go +++ b/providers/dell/idrac9/idrac9.go @@ -47,7 +47,13 @@ func New(ctx context.Context, host string, username string, password string, log return nil, err } - return &IDrac9{ip: host, username: username, password: password, sshClient: sshClient, ctx: ctx, log: log}, nil + idrac := &IDrac9{ip: host, username: username, password: password, sshClient: sshClient, ctx: ctx, log: log} + err = idrac.httpLogin() + if err != nil { + return nil, err + } + + return idrac, nil } // CheckCredentials verify whether the credentials are valid or not