Skip to content

Commit 97b910f

Browse files
authored
Added support for FCP transport layer over SCSI for ASA
1 parent 401990f commit 97b910f

File tree

4 files changed

+537
-53
lines changed

4 files changed

+537
-53
lines changed

storage_drivers/ontap/ontap_asa.go

Lines changed: 76 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type ASAStorageDriver struct {
3232
initialized bool
3333
Config drivers.OntapStorageDriverConfig
3434
ips []string
35+
wwpns []string
3536
API api.OntapAPI
3637
telemetry *Telemetry
3738
iscsi iscsi.ISCSI
@@ -70,6 +71,8 @@ func (d *ASAStorageDriver) BackendName() string {
7071
lif0 := "noLIFs"
7172
if len(d.ips) > 0 {
7273
lif0 = d.ips[0]
74+
} else if len(d.wwpns) > 0 {
75+
lif0 = strings.ReplaceAll(d.wwpns[0], ":", ".")
7376
}
7477
return CleanBackendName("ontapasa_" + lif0)
7578
} else {
@@ -121,18 +124,28 @@ func (d *ASAStorageDriver) Initialize(
121124
if err = PopulateASAConfigurationDefaults(ctx, &d.Config); err != nil {
122125
return fmt.Errorf("could not populate configuration defaults: %v", err)
123126
}
127+
if d.Config.SANType == sa.FCP {
128+
if d.wwpns, err = d.API.NetFcpInterfaceGetDataLIFs(ctx, d.Config.SANType); err != nil {
129+
return err
130+
}
124131

125-
d.ips, err = d.API.NetInterfaceGetDataLIFs(ctx, "iscsi")
126-
if err != nil {
127-
return err
128-
}
129-
130-
if len(d.ips) == 0 {
131-
return fmt.Errorf("no iSCSI data LIFs found on SVM %s", d.API.SVMName())
132+
if len(d.wwpns) == 0 {
133+
return fmt.Errorf("no FC data LIFs found on SVM %s", d.API.SVMName())
134+
} else {
135+
Logc(ctx).WithField("dataLIFs", d.wwpns).Debug("Found FC LIFs.")
136+
}
132137
} else {
133-
Logc(ctx).WithField("dataLIFs", d.ips).Debug("Found iSCSI LIFs.")
134-
}
138+
d.ips, err = d.API.NetInterfaceGetDataLIFs(ctx, d.Config.SANType)
139+
if err != nil {
140+
return err
141+
}
135142

143+
if len(d.ips) == 0 {
144+
return fmt.Errorf("no iSCSI data LIFs found on SVM %s", d.API.SVMName())
145+
} else {
146+
Logc(ctx).WithField("dataLIFs", d.ips).Debug("Found iSCSI LIFs.")
147+
}
148+
}
136149
d.physicalPools, d.virtualPools, err = InitializeASAStoragePoolsCommon(ctx, d,
137150
d.getStoragePoolAttributes(ctx), d.BackendName())
138151
if err != nil {
@@ -713,7 +726,7 @@ func (d *ASAStorageDriver) Publish(
713726
ctx context.Context, volConfig *storage.VolumeConfig, publishInfo *models.VolumePublishInfo,
714727
) error {
715728
name := volConfig.InternalName
716-
729+
var nodeName string
717730
fields := LogFields{
718731
"Method": "Publish",
719732
"Type": "ASAStorageDriver",
@@ -739,18 +752,40 @@ func (d *ASAStorageDriver) Publish(
739752
igroupName := d.Config.IgroupName
740753

741754
// Use the node specific igroup if publish enforcement is enabled and this is for CSI.
742-
if tridentconfig.CurrentDriverContext == tridentconfig.ContextCSI {
743-
igroupName = getNodeSpecificIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
744-
err = ensureIGroupExists(ctx, d.GetAPI(), igroupName, d.Config.SANType)
745-
}
755+
if d.Config.SANType == sa.FCP {
756+
// Handle FCP protocol
757+
if tridentconfig.CurrentDriverContext == tridentconfig.ContextCSI {
758+
igroupName = getNodeSpecificFCPIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
759+
err = ensureIGroupExists(ctx, d.GetAPI(), igroupName, d.Config.SANType)
760+
if err != nil {
761+
return err
762+
}
763+
}
746764

747-
// Get target info.
748-
iSCSINodeName, _, err := GetISCSITargetInfo(ctx, d.API, &d.Config)
749-
if err != nil {
750-
return err
751-
}
765+
// Get FCP target info
766+
FCPNodeName, _, err := GetFCPTargetInfo(ctx, d.API, &d.Config)
767+
if err != nil {
768+
return err
769+
}
770+
nodeName = FCPNodeName
771+
} else {
772+
// Handle iSCSI protocol
773+
if tridentconfig.CurrentDriverContext == tridentconfig.ContextCSI {
774+
igroupName = getNodeSpecificIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
775+
err = ensureIGroupExists(ctx, d.GetAPI(), igroupName, d.Config.SANType)
776+
if err != nil {
777+
return err
778+
}
779+
}
752780

753-
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, iSCSINodeName)
781+
// Get iSCSI target info
782+
iSCSINodeName, _, err := GetISCSITargetInfo(ctx, d.API, &d.Config)
783+
if err != nil {
784+
return err
785+
}
786+
nodeName = iSCSINodeName
787+
}
788+
err = PublishLUN(ctx, d.API, &d.Config, d.ips, publishInfo, lunPath, igroupName, nodeName)
754789
if err != nil {
755790
return fmt.Errorf("error publishing %s driver: %v", d.Name(), err)
756791
}
@@ -768,6 +803,7 @@ func (d *ASAStorageDriver) Unpublish(
768803
) error {
769804
name := volConfig.InternalName
770805

806+
var igroupName string
771807
fields := LogFields{
772808
"Method": "Unpublish",
773809
"Type": "ASAStorageDriver",
@@ -779,17 +815,27 @@ func (d *ASAStorageDriver) Unpublish(
779815
if tridentconfig.CurrentDriverContext != tridentconfig.ContextCSI {
780816
return nil
781817
}
818+
if d.Config.SANType == sa.FCP {
819+
igroupName = getNodeSpecificFCPIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
820+
lunPath := name
821+
if err := LunUnmapIgroup(ctx, d.API, igroupName, lunPath); err != nil {
822+
return fmt.Errorf("error unmapping LUN %s from igroup %s; %v", lunPath, igroupName, err)
823+
}
782824

783-
// Attempt to unmap the LUN from the per-node igroup.
784-
igroupName := getNodeSpecificIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
785-
lunPath := name
786-
if err := LunUnmapIgroup(ctx, d.API, igroupName, lunPath); err != nil {
787-
return fmt.Errorf("error unmapping LUN %s from igroup %s; %v", lunPath, igroupName, err)
788-
}
789-
790-
// Remove igroup from volume config's iscsi access Info
791-
volConfig.AccessInfo.IscsiIgroup = removeIgroupFromIscsiIgroupList(volConfig.AccessInfo.IscsiIgroup, igroupName)
825+
// Remove igroup from volume config's FCP access info
826+
volConfig.AccessInfo.FCPIgroup = removeIgroupFromFCPIgroupList(volConfig.AccessInfo.FCPIgroup,
827+
igroupName)
828+
} else {
829+
// Attempt to unmap the LUN from the per-node igroup.
830+
igroupName = getNodeSpecificIgroupName(publishInfo.HostName, publishInfo.TridentUUID)
831+
lunPath := name
832+
if err := LunUnmapIgroup(ctx, d.API, igroupName, lunPath); err != nil {
833+
return fmt.Errorf("error unmapping LUN %s from igroup %s; %v", lunPath, igroupName, err)
834+
}
792835

836+
// Remove igroup from volume config's iscsi access Info
837+
volConfig.AccessInfo.IscsiIgroup = removeIgroupFromIscsiIgroupList(volConfig.AccessInfo.IscsiIgroup, igroupName)
838+
}
793839
// Remove igroup if no LUNs are mapped.
794840
if err := DestroyUnmappedIgroup(ctx, d.API, igroupName); err != nil {
795841
return fmt.Errorf("error removing empty igroup; %v", err)
@@ -1234,7 +1280,7 @@ func (d *ASAStorageDriver) GetBackendState(ctx context.Context) (string, *roarin
12341280
Logc(ctx).Debug(">>>> GetBackendState")
12351281
defer Logc(ctx).Debug("<<<< GetBackendState")
12361282

1237-
return getSVMState(ctx, d.API, "iscsi", d.GetStorageBackendPhysicalPoolNames(ctx))
1283+
return getSVMState(ctx, d.API, d.Config.SANType, d.GetStorageBackendPhysicalPoolNames(ctx))
12381284
}
12391285

12401286
// String makes ASAStorageDriver satisfy the Stringer interface.

0 commit comments

Comments
 (0)