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 all 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
c.out
c.out
.idea
.vscode
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
10 changes: 8 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
module github.com/dell/gobrick

go 1.13
go 1.17
harishp8889 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-20220217061253-306d51e093bd
github.com/golang/mock v1.3.1
github.com/stretchr/testify v1.4.0
golang.org/x/sync v0.0.0-20190423024810-112230192c58
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dell/goiscsi v1.1.0 h1:ByULW5hzYnDLCEC/7E2B03KhTLt/RpeMIwfGszmTe7U=
github.com/dell/goiscsi v1.1.0/go.mod h1:MfuMjbKWsh/MOb0VDW20C+LFYRIOfWKGiAxWkeM5TKo=
github.com/dell/gonvme v0.0.0-20220217061253-306d51e093bd h1:eA/UOAcQnQSzC7yGF+t2kupaIqJIY2QPPIJpDFeqPyY=
github.com/dell/gonvme v0.0.0-20220217061253-306d51e093bd/go.mod h1:JXLmgxE/2dsiXqW5E+kH5Zo11lOjCuHyiHu92xqR9O0=
github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
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
}
12 changes: 12 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,17 @@ type ISCSILib interface {
CreateOrUpdateNode(target goiscsi.ISCSITarget, options map[string]string) error
}

// NVMeTCP defines NVMe function spec
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