From 7df2ded6d4b7934404623bc2b137fd67cf506b01 Mon Sep 17 00:00:00 2001 From: oothman Date: Thu, 30 Dec 2021 13:15:59 +0100 Subject: [PATCH] Upgrade the bmclib dependency (to v0.4.15). --- go.mod | 2 +- go.sum | 19 +------- .../bmc-toolbox/bmclib/internal/ipmi/ipmi.go | 29 ++++++++++++ .../bmclib/providers/dell/idrac8/idrac8.go | 14 +++--- .../bmclib/providers/dell/idrac9/idrac9.go | 6 +-- .../bmclib/providers/dell/m1000e/m1000e.go | 5 +- .../bmclib/providers/hp/c7000/c7000.go | 4 +- .../bmclib/providers/hp/c7000/configure.go | 47 ++++++++++++++----- .../bmclib/providers/hp/ilo/actions.go | 13 +++-- .../bmclib/providers/hp/ilo/ilo.go | 8 ++-- .../supermicro/supermicrox/actions.go | 2 +- .../supermicro/supermicrox/supermicrox.go | 19 ++++---- .../supermicro/supermicrox11/actions.go | 2 +- .../supermicro/supermicrox11/supermicrox.go | 19 ++++---- vendor/modules.txt | 2 +- 15 files changed, 113 insertions(+), 78 deletions(-) diff --git a/go.mod b/go.mod index e3a47fcd..005c8cb8 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/GeertJohan/go.rice v1.0.2 - github.com/bmc-toolbox/bmclib v0.4.14 + github.com/bmc-toolbox/bmclib v0.4.15 github.com/bmc-toolbox/gin-go-metrics v0.0.2 github.com/daaku/go.zipexe v1.0.1 // indirect github.com/gin-gonic/gin v1.7.2 diff --git a/go.sum b/go.sum index 65bbf9dc..b3085e8a 100644 --- a/go.sum +++ b/go.sum @@ -35,23 +35,17 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bmc-toolbox/bmclib v0.4.13 h1:JOJvQ14Ns8HL2/SW358kJHlBMPdYTKwDFeCYDORoB7Q= -github.com/bmc-toolbox/bmclib v0.4.13/go.mod h1:0WeM06Sacej9UMbt6yFtIRfrwmsl5IK2f4sAUMaNN+4= -github.com/bmc-toolbox/bmclib v0.4.14 h1:G8bBF/awNoZB4FWUJ8/roSwCoYo0e1V5jy5OkAz6W0I= -github.com/bmc-toolbox/bmclib v0.4.14/go.mod h1:9YhAIIwp9tQtlo1LZtN5Qd89e+RfvgQ62ikbreEKOs0= +github.com/bmc-toolbox/bmclib v0.4.15 h1:xoqyJet1UVqY80YmRwbwuPGeoEHMNp3ogulaEXxIlVo= +github.com/bmc-toolbox/bmclib v0.4.15/go.mod h1:9YhAIIwp9tQtlo1LZtN5Qd89e+RfvgQ62ikbreEKOs0= github.com/bmc-toolbox/gin-go-metrics v0.0.2 h1:fIyChVWWq1+7npgx0F+SZc3RSVsekPBW+bmeKaHRFF0= github.com/bmc-toolbox/gin-go-metrics v0.0.2/go.mod h1:JgW/TlIv2rVW1dIFBSUY61L4Fz4fbSQco8hd8BDxOtw= github.com/bombsimon/logrusr v1.0.0 h1:CTCkURYAt5nhCCnKH9eLShYayj2/8Kn/4Qg3QfiU+Ro= github.com/bombsimon/logrusr v1.0.0/go.mod h1:Jq0nHtvxabKE5EMwAAdgTaz7dfWE8C4i11NOltxGQpc= -github.com/cenkalti/backoff/v4 v4.0.2 h1:JIufpQLbh4DkbQoii76ItQIUFzevQSqOLZca4eamEDs= github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8Bog/87DQnVg= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -78,7 +72,6 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/gebn/bmc v0.0.0-20200904230046-a5643220ab2a h1:AyC9EwIaY0IwLIxj/tZZDdFgNQ9MJk0jlE+luzCTIMo= github.com/gebn/bmc v0.0.0-20200904230046-a5643220ab2a/go.mod h1:VlKWLGIyVIhqHRj4hp9lx20lZcSn9PgNKRmDwcyRT7w= github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813 h1:Uc+IZ7gYqAf/rSGFplbWBSHaGolEQlNLgMgSE3ccnIQ= github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813/go.mod h1:P+oSoE9yhSRvsmYyZsshflcR6ePWYLql6UU1amW13IM= @@ -149,7 +142,6 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gopacket v1.1.18 h1:lum7VRA9kdlvBi7/v2p7/zcbkduHaCH/SVVyurs7OpY= github.com/google/gopacket v1.1.18/go.mod h1:UdDNZ1OO62aGYVnPhxT1U6aI7ukYtA/kB8vaU0diBUM= github.com/google/gops v0.3.14 h1:4Gpv4sABlEsVqrtKxiSynzD0//kzjTIUwUm5UgkGILI= github.com/google/gops v0.3.14/go.mod h1:zjT9F4XsKzazOvdVad3+Zwga79UHKziX3r9TN05rVN8= @@ -260,7 +252,6 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg= github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= @@ -317,21 +308,17 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1 h1:NTGy1Ja9pByO+xAeH/qiWnLrKtr3hJPNjaVUwnjpdpA= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a h1:9ZKAASQSHhDYGoxY8uLVpewe1GDZ2vu2Tr/vTdVAkFQ= @@ -373,8 +360,6 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.7.1 h1:pM5oEahlgWv/WnHXpgbKz7iLIxRf65tye2Ci+XFK5sk= github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/stmcginnis/gofish v0.8.0/go.mod h1:BGtQsY16q48M2K6KDAs38QXtNoHrkXaY/WZ/mmyMgNc= -github.com/stmcginnis/gofish v0.12.0 h1:6UbNePjA++XkHtCKKLr7envKENxljJ1YyD8f4vS3Zeo= github.com/stmcginnis/gofish v0.12.0/go.mod h1:BGtQsY16q48M2K6KDAs38QXtNoHrkXaY/WZ/mmyMgNc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go b/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go index 7af949c8..dd2da8ea 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go +++ b/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go @@ -69,6 +69,35 @@ func (i *Ipmi) PowerCycle(ctx context.Context) (status bool, err error) { return false, fmt.Errorf("%v: %v", err, output) } +// ForceRestart does the chassis power cycle even if the chassis is turned off. +// From the RedFish spec (https://www.dmtf.org/sites/default/files/standards/documents/DSP2046_2018.1.pdf): +// Perform an immediate (non-graceful) shutdown, followed by a restart. +func (i *Ipmi) ForceRestart(ctx context.Context) (status bool, err error) { + output, err := i.run(ctx, []string{"chassis", "power", "status"}) + if err != nil { + return false, fmt.Errorf("%v: %v", err, output) + } + + command := "on" + reply := "Up/On" + if strings.HasPrefix(output, "Chassis Power is on") { + command = "cycle" + reply = "Cycle" + } else if !strings.HasPrefix(output, "Chassis Power is off") { + return false, fmt.Errorf("%v: %v", err, output) + } + + output, err = i.run(ctx, []string{"chassis", "power", command}) + if err != nil { + return false, fmt.Errorf("%v: %v", err, output) + } + + if strings.HasPrefix(output, "Chassis Power Control: "+reply) { + return true, err + } + return false, fmt.Errorf("%v: %v", err, output) +} + // PowerReset reboots the machine via bmc func (i *Ipmi) PowerReset(ctx context.Context) (status bool, err error) { output, err := i.run(ctx, []string{"chassis", "power", "reset"}) diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac8/idrac8.go b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac8/idrac8.go index fa039471..6c9ab002 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac8/idrac8.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac8/idrac8.go @@ -277,7 +277,8 @@ func (i *IDrac8) Serial() (serial string, err error) { } } } - return "", nil + + return "", fmt.Errorf("IDrac8 Serial(): Serial not found!") } // ChassisSerial returns the serial number of the chassis where the blade is attached @@ -495,7 +496,8 @@ func (i *IDrac8) Model() (model string, err error) { } } } - return model, err + + return "", fmt.Errorf("IDrac8 Model(): Model not found!") } // HardwareType returns the type of bmc we are talking to @@ -643,7 +645,7 @@ func (i *IDrac8) TempC() (temp int, err error) { func (i *IDrac8) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCount int, err error) { err = i.httpLogin() if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, err } extraHeaders := &map[string]string{ @@ -663,7 +665,7 @@ func (i *IDrac8) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCoun dellBladeProc := &dell.BladeProcessorEndpoint{} err = json.Unmarshal(response, dellBladeProc) if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, err } for _, proc := range dellBladeProc.Proccessors { @@ -673,10 +675,10 @@ func (i *IDrac8) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCoun hasHT = 2 } } - return httpclient.StandardizeProcessorName(proc.Brand), len(dellBladeProc.Proccessors), proc.CoreCount, proc.CoreCount * hasHT, err + return httpclient.StandardizeProcessorName(proc.Brand), len(dellBladeProc.Proccessors), proc.CoreCount, proc.CoreCount * hasHT, nil } - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, fmt.Errorf("IDRAC8 CPU(): No CPUs?!") } // IsBlade returns if the current hardware is a blade or not diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac9/idrac9.go b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac9/idrac9.go index 8e400173..75ce26fb 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac9/idrac9.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/idrac9/idrac9.go @@ -284,7 +284,7 @@ func (i *IDrac9) Serial() (serial string, err error) { } } - return "", nil + return "", fmt.Errorf("IDrac9 Serial(): Serial not found!") } // ChassisSerial returns the serial number of the chassis where the blade is attached @@ -538,7 +538,7 @@ func (i *IDrac9) Model() (model string, err error) { } } - return "", nil + return "", fmt.Errorf("IDrac9 Model(): Model not found!") } // HardwareType returns the type of bmc we are talking to @@ -636,7 +636,7 @@ func (i *IDrac9) TempC() (temp int, err error) { func (i *IDrac9) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCount int, err error) { err = i.loadHwData() if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, err } for _, component := range i.iDracInventory.Component { diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/m1000e/m1000e.go b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/m1000e/m1000e.go index b4c73c7e..5734c7c0 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/dell/m1000e/m1000e.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/dell/m1000e/m1000e.go @@ -112,7 +112,7 @@ func (m *M1000e) Model() (model string, err error) { if err != nil { return model, err } - return strings.TrimSpace(m.cmcJSON.Chassis.ChassisGroupMemberHealthBlob.ChassisStatus.ROChassisProductname), err + return strings.TrimSpace(m.cmcJSON.Chassis.ChassisGroupMemberHealthBlob.ChassisStatus.ROChassisProductname), nil } // Serial returns the device serial @@ -121,7 +121,8 @@ func (m *M1000e) Serial() (serial string, err error) { if err != nil { return serial, err } - return strings.ToLower(m.cmcJSON.Chassis.ChassisGroupMemberHealthBlob.ChassisStatus.ROChassisServiceTag), err + + return strings.ToLower(m.cmcJSON.Chassis.ChassisGroupMemberHealthBlob.ChassisStatus.ROChassisServiceTag), nil } // PowerKw returns the current power usage in Kw diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/c7000.go b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/c7000.go index 623183ac..504a284e 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/c7000.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/c7000.go @@ -91,12 +91,12 @@ func (c *C7000) HardwareType() (model string) { // Model returns the full device model string func (c *C7000) Model() (model string, err error) { - return c.Rimp.MP.Pn, err + return c.Rimp.MP.Pn, nil } // Serial returns the device serial func (c *C7000) Serial() (serial string, err error) { - return strings.ToLower(strings.TrimSpace(c.Rimp.Infra2.EnclSn)), err + return strings.ToLower(strings.TrimSpace(c.Rimp.Infra2.EnclSn)), nil } // PowerKw returns the current power usage in Kw diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/configure.go b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/configure.go index c907efa3..89cb3220 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/configure.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/c7000/configure.go @@ -482,6 +482,8 @@ func (c *C7000) applyAddLdapGroupBayAccess(group string) (err error) { // Implements the Configure interface. // If the user exists, updates their password. func (c *C7000) User(users []*cfgresources.User) (err error) { + // Sanity checks come first. + // This reduces the probability of succeeding with some users and failing with others. for _, cfg := range users { if cfg.Name == "" { err = errors.New("user resource expects parameter: Name") @@ -510,18 +512,25 @@ func (c *C7000) User(users []*cfgresources.User) (err error) { ) return err } + } + // Actual work. + allErrors := "" + for _, cfg := range users { username := Username{Text: cfg.Name} password := Password{Text: cfg.Password} // User account is disabled? Remove them. if !cfg.Enable { payload := RemoveUser{Username: username} - statusCode, _, _ := c.postXML(payload) - - // User doesn't exist? Nothing to do, success claimed! - if statusCode != 400 { - return nil + statusCode, _, err := c.postXML(payload) + if err != nil || statusCode != 200 { + if err == nil { + allErrors += fmt.Sprintf("Received a %d status code from the POST request to remove user %s.", statusCode, username) + } else { + allErrors += fmt.Sprintf("POST request to remove user %s failed with error: %s", username, err.Error()) + } + continue } c.log.V(1).Info("User removed.", @@ -529,14 +538,18 @@ func (c *C7000) User(users []*cfgresources.User) (err error) { "HardwareType", c.HardwareType(), "User", cfg.Name, ) - - return nil + continue } payload := AddUser{Username: username, Password: password} statusCode, _, err := c.postXML(payload) - if err != nil { - return err + if err != nil || statusCode != 200 { + if err == nil { + allErrors += fmt.Sprintf("Received a %d status code from the POST request to add user %s.", statusCode, username) + } else { + allErrors += fmt.Sprintf("POST request to add user %s failed with error: %s", username, err.Error()) + } + continue } if statusCode == 400 { @@ -550,17 +563,20 @@ func (c *C7000) User(users []*cfgresources.User) (err error) { err := c.setUserPassword(cfg.Name, cfg.Password) if err != nil { - return err + allErrors += fmt.Sprintf("Error configuring user %s: %s\n", cfg.Name, err.Error()) + continue } err = c.setUserACL(cfg.Name, cfg.Role) if err != nil { - return err + allErrors += fmt.Sprintf("Error configuring user %s: %s\n", cfg.Name, err.Error()) + continue } err = c.applyAddUserBayAccess(cfg.Name) if err != nil { - return err + allErrors += fmt.Sprintf("Error configuring user %s: %s\n", cfg.Name, err.Error()) + continue } } @@ -570,7 +586,12 @@ func (c *C7000) User(users []*cfgresources.User) (err error) { "user", cfg.Name, ) } - return nil + + if allErrors == "" { + return nil + } else { + return fmt.Errorf(allErrors) + } } func (c *C7000) setUserPassword(user string, password string) (err error) { diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/actions.go b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/actions.go index 89d7e7ea..612eb59d 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/actions.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/actions.go @@ -71,22 +71,21 @@ func (i *Ilo) PowerOff() (bool, error) { // PxeOnce makes the machine to boot via pxe once func (i *Ilo) PxeOnce() (bool, error) { - im, err := ipmi.New(i.username, i.password, i.ip) + p, err := ipmi.New(i.username, i.password, i.ip) if err != nil { return false, err } - // PXE using uefi, does't work for some models - // directly. It only works if you pxe, powercycle and - // power on. - if _, err = im.PxeOnceEfi(context.Background()); err != nil { + // PXE using UEFI does't work for some models directly. + // It only works if you PXE, PowerCycle, and PowerOn. + if _, err = p.PxeOnceEfi(context.Background()); err != nil { return false, err } - if _, err := im.PowerCycle(context.Background()); err != nil { + if _, err := p.ForceRestart(context.Background()); err != nil { return false, err } - return im.PowerOnForce(context.Background()) + return p.PowerOn(context.Background()) } // IsOn tells if a machine is currently powered on diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/ilo.go b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/ilo.go index 69fd5ee8..95749f8e 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/ilo.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/ilo.go @@ -200,7 +200,7 @@ func (i *Ilo) post(endpoint string, data []byte) (statusCode int, body []byte, e // Serial returns the device serial func (i *Ilo) Serial() (serial string, err error) { - return strings.ToLower(strings.TrimSpace(i.rimpBlade.HSI.Sbsn)), err + return strings.ToLower(strings.TrimSpace(i.rimpBlade.HSI.Sbsn)), nil } // Returns the serial number of the chassis where the blade is attached. @@ -240,7 +240,7 @@ func (i *Ilo) ChassisSerial() (string, error) { // Model returns the device model func (i *Ilo) Model() (model string, err error) { - return i.rimpBlade.HSI.Spn, err + return i.rimpBlade.HSI.Spn, nil } // HardwareType returns the type of bmc we are talking to @@ -382,7 +382,7 @@ func (i *Ilo) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCount i return httpclient.StandardizeProcessorName(proc.ProcName), len(hpProcData.Processors), proc.ProcNumCores, proc.ProcNumThreads, nil } - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, fmt.Errorf("Ilo CPU(): No CPUs?!") } // Returns the current version of the BIOS. @@ -438,7 +438,7 @@ func (i *Ilo) PowerKw() (power float64, err error) { return 0, err } - return float64(hpPowerSummary.PowerSupplyInputPower) / 1024, nil + return float64(hpPowerSummary.PowerSupplyInputPower) / 1000, nil } // PowerState returns the current power state of the machine diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/actions.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/actions.go index 897a0054..f37d8b34 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/actions.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/actions.go @@ -57,7 +57,7 @@ func (s *SupermicroX) PxeOnce() (status bool, err error) { if err != nil { return false, err } - return i.PowerCycle(context.Background()) + return i.ForceRestart(context.Background()) } // IsOn tells if a machine is currently powered on diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/supermicrox.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/supermicrox.go index 81919cd3..4ca3ec43 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/supermicrox.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/supermicrox.go @@ -233,14 +233,14 @@ func (s *SupermicroX) query(requestType string) (ipmi *supermicro.IPMI, err erro func (s *SupermicroX) Serial() (serial string, err error) { ipmi, err := s.query("FRU_INFO.XML=(0,0)") if err != nil { - return serial, err + return "", err } if ipmi.FruInfo == nil || ipmi.FruInfo.Board == nil { - return serial, errors.ErrInvalidSerial + return "", errors.ErrInvalidSerial } - return strings.ToLower(ipmi.FruInfo.Board.SerialNum), err + return strings.ToLower(ipmi.FruInfo.Board.SerialNum), nil } // ChassisSerial returns the serial number of the chassis where the blade is attached @@ -288,10 +288,10 @@ func (s *SupermicroX) Model() (model string, err error) { } if ipmi.FruInfo != nil && ipmi.FruInfo.Board != nil { - return ipmi.FruInfo.Board.PartNum, err + return ipmi.FruInfo.Board.PartNum, nil } - return model, err + return "", fmt.Errorf("SupermicroX Model(): Model not found!") } // Version returns the version of the bmc we are running @@ -360,11 +360,11 @@ func (s *SupermicroX) Memory() (mem int, err error) { func (s *SupermicroX) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCount int, err error) { ipmi, err := s.query("SMBIOS_INFO.XML=(0,0)") if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, err } if len(ipmi.CPU) == 0 { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, nil } entry := ipmi.CPU[0] @@ -373,12 +373,11 @@ func (s *SupermicroX) CPU() (cpu string, cpuCount int, coreCount int, hyperthrea coreCount, err = strconv.Atoi(entry.Core) if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return cpu, cpuCount, 0, 0, err } hyperthreadCount = coreCount - - return cpu, cpuCount, coreCount, hyperthreadCount, err + return cpu, cpuCount, coreCount, hyperthreadCount, nil } // BiosVersion returns the current version of the bios diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/actions.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/actions.go index 04334068..23d21c73 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/actions.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/actions.go @@ -57,7 +57,7 @@ func (s *SupermicroX) PxeOnce() (status bool, err error) { if err != nil { return false, err } - return i.PowerCycle(context.Background()) + return i.ForceRestart(context.Background()) } // IsOn tells if a machine is currently powered on diff --git a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/supermicrox.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/supermicrox.go index 5554b546..8a0f3916 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/supermicrox.go +++ b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/supermicrox.go @@ -218,14 +218,14 @@ func (s *SupermicroX) query(requestType string) (ipmi *supermicro.IPMI, err erro func (s *SupermicroX) Serial() (serial string, err error) { ipmi, err := s.query("op=FRU_INFO.XML&r=(0,0)") if err != nil { - return serial, err + return "", err } if ipmi.FruInfo == nil || ipmi.FruInfo.Board == nil { - return serial, errors.ErrInvalidSerial + return "", errors.ErrInvalidSerial } - return strings.ToLower(ipmi.FruInfo.Board.SerialNum), err + return strings.ToLower(ipmi.FruInfo.Board.SerialNum), nil } // ChassisSerial returns the serial number of the chassis where the blade is attached @@ -261,10 +261,10 @@ func (s *SupermicroX) Model() (model string, err error) { } if ipmi.FruInfo != nil && ipmi.FruInfo.Board != nil { - return ipmi.FruInfo.Board.PartNum, err + return ipmi.FruInfo.Board.PartNum, nil } - return model, err + return "", fmt.Errorf("SupermicroX Model(): Model not found!") } // Version returns the version of the bmc we are running @@ -344,11 +344,11 @@ func (s *SupermicroX) Memory() (mem int, err error) { func (s *SupermicroX) CPU() (cpu string, cpuCount int, coreCount int, hyperthreadCount int, err error) { ipmi, err := s.query("op=SMBIOS_INFO.XML&r=(0,0)") if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, err } if len(ipmi.CPU) == 0 { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return "", 0, 0, 0, nil } entry := ipmi.CPU[0] @@ -357,12 +357,11 @@ func (s *SupermicroX) CPU() (cpu string, cpuCount int, coreCount int, hyperthrea coreCount, err = strconv.Atoi(entry.Core) if err != nil { - return cpu, cpuCount, coreCount, hyperthreadCount, err + return cpu, cpuCount, 0, 0, err } hyperthreadCount = coreCount - - return cpu, cpuCount, coreCount, hyperthreadCount, err + return cpu, cpuCount, coreCount, hyperthreadCount, nil } // BiosVersion returns the current version of the bios diff --git a/vendor/modules.txt b/vendor/modules.txt index f8574058..510ee281 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -3,7 +3,7 @@ github.com/DATA-DOG/go-sqlmock # github.com/GeertJohan/go.rice v1.0.2 github.com/GeertJohan/go.rice github.com/GeertJohan/go.rice/embedded -# github.com/bmc-toolbox/bmclib v0.4.14 +# github.com/bmc-toolbox/bmclib v0.4.15 github.com/bmc-toolbox/bmclib/cfgresources github.com/bmc-toolbox/bmclib/devices github.com/bmc-toolbox/bmclib/discover