Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature-389]: Support PowerMax Unisphere 10 and 9 and update goclients #188

Merged
merged 3 commits into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/karavictl/cmd/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"time"

pscale "github.com/dell/goisilon"
pmax "github.com/dell/gopowermax"
pmax "github.com/dell/gopowermax/v2"
"github.com/dell/goscaleio"
"github.com/spf13/cobra"
"google.golang.org/grpc"
Expand Down Expand Up @@ -212,8 +212,7 @@ func validatePowerMaxStorageResourcePool(ctx context.Context, storageSystemDetai
}

epURL.Scheme = "https"
//TODO(aaron): how should the version (90, 91) be determined?
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "", "", true, false)
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "CSM-Authz", true, false)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/karavictl/cmd/role_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ func Test_Unit_RoleCreate_PowerMax(t *testing.T) {
ts := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/univmax/restapi/90/system/version":
fmt.Fprintf(w, `{ "version": "V9.2.1.2"}`)
case "/univmax/restapi/90/sloprovisioning/symmetrix/000197900714/srp/bronze":
case "/univmax/restapi/version":
fmt.Fprintf(w, `{ "version": "V10.0.0.1"}`)
case "/univmax/restapi/100/sloprovisioning/symmetrix/000197900714/srp/bronze":
w.WriteHeader(http.StatusOK)
default:
t.Errorf("unhandled unisphere request path: %s", r.URL.Path)
Expand Down
6 changes: 3 additions & 3 deletions cmd/karavictl/cmd/storage_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"syscall"

pscale "github.com/dell/goisilon"
pmax "github.com/dell/gopowermax"
"github.com/dell/gopowermax/types/v90"
pmax "github.com/dell/gopowermax/v2"
types "github.com/dell/gopowermax/v2/types/v100"
"github.com/dell/goscaleio"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -272,7 +272,7 @@ func NewStorageCreateCmd() *cobra.Command {
tempStorage = make(map[string]System)
}

pmClient, err := pmax.NewClientWithArgs(epURL.String(), "", "karavi-auth", true, false)
pmClient, err := pmax.NewClientWithArgs(epURL.String(), "CSM-Authz", true, false)
if err != nil {
errAndExit(err)
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/karavictl/cmd/storage_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ func TestStorageCreateCmd(t *testing.T) {
usts := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/univmax/restapi/90/system/version":
fmt.Fprintf(w, `{ "version": "V9.2.1.2"}`)
case "/univmax/restapi/90/system/symmetrix":
case "/univmax/restapi/version":
fmt.Fprintf(w, `{ "version": "V10.0.0.1"}`)
case "/univmax/restapi/100/system/symmetrix":
b, err := ioutil.ReadFile(systemInstancesTestDataPath)
if err != nil {
t.Error(err)
Expand All @@ -122,7 +122,7 @@ func TestStorageCreateCmd(t *testing.T) {
t.Error(err)
return
}
case "/univmax/restapi/90/system/symmetrix/testing1":
case "/univmax/restapi/100/system/symmetrix/testing1":
fmt.Fprintf(w, `{ "symmetrix":
[ {
"symmetrixId": "000000000001",
Expand All @@ -132,7 +132,7 @@ func TestStorageCreateCmd(t *testing.T) {
"local": true
} ],
"success": true }"`)
case "/univmax/restapi/90/system/symmetrix/testing2":
case "/univmax/restapi/100/system/symmetrix/testing2":
fmt.Fprintf(w, `{ "symmetrix":
[ {
"symmetrixId": "000000000002",
Expand All @@ -142,7 +142,7 @@ func TestStorageCreateCmd(t *testing.T) {
"local": true
} ],
"success": true }"`)
case "/univmax/restapi/90/system/symmetrix/testing3":
case "/univmax/restapi/100/system/symmetrix/testing3":
fmt.Fprintf(w, `{ "symmetrix":
[ {
"symmetrixId": "000000000003",
Expand All @@ -152,7 +152,7 @@ func TestStorageCreateCmd(t *testing.T) {
"local": true
} ],
"success": true }"`)
case "/univmax/restapi/90/system/symmetrix/testing4":
case "/univmax/restapi/100/system/symmetrix/testing4":
fmt.Fprintf(w, `{ "symmetrix":
[ {
"symmetrixId": "000000000003",
Expand All @@ -162,7 +162,7 @@ func TestStorageCreateCmd(t *testing.T) {
"local": true
} ],
"success": true }"`)
case "/univmax/restapi/90/system/symmetrix/testing5":
case "/univmax/restapi/100/system/symmetrix/testing5":
fmt.Fprintf(w, `{ "symmetrix":
[ {
"symmetrixId": "000000000003",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
"testing3",
"testing4",
"testing5"
],
"num_of_symmetrix_arrays": 5,
"success": true
]
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.18

require (
github.com/alicebob/miniredis/v2 v2.17.0
github.com/dell/goisilon v1.8.0
github.com/dell/gopowermax v1.8.0
github.com/dell/goscaleio v1.7.0
github.com/dell/goisilon v1.9.0
github.com/dell/gopowermax/v2 v2.0.0
github.com/dell/goscaleio v1.8.0
github.com/dustin/go-humanize v1.0.0
github.com/fsnotify/fsnotify v1.5.1
github.com/go-redis/redis v6.15.7+incompatible
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d h1:1iy2qD6JEhHKKhUOA9IWs7mjco7lnw2qx8FsRI2wirE=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d/go.mod h1:tmAIfUFEirG/Y8jhZ9M+h36obRZAk/1fcSpXwAVlfqE=
github.com/dell/goisilon v1.8.0 h1:3CBNKCQMAqyJ8Qz3GiwCHIs2ds1Ur0trSnmR/hBKDX0=
github.com/dell/goisilon v1.8.0/go.mod h1:fJXHyh1JBcbsmPBquEulaNOFTpj1eEN5vISDf/UY1RQ=
github.com/dell/gopowermax v1.8.0 h1:Et02IZjkCTfjUL8vTCmX0pL18hBs54u1ygIuxbpo3zI=
github.com/dell/gopowermax v1.8.0/go.mod h1:rwP7E76NKKl2C+adKe8rDbyfQX4VW041bFbpY0oAKM0=
github.com/dell/goscaleio v1.7.0 h1:ahc4L2TjrT931WdbuZahUmccuyZMdKbijbTRRvQVBBY=
github.com/dell/goscaleio v1.7.0/go.mod h1:TJbQ8N6hk48w5rEyBa+pRtrRJbPVnCTsYM3mmUyPNaY=
github.com/dell/goisilon v1.9.0 h1:FFZiE71NA+cnfFqm9MYxCg8ADgYzIX969jPrFta6edE=
github.com/dell/goisilon v1.9.0/go.mod h1:fJXHyh1JBcbsmPBquEulaNOFTpj1eEN5vISDf/UY1RQ=
github.com/dell/gopowermax/v2 v2.0.0 h1:k4/p6ml8yHQXw8nECCwY0UriIhpcB/VPoueb80AiMTE=
github.com/dell/gopowermax/v2 v2.0.0/go.mod h1:eJEsDN0O0nFqiSdgOXZK73Cv/LlP/+psnkyFSXLR/wI=
github.com/dell/goscaleio v1.8.0 h1:a5wxvUwqvsr1KGUoHkY5Ol1jsNkQ8VKyTGdFeI5RVLQ=
github.com/dell/goscaleio v1.8.0/go.mod h1:TJbQ8N6hk48w5rEyBa+pRtrRJbPVnCTsYM3mmUyPNaY=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
Expand Down
4 changes: 2 additions & 2 deletions internal/powerflex/storage_pool_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type StoragePoolCache struct {
}

// NewStoragePoolCache creates a new StoragePoolCache
// It requires a goscaelio client and a cache size
// It requires a goscaleio client and a cache size
func NewStoragePoolCache(client *goscaleio.Client, cacheSize int) (*StoragePoolCache, error) {
if client == nil {
return nil, fmt.Errorf("goscaleio client is required")
Expand Down Expand Up @@ -81,7 +81,7 @@ func (c *StoragePoolCache) GetStoragePoolNameByID(ctx context.Context, tokenGett

c.client.SetToken(token)

pool, err := c.client.FindStoragePool(id, "", "")
pool, err := c.client.FindStoragePool(id, "", "", "")
if err != nil {
return "", err
}
Expand Down
10 changes: 5 additions & 5 deletions internal/proxy/powermax_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"strings"
"sync"

pmax "github.com/dell/gopowermax"
pmax "github.com/dell/gopowermax/v2"

"github.com/julienschmidt/httprouter"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -157,10 +157,10 @@ func (h *PowerMaxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {

router := httprouter.New()
router.Handler(http.MethodPut,
"/univmax/restapi/91/sloprovisioning/symmetrix/:systemid/storagegroup/:storagegroup/",
"/univmax/restapi/:version/sloprovisioning/symmetrix/:systemid/storagegroup/:storagegroup/",
v.editStorageGroupHandler(proxyHandler, h.enforcer, h.opaHost))
router.Handler(http.MethodPut,
"/univmax/restapi/91/sloprovisioning/symmetrix/:systemid/volume/:volumeid/",
"/univmax/restapi/:version/sloprovisioning/symmetrix/:systemid/volume/:volumeid/",
v.volumeModifyHandler(proxyHandler, h.enforcer, h.opaHost))
router.NotFound = proxyHandler
router.MethodNotAllowed = proxyHandler
Expand Down Expand Up @@ -352,7 +352,7 @@ func (s *PowerMaxSystem) volumeCreateHandler(next http.Handler, enf *quota.Redis
volID := payload.Editstoragegroupactionparam.Expandstoragegroupparam.Addvolumeparam.Volumeattributes[0].Volumeidentifier.IdentifierName

// Determine which pool this SG exists within, as it will form the quota key.
client, err := pmax.NewClientWithArgs(s.Endpoint, pmax.APIVersion91, "CSMAuthz", true, false)
client, err := pmax.NewClientWithArgs(s.Endpoint, appName, true, false)
if err != nil {
writeError(w, "powermax", "failed to build powermax client", http.StatusInternalServerError, s.log)
return
Expand Down Expand Up @@ -568,7 +568,7 @@ func (s *PowerMaxSystem) volumeModifyHandler(next http.Handler, enf *quota.Redis
}

// Determine which pool this SG exists within, as it will form the quota key.
client, err := pmax.NewClientWithArgs(s.Endpoint, pmax.APIVersion91, appName, true, false)
client, err := pmax.NewClientWithArgs(s.Endpoint, appName, true, false)
if err != nil {
writeError(w, "powermax", "failed to build powermax client", http.StatusInternalServerError, s.log)
return
Expand Down
8 changes: 4 additions & 4 deletions internal/proxy/powermax_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func testPowerMaxServeHTTP(t *testing.T) {
t.Fatal(err)
}
r := httptest.NewRequest(http.MethodGet,
"/univmax/restapi/91/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG/",
"/univmax/restapi/100/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG/",
nil)
r.Header.Set("Forwarded", "for=https://1.1.1.1;1234567890")
addJWTToRequestHeader(t, r)
Expand All @@ -122,7 +122,7 @@ func testPowerMaxServeHTTP(t *testing.T) {
)
fakeUni := fakeServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Logf("fake unisphere received: %s %s", r.Method, r.URL)
if r.URL.Path == "/univmax/restapi/91/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG" {
if r.URL.Path == "/univmax/restapi/100/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG" {
b, err := ioutil.ReadFile("testdata/powermax_create_volume_response.json")
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -182,14 +182,14 @@ func testPowerMaxServeHTTP(t *testing.T) {
fakeUni := fakeServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
t.Logf("fake unisphere received: %s %s", r.Method, r.URL)
switch r.URL.Path {
case "/univmax/restapi/91/sloprovisioning/symmetrix/1234567890/volume/003E4":
case "/univmax/restapi/100/sloprovisioning/symmetrix/1234567890/volume/003E4":
b, err := ioutil.ReadFile("testdata/powermax_getvolumebyid_response.json")
if err != nil {
t.Fatal(err)
}
w.Write(b)
return
case "/univmax/restapi/91/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG":
case "/univmax/restapi/100/sloprovisioning/symmetrix/1234567890/storagegroup/csi-CSM-Bronze-SRP_1-SG":
b, err := ioutil.ReadFile("testdata/powermax_getstoragegroup_response.json")
if err != nil {
t.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions internal/role-service/validate/powermax.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"karavi-authorization/internal/types"
"net/url"

pmax "github.com/dell/gopowermax"
pmax "github.com/dell/gopowermax/v2"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -53,7 +53,7 @@ func PowerMax(ctx context.Context, log *logrus.Entry, system types.System, syste
}).Debug("Establishing connection to PowerMax")

epURL.Scheme = "https"
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "", "", true, false)
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "CSM-Authz", true, false)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/role-service/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ func TestValidatePowerMax(t *testing.T) {
goodBackendPowerMax := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/univmax/restapi/90/system/version":
fmt.Fprintf(w, `{ "version": "V9.2.1.2"}`)
case "/univmax/restapi/90/sloprovisioning/symmetrix/000197900714/srp/bronze":
case "/univmax/restapi/version":
fmt.Fprintf(w, `{ "version": "V10.0.0.1"}`)
case "/univmax/restapi/100/sloprovisioning/symmetrix/000197900714/srp/bronze":
w.WriteHeader(http.StatusOK)
default:
t.Errorf("unhandled unisphere request path: %s", r.URL.Path)
Expand Down Expand Up @@ -319,9 +319,9 @@ storage:
goodBackendPowerMax := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/univmax/restapi/90/system/version":
fmt.Fprintf(w, `{ "version": "V9.2.1.2"}`)
case "/univmax/restapi/90/sloprovisioning/symmetrix/000197900714/srp/bronze":
case "/univmax/restapi/version":
fmt.Fprintf(w, `{ "version": "V10.0.0.1"}`)
case "/univmax/restapi/100/sloprovisioning/symmetrix/000197900714/srp/bronze":
w.WriteHeader(http.StatusOK)
default:
t.Errorf("unhandled unisphere request path: %s", r.URL.Path)
Expand Down
4 changes: 2 additions & 2 deletions internal/storage-service/validate/powermax.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"karavi-authorization/internal/types"
"net/url"

pmax "github.com/dell/gopowermax"
pmax "github.com/dell/gopowermax/v2"
"github.com/sirupsen/logrus"
)

Expand All @@ -39,7 +39,7 @@ func PowerMax(ctx context.Context, log *logrus.Entry, system types.System, syste
}

epURL.Scheme = "https"
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "", "", true, false)
powerMaxClient, err := pmax.NewClientWithArgs(epURL.String(), "CSM-Authz", true, false)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/storage-service/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ func TestValidatePowerMax(t *testing.T) {
goodBackendPowerMax := httptest.NewTLSServer(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/univmax/restapi/90/system/version":
fmt.Fprintf(w, `{ "version": "V9.2.1.2"}`)
case "/univmax/restapi/version":
fmt.Fprintf(w, `{ "version": "V10.0.0.1"}`)
default:
t.Errorf("unhandled unisphere request path: %s", r.URL.Path)
}
Expand Down