diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..993102b --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "description": "THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.\n\nGenerated on 2024-12-16T22:32:11Z by kres 318187b.\n\n", + "prHeader": "Update Request | Renovate Bot", + "extends": [ + ":dependencyDashboard", + ":gitSignOff", + ":semanticCommitScopeDisabled", + "schedule:earlyMondays" + ], + "packageRules": [ + { + "groupName": "dependencies", + "matchUpdateTypes": [ + "major", + "minor", + "patch", + "pin", + "digest" + ] + } + ], + "separateMajorMinor": false +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e570920..ee247a4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-12-06T13:45:15Z by kres 1ebe796. +# Generated on 2024-12-16T22:30:59Z by kres 318187b. name: default concurrency: diff --git a/.golangci.yml b/.golangci.yml index 8712a59..0f95a7d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-11-18T15:38:35Z by kres 91b35db. +# Generated on 2024-12-16T22:20:13Z by kres 318187b. # options for analysis running run: @@ -134,6 +134,7 @@ linters: - perfsprint # complains about us using fmt.Sprintf in non-performance critical code, updating just kres took too long - goimports # same as gci - musttag # seems to be broken - goes into imported libraries and reports issues there + - exportloopref # WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar. issues: exclude: [ ] diff --git a/.kres.yaml b/.kres.yaml index 11771fb..1eac413 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -51,12 +51,6 @@ spec: - stage: ghcr.io/siderolabs/liblzma:v1.8.0-16-g71d23b4 # required by zbin source: / destination: / - - stage: ghcr.io/siderolabs/openssl:v1.8.0-16-g71d23b4 # required by ipmitool - source: / - destination: / - - stage: ghcr.io/siderolabs/ipmitool:v1.8.0-16-g71d23b4 - source: / - destination: / - stage: ghcr.io/siderolabs/ipxe:v1.8.0-16-g71d23b4 source: /usr/libexec/zbin destination: /bin/zbin @@ -67,7 +61,7 @@ spec: source: /usr/libexec/ destination: /var/lib/ipxe/arm64 - - stage: ghcr.io/siderolabs/talos-metal-agent-boot-assets:v1.9.0-alpha.3-agent-v0.1.0-alpha.2 # to be used with --use-local-boot-assets for local development + stage: ghcr.io/siderolabs/talos-metal-agent-boot-assets:v1.9.0-beta.1-agent-v0.1.0-beta.0 # to be used with --use-local-boot-assets for local development # stage: 127.0.0.1:5005/siderolabs/talos-metal-agent-boot-assets:v0.0.1-local # for local development, to be replaced with the line above and rekres-ed source: / destination: /assets diff --git a/Dockerfile b/Dockerfile index b53e4c1..0445079 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-12-06T12:07:03Z by kres 1ebe796. +# Generated on 2024-12-16T22:32:11Z by kres 318187b. ARG TOOLCHAIN @@ -17,10 +17,10 @@ FROM --platform=linux/arm64 ghcr.io/siderolabs/ipxe:v1.8.0-16-g71d23b4 AS ipxe-l # runs markdownlint FROM docker.io/oven/bun:1.1.38-alpine AS lint-markdown WORKDIR /src -RUN bun i markdownlint-cli@0.43.0 sentences-per-line@0.2.1 +RUN bun i markdownlint-cli@0.43.0 sentences-per-line@0.3.0 COPY .markdownlint.json . COPY ./README.md ./README.md -RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js . +RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules sentences-per-line . # collects proto specs FROM scratch AS proto-specs @@ -220,12 +220,10 @@ COPY --from=image-fhs / / COPY --from=image-ca-certificates / / COPY --from=ghcr.io/siderolabs/musl:v1.8.0-16-g71d23b4 / / COPY --from=ghcr.io/siderolabs/liblzma:v1.8.0-16-g71d23b4 / / -COPY --from=ghcr.io/siderolabs/openssl:v1.8.0-16-g71d23b4 / / -COPY --from=ghcr.io/siderolabs/ipmitool:v1.8.0-16-g71d23b4 / / COPY --from=ghcr.io/siderolabs/ipxe:v1.8.0-16-g71d23b4 /usr/libexec/zbin /bin/zbin COPY --from=ipxe-linux-amd64 /usr/libexec/ /var/lib/ipxe/amd64 COPY --from=ipxe-linux-arm64 /usr/libexec/ /var/lib/ipxe/arm64 -COPY --from=ghcr.io/siderolabs/talos-metal-agent-boot-assets:v1.9.0-alpha.3-agent-v0.1.0-alpha.2 / /assets +COPY --from=ghcr.io/siderolabs/talos-metal-agent-boot-assets:v1.9.0-beta.1-agent-v0.1.0-beta.0 / /assets LABEL org.opencontainers.image.source=https://github.com/siderolabs/omni-infra-provider-bare-metal ENTRYPOINT ["/provider"] diff --git a/Makefile b/Makefile index 9372619..90a0c0b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2024-12-11T22:07:40Z by kres 8183c20. +# Generated on 2024-12-16T22:30:59Z by kres 318187b. # common variables diff --git a/go.mod b/go.mod index 6633a85..1181a65 100644 --- a/go.mod +++ b/go.mod @@ -8,13 +8,13 @@ replace ( ) require ( + github.com/bougou/go-ipmi v0.5.11 github.com/cosi-project/runtime v0.7.5 github.com/google/uuid v1.6.0 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 github.com/hashicorp/go-multierror v1.1.1 github.com/insomniacslk/dhcp v0.0.0-20240829085014-a3a4c1f04475 github.com/jhump/grpctunnel v0.3.0 - github.com/pensando/goipmi v0.0.0-20240603174436-eb122d901c23 github.com/pin/tftp/v3 v3.1.0 github.com/planetscale/vtprotobuf v0.6.1-0.20241121165744-79df5c4772f2 github.com/siderolabs/gen v0.7.0 @@ -30,7 +30,6 @@ require ( golang.org/x/sync v0.10.0 google.golang.org/grpc v1.68.1 google.golang.org/protobuf v1.35.2 - gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -89,7 +88,10 @@ require ( github.com/jsimonetti/rtnetlink/v2 v2.0.2 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.11 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mdlayher/ethtool v0.2.0 // indirect github.com/mdlayher/genetlink v1.3.2 // indirect github.com/mdlayher/netlink v1.7.2 // indirect @@ -100,12 +102,15 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/runtime-spec v1.2.0 // indirect github.com/pierrec/lz4/v4 v4.1.21 // indirect github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect github.com/siderolabs/crypto v0.5.1 // indirect github.com/siderolabs/go-api-signature v0.3.6 // indirect @@ -144,6 +149,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect k8s.io/api v0.32.0-rc.1 // indirect k8s.io/apimachinery v0.32.0-rc.1 // indirect diff --git a/go.sum b/go.sum index af09f9d..52422cd 100644 --- a/go.sum +++ b/go.sum @@ -26,6 +26,8 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= +github.com/bougou/go-ipmi v0.5.11 h1:M9wa/+6bZfCI8ORfjHjYRidXMo1DoayB3BiIZCfqNLk= +github.com/bougou/go-ipmi v0.5.11/go.mod h1:h3JPPoIK/caMQQJiW0BUtqYPcV8zkLobq1hnKwITlmk= github.com/brianvoe/gofakeit/v6 v6.24.0 h1:74yq7RRz/noddscZHRS2T84oHZisW9muwbb8sRnU52A= github.com/brianvoe/gofakeit/v6 v6.24.0/go.mod h1:Ow6qC71xtwm79anlwKRlWZW6zVq9D2XHE4QSSMP/rU8= github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= @@ -224,6 +226,9 @@ github.com/lithammer/dedent v1.1.0 h1:VNzHMVCBNG1j0fh3OrsFRkVUwStdDArbgBWoPAffkt github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43/go.mod h1:+t7E0lkKfbBsebllff1xdTmyJt8lH37niI6kwFk9OTo= github.com/mdlayher/ethtool v0.2.0 h1:akcA4WZVWozzirPASeMq8qgLkxpF3ykftVXwnrMKrhY= github.com/mdlayher/ethtool v0.2.0/go.mod h1:W0pIBrNPK1TslIN4Z9wt1EVbay66Kbvek2z2f29VBfw= @@ -266,6 +271,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= @@ -280,6 +287,7 @@ github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/planetscale/vtprotobuf v0.6.1-0.20241121165744-79df5c4772f2 h1:1sLMdKq4gNANTj0dUibycTLzpIEKVnLnbaEkxws78nw= @@ -288,7 +296,11 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -316,8 +328,6 @@ github.com/siderolabs/go-retry v0.3.3 h1:zKV+S1vumtO72E6sYsLlmIdV/G/GcYSBLiEx/c9 github.com/siderolabs/go-retry v0.3.3/go.mod h1:Ff/VGc7v7un4uQg3DybgrmOWHEmJ8BzZds/XNn/BqMI= github.com/siderolabs/go-talos-support v0.1.1 h1:g51J0WQssQAycU/0cDliC2l4uX2H02yUs2+fa5pCvHg= github.com/siderolabs/go-talos-support v0.1.1/go.mod h1:o4woiYS+2J3djCQgyHZRVZQm8XpazQr+XPcTXAZvamo= -github.com/siderolabs/goipmi v0.0.0-20211214143420-35f956689e67 h1:R22ZIQgXriopn8zTKnya8JWbEEx2AdgTyKL92hxdJoU= -github.com/siderolabs/goipmi v0.0.0-20211214143420-35f956689e67/go.mod h1:Vr1Oadtcem03hG2RUT/dpSQS5md9d6rJ9nA0lUBC91Q= github.com/siderolabs/image-factory v0.6.2 h1:3Ax/6DGqVxMjvh0UkHxxnqiAl2MaKRFd+GsLzQA1aLU= github.com/siderolabs/image-factory v0.6.2/go.mod h1:Y3ZMytkh5FEfZ1/1T9jZ8fLLYnvrMdNuxqoBEb1pu0c= github.com/siderolabs/net v0.4.0 h1:1bOgVay/ijPkJz4qct98nHsiB/ysLQU0KLoBC4qLm7I= @@ -347,7 +357,6 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= -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.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= diff --git a/internal/provider/controllers/infra_machine_status.go b/internal/provider/controllers/infra_machine_status.go index c444f10..24ffdd2 100644 --- a/internal/provider/controllers/infra_machine_status.go +++ b/internal/provider/controllers/infra_machine_status.go @@ -400,6 +400,7 @@ func (h *infraMachineStatusControllerHelper) ensurePowerManagement(ctx context.C if existingPowerMgmt.Ipmi != nil { status.TypedSpec().Value.PowerManagement.Ipmi = &specs.PowerManagement_IPMI{ Address: existingPowerMgmt.Ipmi.Address, + Port: existingPowerMgmt.Ipmi.Port, Username: ipmiUsername, Password: ipmiPassword, } diff --git a/internal/provider/power/ipmi/ipmi.go b/internal/provider/power/ipmi/ipmi.go index b0ef49a..d01f42e 100644 --- a/internal/provider/power/ipmi/ipmi.go +++ b/internal/provider/power/ipmi/ipmi.go @@ -8,84 +8,89 @@ package ipmi import ( "context" "fmt" + "time" - goipmi "github.com/pensando/goipmi" + "github.com/bougou/go-ipmi" "github.com/siderolabs/omni-infra-provider-bare-metal/api/specs" "github.com/siderolabs/omni-infra-provider-bare-metal/internal/provider/power/pxe" ) -const ipmiUsername = "talos-agent" - // Client is a wrapper around the goipmi client. type Client struct { - ipmiClient *goipmi.Client + client *ipmi.Client } // Close implements the power.Client interface. func (c *Client) Close() error { - return c.ipmiClient.Close() + return c.client.Close() } // Reboot implements the power.Client interface. func (c *Client) Reboot(context.Context) error { - return c.ipmiClient.Control(goipmi.ControlPowerCycle) + _, err := c.client.ChassisControl(ipmi.ChassisControlPowerCycle) + + return err } // PowerOn implements the power.Client interface. func (c *Client) PowerOn(context.Context) error { - return c.ipmiClient.Control(goipmi.ControlPowerUp) + _, err := c.client.ChassisControl(ipmi.ChassisControlPowerUp) + + return err } // PowerOff implements the power.Client interface. func (c *Client) PowerOff(context.Context) error { - return c.ipmiClient.Control(goipmi.ControlPowerDown) + _, err := c.client.ChassisControl(ipmi.ChassisControlPowerDown) + + return err } // SetPXEBootOnce implements the power.Client interface. func (c *Client) SetPXEBootOnce(_ context.Context, mode pxe.BootMode) error { + var biosBootType ipmi.BIOSBootType + switch mode { case pxe.BootModeBIOS: - return c.ipmiClient.SetBootDevice(goipmi.BootDevicePxe) + biosBootType = ipmi.BIOSBootTypeLegacy case pxe.BootModeUEFI: - return c.ipmiClient.SetBootDeviceEFI(goipmi.BootDevicePxe) + biosBootType = ipmi.BIOSBootTypeEFI default: - return fmt.Errorf("unsupported mode %q", mode) + return fmt.Errorf("unknown boot mode: %v", mode) } + + return c.client.SetBootDevice(ipmi.BootDeviceSelectorForcePXE, biosBootType, false) } // IsPoweredOn implements the power.Client interface. func (c *Client) IsPoweredOn(context.Context) (bool, error) { - req := &goipmi.Request{ - NetworkFunction: goipmi.NetworkFunctionChassis, - Command: goipmi.CommandChassisStatus, - Data: goipmi.ChassisStatusRequest{}, - } - - res := &goipmi.ChassisStatusResponse{} - - err := c.ipmiClient.Send(req, res) + status, err := c.client.GetChassisStatus() if err != nil { return false, err } - return res.IsSystemPowerOn(), nil + return status.PowerIsOn, nil } // NewClient creates a new IPMI client. func NewClient(info *specs.PowerManagement_IPMI) (*Client, error) { - conn := &goipmi.Connection{ - Hostname: info.Address, - Port: int(info.Port), - Username: ipmiUsername, - Password: info.Password, - Interface: "lanplus", + if info.Port == 0 { + info.Port = 623 } - client, err := goipmi.NewClient(conn) + client, err := ipmi.NewClient(info.Address, int(info.Port), info.Username, info.Password) if err != nil { return nil, err } - return &Client{ipmiClient: client}, nil + client = client.WithTimeout(30 * time.Second) // todo: rework here, so that context is respected in all calls + + if err = client.Connect(); err != nil { + client.Close() //nolint:errcheck + + return nil, err + } + + return &Client{client: client}, nil }