diff --git a/go.mod b/go.mod index 82c479432..8724d9138 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/opencontainers/image-spec v1.0.1 github.com/spf13/cobra v1.1.1 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.6.1 + github.com/stretchr/testify v1.7.0 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d // indirect golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e // indirect @@ -32,8 +32,8 @@ require ( k8s.io/cli-runtime v0.21.1 k8s.io/client-go v0.21.1 k8s.io/kubectl v0.21.1 - opendev.org/airship/go-redfish v0.0.0-20200318103738-db034d1d753a - opendev.org/airship/go-redfish/client v0.0.0-20200318103738-db034d1d753a + opendev.org/airship/go-redfish v0.0.0-20211004183611-3c3d7c6ba009 + opendev.org/airship/go-redfish/client v0.0.0-20211004183611-3c3d7c6ba009 sigs.k8s.io/cli-utils v0.21.1 sigs.k8s.io/controller-runtime v0.8.3 sigs.k8s.io/kustomize/api v0.8.11 diff --git a/go.sum b/go.sum index b17bee6c0..f24e7a384 100644 --- a/go.sum +++ b/go.sum @@ -8,20 +8,30 @@ cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0 h1:3ithwDMr7/3vpAMXiH+ZQnYbuIsh+OPhUPMFC9enmn0= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0 h1:Dg9iHVQfrhq82rUNu9ZxUDrJLaxFUe/HlCVaLyRruq8= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/360EntSecGroup-Skylar/excelize v1.4.1/go.mod h1:vnax29X2usfl7HHkBrX5EvSCJcmH3dT9luvxzu8iGAE= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= @@ -88,7 +98,6 @@ github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -114,6 +123,7 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/containerd/containerd v1.4.1 h1:pASeJT3R3YyVn+94qEPk0SnU1OQ20Jd/T+SPKy9xehY= github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= @@ -165,7 +175,9 @@ github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.5.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -283,12 +295,15 @@ github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfb github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -308,18 +323,23 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -414,10 +434,7 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= -github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhnIaL+V+BEER86oLrvS+kWobKpbJuye0= github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= -github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE= -github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb h1:w1g9wNDIE/pHSTmAaUhv4TZQuPBS6GV3mMz5hkgziIU= github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= @@ -588,8 +605,9 @@ github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnR 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= -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/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -605,7 +623,9 @@ github.com/xlab/handysort v0.0.0-20150421192137-fb3537ed64a1/go.mod h1:QcJo0QPSf github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI= github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -619,6 +639,7 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.starlark.net v0.0.0-20190528202925-30ae18b8564f/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc= go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= @@ -706,6 +727,7 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -717,8 +739,14 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210224082022-3d97a244fca7/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -728,14 +756,17 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99 h1:5vD4XjIc0X5+kHZjx4UecYdjA6mJo+XXNoaW0EjU5Os= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -777,9 +808,15 @@ golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -851,10 +888,20 @@ golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200616133436-c1934b75d054/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -873,7 +920,13 @@ google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsb google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -898,8 +951,18 @@ google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a h1:pOwg4OoaRYScjmR4LlLgdtnyoHYTSAVhhqe5uPdpII8= google.golang.org/genproto v0.0.0-20201110150050-8816d57aaa9a/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -908,10 +971,15 @@ google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1 h1:zvIju4sqAGvwKspUQOhwnpcqSbzi7/H6QomNNjTL4sk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0 h1:T7P4R73V3SSDPhH7WW7ATbfViLtmamH0DKrP3f9AuDI= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -967,6 +1035,7 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= k8s.io/api v0.18.10/go.mod h1:xWtwPX1v47j5RTncmlMFGCx8b0avh+nP8OgZZ9hjo3M= k8s.io/api v0.20.1/go.mod h1:KqwcCVogGxQY3nBlRpwt+wpAMF/KjaCc7RpywacvqUo= @@ -1037,10 +1106,11 @@ k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20210111153108-fddb29f9d009 h1:0T5IaWHO3sJTEmCP6mUlBvMukxPKUQWqiI/YuiBNMiQ= k8s.io/utils v0.0.0-20210111153108-fddb29f9d009/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -opendev.org/airship/go-redfish v0.0.0-20200318103738-db034d1d753a h1:4ggAMTwpfu/w3ZXOIJ9tfYF37JIYn+eNCA4O10NduZ0= -opendev.org/airship/go-redfish v0.0.0-20200318103738-db034d1d753a/go.mod h1:FEjYcb3bYBWGpQIqtvVM0NrT5eyjlCOCj5JNf4lI+6s= -opendev.org/airship/go-redfish/client v0.0.0-20200318103738-db034d1d753a h1:S1dmsP5Cc6OQjAd6OgIKMcNPBiGjh5TDbijVjNE/VGU= -opendev.org/airship/go-redfish/client v0.0.0-20200318103738-db034d1d753a/go.mod h1:s0hwuUpBsRXOrhN0NR+fNVivXGyWgHKpqtyq7qYjpew= +opendev.org/airship/go-redfish v0.0.0-20211004183611-3c3d7c6ba009 h1:7hSqsvwAjZYc7LTQCR6RCr9XIxIFNUeblqL9zOdpB1s= +opendev.org/airship/go-redfish v0.0.0-20211004183611-3c3d7c6ba009/go.mod h1:wS1HCbABvNuM6MUiEFsX+vp+GOR8D2/lcq2PaKYear0= +opendev.org/airship/go-redfish/client v0.0.0-20210505141832-c442eb5bcb3e/go.mod h1:I3eEaz4jvG/tlmHdk3dBiZ1HhBxpj+qL3k9Ey1C4BW4= +opendev.org/airship/go-redfish/client v0.0.0-20211004183611-3c3d7c6ba009 h1:WCEaHgxrJmq2yjcIC6KNUihmHXNRXWcZwchQGm+oCn0= +opendev.org/airship/go-redfish/client v0.0.0-20211004183611-3c3d7c6ba009/go.mod h1:Ljb94G9G5gP6nHAzYIrZfQOiHNSczfWpgJ9D8jLNWO4= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/remote/redfish/client.go b/pkg/remote/redfish/client.go index 21684d7a7..1507cbd7d 100644 --- a/pkg/remote/redfish/client.go +++ b/pkg/remote/redfish/client.go @@ -68,12 +68,13 @@ func (c *Client) EjectVirtualMedia(ctx context.Context) error { ctx = SetAuth(ctx, c.username, c.password) waitForEjectMedia := func(managerID string, mediaID string) error { for retry := 0; retry < c.systemActionRetries; retry++ { - vMediaMgr, httpResp, err := c.RedfishAPI.GetManagerVirtualMedia(ctx, managerID, mediaID) + getMediaReq := c.RedfishAPI.GetManagerVirtualMedia(ctx, managerID, mediaID) + vMediaMgr, httpResp, err := c.RedfishAPI.GetManagerVirtualMediaExecute(getMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } - if *vMediaMgr.Inserted == false { + if !vMediaMgr.GetInserted() { log.Debugf("Successfully ejected virtual media.") return nil } @@ -87,25 +88,28 @@ func (c *Client) EjectVirtualMedia(ctx context.Context) error { return err } - mediaCollection, httpResp, err := c.RedfishAPI.ListManagerVirtualMedia(ctx, managerID) + listMediaReq := c.RedfishAPI.ListManagerVirtualMedia(ctx, managerID) + mediaCollection, httpResp, err := c.RedfishAPI.ListManagerVirtualMediaExecute(listMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } // Walk all virtual media devices and eject if inserted for _, mediaURI := range mediaCollection.Members { - mediaID := GetResourceIDFromURL(mediaURI.OdataId) + mediaID := GetResourceIDFromURL(*mediaURI.OdataId) - vMediaMgr, httpResp, err := c.RedfishAPI.GetManagerVirtualMedia(ctx, managerID, mediaID) + getMediaReq := c.RedfishAPI.GetManagerVirtualMedia(ctx, managerID, mediaID) + vMediaMgr, httpResp, err := c.RedfishAPI.GetManagerVirtualMediaExecute(getMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } - if *vMediaMgr.Inserted == true { + if vMediaMgr.GetInserted() { log.Debugf("'%s' has virtual media inserted. Attempting to eject.", vMediaMgr.Name) var emptyBody map[string]interface{} - _, httpResp, err = c.RedfishAPI.EjectVirtualMedia(ctx, managerID, mediaID, emptyBody) + ejectMediaReq := c.RedfishAPI.EjectVirtualMedia(ctx, managerID, mediaID).Body(emptyBody) + _, httpResp, err = c.RedfishAPI.EjectVirtualMediaExecute(ejectMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } @@ -123,11 +127,12 @@ func (c *Client) EjectVirtualMedia(ctx context.Context) error { func (c *Client) RebootSystem(ctx context.Context) error { log.Debugf("Rebooting node '%s': powering off.", c.nodeID) ctx = SetAuth(ctx, c.username, c.password) - resetReq := redfishClient.ResetRequestBody{} + resetReq := redfishClient.NewResetRequestBodyWithDefaults() // Send PowerOff request - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF - _, httpResp, err := c.RedfishAPI.ResetSystem(ctx, c.nodeID, resetReq) + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) + resetSystemReq := c.RedfishAPI.ResetSystem(ctx, c.nodeID).ResetRequestBody(*resetReq) + _, httpResp, err := c.RedfishAPI.ResetSystemExecute(resetSystemReq) if err = ScreenRedfishError(httpResp, err); err != nil { log.Debugf("Failed to reboot node '%s': shutdown failure.", c.nodeID) return err @@ -141,8 +146,9 @@ func (c *Client) RebootSystem(ctx context.Context) error { log.Debugf("Rebooting node '%s': powering on.", c.nodeID) // Send PowerOn request - resetReq.ResetType = redfishClient.RESETTYPE_ON - _, httpResp, err = c.RedfishAPI.ResetSystem(ctx, c.nodeID, resetReq) + resetReq.ResetType = redfishClient.RESETTYPE_ON.Ptr() + resetSystemReq = c.RedfishAPI.ResetSystem(ctx, c.nodeID).ResetRequestBody(*resetReq) + _, httpResp, err = c.RedfishAPI.ResetSystemExecute(resetSystemReq) if err = ScreenRedfishError(httpResp, err); err != nil { log.Debugf("Failed to reboot node '%s': startup failure.", c.nodeID) return err @@ -164,18 +170,23 @@ func (c *Client) SetBootSourceByType(ctx context.Context) error { log.Debugf("Setting boot device to '%s'.", vMediaType) // Retrieve system information, containing available boot sources - system, _, err := c.RedfishAPI.GetSystem(ctx, c.nodeID) + systemReq := c.RedfishAPI.GetSystem(ctx, c.nodeID) + system, _, err := c.RedfishAPI.GetSystemExecute(systemReq) if err != nil { return ErrRedfishClient{Message: fmt.Sprintf("Get System[%s] failed with err: %v", c.nodeID, err)} } - allowableValues := system.Boot.BootSourceOverrideTargetRedfishAllowableValues - for _, bootSource := range allowableValues { - if strings.EqualFold(string(bootSource), vMediaType) { + boot := system.GetBoot() + allowableValues := boot.GetBootSourceOverrideTargetRedfishAllowableValues() + for i := range allowableValues { + if strings.EqualFold(string(allowableValues[i]), vMediaType) { /* set boot source */ systemReq := redfishClient.ComputerSystem{} - systemReq.Boot.BootSourceOverrideTarget = bootSource - _, httpResp, err := c.RedfishAPI.SetSystem(ctx, c.nodeID, systemReq) + systemReq.SetBoot(redfishClient.Boot{ + BootSourceOverrideTarget: &allowableValues[i], + }) + setSystemReq := c.RedfishAPI.SetSystem(ctx, c.nodeID).ComputerSystem(systemReq) + _, httpResp, err := c.RedfishAPI.SetSystemExecute(setSystemReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } @@ -212,8 +223,10 @@ func (c *Client) SetVirtualMedia(ctx context.Context, isoPath string) error { // Insert media vMediaReq := redfishClient.InsertMediaRequestBody{} vMediaReq.Image = isoPath - vMediaReq.Inserted = true - _, httpResp, err := c.RedfishAPI.InsertVirtualMedia(ctx, managerID, vMediaID, vMediaReq) + vMediaReq.SetInserted(true) + + insertMediaReq := c.RedfishAPI.InsertVirtualMedia(ctx, managerID, vMediaID).InsertMediaRequestBody(vMediaReq) + _, httpResp, err := c.RedfishAPI.InsertVirtualMediaExecute(insertMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err @@ -227,9 +240,16 @@ func (c *Client) SetVirtualMedia(ctx context.Context, isoPath string) error { func (c *Client) SystemPowerOff(ctx context.Context) error { ctx = SetAuth(ctx, c.username, c.password) resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF.Ptr() - _, httpResp, err := c.RedfishAPI.ResetSystem(ctx, c.nodeID, resetReq) + resetSystemReq := c.RedfishAPI.ResetSystem(ctx, c.nodeID).ResetRequestBody(resetReq) + _, httpResp, err := c.RedfishAPI.ResetSystemExecute(resetSystemReq) + + // if already powered off, a status conflict message is returned but we are good to go + if httpResp != nil && httpResp.StatusCode == http.StatusConflict { + return nil + } + //screen for any errors if err = ScreenRedfishError(httpResp, err); err != nil { return err } @@ -240,10 +260,15 @@ func (c *Client) SystemPowerOff(ctx context.Context) error { // SystemPowerOn powers on a host. func (c *Client) SystemPowerOn(ctx context.Context) error { ctx = SetAuth(ctx, c.username, c.password) - resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_ON + resetReq := redfishClient.NewResetRequestBodyWithDefaults() + resetReq.SetResetType(redfishClient.RESETTYPE_ON) + + resetSystemReq := c.RedfishAPI.ResetSystem(ctx, c.nodeID).ResetRequestBody(*resetReq) + + log.Printf("reset system request: %+v", resetSystemReq) + + _, httpResp, err := c.RedfishAPI.ResetSystemExecute(resetSystemReq) - _, httpResp, err := c.RedfishAPI.ResetSystem(ctx, c.nodeID, resetReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } @@ -254,12 +279,19 @@ func (c *Client) SystemPowerOn(ctx context.Context) error { // SystemPowerStatus retrieves the power status of a host as a human-readable string. func (c *Client) SystemPowerStatus(ctx context.Context) (power.Status, error) { ctx = SetAuth(ctx, c.username, c.password) - computerSystem, httpResp, err := c.RedfishAPI.GetSystem(ctx, c.nodeID) + systemReq := c.RedfishAPI.GetSystem(ctx, c.nodeID) + computerSystem, httpResp, err := c.RedfishAPI.GetSystemExecute(systemReq) + if screenErr := ScreenRedfishError(httpResp, err); screenErr != nil { return power.StatusUnknown, screenErr } - switch computerSystem.PowerState { + if computerSystem.PowerState == nil { + log.Printf("csystem power: %+v", computerSystem) + return power.StatusUnknown, nil + } + + switch *computerSystem.PowerState { case redfishClient.POWERSTATE_ON: return power.StatusOn, nil case redfishClient.POWERSTATE_OFF: @@ -269,6 +301,7 @@ func (c *Client) SystemPowerStatus(ctx context.Context) (power.Status, error) { case redfishClient.POWERSTATE_POWERING_OFF: return power.StatusPoweringOff, nil default: + log.Printf("csystem power: %+v", computerSystem.PowerState) return power.StatusUnknown, nil } } @@ -288,10 +321,10 @@ func RemoteDirect(ctx context.Context, isoURL, redfishURL string, c ifc.Client) return err } - // Power on node if it is off - if powerStatus != power.StatusOn { - log.Debugf("Ephemeral node has power status '%s'. Attempting to power on.", powerStatus.String()) - if err = c.SystemPowerOn(ctx); err != nil { + // Power off node if it is on + if powerStatus != power.StatusOff { + log.Debugf("Ephemeral node has power status '%s'. Attempting to power off.", powerStatus.String()) + if err = c.SystemPowerOff(ctx); err != nil { return err } } @@ -311,7 +344,7 @@ func RemoteDirect(ctx context.Context, isoURL, redfishURL string, c ifc.Client) return err } - err = c.RebootSystem(ctx) + err = c.SystemPowerOn(ctx) if err != nil { return err } @@ -339,7 +372,11 @@ func NewClient(redfishURL string, } cfg := &redfishClient.Configuration{ - BasePath: basePath, + Servers: redfishClient.ServerConfigurations{ + { + URL: basePath, + }, + }, DefaultHeader: make(map[string]string), UserAgent: headerUserAgent, } @@ -350,7 +387,7 @@ func NewClient(redfishURL string, // normally get when not overriding the transport defaultTransportCopy := http.DefaultTransport.(*http.Transport) //nolint:errcheck transport := defaultTransportCopy.Clone() - + transport.DisableKeepAlives = true if insecure { transport.TLSClientConfig = &tls.Config{ InsecureSkipVerify: true, //nolint:gosec diff --git a/pkg/remote/redfish/client_test.go b/pkg/remote/redfish/client_test.go index 31ec0114b..18a97234d 100644 --- a/pkg/remote/redfish/client_test.go +++ b/pkg/remote/redfish/client_test.go @@ -21,7 +21,6 @@ import ( "time" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" redfishMocks "opendev.org/airship/go-redfish/api/mocks" @@ -88,42 +87,45 @@ func TestEjectVirtualMedia(t *testing.T) { assert.NoError(t, err) client.nodeID = nodeID + client.RedfishAPI = m + ctx := SetAuth(context.Background(), "", "") // Mark CD and DVD test media as inserted inserted := true testMediaCD := testutil.GetVirtualMedia([]string{"CD"}) - testMediaCD.Inserted = &inserted + testMediaCD.SetInserted(inserted) testMediaDVD := testutil.GetVirtualMedia([]string{"DVD"}) - testMediaDVD.Inserted = &inserted + testMediaDVD.SetInserted(inserted) httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil).Times(1) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd", "DVD", "Floppy"}), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), httpResp, nil, 1) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd", "DVD", "Floppy"}), httpResp, nil, 1) // Eject CD - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMediaCD, httpResp, nil) - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Times(1). - Return(redfishClient.RedfishError{}, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"Cd"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, + "Cd", testMediaCD, httpResp, nil) + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + redfishClient.RedfishError{}, httpResp, nil) + + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"Cd"}), httpResp, nil) // Eject DVD and simulate two retries - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "DVD").Times(1). - Return(testMediaDVD, httpResp, nil) - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "DVD", mock.Anything).Times(1). - Return(redfishClient.RedfishError{}, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "DVD").Times(1). - Return(testMediaDVD, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "DVD").Times(1). - Return(testutil.GetVirtualMedia([]string{"DVD"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, + "DVD", testMediaDVD, httpResp, nil) + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "DVD", + redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, + "DVD", testMediaDVD, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, + "DVD", testutil.GetVirtualMedia([]string{"DVD"}), httpResp, nil) // Floppy is not inserted, so it is not ejected - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Floppy").Times(1). - Return(testutil.GetVirtualMedia([]string{"Floppy"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, + "Floppy", testutil.GetVirtualMedia([]string{"Floppy"}), httpResp, nil) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -148,22 +150,21 @@ func TestEjectVirtualMediaRetriesExceeded(t *testing.T) { // Mark test media as inserted inserted := true testMedia := testutil.GetVirtualMedia([]string{"CD"}) - testMedia.Inserted = &inserted + testMedia.SetInserted(inserted) httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd"). - Return(testMedia, httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), httpResp, nil, 1) + + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMedia, httpResp, nil) // Verify retry logic - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything). - Return(redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + redfishClient.RedfishError{}, httpResp, nil) // Media still inserted on retry. Since retries are 1, this causes failure. - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd"). - Return(testMedia, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMedia, httpResp, nil) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -186,19 +187,20 @@ func TestRebootSystem(t *testing.T) { // Mock redfish shutdown and status requests resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) httpResp := &http.Response{StatusCode: 200} - m.On("ResetSystem", ctx, client.nodeID, resetReq).Times(1).Return(redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetReq, redfishClient.RedfishError{}, httpResp, nil) - m.On("GetSystem", ctx, client.nodeID).Times(1).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, httpResp, nil) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, httpResp, nil, 1) // Mock redfish startup and status requests - resetReq.ResetType = redfishClient.RESETTYPE_ON - m.On("ResetSystem", ctx, client.nodeID, resetReq).Times(1).Return(redfishClient.RedfishError{}, httpResp, nil) - - m.On("GetSystem", ctx, client.nodeID).Times(1). - Return(redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_ON}, httpResp, nil) + resetReq.SetResetType(redfishClient.RESETTYPE_ON) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetReq, redfishClient.RedfishError{}, httpResp, nil) + computerSystem = redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, httpResp, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -220,10 +222,10 @@ func TestRebootSystemShutdownError(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) // Mock redfish shutdown request for failure - m.On("ResetSystem", ctx, client.nodeID, resetReq).Times(1).Return(redfishClient.RedfishError{}, + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetReq, redfishClient.RedfishError{}, &http.Response{StatusCode: 401}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client @@ -247,21 +249,23 @@ func TestRebootSystemStartupError(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) // Mock redfish shutdown request - m.On("ResetSystem", ctx, client.nodeID, resetReq).Times(1).Return(redfishClient.RedfishError{}, + + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetReq, redfishClient.RedfishError{}, &http.Response{StatusCode: 200}, nil) - m.On("GetSystem", ctx, client.nodeID).Times(1).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, - &http.Response{StatusCode: 200}, nil) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) resetOnReq := redfishClient.ResetRequestBody{} - resetOnReq.ResetType = redfishClient.RESETTYPE_ON + resetOnReq.SetResetType(redfishClient.RESETTYPE_ON) // Mock redfish startup request for failure - m.On("ResetSystem", ctx, client.nodeID, resetOnReq).Times(1).Return(redfishClient.RedfishError{}, + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetOnReq, redfishClient.RedfishError{}, &http.Response{StatusCode: 401}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client @@ -285,14 +289,13 @@ func TestRebootSystemTimeout(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) - m.On("ResetSystem", ctx, client.nodeID, resetReq). - Times(1). - Return(redfishClient.RedfishError{}, &http.Response{StatusCode: 200}, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &resetReq, redfishClient.RedfishError{}, + &http.Response{StatusCode: 200}, nil) - m.On("GetSystem", ctx, client.nodeID). - Return(redfishClient.ComputerSystem{}, &http.Response{StatusCode: 200}, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + &http.Response{StatusCode: 200}, nil, -1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -314,8 +317,8 @@ func TestSetBootSourceByTypeGetSystemError(t *testing.T) { ctx := SetAuth(context.Background(), "", "") // Mock redfish get system request - m.On("GetSystem", ctx, client.NodeID()).Times(1).Return(redfishClient.ComputerSystem{}, - &http.Response{StatusCode: 500}, redfishClient.GenericOpenAPIError{}) + testutil.MockOnGetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + &http.Response{StatusCode: 500}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -337,13 +340,18 @@ func TestSetBootSourceByTypeSetSystemError(t *testing.T) { ctx := SetAuth(context.Background(), "", "") httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) - m.On("SetSystem", ctx, client.nodeID, mock.Anything).Times(1).Return( - redfishClient.ComputerSystem{}, &http.Response{StatusCode: 401}, redfishClient.GenericOpenAPIError{}) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), + httpResp, nil, -1) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + system := redfishClient.ComputerSystem{} + boot := redfishClient.NewBoot() + boot.SetBootSourceOverrideTarget(redfishClient.BOOTSOURCE_CD) + system.SetBoot(*boot) + testutil.MockOnSetSystem(ctx, m, client.nodeID, system, + &http.Response{StatusCode: 401}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -365,17 +373,22 @@ func TestSetBootSourceByTypeBootSourceUnavailable(t *testing.T) { client.nodeID = nodeID invalidSystem := testutil.GetTestSystem() - invalidSystem.Boot.BootSourceOverrideTargetRedfishAllowableValues = []redfishClient.BootSource{ + boot := invalidSystem.GetBoot() + boot.SetBootSourceOverrideTargetRedfishAllowableValues([]redfishClient.BootSource{ redfishClient.BOOTSOURCE_HDD, redfishClient.BOOTSOURCE_PXE, - } + }) httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(invalidSystem, httpResp, nil) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, invalidSystem, + httpResp, nil, 2) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + system := redfishClient.ComputerSystem{} + testutil.MockOnSetSystem(ctx, m, client.nodeID, system, + &http.Response{StatusCode: 401}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -399,29 +412,29 @@ func TestSetVirtualMediaEjectExistingMedia(t *testing.T) { ctx := SetAuth(context.Background(), "", "") // Mark test media as inserted - inserted := true testMedia := testutil.GetVirtualMedia([]string{"CD"}) - testMedia.Inserted = &inserted + testMedia.SetInserted(true) httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), + httpResp, nil, -1) // Eject Media calls - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMedia, httpResp, nil) - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Times(1). - Return(redfishClient.RedfishError{}, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMedia, httpResp, nil) + + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) // Insert media calls - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) - m.On("InsertVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Return( + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnInsertVirtualMedia(ctx, m, testutil.ManagerID, "Cd", redfishClient.RedfishError{}, httpResp, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client @@ -447,20 +460,19 @@ func TestSetVirtualMediaEjectExistingMediaFailure(t *testing.T) { // Mark test media as inserted inserted := true testMedia := testutil.GetVirtualMedia([]string{"CD"}) - testMedia.Inserted = &inserted + testMedia.SetInserted(inserted) httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), + httpResp, nil, 1) // Eject Media calls - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMedia, httpResp, nil) - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Times(1). - Return(redfishClient.RedfishError{}, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMedia, httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMedia, httpResp, nil) + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMedia, httpResp, nil) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -481,8 +493,8 @@ func TestSetVirtualMediaGetSystemError(t *testing.T) { client.nodeID = nodeID // Mock redfish get system request - m.On("GetSystem", ctx, client.nodeID).Times(1).Return(redfishClient.ComputerSystem{}, - nil, redfishClient.GenericOpenAPIError{}) + testutil.MockOnGetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + nil, redfishClient.GenericOpenAPIError{}, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -504,18 +516,19 @@ func TestSetVirtualMediaInsertVirtualMediaError(t *testing.T) { client.nodeID = nodeID httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, client.nodeID).Return(testutil.GetTestSystem(), httpResp, nil) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, testutil.GetTestSystem(), + httpResp, nil, 3) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) // Insert media calls - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) - m.On("InsertVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Return( + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnInsertVirtualMedia(ctx, m, testutil.ManagerID, "Cd", redfishClient.RedfishError{}, &http.Response{StatusCode: 500}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client @@ -538,17 +551,17 @@ func TestSystemPowerOff(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return( - redfishClient.RedfishError{}, - &http.Response{StatusCode: 200}, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &redfishClient.ResetRequestBody{}, + redfishClient.RedfishError{}, &http.Response{StatusCode: 200}, nil) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_ON}, - &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, - &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -570,9 +583,8 @@ func TestSystemPowerOffResetSystemError(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return( - redfishClient.RedfishError{}, - &http.Response{StatusCode: 500}, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &redfishClient.ResetRequestBody{}, + redfishClient.RedfishError{}, &http.Response{StatusCode: 500}, nil) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -594,17 +606,18 @@ func TestSystemPowerOn(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return( - redfishClient.RedfishError{}, - &http.Response{StatusCode: 200}, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &redfishClient.ResetRequestBody{}, + redfishClient.RedfishError{}, &http.Response{StatusCode: 200}, nil) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, - &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_ON}, - &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem = redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -626,9 +639,8 @@ func TestSystemPowerOnResetSystemError(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("ResetSystem", ctx, client.nodeID, mock.Anything).Return( - redfishClient.RedfishError{}, - &http.Response{StatusCode: 500}, nil) + testutil.MockOnResetSystem(ctx, m, client.nodeID, &redfishClient.ResetRequestBody{}, + redfishClient.RedfishError{}, &http.Response{StatusCode: 500}, nil) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -650,11 +662,9 @@ func TestSystemPowerStatusUnknown(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - var unknownState redfishClient.PowerState = "unknown" - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: unknownState}, - &http.Response{StatusCode: 200}, - redfishClient.GenericOpenAPIError{}) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -674,10 +684,10 @@ func TestSystemPowerStatusOn(t *testing.T) { ctx := SetAuth(context.Background(), "", "") client.nodeID = nodeID - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_ON}, - &http.Response{StatusCode: 200}, - redfishClient.GenericOpenAPIError{}) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -697,10 +707,10 @@ func TestSystemPowerStatusOff(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_OFF}, - &http.Response{StatusCode: 200}, - redfishClient.GenericOpenAPIError{}) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -720,10 +730,10 @@ func TestSystemPowerStatusPoweringOn(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_POWERING_ON}, - &http.Response{StatusCode: 200}, - redfishClient.GenericOpenAPIError{}) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_POWERING_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -743,10 +753,10 @@ func TestSystemPowerStatusPoweringOff(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{PowerState: redfishClient.POWERSTATE_POWERING_OFF}, - &http.Response{StatusCode: 200}, - redfishClient.GenericOpenAPIError{}) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_POWERING_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -765,11 +775,8 @@ func TestSystemPowerStatusGetSystemError(t *testing.T) { client.nodeID = nodeID ctx := SetAuth(context.Background(), "", "") - - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{}, - &http.Response{StatusCode: 500}, - redfishClient.GenericOpenAPIError{}) + testutil.MockOnGetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + &http.Response{StatusCode: 500}, redfishClient.GenericOpenAPIError{}, 1) client.RedfishAPI = m @@ -786,10 +793,9 @@ func TestWaitForPowerStateGetSystemFailed(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF - - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{}, &http.Response{StatusCode: 500}, nil) + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + &http.Response{StatusCode: 500}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -810,12 +816,12 @@ func TestWaitForPowerStateNoRetries(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_OFF, - }, &http.Response{StatusCode: 200}, nil) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *computerSystem, + &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -836,17 +842,16 @@ func TestWaitForPowerStateWithRetries(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_ON, - }, &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, + *computerSystem, &http.Response{StatusCode: 200}, nil, 1) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_OFF, - }, &http.Response{StatusCode: 200}, nil).Times(1) + computerSystem.SetPowerState(redfishClient.POWERSTATE_OFF) + testutil.MockOnGetSystem(ctx, m, client.nodeID, + *computerSystem, &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -867,17 +872,17 @@ func TestWaitForPowerStateRetriesExceeded(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_OFF + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_OFF) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_ON, - }, &http.Response{StatusCode: 200}, nil) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, + *computerSystem, &http.Response{StatusCode: 200}, nil, 1) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_ON, - }, &http.Response{StatusCode: 200}, nil) + computerSystem = redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, + *computerSystem, &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -898,12 +903,12 @@ func TestWaitForPowerStateDifferentPowerState(t *testing.T) { ctx := SetAuth(context.Background(), "", "") resetReq := redfishClient.ResetRequestBody{} - resetReq.ResetType = redfishClient.RESETTYPE_FORCE_ON + resetReq.SetResetType(redfishClient.RESETTYPE_FORCE_ON) - m.On("GetSystem", ctx, client.nodeID).Return( - redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_ON, - }, &http.Response{StatusCode: 200}, nil) + computerSystem := redfishClient.NewComputerSystemWithDefaults() + computerSystem.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, + *computerSystem, &http.Response{StatusCode: 200}, nil, 1) // Replace normal API client with mocked API client client.RedfishAPI = m @@ -925,62 +930,57 @@ func TestRemoteDirect(t *testing.T) { inserted := true testMediaCD := testutil.GetVirtualMedia([]string{"CD"}) - testMediaCD.Inserted = &inserted - resetReq := redfishClient.ResetRequestBody{ - ResetType: redfishClient.RESETTYPE_FORCE_OFF, - } + testMediaCD.SetInserted(inserted) httpResp := &http.Response{StatusCode: 200} - system := redfishClient.ComputerSystem{ - PowerState: redfishClient.POWERSTATE_ON, - Links: redfishClient.SystemLinks{ - ManagedBy: []redfishClient.IdRef{ - {OdataId: testutil.ManagerID}, - }, + system := redfishClient.NewComputerSystemWithDefaults() + system.SetPowerState(redfishClient.POWERSTATE_OFF) + links := redfishClient.NewSystemLinksWithDefaults() + idRef := redfishClient.NewIdRefWithDefaults() + idRef.SetOdataId(testutil.ManagerID) + links.SetManagedBy([]redfishClient.IdRef{*idRef}) + system.SetLinks(*links) + system.SetBoot(redfishClient.Boot{ + BootSourceOverrideTargetRedfishAllowableValues: &[]redfishClient.BootSource{ + redfishClient.BOOTSOURCE_CD, }, - Boot: redfishClient.Boot{ - BootSourceOverrideTargetRedfishAllowableValues: []redfishClient.BootSource{ - redfishClient.BOOTSOURCE_CD, - }, - }} + }) ctx := SetAuth(context.Background(), "", "") + testutil.MockOnGetSystem(ctx, m, client.nodeID, *system, httpResp, nil, 7) - m.On("GetSystem", ctx, client.nodeID).Return(system, httpResp, nil).Times(6) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID). - Return(testutil.GetMediaCollection([]string{"Cd", "DVD", "Floppy"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMediaCD, httpResp, nil) - m.On("EjectVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Times(1). - Return(redfishClient.RedfishError{}, httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"Cd"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "DVD").Times(1). - Return(testutil.GetVirtualMedia([]string{"DVD"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Floppy").Times(1). - Return(testutil.GetVirtualMedia([]string{"Floppy"}), httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Cd", "DVD", "Floppy"}), httpResp, nil, -1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", testMediaCD, httpResp, nil) + testutil.MockOnEjectVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"Cd"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "DVD", + testutil.GetVirtualMedia([]string{"DVD"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Floppy", + testutil.GetVirtualMedia([]string{"Floppy"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMediaCD, httpResp, nil) - - m.On("InsertVirtualMedia", ctx, testutil.ManagerID, "Cd", mock.Anything).Return( + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testMediaCD, httpResp, nil) + testutil.MockOnInsertVirtualMedia(ctx, m, testutil.ManagerID, "Cd", redfishClient.RedfishError{}, httpResp, redfishClient.GenericOpenAPIError{}) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testMediaCD, httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testMediaCD, httpResp, nil) - m.On("SetSystem", ctx, client.nodeID, mock.Anything).Times(1).Return( - redfishClient.ComputerSystem{}, httpResp, nil) + testutil.MockOnSetSystem(ctx, m, client.nodeID, redfishClient.ComputerSystem{}, + httpResp, nil) - m.On("ResetSystem", ctx, client.nodeID, resetReq).Times(1).Return(redfishClient.RedfishError{}, httpResp, nil) - offSystem := system - offSystem.PowerState = redfishClient.POWERSTATE_OFF - m.On("GetSystem", ctx, client.nodeID).Return(offSystem, httpResp, nil).Times(1) + system.SetPowerState(redfishClient.POWERSTATE_ON) - m.On("ResetSystem", ctx, client.nodeID, redfishClient.ResetRequestBody{ - ResetType: redfishClient.RESETTYPE_ON, - }).Times(1).Return(redfishClient.RedfishError{}, httpResp, nil) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *system, httpResp, nil, 1) - m.On("GetSystem", ctx, client.nodeID).Return(system, httpResp, nil).Times(1) + resetReq := redfishClient.NewResetRequestBodyWithDefaults() + resetReq.SetResetType(redfishClient.RESETTYPE_ON) + testutil.MockOnResetSystem(ctx, m, client.nodeID, resetReq, + redfishClient.RedfishError{}, httpResp, nil) + system.SetPowerState(redfishClient.POWERSTATE_ON) + testutil.MockOnGetSystem(ctx, m, client.nodeID, *system, httpResp, nil, 2) err = client.RemoteDirect(ctx, "http://some-url") assert.NoError(t, err) diff --git a/pkg/remote/redfish/utils.go b/pkg/remote/redfish/utils.go index 8e05f7421..52ade521d 100644 --- a/pkg/remote/redfish/utils.go +++ b/pkg/remote/redfish/utils.go @@ -113,13 +113,14 @@ func DecodeRawError(rawResponse []byte) (string, error) { // GetManagerID retrieves the manager ID for a redfish system. func GetManagerID(ctx context.Context, api redfishAPI.RedfishAPI, systemID string) (string, error) { - system, httpResp, err := api.GetSystem(ctx, systemID) + systemReq := api.GetSystem(ctx, systemID) + system, httpResp, err := api.GetSystemExecute(systemReq) if err = ScreenRedfishError(httpResp, err); err != nil { log.Debugf("Unable to find manager for node '%s'.", systemID) return "", err } - return GetResourceIDFromURL(system.Links.ManagedBy[0].OdataId), nil + return GetResourceIDFromURL(*(*system.Links.ManagedBy)[0].OdataId), nil } // GetResourceIDFromURL returns a parsed Redfish resource ID @@ -140,7 +141,7 @@ func GetResourceIDFromURL(refURL string) string { // IsIDInList checks whether an ID exists in Redfish IDref collection func IsIDInList(idRefList []redfishClient.IdRef, id string) bool { for _, r := range idRefList { - rID := GetResourceIDFromURL(r.OdataId) + rID := GetResourceIDFromURL(*r.OdataId) if rID == id { return true } @@ -156,21 +157,22 @@ func GetVirtualMediaID(ctx context.Context, api redfishAPI.RedfishAPI, systemID return "", "", err } - mediaCollection, httpResp, err := api.ListManagerVirtualMedia(ctx, managerID) + listMediaReq := api.ListManagerVirtualMedia(ctx, managerID) + mediaCollection, httpResp, err := api.ListManagerVirtualMediaExecute(listMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return "", "", err } for _, mediaURI := range mediaCollection.Members { // Retrieve the virtual media ID from the request URI - mediaID := GetResourceIDFromURL(mediaURI.OdataId) - - vMedia, httpResp, err := api.GetManagerVirtualMedia(ctx, managerID, mediaID) + mediaID := GetResourceIDFromURL(*mediaURI.OdataId) + getMediaReq := api.GetManagerVirtualMedia(ctx, managerID, mediaID) + vMedia, httpResp, err := api.GetManagerVirtualMediaExecute(getMediaReq) if err = ScreenRedfishError(httpResp, err); err != nil { return "", "", err } - for _, mediaType := range vMedia.MediaTypes { + for _, mediaType := range *vMedia.MediaTypes { if mediaType == "CD" || mediaType == "DVD" { log.Debugf("Found virtual media type '%s' with ID '%s' on manager '%s'.", mediaType, mediaID, managerID) @@ -250,12 +252,13 @@ func SetAuth(ctx context.Context, username string, password string) context.Cont } func getManagerID(ctx context.Context, api redfishAPI.RedfishAPI, systemID string) (string, error) { - system, _, err := api.GetSystem(ctx, systemID) + systemReq := api.GetSystem(ctx, systemID) + system, _, err := api.GetSystemExecute(systemReq) if err != nil { return "", err } - return GetResourceIDFromURL(system.Links.ManagedBy[0].OdataId), nil + return GetResourceIDFromURL(*(*system.Links.ManagedBy)[0].OdataId), nil } func getBasePath(redfishURL string) (string, error) { @@ -277,12 +280,13 @@ func (c Client) waitForPowerState(ctx context.Context, desiredState redfishClien log.Debugf("Waiting for node '%s' to reach power state '%s'.", c.nodeID, desiredState) for retry := 0; retry <= c.systemActionRetries; retry++ { - system, httpResp, err := c.RedfishAPI.GetSystem(ctx, c.NodeID()) + systemReq := c.RedfishAPI.GetSystem(ctx, c.NodeID()) + system, httpResp, err := c.RedfishAPI.GetSystemExecute(systemReq) if err = ScreenRedfishError(httpResp, err); err != nil { return err } - if system.PowerState == desiredState { + if system.PowerState != nil && *system.PowerState == desiredState { log.Debugf("Node '%s' reached power state '%s'.", c.nodeID, desiredState) return nil } diff --git a/pkg/remote/redfish/utils_test.go b/pkg/remote/redfish/utils_test.go index 95efe0632..54dde0b9a 100644 --- a/pkg/remote/redfish/utils_test.go +++ b/pkg/remote/redfish/utils_test.go @@ -158,11 +158,16 @@ func TestRedfishUtilGetResIDFromURL(t *testing.T) { } func TestRedfishUtilIsIdInList(t *testing.T) { + path1 := "/path/to/id/1" + path2 := "/path/to/id/2" + path3 := "/path/to/id/3" + path4 := "/path/to/id/4" + idList := []redfishClient.IdRef{ - {OdataId: "/path/to/id/1"}, - {OdataId: "/path/to/id/2"}, - {OdataId: "/path/to/id/3"}, - {OdataId: "/path/to/id/4"}, + {OdataId: &path1}, + {OdataId: &path2}, + {OdataId: &path3}, + {OdataId: &path4}, } var emptyList []redfishClient.IdRef @@ -183,17 +188,16 @@ func TestGetVirtualMediaID(t *testing.T) { ctx := context.Background() httpResp := &http.Response{StatusCode: 200} - m.On("GetSystem", ctx, mock.Anything). - Return(testutil.GetTestSystem(), &http.Response{StatusCode: 200}, nil) + testutil.MockOnGetSystem(ctx, m, mock.Anything, testutil.GetTestSystem(), httpResp, nil, -1) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Floppy", "Cd"}), httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Floppy", "Cd"}), httpResp, nil, 1) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Floppy").Times(1). - Return(testutil.GetVirtualMedia([]string{"Floppy", "USBStick"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Floppy", + testutil.GetVirtualMedia([]string{"Floppy", "USBStick"}), httpResp, nil) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Cd").Times(1). - Return(testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Cd", + testutil.GetVirtualMedia([]string{"CD"}), httpResp, nil) mediaID, mediaType, err := redfish.GetVirtualMediaID(ctx, m, testutil.ManagerID) assert.Equal(t, mediaID, "Cd") @@ -210,12 +214,13 @@ func TestGetVirtualMediaIDNoMedia(t *testing.T) { // Remove available media types from test system system := testutil.GetTestSystem() - system.Boot.BootSourceOverrideTargetRedfishAllowableValues = []redfishClient.BootSource{} - m.On("GetSystem", ctx, mock.Anything). - Return(system, &http.Response{StatusCode: 200}, nil) + boot := system.GetBoot() + boot.SetBootSourceOverrideTargetRedfishAllowableValues([]redfishClient.BootSource{}) + testutil.MockOnGetSystem(ctx, m, mock.Anything, system, + &http.Response{StatusCode: 200}, nil, -1) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(redfishClient.Collection{}, httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + redfishClient.Collection{}, httpResp, nil, 1) mediaID, mediaType, err := redfish.GetVirtualMediaID(ctx, m, testutil.ManagerID) assert.Empty(t, mediaID) @@ -231,17 +236,18 @@ func TestGetVirtualMediaIDUnacceptableMediaTypes(t *testing.T) { httpResp := &http.Response{StatusCode: 200} system := testutil.GetTestSystem() - system.Boot.BootSourceOverrideTargetRedfishAllowableValues = []redfishClient.BootSource{ + boot := system.GetBoot() + boot.SetBootSourceOverrideTargetRedfishAllowableValues([]redfishClient.BootSource{ redfishClient.BOOTSOURCE_PXE, - } - m.On("GetSystem", ctx, mock.Anything). - Return(system, &http.Response{StatusCode: 200}, nil) + }) - m.On("ListManagerVirtualMedia", ctx, testutil.ManagerID).Times(1). - Return(testutil.GetMediaCollection([]string{"Floppy"}), httpResp, nil) + testutil.MockOnGetSystem(ctx, m, mock.Anything, system, + &http.Response{StatusCode: 200}, nil, -1) - m.On("GetManagerVirtualMedia", ctx, testutil.ManagerID, "Floppy").Times(1). - Return(testutil.GetVirtualMedia([]string{"Floppy", "USBStick"}), httpResp, nil) + testutil.MockOnListManagerVirtualMedia(ctx, m, testutil.ManagerID, + testutil.GetMediaCollection([]string{"Floppy"}), httpResp, nil, 1) + testutil.MockOnGetManagerVirtualMedia(ctx, m, testutil.ManagerID, "Floppy", + testutil.GetVirtualMedia([]string{"Floppy", "USBStick"}), httpResp, nil) mediaID, mediaType, err := redfish.GetVirtualMediaID(ctx, m, testutil.ManagerID) assert.Empty(t, mediaID) diff --git a/pkg/remote/redfish/vendors/dell/client.go b/pkg/remote/redfish/vendors/dell/client.go index 8248089ff..c9f7b8648 100644 --- a/pkg/remote/redfish/vendors/dell/client.go +++ b/pkg/remote/redfish/vendors/dell/client.go @@ -88,7 +88,8 @@ func (c *Client) SetBootSourceByType(ctx context.Context) error { // NOTE(drewwalters96): Setting the boot device to a virtual media type requires an API request to the iDRAC // actions API. The request is made below using the same HTTP client used by the Redfish API and exposed by the // standard airshipctl Redfish client. Only iDRAC 9 >= 3.3 is supports this endpoint. - url := fmt.Sprintf(endpointImportSysCFG, c.RedfishCFG.BasePath, managerID) + + url := fmt.Sprintf(endpointImportSysCFG, c.RedfishCFG.Servers[0].URL, managerID) req, err := http.NewRequest(http.MethodPost, url, bytes.NewBufferString(vCDBootRequestBody)) if err != nil { return err diff --git a/pkg/remote/redfish/vendors/dell/client_test.go b/pkg/remote/redfish/vendors/dell/client_test.go index 032b0506b..79ddacbda 100644 --- a/pkg/remote/redfish/vendors/dell/client_test.go +++ b/pkg/remote/redfish/vendors/dell/client_test.go @@ -62,7 +62,9 @@ func TestSetBootSourceByTypeGetSystemError(t *testing.T) { ctx := redfish.SetAuth(context.Background(), "", "") // Mock redfish get system request - m.On("GetSystem", ctx, client.NodeID()).Times(1).Return(redfishClient.ComputerSystem{}, + testSystemRequest := redfishClient.ApiGetSystemRequest{} + m.On("GetSystem", ctx, client.NodeID()).Return(testSystemRequest).Times(1) + m.On("GetSystemExecute", testSystemRequest).Times(1).Return(redfishClient.ComputerSystem{}, &http.Response{StatusCode: 500}, redfishClient.GenericOpenAPIError{}) // Replace normal API client with mocked API client diff --git a/testutil/redfishutils/helpers/helpers.go b/testutil/redfishutils/helpers/helpers.go index c51ecec93..3c787bfc6 100644 --- a/testutil/redfishutils/helpers/helpers.go +++ b/testutil/redfishutils/helpers/helpers.go @@ -13,8 +13,13 @@ package redfishutils import ( + "context" "fmt" + "net/http" + "github.com/stretchr/testify/mock" + + redfishMocks "opendev.org/airship/go-redfish/api/mocks" redfishClient "opendev.org/airship/go-redfish/client" ) @@ -30,7 +35,7 @@ func GetMediaCollection(refs []string) redfishClient.Collection { for _, r := range refs { id := redfishClient.IdRef{} - id.OdataId = fmt.Sprintf("%s/%s", uri, r) + id.SetOdataId(fmt.Sprintf("%s/%s", uri, r)) ids = append(ids, id) } @@ -50,36 +55,113 @@ func GetVirtualMedia(types []string) redfishClient.VirtualMedia { inserted := false - vMedia.MediaTypes = mediaTypes - vMedia.Inserted = &inserted + vMedia.SetMediaTypes(mediaTypes) + vMedia.SetInserted(inserted) return vMedia } // GetTestSystem builds a test computer system. func GetTestSystem() redfishClient.ComputerSystem { - return redfishClient.ComputerSystem{ - Id: "serverid-00", - Name: "server-100", - UUID: "58893887-8974-2487-2389-841168418919", - Status: redfishClient.Status{ - State: "Enabled", - Health: "OK", - }, - Links: redfishClient.SystemLinks{ - ManagedBy: []redfishClient.IdRef{ - {OdataId: fmt.Sprintf("/redfish/v1/Managers/%s", ManagerID)}, - }, - }, - Boot: redfishClient.Boot{ - BootSourceOverrideTarget: redfishClient.BOOTSOURCE_CD, - BootSourceOverrideEnabled: redfishClient.BOOTSOURCEOVERRIDEENABLED_CONTINUOUS, - BootSourceOverrideTargetRedfishAllowableValues: []redfishClient.BootSource{ - redfishClient.BOOTSOURCE_CD, - redfishClient.BOOTSOURCE_FLOPPY, - redfishClient.BOOTSOURCE_HDD, - redfishClient.BOOTSOURCE_PXE, - }, + computerSystem := redfishClient.NewComputerSystem() + computerSystem.SetId("serverid-00") + computerSystem.SetName("server-100") + computerSystem.SetUUID("58893887-8974-2487-2389-841168418919") + + status := redfishClient.NewStatusWithDefaults() + status.SetState(redfishClient.STATE_ENABLED) + status.SetHealth(redfishClient.HEALTH_OK) + computerSystem.SetStatus(*status) + + sysLinks := redfishClient.NewSystemLinksWithDefaults() + sysLinks.SetManagedBy([]redfishClient.IdRef{ + { + OdataId: redfishClient.PtrString(fmt.Sprintf("/redfish/v1/Managers/%s", ManagerID)), }, + }) + computerSystem.SetLinks(*sysLinks) + boot := redfishClient.NewBoot() + boot.SetBootSourceOverrideTarget(redfishClient.BOOTSOURCE_CD) + boot.SetBootSourceOverrideEnabled(redfishClient.BOOTSOURCEOVERRIDEENABLED_CONTINUOUS) + boot.SetBootSourceOverrideTargetRedfishAllowableValues([]redfishClient.BootSource{ + redfishClient.BOOTSOURCE_CD, + redfishClient.BOOTSOURCE_FLOPPY, + redfishClient.BOOTSOURCE_HDD, + redfishClient.BOOTSOURCE_PXE, + }) + computerSystem.SetBoot(*boot) + return *computerSystem +} + +// MockOnGetSystem creates mock On calls for GetSystem and GetSystemExecute +func MockOnGetSystem(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + systemID string, computerSystem redfishClient.ComputerSystem, + httpResponse *http.Response, err error, times int) { + testSystemRequest := redfishClient.ApiGetSystemRequest{} + call := mockAPI.On("GetSystem", ctx, systemID).Return(testSystemRequest) + if times > 0 { + call.Times(times) + } + call = mockAPI.On("GetSystemExecute", testSystemRequest).Return(computerSystem, httpResponse, err) + if times > 0 { + call.Times(times) } } + +// MockOnResetSystem creates mock On calls for ResetSystem and ResetSystemExecute +func MockOnResetSystem(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + systemID string, requestBody *redfishClient.ResetRequestBody, redfishErr redfishClient.RedfishError, + httpResponse *http.Response, err error) { + request := redfishClient.ApiResetSystemRequest{}.ResetRequestBody(*requestBody) + mockAPI.On("ResetSystem", ctx, systemID).Return(request).Times(1) + mockAPI.On("ResetSystemExecute", mock.Anything).Return(redfishErr, httpResponse, err).Times(1) +} + +// MockOnSetSystem creates mock On calls for SetSystem and SetSystemExecute +func MockOnSetSystem(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, systemID string, + computerSystem redfishClient.ComputerSystem, httpResponse *http.Response, err error) { + request := redfishClient.ApiSetSystemRequest{}.ComputerSystem(computerSystem) + mockAPI.On("SetSystem", ctx, systemID).Return(request).Times(1) + mockAPI.On("SetSystemExecute", mock.Anything).Return(computerSystem, httpResponse, err).Times(1) +} + +// MockOnGetManagerVirtualMedia creates mock On calls for GetManagerVirtualMedia and GetManagerVirtualMediaExecute +func MockOnGetManagerVirtualMedia(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + managerID string, virtualMediaID string, virtualMedia redfishClient.VirtualMedia, + httpResponse *http.Response, err error) { + mediaRequest := redfishClient.ApiGetManagerVirtualMediaRequest{} + mockAPI.On("GetManagerVirtualMedia", ctx, managerID, virtualMediaID).Return(mediaRequest).Times(1) + mockAPI.On("GetManagerVirtualMediaExecute", mock.Anything).Return(virtualMedia, httpResponse, err).Times(1) +} + +// MockOnListManagerVirtualMedia creates mock On calls for ListManagerVirtualMedia and ListtManagerVirtualMediaExecute +func MockOnListManagerVirtualMedia(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + managerID string, collection redfishClient.Collection, httpResponse *http.Response, err error, times int) { + mediaRequest := redfishClient.ApiListManagerVirtualMediaRequest{} + called := mockAPI.On("ListManagerVirtualMedia", ctx, managerID).Return(mediaRequest) + if times > 0 { + called.Times(times) + } + called = mockAPI.On("ListManagerVirtualMediaExecute", mock.Anything).Return(collection, httpResponse, err) + if times > 0 { + called.Times(1) + } +} + +// MockOnEjectVirtualMedia creates mock On calls for EjectVirtualMedia and EjectVirtualMediaExecute +func MockOnEjectVirtualMedia(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + managerID string, virtualMediaID string, redfishErr redfishClient.RedfishError, + httpResponse *http.Response, err error) { + mediaRequest := redfishClient.ApiEjectVirtualMediaRequest{} + mockAPI.On("EjectVirtualMedia", ctx, managerID, virtualMediaID).Return(mediaRequest).Times(1) + mockAPI.On("EjectVirtualMediaExecute", mock.Anything).Return(redfishErr, httpResponse, err).Times(1) +} + +// MockOnInsertVirtualMedia creates mock On calls for InsertVirtualMedia and InsertVirtualMediaExecute +func MockOnInsertVirtualMedia(ctx context.Context, mockAPI *redfishMocks.RedfishAPI, + managerID string, virtualMediaID string, redfishErr redfishClient.RedfishError, + httpResponse *http.Response, err error) { + mediaRequest := redfishClient.ApiInsertVirtualMediaRequest{} + mockAPI.On("InsertVirtualMedia", ctx, managerID, virtualMediaID).Return(mediaRequest).Times(1) + mockAPI.On("InsertVirtualMediaExecute", mock.Anything).Return(redfishErr, httpResponse, err).Times(1) +}