diff --git a/cmd/api-regression/main.go b/cmd/api-regression/main.go index 552a8d4..c2f0056 100644 --- a/cmd/api-regression/main.go +++ b/cmd/api-regression/main.go @@ -7,7 +7,7 @@ import ( "fmt" "os" - "github.com/Seagate/seagate-exos-x-api-go/pkg/regression" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/regression" "github.com/onsi/ginkgo/v2" "k8s.io/klog/v2" diff --git a/go.mod b/go.mod index 6012ab4..112a507 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Seagate/seagate-exos-x-api-go +module github.com/Seagate/seagate-exos-x-api-go/v2 go 1.20 @@ -6,13 +6,12 @@ require ( github.com/go-logr/logr v1.2.4 github.com/golang/protobuf v1.5.3 github.com/namsral/flag v1.7.4-pre - github.com/onsi/ginkgo/v2 v2.9.5 - github.com/onsi/gomega v1.27.6 - github.com/prometheus/client_golang v1.11.1 - github.com/stretchr/testify v1.6.1 - golang.org/x/text v0.9.0 - google.golang.org/grpc v1.53.0 - gopkg.in/yaml.v2 v2.4.0 + github.com/onsi/ginkgo/v2 v2.13.0 + github.com/onsi/gomega v1.28.1 + github.com/prometheus/client_golang v1.17.0 + github.com/stretchr/testify v1.8.4 + golang.org/x/text v0.13.0 + google.golang.org/grpc v1.59.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/klog/v2 v2.100.1 ) @@ -22,16 +21,17 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.26.0 // indirect - github.com/prometheus/procfs v0.6.0 // indirect - golang.org/x/net v0.10.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/tools v0.9.1 // indirect - google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect - google.golang.org/protobuf v1.28.1 // indirect + github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/tools v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/protobuf v1.31.0 // indirect ) diff --git a/go.sum b/go.sum index fdfde5b..1d5d53a 100644 --- a/go.sum +++ b/go.sum @@ -1,185 +1,77 @@ -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= 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/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 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.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= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -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.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs= github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo= -github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q= -github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k= -github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/gomega v1.28.1 h1:MijcGUbfYuznzK/5R4CPNoUP/9Xvuo20sXfEm6XxoTA= +github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s= -github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= +github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= +github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM= +github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= +github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= +github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/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-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= -golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w= -google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= -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= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/generator/cmd/main.go b/internal/generator/cmd/main.go index db05535..91183eb 100644 --- a/internal/generator/cmd/main.go +++ b/internal/generator/cmd/main.go @@ -7,9 +7,9 @@ import ( "fmt" "os" - "github.com/Seagate/seagate-exos-x-api-go/internal/generator" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/internal/generator" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "k8s.io/klog/v2" ) diff --git a/internal/generator/spec.go b/internal/generator/spec.go index 3e4bc6a..961faf3 100644 --- a/internal/generator/spec.go +++ b/internal/generator/spec.go @@ -11,7 +11,7 @@ import ( "sort" "strings" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "golang.org/x/text/cases" "golang.org/x/text/language" diff --git a/internal/validator/cmd/main.go b/internal/validator/cmd/main.go index 6b292f7..488f7ab 100644 --- a/internal/validator/cmd/main.go +++ b/internal/validator/cmd/main.go @@ -7,10 +7,9 @@ import ( "fmt" "os" - "github.com/Seagate/seagate-exos-x-api-go/internal/validator" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/internal/validator" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "k8s.io/klog/v2" ) diff --git a/internal/validator/system.go b/internal/validator/system.go index 432249b..ddfbd00 100644 --- a/internal/validator/system.go +++ b/internal/validator/system.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" "github.com/go-logr/logr" "k8s.io/klog/v2" diff --git a/pkg/v2/mcapi.go b/pkg/api/mcapi.go similarity index 97% rename from pkg/v2/mcapi.go rename to pkg/api/mcapi.go index e809cce..4f32e30 100644 --- a/pkg/v2/mcapi.go +++ b/pkg/api/mcapi.go @@ -9,8 +9,8 @@ import ( "net/http" "time" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "github.com/go-logr/logr" "k8s.io/klog/v2" ) diff --git a/pkg/v2/snapshots.go b/pkg/api/snapshots.go similarity index 96% rename from pkg/v2/snapshots.go rename to pkg/api/snapshots.go index b3244c6..00eca55 100644 --- a/pkg/v2/snapshots.go +++ b/pkg/api/snapshots.go @@ -6,8 +6,8 @@ import ( "net/http" "time" - openapiclient "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + openapiclient "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "k8s.io/klog/v2" ) diff --git a/pkg/v2/system.go b/pkg/api/system.go similarity index 96% rename from pkg/v2/system.go rename to pkg/api/system.go index 18cfd90..52b9c18 100644 --- a/pkg/v2/system.go +++ b/pkg/api/system.go @@ -7,7 +7,7 @@ import ( "net/http" "strings" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "k8s.io/klog/v2" ) @@ -201,6 +201,11 @@ func GetTargetId(system *common.SystemInfo, portType string) (string, error) { return "", fmt.Errorf("TargetId was not found for system (%s) with (%d) ports", system.IPAddress, len(system.Ports)) } +// GetPortals: Return a list of portals for the storage system +func (client *Client) GetPortals() (string, error) { + return GetPortals(client.Info) +} + // GetPortals: Return a list of iSCSI portals for the storage system func GetPortals(system *common.SystemInfo) (string, error) { if system == nil { @@ -224,5 +229,5 @@ func GetPortals(system *common.SystemInfo) (string, error) { return portals, nil } - return "", fmt.Errorf("No portals found for system (%s) with (%d) ports", system.IPAddress, len(system.Ports)) + return "", fmt.Errorf("no portals found for system (%s) with (%d) ports", system.IPAddress, len(system.Ports)) } diff --git a/pkg/v2/volumes.go b/pkg/api/volumes.go similarity index 99% rename from pkg/v2/volumes.go rename to pkg/api/volumes.go index a46ab51..adb449c 100644 --- a/pkg/v2/volumes.go +++ b/pkg/api/volumes.go @@ -9,8 +9,8 @@ import ( "strconv" "strings" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "k8s.io/klog/v2" diff --git a/pkg/client/test/api_default_test.go b/pkg/client/test/api_default_test.go index b6b04d8..8bf6713 100644 --- a/pkg/client/test/api_default_test.go +++ b/pkg/client/test/api_default_test.go @@ -13,7 +13,7 @@ import ( "context" "testing" - openapiclient "github.com/Seagate/seagate-exos-x-api-go/pkg/v2" + openapiclient "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -142,19 +142,19 @@ func Test_client_DefaultApiService(t *testing.T) { }) - t.Run("Test DefaultApiService LoginGetByHash", func(t *testing.T) { + // t.Run("Test DefaultApiService LoginGetByHash", func(t *testing.T) { - t.Skip("skip test") // remove to run test + // t.Skip("skip test") // remove to run test - var loginHash string + // var loginHash string - resp, httpRes, err := apiClient.DefaultApi.LoginGetByHash(context.Background(), loginHash).Execute() + // resp, httpRes, err := apiClient.DefaultApi.LoginGetByHash(context.Background(), loginHash).Execute() - require.Nil(t, err) - require.NotNil(t, resp) - assert.Equal(t, 200, httpRes.StatusCode) + // require.Nil(t, err) + // require.NotNil(t, resp) + // assert.Equal(t, 200, httpRes.StatusCode) - }) + // }) t.Run("Test DefaultApiService MapVolumeAccessLunInitiatorNamesGet", func(t *testing.T) { diff --git a/pkg/common/mc.go b/pkg/common/mc.go index 6ad237e..dc71d34 100644 --- a/pkg/common/mc.go +++ b/pkg/common/mc.go @@ -8,7 +8,7 @@ import ( "net/http" "strings" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" "k8s.io/klog/v2" ) diff --git a/pkg/regression/debug.go b/pkg/regression/debug.go index 2126423..07698c2 100644 --- a/pkg/regression/debug.go +++ b/pkg/regression/debug.go @@ -3,7 +3,7 @@ package regression import ( - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "github.com/go-logr/logr" ) diff --git a/pkg/regression/regression.go b/pkg/regression/regression.go index fc39e66..4ee7731 100644 --- a/pkg/regression/regression.go +++ b/pkg/regression/regression.go @@ -4,12 +4,12 @@ package regression import ( "context" - "io/ioutil" + "os" - "github.com/Seagate/seagate-exos-x-api-go/pkg/client" - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/client" + "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/common" "github.com/go-logr/logr" - "gopkg.in/yaml.v2" + "gopkg.in/yaml.v3" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -46,7 +46,7 @@ func ReadConfigurationYaml(filename string) (*ConfigurationYaml, error) { // If it is not possible to extract the configuration.yaml from the tar file, use defaults var yamlc = ConfigurationYaml{} - yamlFile, err := ioutil.ReadFile(filename) + yamlFile, err := os.ReadFile(filename) if err != nil { return &yamlc, err } diff --git a/pkg/regression/v1_login.go b/pkg/regression/v1_login.go deleted file mode 100644 index 653b4bf..0000000 --- a/pkg/regression/v1_login.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2023 Seagate Technology LLC and/or its Affiliates - -package regression - -import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v1" - "k8s.io/klog/v2" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" -) - -var _ = DescribeRegression("Login Testing (v1)", func(tc *TestContext) { - - var ( - client *storageapi.Client - ) - - Describe("v1LoginTest", func() { - - It("should be able to log into storage controller", func() { - client = storageapi.NewClient() - client.StoreCredentials(tc.Config.StorageController.Ip, tc.Config.StorageController.Protocol, tc.Config.StorageController.Username, tc.Config.StorageController.Password) - err := client.Login() - logger := klog.FromContext(tc.Config.Ctx) - logger.V(3).Info("Login", "ip", client.Addr, "username", client.Username, "err", err) - Expect(err).To(BeNil()) - }) - - It("should be a valid session", func() { - valid := client.SessionValid(client.Addr, client.Username) - Expect(valid).To(Equal(true)) - }) - - }) -}) diff --git a/pkg/regression/v1_snapshots.go b/pkg/regression/v1_snapshots.go deleted file mode 100644 index c30d71b..0000000 --- a/pkg/regression/v1_snapshots.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) 2023 Seagate Technology LLC and/or its Affiliates - -package regression - -import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v1" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/klog/v2" -) - -var _ = DescribeRegression("Snapshot Testing (v1)", func(tc *TestContext) { - var ( - client *storageapi.Client = nil - volname1 = "apitest_1" - size = "1GiB" - poolType = "Virtual" - snap1 = "snap1" - snap2 = "snap2" - ) - - BeforeEach(func() { - By("setup client for testing") - - logger := klog.FromContext(tc.Config.Ctx) - client = storageapi.NewClient() - client.StoreCredentials(tc.Config.StorageController.Ip, tc.Config.StorageController.Protocol, tc.Config.StorageController.Username, tc.Config.StorageController.Password) - err := client.Login() - logger.V(3).Info("Login", "ip", client.Addr, "username", client.Username, "err", err) - Expect(err).To(BeNil()) - }) - - Describe("v1SnapshotTest", func() { - It("should successfully create the volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - volume, status, err := client.CreateVolume(volname1, size, tc.Config.StorageController.Pool, poolType) - logger.V(3).Info("CreateVolume", "name", volname1, "size", size, "wwn", volume.Wwn, "status", status.ResponseTypeNumeric) - - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show volumes - response, status, err := client.ShowVolumes(volname1) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - Expect(len(response)).To(Equal(1)) - ShowVolumes(logger, response) - }) - - It("should successfully create a snapshot", func() { - - logger := klog.FromContext(tc.Config.Ctx) - - logger.V(3).Info("CreateSnapshot", "name", volname1, "snap1", snap1) - status, err := client.CreateSnapshot(volname1, snap1) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show snapshots - snapshots, status, err := client.ShowSnapshots(snap1, "") - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - Expect(len(snapshots)).To(Equal(1)) - Expect(snapshots[0].Name).To(Equal(snap1)) - ShowSnapshots(logger, snapshots) - - // Show volumes - volumes, status, err := client.ShowVolumes(volname1) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, volumes) - }) - - It("should successfully create a 2nd snapshot", func() { - - logger := klog.FromContext(tc.Config.Ctx) - - logger.V(3).Info("CreateSnapshot", "name", volname1, "snap2", snap2) - status, err := client.CreateSnapshot(volname1, snap2) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show snapshots - snapshots, status, err := client.ShowSnapshots(snap2, "") - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowSnapshots(logger, snapshots) - Expect(len(snapshots)).To(Equal(1)) - Expect(snapshots[0].Name).To(Equal(snap2)) - - // Show volumes - volumes, status, err := client.ShowVolumes(volname1) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, volumes) - }) - - It("should successfully delete both snapshots", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.DeleteSnapshot(snap1) - logger.V(3).Info("delete snapshot", "name", snap1, "err", err) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - status, err = client.DeleteSnapshot(snap2) - logger.V(3).Info("delete snapshot", "name", snap2, "err", err) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show snapshots - snapshots, status, err := client.ShowSnapshots(snap1, "") - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowSnapshots(logger, snapshots) - }) - - It("should successfully delete the volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.DeleteVolume(volname1) - logger.V(3).Info("delete volume", "name", volname1, "err", err) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show volumes - response, status, err := client.ShowVolumes() - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, response) - }) - }) -}) diff --git a/pkg/regression/v1_system.go b/pkg/regression/v1_system.go deleted file mode 100644 index ac0616d..0000000 --- a/pkg/regression/v1_system.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) 2023 Seagate Technology LLC and/or its Affiliates - -package regression - -import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v1" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/klog/v2" -) - -var _ = DescribeRegression("System Testing (v1)", func(tc *TestContext) { - var ( - client *storageapi.Client = nil - ) - - BeforeEach(func() { - By("setup client for testing") - - logger := klog.FromContext(tc.Config.Ctx) - client = storageapi.NewClient() - client.StoreCredentials(tc.Config.StorageController.Ip, tc.Config.StorageController.Protocol, tc.Config.StorageController.Username, tc.Config.StorageController.Password) - err := client.Login() - logger.V(3).Info("Login", "ipaddress", client.Addr, "username", client.Username, "err", err) - Expect(err).To(BeNil()) - }) - - Describe("v1SystemTest", func() { - It("should successfully init the system info", func() { - - logger := klog.FromContext(tc.Config.Ctx) - err := client.InitSystemInfo() - logger.V(3).Info("InitSystemInfo", "err", err) - Expect(err).To(BeNil()) - - err = storageapi.Log(client.Info) - Expect(err).To(BeNil()) - }) - - It("should be able to get a valid pool type", func() { - - logger := klog.FromContext(tc.Config.Ctx) - err := client.InitSystemInfo() - Expect(err).To(BeNil()) - poolType, err := storageapi.GetPoolType(client.Info, tc.Config.StorageController.Pool) - logger.V(3).Info("GetPoolType", "pool", tc.Config.StorageController.Pool, "type", poolType) - Expect(err).To(BeNil()) - Expect(poolType).ShouldNot(Equal("")) - }) - - It("should be able to get valid portals", func() { - - logger := klog.FromContext(tc.Config.Ctx) - err := client.InitSystemInfo() - Expect(err).To(BeNil()) - portals, err := storageapi.GetPortals(client.Info) - logger.V(3).Info("GetPortals", "portals", portals) - Expect(err).To(BeNil()) - Expect(portals).ShouldNot(Equal("")) - }) - - It("should be able to get valid target id", func() { - - logger := klog.FromContext(tc.Config.Ctx) - err := client.InitSystemInfo() - Expect(err).To(BeNil()) - targetid, err := storageapi.GetTargetId(client.Info, "iSCSI") - logger.V(3).Info("GetTargetId", "targetid", targetid) - Expect(err).To(BeNil()) - Expect(targetid).ShouldNot(Equal("")) - }) - - }) -}) diff --git a/pkg/regression/v1_volumes.go b/pkg/regression/v1_volumes.go deleted file mode 100644 index f0c8503..0000000 --- a/pkg/regression/v1_volumes.go +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright (c) 2023 Seagate Technology LLC and/or its Affiliates - -package regression - -import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v1" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "k8s.io/klog/v2" -) - -var _ = DescribeRegression("Volume Testing (v1)", func(tc *TestContext) { - var ( - client *storageapi.Client = nil - volname1 = "apitest_1" - volname2 = "apitest_2" - size = "1GiB" - expandSize = "1GiB" - poolType = "Virtual" - sizeValue int64 = 1024 * 1024 * 1024 - ) - - BeforeEach(func() { - By("setup client for testing") - - logger := klog.FromContext(tc.Config.Ctx) - client = storageapi.NewClient() - client.StoreCredentials(tc.Config.StorageController.Ip, tc.Config.StorageController.Protocol, tc.Config.StorageController.Username, tc.Config.StorageController.Password) - err := client.Login() - logger.V(3).Info("Login", "ip", client.Addr, "username", client.Username, "err", err) - Expect(err).To(BeNil()) - }) - - Describe("v1VolumeTest", func() { - It("should successfully create the volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - volume, status, err := client.CreateVolume(volname1, size, tc.Config.StorageController.Pool, poolType) - logger.V(3).Info("CreateVolume", "name", volname1, "size", size, "wwn", volume.Wwn, "status", status.ResponseTypeNumeric) - - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - Expect(volume.Wwn).ShouldNot(BeEmpty()) - - // Dump volumes - response, status, err := client.ShowVolumes(volname1) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, response) - }) - - It("created volume should exist", func() { - - logger := klog.FromContext(tc.Config.Ctx) - exists, err := client.CheckVolumeExists(volname1, sizeValue) - logger.V(3).Info("CheckVolumeExists", "name", volname1, "exists", exists) - Expect(err).To(BeNil()) - Expect(exists).To(Equal(true)) - }) - - It("unknown volume should NOT exist", func() { - - logger := klog.FromContext(tc.Config.Ctx) - exists, err := client.CheckVolumeExists("unknown-volume", sizeValue) - logger.V(3).Info("CheckVolumeExists", "name", volname1, "exists", exists) - Expect(err).To(BeNil()) - Expect(exists).To(Equal(false)) - }) - - It("created volume should have valid WWN", func() { - - logger := klog.FromContext(tc.Config.Ctx) - wwn, err := client.GetVolumeWwn(volname1) - logger.V(3).Info("GetVolumeWwn", "name", volname1, "wwn", wwn) - Expect(err).To(BeNil()) - Expect(wwn).ShouldNot(Equal("")) - }) - - It("should be able to publish/map volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - lun, err := client.PublishVolume(volname1, tc.Config.StorageController.Initiator) - logger.V(3).Info("PublishVolume", "name", volname1, "lun", lun, "initiator", tc.Config.StorageController.Initiator) - Expect(err).To(BeNil()) - Expect(lun).ToNot(Equal(0)) - }) - - It("should be able to unmap volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.UnmapVolume(volname1, tc.Config.StorageController.Initiator[0]) - logger.V(3).Info("UnmapVolume", "name", volname1, "initiator", tc.Config.StorageController.Initiator, "response", status.ResponseTypeNumeric) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - }) - - It("should be able to expand the volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.ExpandVolume(volname1, expandSize) - logger.V(3).Info("ExpandVolume", "name", volname1, "response", status.ResponseTypeNumeric) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show volumes - response, status, err := client.ShowVolumes() - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, response) - }) - - It("should be able to copy the volume", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.CopyVolume(volname1, volname2, tc.Config.StorageController.Pool) - logger.V(3).Info("CopyVolume", "from", volname1, "to", volname2, "pool", tc.Config.StorageController.Pool, "status", status.ResponseTypeNumeric) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show volumes - response, status, err := client.ShowVolumes() - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, response) - }) - - It("should successfully delete both volumes", func() { - - logger := klog.FromContext(tc.Config.Ctx) - status, err := client.DeleteVolume(volname1) - logger.V(3).Info("delete volume", "name", volname1, "err", err) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - status, err = client.DeleteVolume(volname2) - logger.V(3).Info("delete volume", "name", volname2, "err", err) - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - - // Show volumes - response, status, err := client.ShowVolumes() - Expect(err).To(BeNil()) - Expect(status.ResponseTypeNumeric).To(Equal(0)) - ShowVolumes(logger, response) - }) - }) -}) diff --git a/pkg/regression/v2_login.go b/pkg/regression/v2_login.go index 72e2c3a..3c5673f 100644 --- a/pkg/regression/v2_login.go +++ b/pkg/regression/v2_login.go @@ -3,7 +3,7 @@ package regression import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v2" + storageapi "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/api" "k8s.io/klog/v2" . "github.com/onsi/ginkgo/v2" diff --git a/pkg/regression/v2_snapshots.go b/pkg/regression/v2_snapshots.go index 061d0af..c2e1891 100644 --- a/pkg/regression/v2_snapshots.go +++ b/pkg/regression/v2_snapshots.go @@ -3,7 +3,7 @@ package regression import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v2" + storageapi "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/api" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/klog/v2" diff --git a/pkg/regression/v2_system.go b/pkg/regression/v2_system.go index dadd8c6..a537b2e 100644 --- a/pkg/regression/v2_system.go +++ b/pkg/regression/v2_system.go @@ -3,7 +3,7 @@ package regression import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v2" + storageapi "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/api" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/klog/v2" diff --git a/pkg/regression/v2_volumes.go b/pkg/regression/v2_volumes.go index 52ed922..ab7a5f6 100644 --- a/pkg/regression/v2_volumes.go +++ b/pkg/regression/v2_volumes.go @@ -3,7 +3,7 @@ package regression import ( - storageapi "github.com/Seagate/seagate-exos-x-api-go/pkg/v2" + storageapi "github.com/Seagate/seagate-exos-x-api-go/v2/pkg/api" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "k8s.io/klog/v2" diff --git a/pkg/v1/api.go b/pkg/v1/api.go deleted file mode 100644 index 5f16ec9..0000000 --- a/pkg/v1/api.go +++ /dev/null @@ -1,472 +0,0 @@ -// -// Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// For any questions about this software or licensing, -// please email opensource@seagate.com or cortx-questions@seagate.com. - -package exosx - -import ( - "fmt" - "sort" - "strconv" - "strings" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "k8s.io/klog/v2" -) - -// Configuration constants -const ( - MaximumLUN = 255 -) - -type VolumeMapInfo struct { - Volume string - Exists bool - SerialNumber string - Mappings []VolumeMapItem -} - -type VolumeMapItem struct { - InitiatorId string - LUN string - Access string - Ports string - Nickname string - Profile string -} - -type InitiatorMapInfo struct { - InitiatorId string - Nickname string - Profile string - Mappings []InitiatorMapItem -} - -type InitiatorMapItem struct { - Volume string - SerialNumber string - LUN string - Access string - Ports string -} - -type Volumes []Volume - -func (v Volumes) Len() int { - return len(v) -} - -func (v Volumes) Swap(i, j int) { - v[i], v[j] = v[j], v[i] -} - -func (v Volumes) Less(i, j int) bool { - return v[i].LUN < v[j].LUN -} - -// InitSystemInfo: Retrieve and store system information for this client -func (client *Client) InitSystemInfo() error { - - err := AddSystem(client.Addr, client) - if err != nil { - return fmt.Errorf("unable to add system info for ip (%s) ", client.Addr) - } - - client.Info, err = GetSystem(client.Addr) - if err == nil { - _ = Log(client.Info) - } - - return err -} - -// GetVolumeMaps2: Return a list of mapped initiators for a specified volume -func (client *Client) GetVolumeMaps2(volume string) (VolumeMapInfo, *common.ResponseStatus, error) { - - m := VolumeMapInfo{Volume: volume} - original := volume - - if len(volume) > 0 { - volume = fmt.Sprintf("\"%s\"", volume) - } - - results, status, _ := client.FormattedRequest("/show/maps/%s", volume) - - if status.ReturnCode != 0 { - klog.V(0).Infof("volume (%s) was not found", volume) - m.Exists = false - return m, status, nil - } - - for _, rootObj := range results.Objects { - if rootObj.Name == "volume-view" { - id := rootObj.PropertiesMap["volume-name"].Data - if id != original { - klog.Warningf("Map data volume-name (%s) did not match parameter volume (%s)\n", id, volume) - } - m.Exists = true - m.SerialNumber = rootObj.PropertiesMap["volume-serial"].Data - - m.Mappings = make([]VolumeMapItem, 0) - var mi VolumeMapItem - - for _, object := range rootObj.Objects { - if object.Name == "host-view" && object.PropertiesMap["identifier"].Data != "all other initiators" { - mi = VolumeMapItem{ - InitiatorId: object.PropertiesMap["identifier"].Data, - LUN: object.PropertiesMap["lun"].Data, - Access: object.PropertiesMap["access"].Data, - Ports: object.PropertiesMap["ports"].Data, - Nickname: object.PropertiesMap["nickname"].Data, - Profile: object.PropertiesMap["host-profile"].Data, - } - m.Mappings = append(m.Mappings, mi) - } - } - } - } - - return m, status, nil -} - -// LogVolumeMaps: Log all map information -func (client *Client) LogVolumeMaps(maps VolumeMapInfo) error { - - klog.V(0).Infof("Mapping for (%s)\n", maps.Volume) - klog.V(0).Infof("-- SerialNumber: %s\n", maps.SerialNumber) - klog.V(0).Infof("-- Exists: %v\n", maps.Exists) - klog.V(0).Infof("-- Mappings:\n") - - klog.V(0).Infof("-- %-46s %-4s %-16s %-8s %-16s %-12s\n", "Initiator", "LUN", "Access", "Ports", "Nickname", "Profile") - klog.V(0).Infof("-- %-46s %-4s %-16s %-8s %-16s %-12s\n", strings.Repeat("-", 46), strings.Repeat("-", 4), strings.Repeat("-", 16), strings.Repeat("-", 8), strings.Repeat("-", 16), strings.Repeat("-", 12)) - - for i, m := range maps.Mappings { - klog.V(0).Infof("-- [%3d] %-46s %-4s %-16s %-8s %-16s %-12s\n", i, m.InitiatorId, m.LUN, m.Access, m.Ports, m.Ports, m.Nickname) - } - - klog.V(0).Infof("\n") - - return nil -} - -// GetInitiatorMaps: Return a list of mapped volumes for a specified initiator -func (client *Client) GetInitiatorMaps(initiator string) (InitiatorMapInfo, *common.ResponseStatus, error) { - - m := InitiatorMapInfo{InitiatorId: initiator} - original := initiator - - if len(initiator) > 0 { - initiator = fmt.Sprintf("\"%s\"", initiator) - } - - results, status, err := client.FormattedRequest("/show/maps/%s", initiator) - if err != nil { - return m, status, err - } - - for _, rootObj := range results.Objects { - if rootObj.Name == "initiator-view" { - id := rootObj.PropertiesMap["id"].Data - if id != original { - klog.Warningf("Map data id (%s) did not match parameter initiator (%s)\n", id, initiator) - } - m.Nickname = rootObj.PropertiesMap["hba-nickname"].Data - m.Profile = rootObj.PropertiesMap["host-profile"].Data - - m.Mappings = make([]InitiatorMapItem, 0) - var mi InitiatorMapItem - - for _, object := range rootObj.Objects { - if object.Name == "volume-view" { - mi = InitiatorMapItem{ - Volume: object.PropertiesMap["volume"].Data, - SerialNumber: object.PropertiesMap["volume-serial"].Data, - LUN: object.PropertiesMap["lun"].Data, - Access: object.PropertiesMap["access"].Data, - Ports: object.PropertiesMap["ports"].Data, - } - m.Mappings = append(m.Mappings, mi) - } - } - } - } - - return m, status, nil -} - -// LogInitiatorMaps: Log all map information -func (client *Client) LogInitiatorMaps(maps InitiatorMapInfo) error { - - klog.V(0).Infof("Mapping for (%s)\n", maps.InitiatorId) - klog.V(0).Infof("-- Nickname: %s\n", maps.Nickname) - klog.V(0).Infof("-- Profile : %s\n", maps.Profile) - klog.V(0).Infof("-- Mappings:\n") - - klog.V(0).Infof("-- %-32s %-32s %-4s %-16s %-8s\n", "Volume", "SerialNumber", "LUN", "Access", "Ports") - klog.V(0).Infof("-- %-32s %-32s %-4s %-16s %-8s\n", strings.Repeat("-", 32), strings.Repeat("-", 32), strings.Repeat("-", 4), strings.Repeat("-", 16), strings.Repeat("-", 8)) - - for i, m := range maps.Mappings { - klog.V(0).Infof("-- [%3d] %-32s %-32s %-4s %-16s %-8s\n", i, m.Volume, m.SerialNumber, m.LUN, m.Access, m.Ports) - } - - klog.V(0).Infof("\n") - - return nil -} - -// GetVolumeMaps: Return a slice of mapped initiators for a specified volume -func (client *Client) GetVolumeMaps(volume string) ([]string, []string, *common.ResponseStatus, error) { - if volume != "" { - volume = fmt.Sprintf("\"%s\"", volume) - } - res, status, err := client.FormattedRequest("/show/maps/%s", volume) - - if err != nil { - return []string{}, []string{}, status, err - } - - initiators := []string{} - luns := []string{} - - for _, rootObj := range res.Objects { - if rootObj.Name != "volume-view" { - continue - } - - for _, object := range rootObj.Objects { - //klog.Infof("%v", object) - initiatorName := object.PropertiesMap["identifier"].Data - lun := object.PropertiesMap["lun"].Data - - if object.Name == "host-view" && initiatorName != "all other initiators" { - klog.V(2).Infof("map: volume (%s) --> initiator (%s) lun (%s)", volume, initiatorName, lun) - initiators = append(initiators, initiatorName) - luns = append(luns, lun) - } - } - } - - return initiators, luns, status, err -} - -// nextLUN: Determine the next available Logical Unit Number (LUN), which is used for mapping avolume to an initiator -func (client *Client) nextLUN(maps InitiatorMapInfo) (int, error) { - - if len(maps.InitiatorId) == 0 { - klog.V(0).Infof("initiator does not exist, no LUN mappings yet, using LUN 1") - return 1, nil - } - - luns := make([]int, 0) - for _, m := range maps.Mappings { - lun, err := strconv.Atoi(m.LUN) - if err == nil { - luns = append(luns, lun) - } - } - sort.Ints(luns) - - klog.V(2).Infof("checking if LUN 1 is in use") - if len(luns) == 0 || luns[0] > 1 { - return 1, nil - } - - klog.V(2).Infof("searching for an available LUN between LUNs in use") - for index := 1; index < len(luns); index++ { - if luns[index]-luns[index-1] > 1 { - return luns[index-1] + 1, nil - } - } - - klog.V(2).Infof("checking if next LUN is not above maximum LUNs limit") - if luns[len(luns)-1]+1 < MaximumLUN { - return luns[len(luns)-1] + 1, nil - } - - return -1, status.Error(codes.ResourceExhausted, "no LUN is available") -} - -// chooseLUN: Choose the next available LUN for a given initiator -func (client *Client) chooseLUN(initiators []string) (int, error) { - klog.Infof("listing all LUN mappings") - - var allvolumes []Volume - for _, initiatorName := range initiators { - volumes, responseStatus, err := client.ShowHostMaps(initiatorName) - if err != nil { - klog.Errorf("error looking for host maps for initiator %s: %s", initiatorName, err) - } - if responseStatus.ReturnCode == common.HostMapDoesNotExistsErrorCode { - klog.Infof("initiator %s does not exist", initiatorName) - } - if volumes != nil { - allvolumes = append(allvolumes, volumes...) - } - } - - sort.Sort(Volumes(allvolumes)) - - klog.V(5).Infof("use LUN 1 when volumes slice is empty") - if len(allvolumes) == 0 { - return 1, nil - } - - klog.V(5).Infof("use the next highest LUN number, until the end is reached") - if allvolumes[len(allvolumes)-1].LUN+1 < MaximumLUN { - return allvolumes[len(allvolumes)-1].LUN + 1, nil - } - - klog.V(5).Infof("use LUN 1 when not in use") - if allvolumes[0].LUN > 1 { - return 1, nil - } - - klog.V(5).Infof("use the next available LUN, searching from LUN 1 towards the maximum") - for index := 1; index < len(allvolumes); index++ { - // Find a gap between used LUNs - if allvolumes[index].LUN-allvolumes[index-1].LUN > 1 { - return allvolumes[index-1].LUN + 1, nil - } - } - - klog.Errorf("no available LUN: [%d] luns=%v", len(allvolumes), allvolumes) - - return -1, status.Error(codes.ResourceExhausted, "no more available LUNs") -} - -// mapVolumeProcess: Map a volume to an initiator and create a nickname when required by the storage array -func (client *Client) mapVolumeProcess(volumeName, initiatorName string, lun int) error { - klog.Infof("trying to map volume %s for initiator %s on LUN %d", volumeName, initiatorName, lun) - metadata, err := client.MapVolume(volumeName, initiatorName, "rw", lun) - if err != nil && metadata == nil { - return err - } - - klog.Infof("status: metadata.ReturnCode=%v", metadata.ReturnCode) - if metadata.ReturnCode == common.InitiatorNicknameOrIdentifierNotFound { - nodeIDParts := strings.Split(initiatorName, ":") - if len(nodeIDParts) < 2 { - return status.Error(codes.NotFound, "specified node ID is not a valid IQN") - } - - nickname := strings.Join(nodeIDParts[1:], ":") - nickname = strings.ReplaceAll(nickname, ".", "-") - - klog.Infof("initiator does not exist, creating it with nickname %s", nickname) - _, err = client.CreateNickname(nickname, initiatorName) - if err != nil { - return err - } - klog.Info("retrying to map volume") - _, err = client.MapVolume(volumeName, initiatorName, "rw", lun) - if err != nil { - return err - } - } else if metadata.ReturnCode == common.VolumeNotFoundErrorCode { - return status.Errorf(codes.NotFound, "volume %s not found", volumeName) - } else if err != nil { - return status.Error(codes.Internal, err.Error()) - } - - return nil -} - -// CheckVolumeExists: Return true if a volume already exists -func (client *Client) CheckVolumeExists(volumeID string, size int64) (bool, error) { - data, responseStatus, err := client.ShowVolumes(volumeID) - fmt.Printf("==0 CheckVolumeExists id=%s, len=%d\n", volumeID, len(data)) - if err != nil && responseStatus.ReturnCode != common.BadInputParam { - return false, err - } - - for _, object := range data { - if object.ObjectName == "volume" { - if object.VolumeName == volumeID { - klog.V(3).Infof("volume exists: checking (%s) size (%d) against blocks(%d) block size (%d)", volumeID, size, object.Blocks, object.BlockSize) - - if object.Blocks*object.BlockSize == size { - return true, nil - } - return true, status.Error(codes.AlreadyExists, "cannot create volume with same name but different capacity than the existing one") - } - } - } - - return false, nil -} - -// PublishVolume: Attach a volume to an initiator -func (client *Client) PublishVolume(volumeId string, initiators []string) (string, error) { - - klog.V(0).InfoS("publish volume", "volume", volumeId, "initiators", initiators) - - hostNames, apistatus, err := client.GetVolumeMapsHostNames(volumeId) - if err != nil { - if apistatus != nil && apistatus.ReturnCode == common.VolumeNotFoundErrorCode { - return "", status.Errorf(codes.NotFound, "The specified volume (%s) was not found.", volumeId) - } else { - return "", err - } - } - for _, hostName := range hostNames { - for _, initiator := range initiators { - if hostName == initiator { - klog.Infof("volume %s is already mapped to initiator %s", volumeId, initiators) - } - } - } - - lun, err := client.chooseLUN(initiators) - if err != nil { - return "", err - } - - klog.Infof("using LUN %d", lun) - - mappingSuccessful := false - for _, initiator := range initiators { - if err = client.mapVolumeProcess(volumeId, initiator, lun); err != nil { - klog.Errorf("error mapping volume (%s) for initiator (%s) using LUN (%d): %v", volumeId, initiators, lun, err) - } else { - mappingSuccessful = true - klog.Infof("successfully mapped volume (%s) for initiator (%s) using LUN (%d)", volumeId, initiators, lun) - } - } - - if mappingSuccessful { - return strconv.Itoa(lun), nil - } else { - return "", fmt.Errorf("error mapping volume (%s), no initiators were mapped successfully", volumeId) - } -} - -// GetVolumeWwn: Retrieve the WWN for a volume, very useful for host operating system device mapping -func (client *Client) GetVolumeWwn(volumeName string) (string, error) { - - wwn := "" - response, status, err := client.ShowVolumes(volumeName) - if err == nil && status.ResponseTypeNumeric == 0 { - if len(response) > 0 && response[0].ObjectName == "volume" { - wwn = strings.ToLower(response[0].Wwn) - } - } - - klog.V(3).Infof("GetVolumeWwn (%s) returning wwn (%s)", volumeName, wwn) - return wwn, err -} diff --git a/pkg/v1/endpoints.go b/pkg/v1/endpoints.go deleted file mode 100644 index 2bbbec0..0000000 --- a/pkg/v1/endpoints.go +++ /dev/null @@ -1,353 +0,0 @@ -package exosx - -import ( - "crypto/md5" - "fmt" - "strconv" - "strings" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" - "k8s.io/klog/v2" -) - -// SessionValid : Determine if a session is valid, if not a login is required -func (client *Client) SessionValid(addr, username string) bool { - - // addr may include protocol and ip address or hostname, or only ip address - ipaddress := common.GetAddress(addr) - - if client.Addr == ipaddress && client.Username == username { - if client.SessionKey == "" { - klog.Infof("SessionKey is invalid: %q", client.SessionKey) - return false - } - klog.Infof("client is already configured for API address %q, session is valid", addr) - return true - } - - return false -} - -// StoreCredentials : Called to store ip address, protocol, username, and password for the client -func (client *Client) StoreCredentials(addr string, protocol string, username string, password string) { - - // addr may include protocol and ip address or hostname, or only ip address - ipaddress, usingProtocol := common.GetAddressAndProtocol(addr, protocol) - - // Store the login credentials in the Client object - client.Username = username - client.Password = password - client.Addr = ipaddress - client.Protocol = usingProtocol -} - -// Login : Called automatically, may be called manually if credentials changed -func (client *Client) Login() error { - - userpass := fmt.Sprintf("%s_%s", client.Username, client.Password) - hash := fmt.Sprintf("%x", md5.Sum([]byte(userpass))) - res, _, err := client.FormattedRequest("/login/%s", hash) - - if err != nil { - return err - } - - client.SessionKey = res.ObjectsMap["status"].PropertiesMap["response"].Data - - return nil -} - -// CloseConnections: Called to close any idle connections -func (client *Client) CloseConnections() error { - client.HTTPClient.CloseIdleConnections() - return nil -} - -// GetPoolType: Returns the pool type for a specified pool -func (client *Client) GetPoolType(pool string) (string, error) { - return GetPoolType(client.Info, pool) -} - -// CreateVolume : creates a volume with the given name, capacity in the given pool -func (client *Client) CreateVolume(name, size, pool, poolType string) (*common.VolumeObject, *common.ResponseStatus, error) { - request := "" - if poolType == "Virtual" { - request = fmt.Sprintf("/create/volume/pool/\"%s\"/size/%s/tier-affinity/no-affinity/\"%s\"", pool, size, name) - } else { - request = fmt.Sprintf("/create/volume/pool/\"%s\"/size/%s/\"%s\"", pool, size, name) - } - - data, status, err := client.FormattedRequest(request) - - // Fill in Volume properties for the volume data object returned - volume := common.VolumeObject{} - if err == nil && status.ResponseTypeNumeric == 0 && len(data.Objects) > 0 { - volume.ObjectName = data.Objects[0].Name - - if val, ok := data.Objects[0].PropertiesMap["blocks"]; ok { - volume.Blocks, _ = strconv.ParseInt(val.Data, 10, 64) - } - if val, ok := data.Objects[0].PropertiesMap["blocksize"]; ok { - volume.BlockSize, _ = strconv.ParseInt(val.Data, 10, 64) - } - if val, ok := data.Objects[0].PropertiesMap["health"]; ok { - volume.Health = val.Data - } - if _, ok := data.Objects[0].PropertiesMap["size-numeric"]; ok { - volume.SizeNumeric, _ = strconv.ParseInt(data.Objects[0].PropertiesMap["size-numeric"].Data, 10, 64) - } - if val, ok := data.Objects[0].PropertiesMap["storage-pool-name"]; ok { - volume.StoragePoolName = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["storage-type"]; ok { - volume.StorageType = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["tier-affinity"]; ok { - volume.TierAffinity = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["total-size"]; ok { - volume.TotalSize = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["volume-name"]; ok { - volume.VolumeName = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["volume-type"]; ok { - volume.VolumeType = val.Data - } - if val, ok := data.Objects[0].PropertiesMap["wwn"]; ok { - volume.Wwn = strings.ToLower(val.Data) - } - } - - // For API versions that do not return a representation of the volume object, use ShowVolumes to fill in the data - if err == nil && status.ResponseTypeNumeric == 0 && volume.Wwn == "" { - volumes, status, err := client.ShowVolumes(name) - if err == nil && status.ResponseTypeNumeric == 0 { - if len(volumes) > 0 && volumes[0].ObjectName == "volume" { - volume.Blocks = volumes[0].Blocks - volume.BlockSize = volumes[0].BlockSize - volume.Health = volumes[0].Health - volume.SizeNumeric = volumes[0].SizeNumeric - volume.StoragePoolName = volumes[0].StoragePoolName - volume.StorageType = volumes[0].StorageType - volume.TierAffinity = volumes[0].TierAffinity - volume.TotalSize = volumes[0].TotalSize - volume.VolumeName = volumes[0].VolumeName - volume.VolumeType = volumes[0].VolumeType - volume.Wwn = strings.ToLower(volumes[0].Wwn) - } - } - } - - return &volume, status, err -} - -// GetPortals: Return a list of portals for the storage system -func (client *Client) GetPortals() (string, error) { - return GetPortals(client.Info) -} - -// CreateNickname : Create a nickname for an initiator. The Storage API policy is to prohibit mapping of initiators which are not either -// (a) presently connected to the array or (b) represented by an entry in the initiator nickname table. -func (client *Client) CreateNickname(name, iqn string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/set/initiator/id/\"%s\"/nickname/\"%s\"", iqn, name) - return status, err -} - -// MapVolume : map a volume to an initiator using a specified LUN -func (client *Client) MapVolume(name, initiator, access string, lun int) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/map/volume/access/%s/lun/%d/initiator/\"%s\"/\"%s\"", access, lun, initiator, name) - return status, err -} - -// ShowVolumes : get information about volumes -func (client *Client) ShowVolumes(volumes ...string) ([]common.VolumeObject, *common.ResponseStatus, error) { - - request := "" - returnVolumes := []common.VolumeObject{} - - if len(volumes) == 0 { - request = "/show/volumes/" - } else { - request = fmt.Sprintf("/show/volumes/\"%s\"", strings.Join(volumes, ",")) - } - - data, status, err := client.FormattedRequest(request) - - // Fill in Volume properties for all volume data objects returned - if err == nil && status.ResponseTypeNumeric == 0 { - for _, object := range data.Objects { - if object.Name == "volume" { - volume := common.VolumeObject{} - volume.ObjectName = object.Name - volume.Blocks, _ = strconv.ParseInt(object.PropertiesMap["blocks"].Data, 10, 64) - volume.BlockSize, _ = strconv.ParseInt(object.PropertiesMap["blocksize"].Data, 10, 64) - volume.Health = object.PropertiesMap["health"].Data - volume.SizeNumeric, _ = strconv.ParseInt(object.PropertiesMap["size-numeric"].Data, 10, 64) - volume.StoragePoolName = object.PropertiesMap["storage-pool-name"].Data - volume.StorageType = object.PropertiesMap["storage-type"].Data - volume.TierAffinity = object.PropertiesMap["tier-affinity"].Data - volume.TotalSize = object.PropertiesMap["total-size"].Data - volume.VolumeName = object.PropertiesMap["volume-name"].Data - volume.VolumeType = object.PropertiesMap["volume-type"].Data - volume.Wwn = strings.ToLower(object.PropertiesMap["wwn"].Data) - - returnVolumes = append(returnVolumes, volume) - } - } - } - - return returnVolumes, status, err -} - -// UnmapVolume : unmap a volume from an initiator -func (client *Client) UnmapVolume(name, initiator string) (*common.ResponseStatus, error) { - if len(initiator) == 0 { - _, status, err := client.FormattedRequest("/unmap/volume/\"%s\"", name) - return status, err - } - _, status, err := client.FormattedRequest("/unmap/volume/initiator/\"%s\"/\"%s\"", initiator, name) - return status, err -} - -// ExpandVolume : extend a volume if there is enough space on the vdisk -func (client *Client) ExpandVolume(name, size string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/expand/volume/size/\"%s\"/\"%s\"", size, name) - return status, err -} - -// DeleteVolume : deletes a volume -func (client *Client) DeleteVolume(name string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/delete/volumes/\"%s\"", name) - return status, err -} - -// DeleteHost : deletes a host by its ID or nickname -func (client *Client) DeleteHost(name string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/delete/hosts/\"%s\"", name) - return status, err -} - -// ShowHostMaps : list the volume mappings for given host -// If host is an empty string, mapping for all hosts is shown -func (client *Client) ShowHostMaps(host string) ([]Volume, *common.ResponseStatus, error) { - // We don't use "/show/maps/initiator/" here because - // the maps for an initiator with a nickname or in a host group will not - // be returned. Instead we get all initiator mappings and filter by initiator - klog.Infof("++ ShowHostMaps(%v)", host) - res, status, err := client.FormattedRequest("/show/maps/initiator/") - if err != nil { - return nil, status, err - } - - mappings := make([]Volume, 0) - for _, rootObj := range res.Objects { - if host != "" { - id, err := rootObj.GetProperties("id") - if err != nil || id[0].Data != host { - continue - } - } - if rootObj.Name != "initiator-view" { - continue - } - - for i, object := range rootObj.Objects { - if object.Name == "volume-view" { - vol := Volume{} - vol.fillFromObject(&object) - klog.Infof("++ volume[%v]: %v", i, vol) - mappings = append(mappings, vol) - } - } - } - - return mappings, status, err -} - -// ShowSnapshots : Show one snaphot, or all snapshots, or all snapshots for a volume -func (client *Client) ShowSnapshots(snapshotId string, sourceVolumeId string) ([]common.SnapshotObject, *common.ResponseStatus, error) { - - request := "" - returnSnapshots := []common.SnapshotObject{} - - // Create the correctly formatted request command - if sourceVolumeId != "" { - request = fmt.Sprintf("/show/snapshots/volume/%q", sourceVolumeId) - } else if snapshotId != "" { - request = fmt.Sprintf("/show/snapshots/pattern/%q", snapshotId) - } else { - request = "/show/snapshots" - } - - data, status, err := client.FormattedRequest(request) - - // Fill in Snapshot properties for all data objects returned - if err == nil && status.ResponseTypeNumeric == 0 { - for _, object := range data.Objects { - if object.Name == "snapshot" { - snapshot := common.SnapshotObject{} - snapshot.ObjectName = object.Name - snapshot.CreationTime, _ = common.CreationTimeFromString(object.PropertiesMap["creation-date-time-numeric"].Data) - snapshot.CreationDateTime = object.PropertiesMap["creation-date-time"].Data - snapshot.CreationDateTimeNumeric, _ = strconv.ParseInt(object.PropertiesMap["creation-date-time-numeric"].Data, 10, 64) - snapshot.MasterVolumeName = object.PropertiesMap["master-volume-name"].Data - snapshot.Name = object.PropertiesMap["name"].Data - snapshot.StoragePoolName = object.PropertiesMap["storage-pool-name"].Data - snapshot.TotalSize = object.PropertiesMap["total-size"].Data - snapshot.TotalSizeNumeric, _ = strconv.ParseInt(object.PropertiesMap["total-size-numeric"].Data, 10, 64) - snapshot.VolumeParent = object.PropertiesMap["volume-parent"].Data - - returnSnapshots = append(returnSnapshots, snapshot) - } - } - } - - return returnSnapshots, status, err -} - -// CreateSnapshot : create a snapshot in a snap pool and the snap pool if it doesn't exsits -func (client *Client) CreateSnapshot(name string, snapshotName string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/create/snapshots/volumes/%q/%q", name, snapshotName) - return status, err -} - -// DeleteSnapshot : delete a snapshot -func (client *Client) DeleteSnapshot(names ...string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/delete/snapshot/%q", strings.Join(names, ",")) - return status, err -} - -// CopyVolume : create an new volume by copying another one or a snapshot -func (client *Client) CopyVolume(sourceName string, destinationName string, pool string) (*common.ResponseStatus, error) { - _, status, err := client.FormattedRequest("/copy/volume/destination-pool/%q/name/%q/%q", pool, destinationName, sourceName) - return status, err -} - -func (client *Client) GetVolumeMapsHostNames(name string) ([]string, *common.ResponseStatus, error) { - if name != "" { - name = fmt.Sprintf("\"%s\"", name) - } - klog.V(2).Infof("++ GetVolumeMapsHostNames(%v)", name) - res, status, err := client.FormattedRequest("/show/maps/%s", name) - if err != nil { - return []string{}, status, err - } - - hostNames := []string{} - for _, rootObj := range res.Objects { - if rootObj.Name != "volume-view" { - continue - } - - for i, object := range rootObj.Objects { - hostName := object.PropertiesMap["identifier"].Data - if object.Name == "host-view" && hostName != "all other initiators" { - klog.Infof("++ hostName[%v]: %v", i, hostName) - hostNames = append(hostNames, hostName) - } - } - } - - return hostNames, status, err -} diff --git a/pkg/v1/exosx.go b/pkg/v1/exosx.go deleted file mode 100644 index 96af848..0000000 --- a/pkg/v1/exosx.go +++ /dev/null @@ -1,145 +0,0 @@ -package exosx - -import ( - "crypto/tls" - "errors" - "fmt" - "net/http" - "strings" - "time" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" - "k8s.io/klog/v2" -) - -// Client : Can be used to request the API -type Client struct { - Username string - Password string - Addr string - Protocol string - HTTPClient http.Client - Collector *common.Collector - SessionKey string - Initiator []string - PoolName string - Info *common.SystemInfo -} - -// NewClient : Creates an API client by setting up its HTTP transport -func NewClient() *Client { - return &Client{ - HTTPClient: http.Client{ - Timeout: time.Duration(60 * time.Second), - Transport: &http.Transport{ - // Proxy: http.ProxyURL(proxy), - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: true, - }, - }, - }, - Collector: common.NewCollector(), - } -} - -// internalRequest : Execute the given request with client's configuration -func (client *Client) internalRequest(endpoint string) (*Response, *common.ResponseStatus, error) { - if client.Addr == "" { - err := errors.New("missing server address") - return nil, NewErrorStatus(err.Error()), err - } - - return client.request(&Request{Endpoint: endpoint}) -} - -// FormattedRequest : Format and execute the given request with client's configuration -func (client *Client) FormattedRequest(endpointFormat string, opts ...interface{}) (*Response, *common.ResponseStatus, error) { - endpoint := fmt.Sprintf(endpointFormat, opts...) - stopTrackAPICall := client.Collector.TrackAPICall(endpointFormat) - resp, status, err := client.internalRequest(endpoint) - stopTrackAPICall(err == nil) - return resp, status, err -} - -// request: process a storage api request -func (client *Client) request(req *Request) (*Response, *common.ResponseStatus, error) { - isLoginReq := strings.Contains(req.Endpoint, "login") - if !isLoginReq { - if len(client.SessionKey) == 0 { - klog.Info("no session key stored, authenticating before sending request") - err := client.Login() - if err != nil { - return nil, NewErrorStatus("login failed"), err - } - } - - klog.Infof("-> GET %s", req.Endpoint) - } else { - klog.Infof("-> GET /login/") - } - - raw, code, err := req.execute(client) - klog.V(2).Infof("req.execute: status code %d", code) - - if (code == http.StatusUnauthorized || code == http.StatusForbidden) && !isLoginReq { - klog.Info("session key may have expired, trying to re-login") - err = client.Login() - if err != nil { - return nil, NewErrorStatus("re-login failed"), err - } - klog.Info("re-login succeeded, re-trying request") - raw, _, err = req.execute(client) - } - if err != nil { - return nil, NewErrorStatus("request failed"), err - } - - res, err := NewResponse(raw) - if err != nil { - if res != nil { - return res, res.GetStatus(), err - } - - return nil, NewErrorStatus("corrupted response"), err - } - - status := res.GetStatus() - - // Some API versions return success with an invalid session key response, so log in again - if !isLoginReq && code == http.StatusOK && status.ReturnCode == common.InvalidSessionKey { - klog.Info("invalid session key response, trying to re-login") - err = client.Login() - if err != nil { - return nil, NewErrorStatus("re-login failed"), err - } - klog.Info("re-login succeeded, re-trying request") - raw, _, err = req.execute(client) - - if err != nil { - return nil, NewErrorStatus("request failed"), err - } - - res, err := NewResponse(raw) - if err != nil { - if res != nil { - return res, res.GetStatus(), err - } - - return nil, NewErrorStatus("corrupted response"), err - } - - status = res.GetStatus() - } - - if !isLoginReq { - klog.Infof("<- [%d %s] %s", status.ReturnCode, status.ResponseType, status.Response) - } else { - klog.Infof("<- [%d %s] ", status.ReturnCode, status.ResponseType) - } - - if status.ResponseTypeNumeric != 0 { - return res, status, fmt.Errorf("API returned non-zero code %d (%s)", status.ReturnCode, status.Response) - } - - return res, status, nil -} diff --git a/pkg/v1/models.go b/pkg/v1/models.go deleted file mode 100644 index 91a3ff5..0000000 --- a/pkg/v1/models.go +++ /dev/null @@ -1,23 +0,0 @@ -package exosx - -import "strconv" - -// model : interface to allow generic conversion from raw response to user-object -type model interface { - fillFromObject(obj *Object) error -} - -// Volume : volume-view representation -type Volume struct { - LUN int -} - -func (m *Volume) fillFromObject(obj *Object) error { - lun, err := strconv.Atoi(obj.PropertiesMap["lun"].Data) - if err != nil { - return err - } - - m.LUN = lun - return nil -} diff --git a/pkg/v1/request.go b/pkg/v1/request.go deleted file mode 100644 index a0ada39..0000000 --- a/pkg/v1/request.go +++ /dev/null @@ -1,41 +0,0 @@ -package exosx - -import ( - "fmt" - "io/ioutil" - "net/http" - "strings" -) - -// Request : Used internally, and can be used to send custom requests (see Client.Request()) -type Request struct { - Endpoint string - Data interface{} -} - -func (req *Request) execute(client *Client) ([]byte, int, error) { - // Remove any trailing slash if supplied, other login fails with HTTP status 403 - if strings.HasSuffix(client.Addr, "/") { - client.Addr = client.Addr[0 : len(client.Addr)-1] - } - url := fmt.Sprintf("%s://%s/api%s", client.Protocol, client.Addr, req.Endpoint) - httpReq, err := http.NewRequest("GET", url, nil) - if err != nil { - return nil, 0, err - } - - httpReq.Header.Set("sessionKey", client.SessionKey) - httpReq.SetBasicAuth(client.Username, client.Password) - res, err := client.HTTPClient.Do(httpReq) - if err != nil { - return nil, 0, err - } - - if res.StatusCode >= 400 { - return nil, res.StatusCode, fmt.Errorf("API returned unexpected HTTP status %d", res.StatusCode) - } - - defer res.Body.Close() - data, err := ioutil.ReadAll(res.Body) - return data, res.StatusCode, err -} diff --git a/pkg/v1/response.go b/pkg/v1/response.go deleted file mode 100644 index eb54e8e..0000000 --- a/pkg/v1/response.go +++ /dev/null @@ -1,126 +0,0 @@ -package exosx - -import ( - "encoding/xml" - "fmt" - "strconv" - "strings" - "time" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" -) - -// Response : Typed representation of any XML API response -type Response struct { - Version string `xml:"VERSION,attr"` - Objects []Object `xml:"OBJECT"` - ObjectsMap map[string]*Object -} - -// Object : Typed representation of any XML API object -type Object struct { - Typ string `xml:"basetype,attr"` - Name string `xml:"name,attr"` - OID int32 `xml:"oid,attr"` - Format string `xml:"format,attr,omitempty"` - Objects []Object `xml:"OBJECT"` - Properties []Property `xml:"PROPERTY"` - ObjectsMap map[string]*Object - PropertiesMap map[string]*Property -} - -// Property : Typed representation of any XML API property -type Property struct { - Name string `xml:"name,attr"` - Typ string `xml:"type,attr"` - Size int32 `xml:"size,attr"` - Draw bool `xml:"draw,attr"` - Sort string `xml:"sort,attr"` - DisplayName string `xml:"display-name,attr"` - Data string `xml:",chardata"` -} - -// ResponseStatus : Final representation of the "status" object in every API response -type ResponseStatus struct { - ResponseType string - ResponseTypeNumeric int - Response string - ReturnCode int - Time time.Time -} - -// NewResponse : Unmarshals the raw data into a typed response object -// and generate a hash map from fields for optimization -func NewResponse(data []byte) (*Response, error) { - res := &Response{} - err := xml.Unmarshal(data, res) - if err != nil { - return nil, err - } - - res.ObjectsMap = make(map[string]*Object) - for idx := range res.Objects { - obj := &res.Objects[idx] - fillObjectMap(obj) - res.ObjectsMap[obj.Name] = obj - } - - return res, nil -} - -// NewErrorStatus : Creates an error status when response is not available -func NewErrorStatus(err string) *common.ResponseStatus { - return &common.ResponseStatus{ - ResponseType: "Error", - Response: err, - Time: time.Now(), - } -} - -// GetStatus : Creates and returns the final ResponseStatus struct -// from the raw status object in response -func (res *Response) GetStatus() *common.ResponseStatus { - statusObject := res.ObjectsMap["status"] - responseTypeNumeric, _ := strconv.Atoi(statusObject.PropertiesMap["response-type-numeric"].Data) - returnCode, _ := strconv.Atoi(statusObject.PropertiesMap["return-code"].Data) - timestampNumeric, _ := strconv.Atoi(statusObject.PropertiesMap["time-stamp-numeric"].Data) - - return &common.ResponseStatus{ - ResponseType: statusObject.PropertiesMap["response-type"].Data, - ResponseTypeNumeric: responseTypeNumeric, - Response: statusObject.PropertiesMap["response"].Data, - ReturnCode: returnCode, - Time: time.Unix(int64(timestampNumeric), 0), - } -} - -func (object *Object) GetProperties(names ...string) ([]*Property, error) { - var properties []*Property - - for _, name := range names { - if property, ok := object.PropertiesMap[name]; ok { - properties = append(properties, property) - } else { - return nil, fmt.Errorf("missing property %q", name) - } - } - - return properties, nil -} - -func fillObjectMap(obj *Object) { - obj.PropertiesMap = make(map[string]*Property) - - for idx2 := range obj.Properties { - prop := &obj.Properties[idx2] - prop.Data = strings.TrimSpace(prop.Data) - obj.PropertiesMap[prop.Name] = prop - } - - obj.ObjectsMap = make(map[string]*Object) - for idx2 := range obj.Objects { - subObject := &obj.Objects[idx2] - fillObjectMap(subObject) - obj.ObjectsMap[subObject.Name] = subObject - } -} diff --git a/pkg/v1/system.go b/pkg/v1/system.go deleted file mode 100644 index 303c07a..0000000 --- a/pkg/v1/system.go +++ /dev/null @@ -1,241 +0,0 @@ -// -// Copyright (c) 2021 Seagate Technology LLC and/or its Affiliates -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// For any questions about this software or licensing, -// please email opensource@seagate.com or cortx-questions@seagate.com. - -package exosx - -import ( - "fmt" - "strings" - - "github.com/Seagate/seagate-exos-x-api-go/pkg/common" - "k8s.io/klog/v2" -) - -// -// System Information Storage and Creation -// - -// systems: Data object storing all system information for all added controllers -var systems common.SystemsData - -// AddSystem: Uses the client to query and store system data -func AddSystem(url string, client *Client) error { - - // Create the system record with the designated ip address - var s common.SystemInfo - s.URL = strings.ToLower(url) - if strings.HasPrefix(s.URL, "http://") { - parts := strings.Split(s.URL, "http://") - if len(parts) >= 2 { - s.Protocol = "http://" - s.IPAddress = parts[1] - } - } else if strings.HasPrefix(s.URL, "https://") { - parts := strings.Split(s.URL, "https://") - if len(parts) >= 2 { - s.Protocol = "https://" - s.IPAddress = parts[1] - } - } else { - s.IPAddress = s.URL - s.Protocol = "http://" - } - systems.Systems = append(systems.Systems, &s) - s.Ports = nil - - // Extract and store controller data, including ports - response, status, err := client.FormattedRequest("/show/controllers") - if err == nil && status.ResponseTypeNumeric == 0 { - for _, obj1 := range response.Objects { - if obj1.Name == "controller" || obj1.Name == "controllers" { - klog.V(2).Infof("++ Processing controller (%s)\n", obj1.PropertiesMap["controller-id"].Data) - - if obj1.PropertiesMap["ip-address"].Data == s.IPAddress { - klog.V(2).Infof("++ Saving controller (%s)\n", obj1.PropertiesMap["controller-id"].Data) - s.Controller = obj1.PropertiesMap["controller-id"].Data - s.Platform = obj1.PropertiesMap["platform-type"].Data - s.SerialNumber = obj1.PropertiesMap["serial-number"].Data - s.Status = obj1.PropertiesMap["status"].Data - } - - for _, obj2 := range obj1.Objects { - if obj2.Name == "ports" { - klog.V(2).Infof("++ Adding port (%s)\n", obj2.PropertiesMap["port"].Data) - p := common.PortType{ - Label: obj2.PropertiesMap["port"].Data, - Type: obj2.PropertiesMap["port-type"].Data, - TargetId: obj2.PropertiesMap["target-id"].Data, - } - if obj2.PropertiesMap["port-type"].Data == "iSCSI" { - for _, obj3 := range obj2.Objects { - if obj3.Name == "port-details" { - p.IPAddress = obj3.PropertiesMap["ip-address"].Data - p.Present = obj3.PropertiesMap["sfp-present"].Data - p.Compliance = obj3.PropertiesMap["sfp-ethernet-compliance"].Data - } - } - } - s.Ports = append(s.Ports, p) - } - } - } - } - } - - // Extract and store controller firmware versions - response, status, err = client.FormattedRequest("/show/versions/detail") - if err == nil && status.ResponseTypeNumeric == 0 { - for _, obj1 := range response.Objects { - if strings.EqualFold("A", s.Controller) && obj1.Name == "controller-a-versions" { - s.MCCodeVersion = obj1.PropertiesMap["mc-fw"].Data - s.MCBaseVersion = obj1.PropertiesMap["mc-base-fw"].Data - } - if strings.EqualFold("B", s.Controller) && obj1.Name == "controller-b-versions" { - s.MCCodeVersion = obj1.PropertiesMap["mc-fw"].Data - s.MCBaseVersion = obj1.PropertiesMap["mc-base-fw"].Data - } - } - } - - // Extract and store pool data - s.Pools = nil - response, status, err = client.FormattedRequest("/show/pools") - if err == nil && status.ResponseTypeNumeric == 0 { - for _, obj1 := range response.Objects { - if obj1.Name == "pools" || obj1.Name == "pool" { - klog.V(2).Infof("++ Adding pool (%s)\n", obj1.PropertiesMap["name"].Data) - s.Pools = append(s.Pools, - common.PoolType{ - Name: obj1.PropertiesMap["name"].Data, - SerialNumber: obj1.PropertiesMap["serial-number"].Data, - Type: obj1.PropertiesMap["storage-type"].Data, - }) - } - } - } - - return nil -} - -// GetSystem: Return the System data object corresponding to the IP Address -func GetSystem(url string) (*common.SystemInfo, error) { - - for _, s := range systems.Systems { - if s.URL == url { - return s, nil - } - } - - return nil, fmt.Errorf("no system data found for ip (%s) in (%d) systems", url, len(systems.Systems)) -} - -// -// System functions for ease of use -// - -// Log: Display the contents of all system information collected -func Log(system *common.SystemInfo) error { - - klog.Infof("\n") - klog.Infof("System Information:") - - klog.Infof("\n") - klog.Infof("=== Controller ===") - klog.Infof("IPAddress: %v\n", system.IPAddress) - klog.Infof("Protocol: %v\n", system.Protocol) - klog.Infof("Controller: %v\n", system.Controller) - klog.Infof("Platform: %v\n", system.Platform) - klog.Infof("SerialNumber: %v\n", system.SerialNumber) - klog.Infof("Status: %v\n", system.Status) - klog.Infof("MCCodeVersion: %v\n", system.MCCodeVersion) - klog.Infof("MCBaseVersion: %v\n", system.MCBaseVersion) - - klog.Infof("\n") - klog.Infof("=== Ports ===") - for i, p := range system.Ports { - klog.Infof("Port [%d] %v, %v, %v, %15v, %12v, %v\n", - i, p.Label, p.Type, p.TargetId, p.IPAddress, p.Present, p.Compliance) - } - - klog.Infof("\n") - klog.Infof("=== Pools ===") - for i, p := range system.Pools { - klog.Infof("Pool [%d] %-12s %-8s %s\n", i, p.Name, p.Type, p.SerialNumber) - } - - klog.Infof("\n") - return nil -} - -// GetPoolType: Return the pool type for a given pool -func GetPoolType(system *common.SystemInfo, pool string) (string, error) { - if system == nil { - return "", fmt.Errorf("system pointer is nil") - } - - for _, p := range system.Pools { - if p.Name == pool { - klog.V(2).Infof("++ pool (%s) type is (%s)\n", p.Name, p.Type) - return p.Type, nil - } - } - - return "", fmt.Errorf("pool (%s) was not found in (%d) system information pools", pool, len(system.Pools)) -} - -// GetTargetId: Return the target id value for this storage system -func GetTargetId(system *common.SystemInfo, portType string) (string, error) { - if system == nil { - return "", fmt.Errorf("system pointer is nil") - } - - for _, p := range system.Ports { - if p.Type == portType && p.TargetId != "" { - klog.V(2).Infof("++ TargetId (%s) for (%s) type (%s)\n", p.TargetId, system.IPAddress, p.Type) - return p.TargetId, nil - } - } - - return "", fmt.Errorf("TargetId was not found for system (%s) with (%d) ports", system.IPAddress, len(system.Ports)) -} - -// GetPortals: Return a list of iSCSI portals for the storage system -func GetPortals(system *common.SystemInfo) (string, error) { - if system == nil { - return "", fmt.Errorf("system pointer is nil") - } - - portals := "" - - for _, p := range system.Ports { - if p.IPAddress != "0.0.0.0" { - klog.V(2).Infof("++ Add portal (%s) for (%s)\n", p.IPAddress, system.IPAddress) - if portals != "" { - portals = portals + "," + p.IPAddress - } else { - portals = p.IPAddress - } - } - } - - if portals != "" { - return portals, nil - } - - return "", fmt.Errorf("No portals found for system (%s) with (%d) ports", system.IPAddress, len(system.Ports)) -}