Skip to content

Commit

Permalink
Feature/nvme tcp connect (#8)
Browse files Browse the repository at this point in the history
* Nvme tcp initial commit

* Nvme tcp - added get session

* NVMe connect

* Fixed errors on nvme tcp

* Waitgroup error fix

* Added readDevicesFromResultCH

* Added readNVMeDevicesFromResultCH

* Added readNVMeDevicesFromResultCH

* Added readNVMeDevicesFromResultCH

* Added readNVMeDevicesFromResultCH

* NVMe connect changes

* NVMe disconnect changes

* Review changes

* Resolving conflicts

* Review changes

* Review changes

* Lint errors fix

* Lint errors fix

* Lint errors fix

* updated go.mod

* updated gitignore

* fixed lint error

* updated go.sum

Co-authored-by: Harshita Pandey <[email protected]>
Co-authored-by: Harshita Pandey <[email protected]>
Co-authored-by: Harish P <[email protected]>
  • Loading branch information
4 people authored Feb 22, 2022
1 parent ea0ebde commit 209fb19
Show file tree
Hide file tree
Showing 8 changed files with 675 additions and 8 deletions.
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

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"

"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

0 comments on commit 209fb19

Please sign in to comment.