Skip to content

Commit 746c138

Browse files
Introduce dataLIF check for FC protocol
1 parent 1a19a09 commit 746c138

File tree

14 files changed

+302
-44
lines changed

14 files changed

+302
-44
lines changed

mocks/mock_storage_drivers/mock_ontap/mock_api.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_storage_drivers/mock_ontap/mock_ontap_rest_interface.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mock_storage_drivers/mock_ontap/mock_ontap_zapi_interface.go

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

storage_drivers/ontap/api/abstraction.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ type OntapAPI interface {
144144

145145
GetSLMDataLifs(ctx context.Context, ips, reportingNodeNames []string) ([]string, error)
146146
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
147+
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
147148
NodeListSerialNumbers(ctx context.Context) ([]string, error)
148149

149150
SnapshotRestoreVolume(ctx context.Context, snapshotName, sourceVolume string) error

storage_drivers/ontap/api/abstraction_rest.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,10 @@ func (d OntapAPIREST) NetInterfaceGetDataLIFs(ctx context.Context, protocol stri
535535
return d.api.NetInterfaceGetDataLIFs(ctx, protocol)
536536
}
537537

538+
func (d OntapAPIREST) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
539+
return d.api.NetFcpInterfaceGetDataLIFs(ctx, protocol)
540+
}
541+
538542
func (d OntapAPIREST) GetSVMAggregateNames(ctx context.Context) ([]string, error) {
539543
return d.api.SVMGetAggregateNames(ctx)
540544
}

storage_drivers/ontap/api/abstraction_zapi.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,10 @@ func (d OntapAPIZAPI) NetInterfaceGetDataLIFs(ctx context.Context, protocol stri
10911091
return d.api.NetInterfaceGetDataLIFs(ctx, protocol)
10921092
}
10931093

1094+
func (d OntapAPIZAPI) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
1095+
return d.api.NetFcpInterfaceGetDataLIFs(ctx, protocol)
1096+
}
1097+
10941098
func (d OntapAPIZAPI) GetSVMAggregateNames(_ context.Context) ([]string, error) {
10951099
return d.api.SVMGetAggregateNames()
10961100
}

storage_drivers/ontap/api/ontap_rest.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,6 +3159,40 @@ func (c RestClient) NetInterfaceGetDataLIFs(ctx context.Context, protocol string
31593159
return dataLIFs, nil
31603160
}
31613161

3162+
func (c RestClient) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
3163+
if protocol == "" {
3164+
return nil, fmt.Errorf("missing protocol specification")
3165+
}
3166+
3167+
params := networking.NewFcInterfaceCollectionGetParamsWithTimeout(c.httpClient.Timeout)
3168+
params.Context = ctx
3169+
params.HTTPClient = c.httpClient
3170+
3171+
params.SvmUUID = utils.Ptr(c.svmUUID)
3172+
fields := []string{"wwpn", "state"}
3173+
params.SetFields(fields)
3174+
3175+
lifResponse, err := c.api.Networking.FcInterfaceCollectionGet(params, c.authInfo)
3176+
if err != nil {
3177+
return nil, fmt.Errorf("error checking network interfaces; %v", err)
3178+
}
3179+
if lifResponse == nil {
3180+
return nil, fmt.Errorf("unexpected error checking network interfaces")
3181+
}
3182+
3183+
dataLIFs := make([]string, 0)
3184+
for _, record := range lifResponse.Payload.FcInterfaceResponseInlineRecords {
3185+
if record.Wwpn != nil && record.State != nil && *record.State == models.IPInterfaceStateUp {
3186+
if record.Wwpn != nil {
3187+
dataLIFs = append(dataLIFs, *record.Wwpn)
3188+
}
3189+
}
3190+
}
3191+
3192+
Logc(ctx).WithField("dataLIFs", dataLIFs).Debug("Data LIFs")
3193+
return dataLIFs, nil
3194+
}
3195+
31623196
// ////////////////////////////////////////////////////////////////////////////
31633197
// JOB operations
31643198
// ////////////////////////////////////////////////////////////////////////////

storage_drivers/ontap/api/ontap_rest_interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ type RestClientInterface interface {
172172
// NetworkIPInterfacesList lists all IP interfaces
173173
NetworkIPInterfacesList(ctx context.Context) (*networking.NetworkIPInterfacesGetOK, error)
174174
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
175+
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
175176
// JobGet returns the job by ID
176177
JobGet(ctx context.Context, jobUUID string, fields []string) (*cluster.JobGetOK, error)
177178
// IsJobFinished lookus up the supplied JobLinkResponse's UUID to see if it's reached a terminal state

storage_drivers/ontap/api/ontap_zapi.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2984,6 +2984,37 @@ func (c Client) NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([
29842984
return dataLIFs, nil
29852985
}
29862986

2987+
func (c Client) NetFcpInterfaceGet() (*azgo.FcpInterfaceGetIterResponse, error) {
2988+
response, err := azgo.NewFcpInterfaceGetIterRequest().
2989+
SetMaxRecords(DefaultZapiRecords).
2990+
SetQuery(azgo.FcpInterfaceGetIterRequestQuery{
2991+
FcpInterfaceInfoPtr: &azgo.FcpInterfaceInfoType{},
2992+
}).ExecuteUsing(c.zr)
2993+
2994+
return response, err
2995+
}
2996+
2997+
func (c Client) NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error) {
2998+
lifResponse, err := c.NetFcpInterfaceGet()
2999+
if err = azgo.GetError(ctx, lifResponse, err); err != nil {
3000+
return nil, fmt.Errorf("error checking network interfaces: %v", err)
3001+
}
3002+
3003+
dataLIFs := make([]string, 0)
3004+
if lifResponse.Result.AttributesListPtr != nil {
3005+
for _, attrs := range lifResponse.Result.AttributesListPtr.FcpInterfaceInfoPtr {
3006+
dataLIFs = append(dataLIFs, attrs.PortName())
3007+
}
3008+
}
3009+
3010+
if len(dataLIFs) < 1 {
3011+
return []string{}, fmt.Errorf("no data LIFs meet the provided criteria (protocol: %s)", protocol)
3012+
}
3013+
3014+
Logc(ctx).WithField("dataLIFs", dataLIFs).Debug("Data LIFs")
3015+
return dataLIFs, nil
3016+
}
3017+
29873018
// SystemGetVersion returns the system version
29883019
// equivalent to filer::> version
29893020
func (c Client) SystemGetVersion() (*azgo.SystemGetVersionResponse, error) {

storage_drivers/ontap/api/ontap_zapi_interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ type ZapiClientInterface interface {
366366
// equivalent to filer::> net interface list, but only those LIFs that are operational
367367
NetInterfaceGet() (*azgo.NetInterfaceGetIterResponse, error)
368368
NetInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
369+
NetFcpInterfaceGetDataLIFs(ctx context.Context, protocol string) ([]string, error)
369370
// SystemGetVersion returns the system version
370371
// equivalent to filer::> version
371372
SystemGetVersion() (*azgo.SystemGetVersionResponse, error)

0 commit comments

Comments
 (0)