Skip to content

Commit

Permalink
Merge pull request #63 from dell/feature_nvme_tcp
Browse files Browse the repository at this point in the history
Feature nvme tcp
  • Loading branch information
nidtara authored Jun 3, 2024
2 parents 9ce9d04 + a8b38d5 commit 59f78eb
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
8 changes: 8 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ type ISCSITarget struct {
PortalIPs []string
}

// NVMeTCPTarget is a structure representing a target NQN and associated IP addresses
type NVMeTCPTarget struct {
NQN string
PortalIPs []string
}

const (
// DefaultAPIVersion is the default API version you will get if not specified to NewClientWithArgs.
// The other supported versions are listed here.
Expand Down Expand Up @@ -251,6 +257,8 @@ type Pmax interface {
GetPort(ctx context.Context, symID string, directorID string, portID string) (*types.Port, error)
// GetListOfTargetAddresses returns an array of all IP addresses which expose iscsi targets.
GetListOfTargetAddresses(ctx context.Context, symID string) ([]string, error)
// GetNVMeTCPTargets returns a list of NVMeTCP targets for given sym id
GetNVMeTCPTargets(ctx context.Context, symID string) ([]NVMeTCPTarget, error)
// GetISCSITargets returns a list of ISCSI Targets for a given sym id
GetISCSITargets(ctx context.Context, symID string) ([]ISCSITarget, error)
// CreateHostGroup creates a hostGroup from a list of hostIDs (and optional HostFlags) and returns a types.HostGroup.
Expand Down
12 changes: 8 additions & 4 deletions mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ var InducedErrors struct {
DeleteNFSExportError bool
GetFileInterfaceError bool
ExecuteActionError bool
GetFreshMetrics bool
}

// hasError checks to see if the specified error (via pointer)
Expand Down Expand Up @@ -391,6 +392,7 @@ func Reset() {
InducedErrors.DeleteNFSExportError = false
InducedErrors.GetFileInterfaceError = false
InducedErrors.ExecuteActionError = false
InducedErrors.GetFreshMetrics = false
Data.JSONDir = "mock"
Data.VolumeIDToIdentifier = make(map[string]string)
Data.VolumeIDToSize = make(map[string]int)
Expand Down Expand Up @@ -3308,8 +3310,12 @@ func handleVolumeMetrics(w http.ResponseWriter, r *http.Request) {
Writes: 0.0,
ReadResponseTime: 0.0,
WriteResponseTime: 0.0,
IoRate: 5.0,
Timestamp: 1671091500000,
}
if InducedErrors.GetFreshMetrics {
volumeMetric.Timestamp = time.Now().UnixMilli()
}
volumeResult := types.VolumeResult{
VolumeResult: []types.VolumeMetric{volumeMetric},
VolumeID: "002C8",
Expand Down Expand Up @@ -3378,17 +3384,15 @@ func handleStorageGroupPerfKeys(w http.ResponseWriter, r *http.Request) {
}

// /univmax/restapi/performance/Array/keys
func handleArrayPerfKeys(w http.ResponseWriter, r *http.Request) {
func handleArrayPerfKeys(w http.ResponseWriter, _ *http.Request) {
mockCacheMutex.Lock()
defer mockCacheMutex.Unlock()
vars := mux.Vars(r)
symmetrixID := vars["symmetrixId"]
if InducedErrors.GetArrayPerfKeyError {
writeError(w, "Error getting array perf key: induced error", http.StatusRequestTimeout)
return
}
arrayInfo := types.ArrayInfo{
SymmetrixID: symmetrixID,
SymmetrixID: DefaultSymmetrixID,
FirstAvailableDate: 0,
LastAvailableDate: 1671091597409,
}
Expand Down
53 changes: 53 additions & 0 deletions system.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,59 @@ func (c *Client) GetISCSITargets(ctx context.Context, symID string) ([]ISCSITarg
return targets, nil
}

// GetNVMeTCPTargets returns list of target addresses
func (c *Client) GetNVMeTCPTargets(ctx context.Context, symID string) ([]NVMeTCPTarget, error) {
if _, err := c.IsAllowedArray(symID); err != nil {
return nil, err
}
targets := make([]NVMeTCPTarget, 0)
// Get list of all directors
directors, err := c.GetDirectorIDList(ctx, symID)
if err != nil {
return []NVMeTCPTarget{}, err
}

for _, d := range directors.DirectorIDs {
// Check if director is ISCSI
// To do this, check if any ports have ports with GigE enabled
ports, err := c.GetPortList(ctx, symID, d, "type=OSHostAndRDF")
if err != nil {
// Ignore the error and continue
log.Errorf("Failed to get ports of type OSHost for director: %s. Error: %s",
d, err.Error())
continue
}
if len(ports.SymmetrixPortKey) > 0 {
// This is a director with ISCSI port(s)
// Query for iscsi_targets
virtualPorts, err := c.GetPortList(ctx, symID, d, "nvmetcp_endpoint=true")
if err != nil {
return []NVMeTCPTarget{}, err
}
// we have a list of virtual director ports which have NVMeTCP endpoints
// and portal IPs associated with it
for _, vp := range virtualPorts.SymmetrixPortKey {
port, err := c.GetPort(ctx, symID, vp.DirectorID, vp.PortID)
if err != nil {
// Ignore the error and continue
log.Errorf("Failed to fetch port details for %s:%s. Error: %s",
vp.DirectorID, vp.PortID, err.Error())
continue
}
// this should always be set
if port.SymmetrixPort.Identifier != "" {
tgt := NVMeTCPTarget{
NQN: port.SymmetrixPort.Identifier,
PortalIPs: port.SymmetrixPort.IPAddresses,
}
targets = append(targets, tgt)
}
}
}
}
return targets, nil
}

// RefreshSymmetrix refreshes symmetrix cache
func (c *Client) RefreshSymmetrix(ctx context.Context, symID string) error {
defer c.TimeSpent("RefreshSymmetrix", time.Now())
Expand Down

0 comments on commit 59f78eb

Please sign in to comment.