Skip to content

Commit

Permalink
Introduce dataLIF check for FC protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
VinayKumarHavanur authored Dec 4, 2024
1 parent 1a19a09 commit 746c138
Show file tree
Hide file tree
Showing 14 changed files with 302 additions and 44 deletions.
15 changes: 15 additions & 0 deletions mocks/mock_storage_drivers/mock_ontap/mock_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions mocks/mock_storage_drivers/mock_ontap/mock_ontap_rest_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions mocks/mock_storage_drivers/mock_ontap/mock_ontap_zapi_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions storage_drivers/ontap/api/abstraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ type OntapAPI interface {

GetSLMDataLifs(ctx context.Context, ips, reportingNodeNames []string) ([]string, error)
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
NodeListSerialNumbers(ctx context.Context) ([]string, error)

SnapshotRestoreVolume(ctx context.Context, snapshotName, sourceVolume string) error
Expand Down
4 changes: 4 additions & 0 deletions storage_drivers/ontap/api/abstraction_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ func (d OntapAPIREST) NetInterfaceGetDataLIFs(ctx context.Context, protocol stri
return d.api.NetInterfaceGetDataLIFs(ctx, protocol)
}

func (d OntapAPIREST) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
return d.api.NetFcpInterfaceGetDataLIFs(ctx, protocol)
}

func (d OntapAPIREST) GetSVMAggregateNames(ctx context.Context) ([]string, error) {
return d.api.SVMGetAggregateNames(ctx)
}
Expand Down
4 changes: 4 additions & 0 deletions storage_drivers/ontap/api/abstraction_zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,10 @@ func (d OntapAPIZAPI) NetInterfaceGetDataLIFs(ctx context.Context, protocol stri
return d.api.NetInterfaceGetDataLIFs(ctx, protocol)
}

func (d OntapAPIZAPI) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
return d.api.NetFcpInterfaceGetDataLIFs(ctx, protocol)
}

func (d OntapAPIZAPI) GetSVMAggregateNames(_ context.Context) ([]string, error) {
return d.api.SVMGetAggregateNames()
}
Expand Down
34 changes: 34 additions & 0 deletions storage_drivers/ontap/api/ontap_rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3159,6 +3159,40 @@ func (c RestClient) NetInterfaceGetDataLIFs(ctx context.Context, protocol string
return dataLIFs, nil
}

func (c RestClient) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
if protocol == "" {
return nil, fmt.Errorf("missing protocol specification")
}

params := networking.NewFcInterfaceCollectionGetParamsWithTimeout(c.httpClient.Timeout)
params.Context = ctx
params.HTTPClient = c.httpClient

params.SvmUUID = utils.Ptr(c.svmUUID)
fields := []string{"wwpn", "state"}
params.SetFields(fields)

lifResponse, err := c.api.Networking.FcInterfaceCollectionGet(params, c.authInfo)
if err != nil {
return nil, fmt.Errorf("error checking network interfaces; %v", err)
}
if lifResponse == nil {
return nil, fmt.Errorf("unexpected error checking network interfaces")
}

dataLIFs := make([]string, 0)
for _, record := range lifResponse.Payload.FcInterfaceResponseInlineRecords {
if record.Wwpn != nil && record.State != nil && *record.State == models.IPInterfaceStateUp {
if record.Wwpn != nil {
dataLIFs = append(dataLIFs, *record.Wwpn)
}
}
}

Logc(ctx).WithField("dataLIFs", dataLIFs).Debug("Data LIFs")
return dataLIFs, nil
}

// ////////////////////////////////////////////////////////////////////////////
// JOB operations
// ////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions storage_drivers/ontap/api/ontap_rest_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type RestClientInterface interface {
// NetworkIPInterfacesList lists all IP interfaces
NetworkIPInterfacesList(ctx context.Context) (*networking.NetworkIPInterfacesGetOK, error)
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
// JobGet returns the job by ID
JobGet(ctx context.Context, jobUUID string, fields []string) (*cluster.JobGetOK, error)
// IsJobFinished lookus up the supplied JobLinkResponse's UUID to see if it's reached a terminal state
Expand Down
31 changes: 31 additions & 0 deletions storage_drivers/ontap/api/ontap_zapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2984,6 +2984,37 @@ func (c Client) NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([
return dataLIFs, nil
}

func (c Client) NetFcpInterfaceGet() (*azgo.FcpInterfaceGetIterResponse, error) {
response, err := azgo.NewFcpInterfaceGetIterRequest().
SetMaxRecords(DefaultZapiRecords).
SetQuery(azgo.FcpInterfaceGetIterRequestQuery{
FcpInterfaceInfoPtr: &azgo.FcpInterfaceInfoType{},
}).ExecuteUsing(c.zr)

return response, err
}

func (c Client) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
lifResponse, err := c.NetFcpInterfaceGet()
if err = azgo.GetError(ctx, lifResponse, err); err != nil {
return nil, fmt.Errorf("error checking network interfaces: %v", err)
}

dataLIFs := make([]string, 0)
if lifResponse.Result.AttributesListPtr != nil {
for _, attrs := range lifResponse.Result.AttributesListPtr.FcpInterfaceInfoPtr {
dataLIFs = append(dataLIFs, attrs.PortName())
}
}

if len(dataLIFs) < 1 {
return []string{}, fmt.Errorf("no data LIFs meet the provided criteria (protocol: %s)", protocol)
}

Logc(ctx).WithField("dataLIFs", dataLIFs).Debug("Data LIFs")
return dataLIFs, nil
}

// SystemGetVersion returns the system version
// equivalent to filer::> version
func (c Client) SystemGetVersion() (*azgo.SystemGetVersionResponse, error) {
Expand Down
1 change: 1 addition & 0 deletions storage_drivers/ontap/api/ontap_zapi_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ type ZapiClientInterface interface {
// equivalent to filer::> net interface list, but only those LIFs that are operational
NetInterfaceGet() (*azgo.NetInterfaceGetIterResponse, error)
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
// SystemGetVersion returns the system version
// equivalent to filer::> version
SystemGetVersion() (*azgo.SystemGetVersionResponse, error)
Expand Down
26 changes: 16 additions & 10 deletions storage_drivers/ontap/ontap_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,17 +485,23 @@ func getSVMState(
}
}

// Check dataLIF for iSCSI and NVMe protocols
if protocol != sa.FCP {
upDataLIFs, err := client.NetInterfaceGetDataLIFs(ctx, protocol)
if err != nil || len(upDataLIFs) == 0 {
if err != nil {
// Log error and keep going.
Logc(ctx).WithField("error", err).Warn("Error getting list of data LIFs from backend.")
}
// No data LIFs with state 'up' found.
return StateReasonDataLIFsDown, changeMap
upDataLIFs := make([]string, 0)
if protocol == sa.FCP {
// Check dataLIF for FC protocol
upDataLIFs, err = client.NetFcpInterfaceGetDataLIFs(ctx, protocol)
} else {
// Check dataLIF for iSCSI and NVMe protocols
upDataLIFs, err = client.NetInterfaceGetDataLIFs(ctx, protocol)
}

if err != nil || len(upDataLIFs) == 0 {
if err != nil {
// Log error and keep going.
fields := LogFields{"error": err, "protocol": protocol}
Logc(ctx).WithFields(fields).Warn("Error getting list of data LIFs from backend.")
}
// No data LIFs with state 'up' found.
return StateReasonDataLIFsDown, changeMap
}

// Get ONTAP version
Expand Down
Loading

0 comments on commit 746c138

Please sign in to comment.