Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/nvme tcp connect #8

Merged
merged 26 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0ee9505
Nvme tcp initial commit
francis-nijay Jan 31, 2022
1146a31
Nvme tcp - added get session
francis-nijay Feb 4, 2022
9bd00cb
NVMe connect
francis-nijay Feb 15, 2022
83379bf
Fixed errors on nvme tcp
francis-nijay Feb 15, 2022
41937a5
Waitgroup error fix
francis-nijay Feb 16, 2022
00c32d9
Added readDevicesFromResultCH
francis-nijay Feb 16, 2022
74839c1
Added readNVMeDevicesFromResultCH
francis-nijay Feb 17, 2022
dcc4380
Added readNVMeDevicesFromResultCH
francis-nijay Feb 17, 2022
8a475bd
Added readNVMeDevicesFromResultCH
francis-nijay Feb 17, 2022
a7daebf
Added readNVMeDevicesFromResultCH
francis-nijay Feb 17, 2022
00445af
NVMe connect changes
harshitap26 Feb 18, 2022
f61fda6
NVMe disconnect changes
harshitap26 Feb 18, 2022
b1c701a
Review changes
francis-nijay Feb 21, 2022
fa1688a
Merge branch 'main' into feature/nvme-tcp-connect
harshitap26 Feb 22, 2022
acc42f0
Resolving conflicts
harshitap26 Feb 22, 2022
e4b2287
Review changes
francis-nijay Feb 22, 2022
e07b6ad
Merge branch 'feature/nvme-tcp-connect' of github.com:dell/gobrick in…
francis-nijay Feb 22, 2022
8f1f223
Review changes
francis-nijay Feb 22, 2022
5394bf6
Lint errors fix
francis-nijay Feb 22, 2022
430f3a2
Lint errors fix
francis-nijay Feb 22, 2022
7282113
Lint errors fix
francis-nijay Feb 22, 2022
e3a9a36
updated go.mod
harishp8889 Feb 22, 2022
604f4bb
Merge branch 'feature/nvme-tcp-connect' of github.com:dell/gobrick in…
harishp8889 Feb 22, 2022
2d4bd53
updated gitignore
harishp8889 Feb 22, 2022
c94f272
fixed lint error
harishp8889 Feb 22, 2022
53cb1b2
updated go.sum
harishp8889 Feb 22, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ func (bc *baseConnector) disconnectDevicesByDeviceName(ctx context.Context, name
return bc.cleanDevices(ctx, false, devices)
}

func (bc *baseConnector) disconnectNVMEDevicesByDeviceName(ctx context.Context, name string) error {
defer tracer.TraceFuncCall(ctx, "baseConnector.disconnectDevicesByDeviceName")()
if !bc.scsi.IsDeviceExist(ctx, name) {
logger.Info(ctx, "device %s not found", name)
return nil
}
var err error
var wwn string
if strings.HasPrefix(name, deviceMapperPrefix) {
wwn, err = bc.getDMWWN(ctx, name)

} else {
wwn, err = bc.scsi.GetNVMEDeviceWWN(ctx, []string{name})
}
if err != nil {
logger.Error(ctx, "can't find wwn for device: %s", err.Error())
return err
}

devices, err := bc.scsi.GetDevicesByWWN(ctx, wwn)
if err != nil {
logger.Error(ctx, "failed to find devices by wwn: %s", err.Error())
return err
}
return bc.cleanDevices(ctx, false, devices)
}

func (bc *baseConnector) cleanDevices(ctx context.Context,
force bool, devices []string) error {
defer tracer.TraceFuncCall(ctx, "baseConnector.cleanDevices")()
Expand Down
6 changes: 5 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module github.com/dell/gobrick

go 1.13
go 1.17
harishp8889 marked this conversation as resolved.
Show resolved Hide resolved

replace github.com/dell/gonvme => ../gonvme
francis-nijay marked this conversation as resolved.
Show resolved Hide resolved

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dell/goiscsi v1.1.0
github.com/dell/gonvme v0.0.0-20220214203653-9781a8511a08
github.com/golang/mock v1.3.1
github.com/stretchr/testify v1.4.0
golang.org/x/sync v0.0.0-20190423024810-112230192c58

)
2 changes: 2 additions & 0 deletions internal/scsi/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ type SCSI interface {
DeleteSCSIDeviceByName(ctx context.Context, name string) error
DeleteSCSIDeviceByPath(ctx context.Context, devPath string) error
GetDeviceWWN(ctx context.Context, devices []string) (string, error)
GetNVMEDeviceWWN(ctx context.Context, devices []string) (string, error)
GetDevicesByWWN(ctx context.Context, wwn string) ([]string, error)
GetDMDeviceByChildren(ctx context.Context, devices []string) (string, error)
GetDMChildren(ctx context.Context, dmPath string) ([]string, error)
CheckDeviceIsValid(ctx context.Context, device string) bool
GetDeviceNameByHCTL(ctx context.Context, h scsi.HCTL) (string, error)
WaitUdevSymlink(ctx context.Context, deviceName string, wwn string) error
WaitUdevSymlinkNVMe(ctx context.Context, deviceName string, wwn string) error
}
11 changes: 11 additions & 0 deletions internal/wrappers/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"path/filepath"

harishp8889 marked this conversation as resolved.
Show resolved Hide resolved
"github.com/dell/goiscsi"
"github.com/dell/gonvme"
)

// LimitedFileInfo defines limited file info interface
Expand Down Expand Up @@ -61,6 +62,16 @@ type ISCSILib interface {
CreateOrUpdateNode(target goiscsi.ISCSITarget, options map[string]string) error
}

type NVMeTCP interface {
DiscoverNVMeTCPTargets(address string, login bool) ([]gonvme.NVMeTarget, error)
GetInitiators(filename string) ([]string, error)
NVMeConnect(target gonvme.NVMeTarget) error
NVMeDisconnect(target gonvme.NVMeTarget) error
GetSessions() ([]gonvme.NVMESession, error)
ListNamespaceDevices() map[string][]string
GetNamespaceData(path string, namespaceID string) (string, error)
}

// wrappers

// OSExecWrapper contains implementation of LimitedOSExec interface
Expand Down
Loading