Skip to content

Commit 46cba0b

Browse files
Add dell poweredge R6415 to probe (#140)
* 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 <jakobweinstock@gmail.com> * 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 <jakobweinstock@gmail.com> * 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 <jakobweinstock@gmail.com>
1 parent 614319b commit 46cba0b

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

discover/probe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424

2525
var (
2626
idrac8SysDesc = []string{"PowerEdge M630", "PowerEdge R630"}
27-
idrac9SysDesc = []string{"PowerEdge M640", "PowerEdge R640"}
27+
idrac9SysDesc = []string{"PowerEdge M640", "PowerEdge R640", "PowerEdge R6415", "PowerEdge R6515"}
2828
m1000eSysDesc = []string{"PowerEdge M1000e"}
2929
)
3030

examples/main.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,18 @@ func main() {
4646

4747
func withUserDefinedLogger(ip, user, pass string, logger *logrus.Logger) (interface{}, error) {
4848
myLog := logrusr.NewLogger(logger)
49-
opts := func(o *discover.Options) {
50-
o.Logger = myLog
51-
}
5249

53-
return discover.ScanAndConnect(ip, user, pass, opts)
50+
return discover.ScanAndConnect(ip, user, pass, discover.WithLogger(myLog))
5451
}
5552

5653
func withDefaultBuiltinLogger(ip, user, pass string) (interface{}, error) {
5754
return discover.ScanAndConnect(ip, user, pass)
5855
}
5956

6057
func printStatus(connection interface{}, logger *logrus.Logger) {
61-
switch connection.(type) {
58+
switch con := connection.(type) {
6259
case devices.Bmc:
63-
conn := connection.(devices.Bmc)
60+
conn := con
6461
defer conn.Close()
6562

6663
sr, err := conn.Serial()
@@ -97,7 +94,8 @@ func printStatus(connection interface{}, logger *logrus.Logger) {
9794
logger.WithFields(logrus.Fields{"state": state}).Info("state")
9895

9996
case devices.Cmc:
100-
cmc := connection.(devices.Cmc)
97+
cmc := con
98+
defer cmc.Close()
10199
sts, err := cmc.Status()
102100
if err != nil {
103101
logger.Fatal(err)

providers/dell/idrac9/idrac9.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ func New(ctx context.Context, host string, username string, password string, log
4747
return nil, err
4848
}
4949

50-
return &IDrac9{ip: host, username: username, password: password, sshClient: sshClient, ctx: ctx, log: log}, nil
50+
idrac := &IDrac9{ip: host, username: username, password: password, sshClient: sshClient, ctx: ctx, log: log}
51+
err = idrac.httpLogin()
52+
if err != nil {
53+
return nil, err
54+
}
55+
56+
return idrac, nil
5157
}
5258

5359
// CheckCredentials verify whether the credentials are valid or not

0 commit comments

Comments
 (0)