From 2ef27657ba294ca947004c29b675a1b51a4972ed Mon Sep 17 00:00:00 2001 From: oothman Date: Thu, 30 Dec 2021 13:22:56 +0100 Subject: [PATCH] Upgrade the bmclib dependency (to v0.4.15). --- go.mod | 2 +- go.sum | 21 ++------- .../bmc-toolbox/bmclib/internal/ipmi/ipmi.go | 13 +++++ .../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/ilo.go | 8 ++-- .../supermicro/supermicrox/supermicrox.go | 19 ++++---- .../supermicro/supermicrox11/supermicrox.go | 19 ++++---- .../ugorji/go/codec/sort-slice.generated.go | 4 +- vendor/modules.txt | 2 +- 13 files changed, 92 insertions(+), 72 deletions(-) diff --git a/go.mod b/go.mod index 8b63954..aee8044 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.12 require ( github.com/GeertJohan/go.rice v1.0.2 github.com/aws/aws-sdk-go v1.37.5 - 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 e472a97..59ce69c 100644 --- a/go.sum +++ b/go.sum @@ -32,23 +32,17 @@ github.com/aws/aws-sdk-go v1.37.5 h1:9zJ1aXRk1gLSWEeaMXa7Hbv1pIM915T2tpaIJi0+mkA github.com/aws/aws-sdk-go v1.37.5/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= 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= @@ -71,7 +65,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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= @@ -134,7 +127,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/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -214,7 +206,6 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -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= @@ -252,21 +243,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= @@ -305,16 +292,14 @@ 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= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= 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 08782cb..dd2da8e 100644 --- a/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go +++ b/vendor/github.com/bmc-toolbox/bmclib/internal/ipmi/ipmi.go @@ -158,6 +158,19 @@ func (i *Ipmi) PowerOn(ctx context.Context) (status bool, err error) { return false, fmt.Errorf("stderr/stdout: %v", output) } +// PowerOnForce power on the machine via bmc even when the machine is already on (Thanks HP!) +func (i *Ipmi) PowerOnForce(ctx context.Context) (status bool, err error) { + output, err := i.run(ctx, []string{"chassis", "power", "on"}) + if err != nil { + return false, fmt.Errorf("%v: %v", err, output) + } + + if strings.HasPrefix(output, "Chassis Power Control: Up/On") { + return true, err + } + return false, fmt.Errorf("%v: %v", err, output) +} + // PowerOff power off the machine via bmc func (i *Ipmi) PowerOff(ctx context.Context) (status bool, err error) { s, err := i.IsOn(ctx) 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 fa03947..6c9ab00 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 8e40017..75ce26f 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 b4c73c7..5734c7c 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 623183a..504a284 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 c907efa..89cb322 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/ilo.go b/vendor/github.com/bmc-toolbox/bmclib/providers/hp/ilo/ilo.go index 69fd5ee..95749f8 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/supermicrox.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox/supermicrox.go index 81919cd..4ca3ec4 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/supermicrox.go b/vendor/github.com/bmc-toolbox/bmclib/providers/supermicro/supermicrox11/supermicrox.go index 5554b54..8a0f391 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/github.com/ugorji/go/codec/sort-slice.generated.go b/vendor/github.com/ugorji/go/codec/sort-slice.generated.go index 1ea4e97..8cabcb1 100644 --- a/vendor/github.com/ugorji/go/codec/sort-slice.generated.go +++ b/vendor/github.com/ugorji/go/codec/sort-slice.generated.go @@ -6,9 +6,9 @@ package codec import ( - "bytes" - "reflect" "time" + "reflect" + "bytes" ) type stringSlice []string diff --git a/vendor/modules.txt b/vendor/modules.txt index 0ea6411..3d41b83 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -51,7 +51,7 @@ github.com/aws/aws-sdk-go/service/sso github.com/aws/aws-sdk-go/service/sso/ssoiface github.com/aws/aws-sdk-go/service/sts github.com/aws/aws-sdk-go/service/sts/stsiface -# 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