Skip to content

Commit

Permalink
Add dell poweredge R6415 to probe (#140)
Browse files Browse the repository at this point in the history
* Add dell poweredge R6415 and R6515 to probe:

Enable discovery of dell poweredge R6415 and R6515 machines
using idrac9 so we can interact with them.

Signed-off-by: Jacob Weinstock <[email protected]>

* Add httpClient to new iDrac9 client:

The `New` idrac9 function was not setting the httpClient and
xsrfToken so that functions like configuring users works properly.

Signed-off-by: Jacob Weinstock <[email protected]>

* Update example/main.go:

Simplify the example of passing in a logger to
`ScanAndConnect` and only type assert once in
`printStatus`, for clearer understanding and
simplicity.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock authored Oct 30, 2020
1 parent 614319b commit 46cba0b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion discover/probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
)

Expand Down
12 changes: 5 additions & 7 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,18 @@ 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) {
return discover.ScanAndConnect(ip, user, pass)
}

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()
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion providers/dell/idrac9/idrac9.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46cba0b

Please sign in to comment.