diff --git a/go.mod b/go.mod index 23f0865..fd6ce5d 100644 --- a/go.mod +++ b/go.mod @@ -10,10 +10,10 @@ require ( github.com/go-redis/redis/v8 v8.11.5 github.com/google/addlicense v1.1.1 github.com/google/uuid v1.5.0 + github.com/ironcore-dev/metal v0.11.0 github.com/jeek120/cpuid v0.0.0-20200914054105-8fa8c861dea6 github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 github.com/mdlayher/lldp v0.0.0-20150915211757-afd9f83164c5 - github.com/onmetal/metal-api v0.10.3 github.com/onmetal/metal-api-gateway v0.4.1 github.com/opencontainers/runtime-spec v1.1.0 github.com/pkg/errors v0.9.1 @@ -23,6 +23,7 @@ require ( github.com/urfave/cli/v2 v2.27.1 github.com/vishvananda/netlink v1.2.1-beta.2 go.uber.org/zap v1.26.0 + golang.org/x/sys v0.15.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/apimachinery v0.29.1 @@ -64,7 +65,8 @@ 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/onmetal/ipam v0.0.25 // indirect + github.com/onmetal/ipam v0.0.26 // indirect + github.com/onmetal/metal-api v0.10.3 // indirect github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pkg/xattr v0.4.9 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -84,7 +86,6 @@ require ( golang.org/x/net v0.19.0 // indirect golang.org/x/oauth2 v0.10.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.15.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect @@ -94,12 +95,12 @@ require ( gopkg.in/djherbis/times.v1 v1.3.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect k8s.io/api v0.29.1 // indirect - k8s.io/apiextensions-apiserver v0.28.0 // indirect - k8s.io/component-base v0.28.1 // indirect + k8s.io/apiextensions-apiserver v0.28.3 // indirect + k8s.io/component-base v0.28.3 // indirect k8s.io/klog/v2 v2.110.1 // indirect k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - sigs.k8s.io/controller-runtime v0.16.2 // indirect + sigs.k8s.io/controller-runtime v0.16.3 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/go.sum b/go.sum index fafd7ed..7c657b9 100644 --- a/go.sum +++ b/go.sum @@ -41,8 +41,8 @@ github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4 github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= -github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= +github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= +github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/zapr v1.2.4 h1:QHVo+6stLbfJmYGkQ7uGHUCu5hnAFAj6mDe6Ea0SeOo= @@ -92,6 +92,8 @@ github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/ironcore-dev/metal v0.11.0 h1:lOZqHe8RmYKSI05GUHVyx9HjkvMd8ZrNMzRJ6txkovQ= +github.com/ironcore-dev/metal v0.11.0/go.mod h1:3Mj+xiZux3DwQkcaYwXSZ0YqgjckHRtcW567LtCQE4w= github.com/jeek120/cpuid v0.0.0-20200914054105-8fa8c861dea6 h1:yYizUAyOFS0NEC88Fy7zV1P+p4ms3akuRebq4oyrtkY= github.com/jeek120/cpuid v0.0.0-20200914054105-8fa8c861dea6/go.mod h1:yVF/19OfI1zhR3WPrIsQFWwC9cfPHvwy4TOd4L7cKWM= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -130,8 +132,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onmetal/ipam v0.0.25 h1:4f9etb5Hpl+QOKt0gtImcNfEQ+MHvWAntRmpgmmJwf8= -github.com/onmetal/ipam v0.0.25/go.mod h1:/b44FpL40z6jM1uAs1Y6vioUi2Hy6Z7MZObiM2u3djg= +github.com/onmetal/ipam v0.0.26 h1:1MExfeV8W24btRAxwQD41nxRxXCF3utqq9YDq4UHmS4= +github.com/onmetal/ipam v0.0.26/go.mod h1:5RWWO4gwdk1vKggVV8aVJNszNiJn6HMVr/lxMj8ON6A= github.com/onmetal/metal-api v0.10.3 h1:lAzApPomrItJVPcEAuLZu70T0sLppeDjvwzNoVTak+0= github.com/onmetal/metal-api v0.10.3/go.mod h1:PUhwl8ViQkBYJBeIxsJ6O74pxmeTYJ7qLMefKndPzGs= github.com/onmetal/metal-api-gateway v0.4.1 h1:vtUnoOr2QI+gmB/RnO30w66wz0naUMWbNmbNqo2hZS8= @@ -140,8 +142,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= @@ -275,6 +277,8 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o= gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8= +gopkg.in/evanphx/json-patch.v5 v5.6.0 h1:BMT6KIwBD9CaU91PJCZIe46bDmBWa9ynTQgJIOpfQBk= +gopkg.in/evanphx/json-patch.v5 v5.6.0/go.mod h1:/kvTRh1TVm5wuM6OkHxqXtE/1nUZZpihg29RtuIyfvk= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= @@ -288,28 +292,28 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/api v0.29.1 h1:DAjwWX/9YT7NQD4INu49ROJuZAAAP/Ijki48GUPzxqw= k8s.io/api v0.29.1/go.mod h1:7Kl10vBRUXhnQQI8YR/R327zXC8eJ7887/+Ybta+RoQ= -k8s.io/apiextensions-apiserver v0.28.0 h1:CszgmBL8CizEnj4sj7/PtLGey6Na3YgWyGCPONv7E9E= -k8s.io/apiextensions-apiserver v0.28.0/go.mod h1:uRdYiwIuu0SyqJKriKmqEN2jThIJPhVmOWETm8ud1VE= +k8s.io/apiextensions-apiserver v0.28.3 h1:Od7DEnhXHnHPZG+W9I97/fSQkVpVPQx2diy+2EtmY08= +k8s.io/apiextensions-apiserver v0.28.3/go.mod h1:NE1XJZ4On0hS11aWWJUTNkmVB03j9LM7gJSisbRt8Lc= k8s.io/apimachinery v0.29.1 h1:KY4/E6km/wLBguvCZv8cKTeOwwOBqFNjwJIdMkMbbRc= k8s.io/apimachinery v0.29.1/go.mod h1:6HVkd1FwxIagpYrHSwJlQqZI3G9LfYWRPAkUvLnXTKU= k8s.io/client-go v0.29.1 h1:19B/+2NGEwnFLzt0uB5kNJnfTsbV8w6TgQRz9l7ti7A= k8s.io/client-go v0.29.1/go.mod h1:TDG/psL9hdet0TI9mGyHJSgRkW3H9JZk2dNEUS7bRks= -k8s.io/component-base v0.28.1 h1:LA4AujMlK2mr0tZbQDZkjWbdhTV5bRyEyAFe0TJxlWg= -k8s.io/component-base v0.28.1/go.mod h1:jI11OyhbX21Qtbav7JkhehyBsIRfnO8oEgoAR12ArIU= +k8s.io/component-base v0.28.3 h1:rDy68eHKxq/80RiMb2Ld/tbH8uAE75JdCqJyi6lXMzI= +k8s.io/component-base v0.28.3/go.mod h1:fDJ6vpVNSk6cRo5wmDa6eKIG7UlIQkaFmZN2fYgIUD8= k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -sigs.k8s.io/controller-runtime v0.16.2 h1:mwXAVuEk3EQf478PQwQ48zGOXvW27UJc8NHktQVuIPU= -sigs.k8s.io/controller-runtime v0.16.2/go.mod h1:vpMu3LpI5sYWtujJOa2uPK61nB5rbwlN7BAB8aSLvGU= +sigs.k8s.io/controller-runtime v0.16.3 h1:2TuvuokmfXvDUamSx1SuAOO3eTyye+47mJCigwG62c4= +sigs.k8s.io/controller-runtime v0.16.3/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/kustomize/api v0.13.4 h1:E38Hfx0G9R9v7vRgKshviPotJQETG0S2gD3JdHLCAsI= -sigs.k8s.io/kustomize/api v0.13.4/go.mod h1:Bkaavz5RKK6ZzP0zgPrB7QbpbBJKiHuD3BB0KujY7Ls= -sigs.k8s.io/kustomize/kyaml v0.14.3 h1:WpabVAKZe2YEp/irTSHwD6bfjwZnTtSDewd2BVJGMZs= -sigs.k8s.io/kustomize/kyaml v0.14.3/go.mod h1:npvh9epWysfQ689Rtt/U+dpOJDTBn8kUnF1O6VzvmZA= +sigs.k8s.io/kustomize/api v0.15.0 h1:6Ca88kEOBVotHDw+y2IsIMYtg9Pvv7MKpW9JMyF/OH4= +sigs.k8s.io/kustomize/api v0.15.0/go.mod h1:p19kb+E14gN7zcIBR/nhByJDAfUa7N8mp6ZdH/mMXbg= +sigs.k8s.io/kustomize/kyaml v0.15.0 h1:ynlLMAxDhrY9otSg5GYE2TcIz31XkGZ2Pkj7SdolD84= +sigs.k8s.io/kustomize/kyaml v0.15.0/go.mod h1:+uMkBahdU1KNOj78Uta4rrXH+iH7wvg+nW7+GULvREA= sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/internal/provider/http_test.go b/internal/provider/http_test.go index 56e6cdf..e49004b 100644 --- a/internal/provider/http_test.go +++ b/internal/provider/http_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - benchv1alpha3 "github.com/onmetal/metal-api/apis/benchmark/v1alpha3" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/stretchr/testify/assert" "github.com/onmetal/inventory/cmd/benchmark-scheduler/logger" @@ -54,9 +54,9 @@ func TestPatch(t *testing.T) { ctx: ctx, log: l, } - mm := make(map[string]benchv1alpha3.Benchmarks) - mm["test"] = []benchv1alpha3.Benchmark{{Name: "disk-test", Value: 123}} - spec := benchv1alpha3.Machine{Spec: benchv1alpha3.MachineSpec{Benchmarks: mm}} + mm := make(map[string]metalv1alpha4.Benchmarks) + mm["test"] = []metalv1alpha4.BenchmarkResult{{Name: "disk-test", Value: 123}} + spec := metalv1alpha4.Benchmark{Spec: metalv1alpha4.BenchmarkSpec{Benchmarks: mm}} patch, err := json.Marshal(spec) a.Nil(err, "json serialization failed") diff --git a/internal/updater/updater.go b/internal/updater/updater.go index 0ece3cc..77c5f85 100644 --- a/internal/updater/updater.go +++ b/internal/updater/updater.go @@ -21,7 +21,7 @@ import ( "sync" "github.com/Jeffail/gabs/v2" - benchv1alpha3 "github.com/onmetal/metal-api/apis/benchmark/v1alpha3" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/onmetal/inventory/cmd/benchmark-scheduler/logger" "github.com/onmetal/inventory/internal/benchmarks/output" @@ -35,7 +35,7 @@ const ( type Machine struct { provider.Client - resultMap map[string]benchv1alpha3.Benchmarks + resultMap map[string]metalv1alpha4.Benchmarks uuid string wg *sync.WaitGroup log logger.Logger @@ -52,7 +52,7 @@ func New(machineUUID string, results []output.Result, c provider.Client, l logge wg: new(sync.WaitGroup), uuid: machineUUID, results: results, - resultMap: make(map[string]benchv1alpha3.Benchmarks, len(results)), + resultMap: make(map[string]metalv1alpha4.Benchmarks, len(results)), log: l, }, nil } @@ -72,22 +72,22 @@ func (m *Machine) Do() error { value := m.parseText(&m.results[r]) benches, ok := m.resultMap[name] if !ok { - m.resultMap[name] = benchv1alpha3.Benchmarks{{Name: m.results[r].BenchmarkName, Value: value}} + m.resultMap[name] = metalv1alpha4.Benchmarks{{Name: m.results[r].BenchmarkName, Value: value}} continue } - m.resultMap[name] = append(benches, benchv1alpha3.Benchmark{ + m.resultMap[name] = append(benches, metalv1alpha4.BenchmarkResult{ Name: m.results[r].BenchmarkName, Value: value, }) default: value := m.parseJSON(&m.results[r]) benches, ok := m.resultMap[name] if !ok { - m.resultMap[name] = benchv1alpha3.Benchmarks{{Name: m.results[r].BenchmarkName, Value: value}} + m.resultMap[name] = metalv1alpha4.Benchmarks{{Name: m.results[r].BenchmarkName, Value: value}} } - m.resultMap[name] = append(benches, benchv1alpha3.Benchmark{Name: m.results[r].BenchmarkName, Value: value}) + m.resultMap[name] = append(benches, metalv1alpha4.BenchmarkResult{Name: m.results[r].BenchmarkName, Value: value}) } } - patch := benchv1alpha3.Machine{Spec: benchv1alpha3.MachineSpec{Benchmarks: m.resultMap}} + patch := metalv1alpha4.Benchmark{Spec: metalv1alpha4.BenchmarkSpec{Benchmarks: m.resultMap}} body, err := json.Marshal(patch) if err != nil { return err diff --git a/internal/updater/updater_test.go b/internal/updater/updater_test.go index 01ca580..8a4f32e 100644 --- a/internal/updater/updater_test.go +++ b/internal/updater/updater_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/google/uuid" - benchv1alpha3 "github.com/onmetal/metal-api/apis/benchmark/v1alpha3" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/stretchr/testify/assert" "github.com/onmetal/inventory/cmd/benchmark-scheduler/logger" @@ -54,7 +54,7 @@ func TestDo(t *testing.T) { log: l, results: getResults(data), Client: fakeClient, - resultMap: make(map[string]benchv1alpha3.Benchmarks), + resultMap: make(map[string]metalv1alpha4.Benchmarks), } if err := m.Do(); !a.Nil(err) { t.Log(err) diff --git a/pkg/app/benchmark.go b/pkg/app/benchmark.go index 38ec16c..9a6c1c0 100644 --- a/pkg/app/benchmark.go +++ b/pkg/app/benchmark.go @@ -18,7 +18,7 @@ import ( "bytes" "encoding/json" - apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/pkg/errors" "github.com/onmetal/inventory/pkg/crd" @@ -98,7 +98,7 @@ func (s *BenchmarkApp) Run() int { s.printer.VOut("Gathered data:") s.printer.VOut(prettifiedJsonBuf.String()) - buildSetters := []func(*apiv1alpha1.Inventory, *inventory.Inventory){ + buildSetters := []func(*metalv1alpha4.Inventory, *inventory.Inventory){ s.crdBuilderSvc.SetMLCPerf, } diff --git a/pkg/app/nic_updater.go b/pkg/app/nic_updater.go index 93b8b5e..b4293b5 100644 --- a/pkg/app/nic_updater.go +++ b/pkg/app/nic_updater.go @@ -15,7 +15,7 @@ package app import ( - apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/pkg/errors" "github.com/onmetal/inventory/pkg/crd" @@ -110,7 +110,7 @@ func (s *NICUpdaterApp) Run() int { inv := s.gathererSvc.GatherInOrder(gatherSetters) - buildSetters := []func(*apiv1alpha1.Inventory, *inventory.Inventory){ + buildSetters := []func(*metalv1alpha4.Inventory, *inventory.Inventory){ s.crdBuilderSvc.SetSystem, s.crdBuilderSvc.SetNICs, } @@ -123,7 +123,7 @@ func (s *NICUpdaterApp) Run() int { patch := struct { Spec struct { - Nics []apiv1alpha1.NICSpec `json:"nics"` + Nics []metalv1alpha4.NICSpec `json:"nics"` } `json:"spec"` }{} patch.Spec.Nics = cr.Spec.NICs diff --git a/pkg/crd/builder.go b/pkg/crd/builder.go index e698ec5..d3d6484 100644 --- a/pkg/crd/builder.go +++ b/pkg/crd/builder.go @@ -19,7 +19,7 @@ import ( "strconv" "strings" - apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -50,8 +50,8 @@ func NewBuilderSvc(printer *printer.Svc) *BuilderSvc { } } -func (s *BuilderSvc) Build(inv *inventory.Inventory) (*apiv1alpha1.Inventory, error) { - setters := []func(*apiv1alpha1.Inventory, *inventory.Inventory){ +func (s *BuilderSvc) Build(inv *inventory.Inventory) (*metalv1alpha4.Inventory, error) { + setters := []func(*metalv1alpha4.Inventory, *inventory.Inventory){ s.SetSystem, s.SetIPMIs, s.SetBlocks, @@ -68,10 +68,10 @@ func (s *BuilderSvc) Build(inv *inventory.Inventory) (*apiv1alpha1.Inventory, er return s.BuildInOrder(inv, setters) } -func (s *BuilderSvc) BuildInOrder(inv *inventory.Inventory, setters []func(*apiv1alpha1.Inventory, *inventory.Inventory)) (*apiv1alpha1.Inventory, error) { - cr := &apiv1alpha1.Inventory{ +func (s *BuilderSvc) BuildInOrder(inv *inventory.Inventory, setters []func(*metalv1alpha4.Inventory, *inventory.Inventory)) (*metalv1alpha4.Inventory, error) { + cr := &metalv1alpha4.Inventory{ ObjectMeta: metav1.ObjectMeta{}, - Spec: apiv1alpha1.InventorySpec{}, + Spec: metalv1alpha4.InventorySpec{}, } for _, setter := range setters { @@ -81,7 +81,7 @@ func (s *BuilderSvc) BuildInOrder(inv *inventory.Inventory, setters []func(*apiv return cr, nil } -func (s *BuilderSvc) SetSystem(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetSystem(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if inv.DMI == nil { return } @@ -103,7 +103,7 @@ func (s *BuilderSvc) SetSystem(cr *apiv1alpha1.Inventory, inv *inventory.Invento } cr.Name = hostUUID - cr.Spec.System = &apiv1alpha1.SystemSpec{ + cr.Spec.System = &metalv1alpha4.SystemSpec{ ID: hostUUID, Manufacturer: dmi.SystemInformation.Manufacturer, ProductSKU: dmi.SystemInformation.SKUNumber, @@ -111,16 +111,16 @@ func (s *BuilderSvc) SetSystem(cr *apiv1alpha1.Inventory, inv *inventory.Invento } } -func (s *BuilderSvc) SetIPMIs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetIPMIs(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { ipmiDevCount := len(inv.IPMIDevices) if ipmiDevCount == 0 { return } - ipmis := make([]apiv1alpha1.IPMISpec, ipmiDevCount) + ipmis := make([]metalv1alpha4.IPMISpec, ipmiDevCount) for i, ipmiDev := range inv.IPMIDevices { - ipmi := apiv1alpha1.IPMISpec{ + ipmi := metalv1alpha4.IPMISpec{ IPAddress: ipmiDev.IPAddress, MACAddress: ipmiDev.MACAddress, } @@ -137,12 +137,12 @@ func (s *BuilderSvc) SetIPMIs(cr *apiv1alpha1.Inventory, inv *inventory.Inventor cr.Spec.IPMIs = ipmis } -func (s *BuilderSvc) SetBlocks(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetBlocks(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if len(inv.BlockDevices) == 0 { return } - blocks := make([]apiv1alpha1.BlockSpec, 0) + blocks := make([]metalv1alpha4.BlockSpec, 0) var capacity uint64 = 0 for _, blockDev := range inv.BlockDevices { @@ -151,20 +151,20 @@ func (s *BuilderSvc) SetBlocks(cr *apiv1alpha1.Inventory, inv *inventory.Invento continue } - var partitionTable *apiv1alpha1.PartitionTableSpec + var partitionTable *metalv1alpha4.PartitionTableSpec if blockDev.PartitionTable != nil { table := blockDev.PartitionTable - partitionTable = &apiv1alpha1.PartitionTableSpec{ + partitionTable = &metalv1alpha4.PartitionTableSpec{ Type: string(table.Type), } partCount := len(table.Partitions) if partCount > 0 { - parts := make([]apiv1alpha1.PartitionSpec, partCount) + parts := make([]metalv1alpha4.PartitionSpec, partCount) for i, partition := range table.Partitions { - part := apiv1alpha1.PartitionSpec{ + part := metalv1alpha4.PartitionSpec{ ID: partition.ID, Name: partition.Name, Size: partition.Size, @@ -181,7 +181,7 @@ func (s *BuilderSvc) SetBlocks(cr *apiv1alpha1.Inventory, inv *inventory.Invento } } - block := apiv1alpha1.BlockSpec{ + block := metalv1alpha4.BlockSpec{ Name: blockDev.Name, Type: blockDev.Type, Rotational: blockDev.Rotational, @@ -202,26 +202,26 @@ func (s *BuilderSvc) SetBlocks(cr *apiv1alpha1.Inventory, inv *inventory.Invento cr.Spec.Blocks = blocks } -func (s *BuilderSvc) SetMemory(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetMemory(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if inv.MemInfo == nil { return } - cr.Spec.Memory = &apiv1alpha1.MemorySpec{ + cr.Spec.Memory = &metalv1alpha4.MemorySpec{ Total: inv.MemInfo.MemTotal, } } -func (s *BuilderSvc) SetMLCPerf(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetMLCPerf(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { // TODO set data to inventory when CRD will get perf fields } -func (s *BuilderSvc) SetCPUs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetCPUs(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if len(inv.CPUInfo) == 0 { return } - cpuMarkMap := make(map[uint64]apiv1alpha1.CPUSpec) + cpuMarkMap := make(map[uint64]metalv1alpha4.CPUSpec) for _, cpuInfo := range inv.CPUInfo { if val, ok := cpuMarkMap[cpuInfo.PhysicalID]; ok { @@ -230,7 +230,7 @@ func (s *BuilderSvc) SetCPUs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory continue } - cpu := apiv1alpha1.CPUSpec{ + cpu := metalv1alpha4.CPUSpec{ PhysicalID: cpuInfo.PhysicalID, LogicalIDs: []uint64{cpuInfo.Processor}, Cores: cpuInfo.CpuCores, @@ -266,7 +266,7 @@ func (s *BuilderSvc) SetCPUs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory cpuMarkMap[cpuInfo.PhysicalID] = cpu } - cpus := make([]apiv1alpha1.CPUSpec, 0) + cpus := make([]metalv1alpha4.CPUSpec, 0) for _, v := range cpuMarkMap { cpus = append(cpus, v) } @@ -278,20 +278,20 @@ func (s *BuilderSvc) SetCPUs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory cr.Spec.CPUs = cpus } -func (s *BuilderSvc) SetNUMANodes(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetNUMANodes(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if len(inv.NumaNodes) == 0 { return } - numaNodes := make([]apiv1alpha1.NumaSpec, len(inv.NumaNodes)) + numaNodes := make([]metalv1alpha4.NumaSpec, len(inv.NumaNodes)) for idx, numaNode := range inv.NumaNodes { - numaNodes[idx] = apiv1alpha1.NumaSpec{ + numaNodes[idx] = metalv1alpha4.NumaSpec{ ID: numaNode.ID, CPUs: numaNode.CPUs, Distances: numaNode.Distances, } if numaNode.Memory != nil { - numaNodes[idx].Memory = &apiv1alpha1.MemorySpec{ + numaNodes[idx].Memory = &metalv1alpha4.MemorySpec{ Total: numaNode.Memory.MemTotal, } } @@ -304,56 +304,56 @@ func (s *BuilderSvc) SetNUMANodes(cr *apiv1alpha1.Inventory, inv *inventory.Inve cr.Spec.NUMA = numaNodes } -func (s *BuilderSvc) SetPCIDevices(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetPCIDevices(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if len(inv.PCIBusDevices) == 0 { return } - pciDevices := make([]apiv1alpha1.PCIDeviceSpec, 0) + pciDevices := make([]metalv1alpha4.PCIDeviceSpec, 0) for _, pciBus := range inv.PCIBusDevices { for _, pciDevice := range pciBus.Devices { - pciDeviceSpec := apiv1alpha1.PCIDeviceSpec{ + pciDeviceSpec := metalv1alpha4.PCIDeviceSpec{ BusID: pciBus.ID, Address: pciDevice.Address, } if pciDevice.Vendor != nil { - pciDeviceSpec.Vendor = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Vendor = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Vendor.ID, Name: pciDevice.Vendor.Name, } } if pciDevice.Subvendor != nil { - pciDeviceSpec.Subvendor = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Subvendor = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Subvendor.ID, Name: pciDevice.Subvendor.Name, } } if pciDevice.Type != nil { - pciDeviceSpec.Type = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Type = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Type.ID, Name: pciDevice.Type.Name, } } if pciDevice.Subtype != nil { - pciDeviceSpec.Subtype = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Subtype = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Subtype.ID, Name: pciDevice.Subtype.Name, } } if pciDevice.Class != nil { - pciDeviceSpec.Class = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Class = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Class.ID, Name: pciDevice.Class.Name, } } if pciDevice.Subclass != nil { - pciDeviceSpec.Subclass = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.Subclass = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.Subclass.ID, Name: pciDevice.Subclass.Name, } } if pciDevice.ProgrammingInterface != nil { - pciDeviceSpec.ProgrammingInterface = &apiv1alpha1.PCIDeviceDescriptionSpec{ + pciDeviceSpec.ProgrammingInterface = &metalv1alpha4.PCIDeviceDescriptionSpec{ ID: pciDevice.ProgrammingInterface.ID, Name: pciDevice.ProgrammingInterface.Name, } @@ -370,7 +370,7 @@ func (s *BuilderSvc) SetPCIDevices(cr *apiv1alpha1.Inventory, inv *inventory.Inv cr.Spec.PCIDevices = pciDevices } -func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetNICs(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if len(inv.NICs) == 0 { return } @@ -379,13 +379,13 @@ func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory return } - lldpMap := make(map[int][]apiv1alpha1.LLDPSpec) + lldpMap := make(map[int][]metalv1alpha4.LLDPSpec) for _, f := range inv.LLDPFrames { checkMap := make(map[frame.Capability]struct{}) - enabledCapabilities := make([]apiv1alpha1.LLDPCapabilities, 0) + enabledCapabilities := make([]metalv1alpha4.LLDPCapabilities, 0) for _, capability := range f.EnabledCapabilities { if _, ok := checkMap[capability]; !ok { - enabledCapabilities = append(enabledCapabilities, apiv1alpha1.LLDPCapabilities(capability)) + enabledCapabilities = append(enabledCapabilities, metalv1alpha4.LLDPCapabilities(capability)) checkMap[capability] = struct{}{} } } @@ -393,7 +393,7 @@ func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory return enabledCapabilities[i] < enabledCapabilities[j] }) id, _ := strconv.Atoi(f.InterfaceID) - l := apiv1alpha1.LLDPSpec{ + l := metalv1alpha4.LLDPSpec{ ChassisID: f.ChassisID, SystemName: f.SystemName, SystemDescription: f.SystemDescription, @@ -403,33 +403,33 @@ func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory } if _, ok := lldpMap[id]; !ok { - lldpMap[id] = make([]apiv1alpha1.LLDPSpec, 0) + lldpMap[id] = make([]metalv1alpha4.LLDPSpec, 0) } lldpMap[id] = append(lldpMap[id], l) } - ndpMap := make(map[int][]apiv1alpha1.NDPSpec) + ndpMap := make(map[int][]metalv1alpha4.NDPSpec) for _, ndp := range inv.NDPFrames { // filtering no arp as ip neigh does if ndp.State == netlink.CNeighbourNoARPCacheState { continue } - n := apiv1alpha1.NDPSpec{ + n := metalv1alpha4.NDPSpec{ IPAddress: ndp.IP, MACAddress: ndp.MACAddress, State: string(ndp.State), } if _, ok := ndpMap[ndp.DeviceIndex]; !ok { - ndpMap[ndp.DeviceIndex] = make([]apiv1alpha1.NDPSpec, 0) + ndpMap[ndp.DeviceIndex] = make([]metalv1alpha4.NDPSpec, 0) } ndpMap[ndp.DeviceIndex] = append(ndpMap[ndp.DeviceIndex], n) } - nics := make([]apiv1alpha1.NICSpec, 0) + nics := make([]metalv1alpha4.NICSpec, 0) for _, nic := range inv.NICs { // it was reported that loopback and docker interfaces on some systems may have // PCI address assigned (but they have weird format), so we need to exclude them too @@ -469,7 +469,7 @@ func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory return iStr < jStr }) - ns := apiv1alpha1.NICSpec{ + ns := metalv1alpha4.NICSpec{ Name: nic.Name, PCIAddress: nic.PCIAddress, MACAddress: nic.Address, @@ -491,30 +491,30 @@ func (s *BuilderSvc) SetNICs(cr *apiv1alpha1.Inventory, inv *inventory.Inventory cr.Spec.NICs = nics } -func (s *BuilderSvc) SetVirt(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetVirt(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if inv.Virtualization == nil { return } - cr.Spec.Virt = &apiv1alpha1.VirtSpec{ + cr.Spec.Virt = &metalv1alpha4.VirtSpec{ VMType: string(inv.Virtualization.Type), } } -func (s *BuilderSvc) SetHost(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetHost(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if inv.Host == nil { return } - cr.Spec.Host = &apiv1alpha1.HostSpec{ + cr.Spec.Host = &metalv1alpha4.HostSpec{ Name: inv.Host.Name, } } -func (s *BuilderSvc) SetDistro(cr *apiv1alpha1.Inventory, inv *inventory.Inventory) { +func (s *BuilderSvc) SetDistro(cr *metalv1alpha4.Inventory, inv *inventory.Inventory) { if inv.Distro == nil { return } - cr.Spec.Distro = &apiv1alpha1.DistroSpec{ + cr.Spec.Distro = &metalv1alpha4.DistroSpec{ BuildVersion: inv.Distro.BuildVersion, DebianVersion: inv.Distro.DebianVersion, KernelVersion: inv.Distro.KernelVersion, diff --git a/pkg/crd/gateway_saver.go b/pkg/crd/gateway_saver.go index 1060fb9..dde1cf0 100644 --- a/pkg/crd/gateway_saver.go +++ b/pkg/crd/gateway_saver.go @@ -20,7 +20,7 @@ import ( "net/http" "time" - apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/json" ) @@ -53,7 +53,7 @@ func NewGatewaySaverSvc(host, namespace string, timeout string) (SaverSvc, error }, nil } -func (g GatewaySaverSvc) Save(inv *apiv1alpha1.Inventory) error { +func (g GatewaySaverSvc) Save(inv *metalv1alpha4.Inventory) error { url := fmt.Sprintf(CSaveRequestURLTemplate, g.host, g.namespace) body, err := json.Marshal(inv) diff --git a/pkg/crd/kubeapi_saver.go b/pkg/crd/kubeapi_saver.go index fcc4597..626a453 100644 --- a/pkg/crd/kubeapi_saver.go +++ b/pkg/crd/kubeapi_saver.go @@ -18,8 +18,8 @@ import ( "context" "fmt" - apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" - clientv1alpha1 "github.com/onmetal/metal-api/clientset/inventory/v1alpha1" + metalv1alpha4 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" + clientv1alpha1 "github.com/ironcore-dev/metal/clientset/inventory/v1alpha1" "github.com/pkg/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,7 +43,7 @@ func NewKubeAPISaverSvc(kubeconfig string, namespace string) (SaverSvc, error) { return nil, errors.Wrapf(err, "unable to read kubeconfig from path %s", kubeconfig) } - if err := apiv1alpha1.AddToScheme(scheme.Scheme); err != nil { + if err := metalv1alpha4.AddToScheme(scheme.Scheme); err != nil { return nil, errors.Wrap(err, "unable to add registered types to client scheme") } @@ -59,7 +59,7 @@ func NewKubeAPISaverSvc(kubeconfig string, namespace string) (SaverSvc, error) { }, nil } -func (s *KubeAPISaverSvc) Save(inv *apiv1alpha1.Inventory) error { +func (s *KubeAPISaverSvc) Save(inv *metalv1alpha4.Inventory) error { _, err := s.client.Create(context.Background(), inv, metav1.CreateOptions{}) if err == nil { return nil diff --git a/pkg/crd/saver.go b/pkg/crd/saver.go index c1c6025..21ad975 100644 --- a/pkg/crd/saver.go +++ b/pkg/crd/saver.go @@ -14,7 +14,7 @@ package crd -import apiv1alpha1 "github.com/onmetal/metal-api/apis/inventory/v1alpha1" +import apiv1alpha1 "github.com/ironcore-dev/metal/apis/metal/v1alpha4" type SaverSvc interface { Save(inv *apiv1alpha1.Inventory) error diff --git a/pkg/netlink/svc.go b/pkg/netlink/svc.go index 0311153..a4257c1 100644 --- a/pkg/netlink/svc.go +++ b/pkg/netlink/svc.go @@ -17,6 +17,7 @@ package netlink import ( "github.com/pkg/errors" "github.com/vishvananda/netlink" + "golang.org/x/sys/unix" "github.com/onmetal/inventory/pkg/chroot" "github.com/onmetal/inventory/pkg/printer" @@ -59,7 +60,7 @@ func (s *Svc) GetIPv6NeighbourData() ([]IPv6Neighbour, error) { for _, l := range ll { iIdx := l.Attrs().Index iName := l.Attrs().Name - nl, err := netlink.NeighList(iIdx, netlink.FAMILY_V6) + nl, err := netlink.NeighList(iIdx, unix.AF_INET6) if err != nil { s.printer.VErr(errors.Wrapf(err, "unable to get neighbours for %s", iName)) continue diff --git a/pkg/nic/svc.go b/pkg/nic/svc.go index 2970ea1..0ca556c 100644 --- a/pkg/nic/svc.go +++ b/pkg/nic/svc.go @@ -22,11 +22,12 @@ import ( "github.com/pkg/errors" + switchConstants "github.com/ironcore-dev/metal/pkg/constants" + "github.com/onmetal/inventory/pkg/host" "github.com/onmetal/inventory/pkg/printer" "github.com/onmetal/inventory/pkg/redis" "github.com/onmetal/inventory/pkg/utils" - switchConstants "github.com/onmetal/metal-api/pkg/constants" ) const (