Skip to content

Commit

Permalink
Changes to support Fibre Channel for ONTAP-SAN driver
Browse files Browse the repository at this point in the history
Co-authored-by: Vinay Kumar H S <[email protected]>
  • Loading branch information
prajwalv-netapp and VinayKumarHavanur authored Oct 14, 2024
1 parent 2469585 commit 46b4305
Show file tree
Hide file tree
Showing 51 changed files with 4,361 additions and 254 deletions.
7 changes: 6 additions & 1 deletion core/orchestrator_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/netapp/trident/storage_drivers/fake"
"github.com/netapp/trident/utils"
"github.com/netapp/trident/utils/errors"
"github.com/netapp/trident/utils/fcp"
"github.com/netapp/trident/utils/iscsi"
"github.com/netapp/trident/utils/models"
)
Expand Down Expand Up @@ -99,6 +100,7 @@ type TridentOrchestrator struct {
stopReconcileBackendLoop chan bool
uuid string
iscsi iscsi.ISCSI
fcp fcp.FCP
}

// NewTridentOrchestrator returns a storage orchestrator instance
Expand All @@ -120,6 +122,8 @@ func NewTridentOrchestrator(client persistentstore.Client) *TridentOrchestrator
// NewClient() must plugin default implementation of the various package clients.
iscsi: iscsi.New(utils.NewOSClient(), utils.NewDevicesClient(), utils.NewFilesystemClient(),
utils.NewMountClient()),
fcp: fcp.New(utils.NewOSClient(), utils.NewDevicesClient(), utils.NewFilesystemClient(),
utils.NewMountClient()),
}
}

Expand Down Expand Up @@ -1512,7 +1516,8 @@ func (o *TridentOrchestrator) updateUserBackendState(ctx context.Context, sb *st
if newUserBackendState.IsSuspended() {
// Backend is only suspended when its current state is either online, offline or failed.
if !backend.State().IsOnline() && !backend.State().IsOffline() && !backend.State().IsFailed() {
return fmt.Errorf("the backend '%s' is currently not in any of the expected states: offline, online, or failed. Its current state is '%s'", backend.Name(), backend.State())
return fmt.Errorf("the backend '%s' is currently not in any of the expected states: offline, online, or failed. Its current state is '%s'", backend.Name(),
backend.State())
}
}

Expand Down
32 changes: 20 additions & 12 deletions frontend/csi/controller_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ func (p *Plugin) ControllerPublishVolume(
Localhost: false,
HostIQN: []string{nodeInfo.IQN},
HostNQN: nodeInfo.NQN,
HostWWPN: nodeInfo.WWPNs,
HostIP: nodeInfo.IPs,
HostName: nodeInfo.Name,
Unmanaged: volume.Config.ImportNotManaged,
Expand Down Expand Up @@ -408,8 +409,16 @@ func (p *Plugin) ControllerPublishVolume(
publishInfo["nvmeNamespaceUUID"] = volumePublishInfo.NVMeNamespaceUUID
publishInfo["nvmeTargetIPs"] = strings.Join(volumePublishInfo.NVMeTargetIPs, ",")
publishInfo["SANType"] = sa.NVMe
} else if volumePublishInfo.SANType == sa.FCP {
// Fill in only FCP specific fields in publishInfo
publishInfo["fcTargetWWNN"] = volumePublishInfo.FCTargetWWNN
publishInfo["fcpLunNumber"] = strconv.Itoa(int(volumePublishInfo.FCPLunNumber))
publishInfo["fcpLunSerial"] = volumePublishInfo.FCPLunSerial
publishInfo["fcpIgroup"] = volumePublishInfo.FCPIgroup
publishInfo["useCHAP"] = "false"
publishInfo["SANType"] = sa.FCP
} else {
// fill in only iSCSI specific fields in publishInfo
// Fill in only iSCSI specific fields in publishInfo
stashIscsiTargetPortals(publishInfo, volumePublishInfo)
publishInfo["iscsiTargetIqn"] = volumePublishInfo.IscsiTargetIQN
publishInfo["iscsiLunNumber"] = strconv.Itoa(int(volumePublishInfo.IscsiLunNumber))
Expand All @@ -418,18 +427,17 @@ func (p *Plugin) ControllerPublishVolume(
publishInfo["iscsiIgroup"] = volumePublishInfo.IscsiIgroup
publishInfo["useCHAP"] = strconv.FormatBool(volumePublishInfo.UseCHAP)
publishInfo["SANType"] = sa.ISCSI

// Encrypt and add CHAP credentials if they're needed
if volumePublishInfo.UseCHAP {
if p.aesKey != nil {
if err := encryptCHAPPublishInfo(ctx, publishInfo, volumePublishInfo, p.aesKey); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
} else {
msg := "encryption key not set; cannot encrypt CHAP credentials for transit"
Logc(ctx).Error(msg)
return nil, status.Error(codes.Internal, msg)
}
// Encrypt and add CHAP credentials if they're needed
if volumePublishInfo.UseCHAP {
if p.aesKey != nil {
if err := encryptCHAPPublishInfo(ctx, publishInfo, volumePublishInfo, p.aesKey); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
} else {
msg := "encryption key not set; cannot encrypt CHAP credentials for transit"
Logc(ctx).Error(msg)
return nil, status.Error(codes.Internal, msg)
}
}
}
Expand Down
Loading

0 comments on commit 46b4305

Please sign in to comment.