diff --git a/go.mod b/go.mod index 7721952..fc9043a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/dell/goiscsi v1.1.0 - github.com/dell/gonvme v0.0.0-20220217061253-306d51e093bd + github.com/dell/gonvme v0.0.0-20220224072409-dcb82cef802a github.com/golang/mock v1.3.1 github.com/stretchr/testify v1.4.0 golang.org/x/sync v0.0.0-20190423024810-112230192c58 diff --git a/go.sum b/go.sum index aa6ab0c..ab55e1e 100644 --- a/go.sum +++ b/go.sum @@ -5,20 +5,49 @@ 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/dell/gonvme v0.0.0-20220224060134-c0b7f420e4e0 h1:hhaNM3bNAPAqGe1afMZl31kM1E4MNBo336UVxX2n0+A= +github.com/dell/gonvme v0.0.0-20220224060134-c0b7f420e4e0/go.mod h1:JXLmgxE/2dsiXqW5E+kH5Zo11lOjCuHyiHu92xqR9O0= +github.com/dell/gonvme v0.0.0-20220224072409-dcb82cef802a h1:VbnFMQoJ0XYCwQbCktQlkqyrpBKaQu/vyXs8Ss5KSGQ= +github.com/dell/gonvme v0.0.0-20220224072409-dcb82cef802a/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/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1 h1:wGiQel/hW0NnEkJUk8lbzkX2gFJU6PFxf1v5OlCfuOs= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= diff --git a/internal/scsi/scsi_mock.go b/internal/scsi/scsi_mock.go index 4445cb4..7f078b3 100644 --- a/internal/scsi/scsi_mock.go +++ b/internal/scsi/scsi_mock.go @@ -6,77 +6,50 @@ package scsi import ( context "context" + reflect "reflect" + scsi "github.com/dell/gobrick/pkg/scsi" gomock "github.com/golang/mock/gomock" - reflect "reflect" ) -// MockSCSI is a mock of SCSI interface +// MockSCSI is a mock of SCSI interface. type MockSCSI struct { ctrl *gomock.Controller recorder *MockSCSIMockRecorder } -// MockSCSIMockRecorder is the mock recorder for MockSCSI +// MockSCSIMockRecorder is the mock recorder for MockSCSI. type MockSCSIMockRecorder struct { mock *MockSCSI } -// NewMockSCSI creates a new mock instance +// NewMockSCSI creates a new mock instance. func NewMockSCSI(ctrl *gomock.Controller) *MockSCSI { mock := &MockSCSI{ctrl: ctrl} mock.recorder = &MockSCSIMockRecorder{mock} return mock } -// EXPECT returns an object that allows the caller to indicate expected use +// EXPECT returns an object that allows the caller to indicate expected use. func (m *MockSCSI) EXPECT() *MockSCSIMockRecorder { return m.recorder } -// IsDeviceExist mocks base method -func (m *MockSCSI) IsDeviceExist(ctx context.Context, device string) bool { +// CheckDeviceIsValid mocks base method. +func (m *MockSCSI) CheckDeviceIsValid(ctx context.Context, device string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsDeviceExist", ctx, device) + ret := m.ctrl.Call(m, "CheckDeviceIsValid", ctx, device) ret0, _ := ret[0].(bool) return ret0 } -// IsDeviceExist indicates an expected call of IsDeviceExist -func (mr *MockSCSIMockRecorder) IsDeviceExist(ctx, device interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDeviceExist", reflect.TypeOf((*MockSCSI)(nil).IsDeviceExist), ctx, device) -} - -// RescanSCSIHostByHCTL mocks base method -func (m *MockSCSI) RescanSCSIHostByHCTL(ctx context.Context, h scsi.HCTL) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RescanSCSIHostByHCTL", ctx, h) - ret0, _ := ret[0].(error) - return ret0 -} - -// RescanSCSIHostByHCTL indicates an expected call of RescanSCSIHostByHCTL -func (mr *MockSCSIMockRecorder) RescanSCSIHostByHCTL(ctx, h interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RescanSCSIHostByHCTL", reflect.TypeOf((*MockSCSI)(nil).RescanSCSIHostByHCTL), ctx, h) -} - -// RescanSCSIDeviceByHCTL mocks base method -func (m *MockSCSI) RescanSCSIDeviceByHCTL(ctx context.Context, h scsi.HCTL) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RescanSCSIDeviceByHCTL", ctx, h) - ret0, _ := ret[0].(error) - return ret0 -} - -// RescanSCSIDeviceByHCTL indicates an expected call of RescanSCSIDeviceByHCTL -func (mr *MockSCSIMockRecorder) RescanSCSIDeviceByHCTL(ctx, h interface{}) *gomock.Call { +// CheckDeviceIsValid indicates an expected call of CheckDeviceIsValid. +func (mr *MockSCSIMockRecorder) CheckDeviceIsValid(ctx, device interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RescanSCSIDeviceByHCTL", reflect.TypeOf((*MockSCSI)(nil).RescanSCSIDeviceByHCTL), ctx, h) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDeviceIsValid", reflect.TypeOf((*MockSCSI)(nil).CheckDeviceIsValid), ctx, device) } -// DeleteSCSIDeviceByHCTL mocks base method +// DeleteSCSIDeviceByHCTL mocks base method. func (m *MockSCSI) DeleteSCSIDeviceByHCTL(ctx context.Context, h scsi.HCTL) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteSCSIDeviceByHCTL", ctx, h) @@ -84,13 +57,13 @@ func (m *MockSCSI) DeleteSCSIDeviceByHCTL(ctx context.Context, h scsi.HCTL) erro return ret0 } -// DeleteSCSIDeviceByHCTL indicates an expected call of DeleteSCSIDeviceByHCTL +// DeleteSCSIDeviceByHCTL indicates an expected call of DeleteSCSIDeviceByHCTL. func (mr *MockSCSIMockRecorder) DeleteSCSIDeviceByHCTL(ctx, h interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSCSIDeviceByHCTL", reflect.TypeOf((*MockSCSI)(nil).DeleteSCSIDeviceByHCTL), ctx, h) } -// DeleteSCSIDeviceByName mocks base method +// DeleteSCSIDeviceByName mocks base method. func (m *MockSCSI) DeleteSCSIDeviceByName(ctx context.Context, name string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteSCSIDeviceByName", ctx, name) @@ -98,13 +71,13 @@ func (m *MockSCSI) DeleteSCSIDeviceByName(ctx context.Context, name string) erro return ret0 } -// DeleteSCSIDeviceByName indicates an expected call of DeleteSCSIDeviceByName +// DeleteSCSIDeviceByName indicates an expected call of DeleteSCSIDeviceByName. func (mr *MockSCSIMockRecorder) DeleteSCSIDeviceByName(ctx, name interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSCSIDeviceByName", reflect.TypeOf((*MockSCSI)(nil).DeleteSCSIDeviceByName), ctx, name) } -// DeleteSCSIDeviceByPath mocks base method +// DeleteSCSIDeviceByPath mocks base method. func (m *MockSCSI) DeleteSCSIDeviceByPath(ctx context.Context, devPath string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "DeleteSCSIDeviceByPath", ctx, devPath) @@ -112,13 +85,58 @@ func (m *MockSCSI) DeleteSCSIDeviceByPath(ctx context.Context, devPath string) e return ret0 } -// DeleteSCSIDeviceByPath indicates an expected call of DeleteSCSIDeviceByPath +// DeleteSCSIDeviceByPath indicates an expected call of DeleteSCSIDeviceByPath. func (mr *MockSCSIMockRecorder) DeleteSCSIDeviceByPath(ctx, devPath interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSCSIDeviceByPath", reflect.TypeOf((*MockSCSI)(nil).DeleteSCSIDeviceByPath), ctx, devPath) } -// GetDeviceWWN mocks base method +// GetDMChildren mocks base method. +func (m *MockSCSI) GetDMChildren(ctx context.Context, dmPath string) ([]string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDMChildren", ctx, dmPath) + ret0, _ := ret[0].([]string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDMChildren indicates an expected call of GetDMChildren. +func (mr *MockSCSIMockRecorder) GetDMChildren(ctx, dmPath interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDMChildren", reflect.TypeOf((*MockSCSI)(nil).GetDMChildren), ctx, dmPath) +} + +// GetDMDeviceByChildren mocks base method. +func (m *MockSCSI) GetDMDeviceByChildren(ctx context.Context, devices []string) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDMDeviceByChildren", ctx, devices) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDMDeviceByChildren indicates an expected call of GetDMDeviceByChildren. +func (mr *MockSCSIMockRecorder) GetDMDeviceByChildren(ctx, devices interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDMDeviceByChildren", reflect.TypeOf((*MockSCSI)(nil).GetDMDeviceByChildren), ctx, devices) +} + +// GetDeviceNameByHCTL mocks base method. +func (m *MockSCSI) GetDeviceNameByHCTL(ctx context.Context, h scsi.HCTL) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetDeviceNameByHCTL", ctx, h) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetDeviceNameByHCTL indicates an expected call of GetDeviceNameByHCTL. +func (mr *MockSCSIMockRecorder) GetDeviceNameByHCTL(ctx, h interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeviceNameByHCTL", reflect.TypeOf((*MockSCSI)(nil).GetDeviceNameByHCTL), ctx, h) +} + +// GetDeviceWWN mocks base method. func (m *MockSCSI) GetDeviceWWN(ctx context.Context, devices []string) (string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDeviceWWN", ctx, devices) @@ -127,13 +145,13 @@ func (m *MockSCSI) GetDeviceWWN(ctx context.Context, devices []string) (string, return ret0, ret1 } -// GetDeviceWWN indicates an expected call of GetDeviceWWN +// GetDeviceWWN indicates an expected call of GetDeviceWWN. func (mr *MockSCSIMockRecorder) GetDeviceWWN(ctx, devices interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeviceWWN", reflect.TypeOf((*MockSCSI)(nil).GetDeviceWWN), ctx, devices) } -// GetDevicesByWWN mocks base method +// GetDevicesByWWN mocks base method. func (m *MockSCSI) GetDevicesByWWN(ctx context.Context, wwn string) ([]string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetDevicesByWWN", ctx, wwn) @@ -142,72 +160,70 @@ func (m *MockSCSI) GetDevicesByWWN(ctx context.Context, wwn string) ([]string, e return ret0, ret1 } -// GetDevicesByWWN indicates an expected call of GetDevicesByWWN +// GetDevicesByWWN indicates an expected call of GetDevicesByWWN. func (mr *MockSCSIMockRecorder) GetDevicesByWWN(ctx, wwn interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDevicesByWWN", reflect.TypeOf((*MockSCSI)(nil).GetDevicesByWWN), ctx, wwn) } -// GetDMDeviceByChildren mocks base method -func (m *MockSCSI) GetDMDeviceByChildren(ctx context.Context, devices []string) (string, error) { +// GetNVMEDeviceWWN mocks base method. +func (m *MockSCSI) GetNVMEDeviceWWN(ctx context.Context, devices []string) (string, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDMDeviceByChildren", ctx, devices) + ret := m.ctrl.Call(m, "GetNVMEDeviceWWN", ctx, devices) ret0, _ := ret[0].(string) ret1, _ := ret[1].(error) return ret0, ret1 } -// GetDMDeviceByChildren indicates an expected call of GetDMDeviceByChildren -func (mr *MockSCSIMockRecorder) GetDMDeviceByChildren(ctx, devices interface{}) *gomock.Call { +// GetNVMEDeviceWWN indicates an expected call of GetNVMEDeviceWWN. +func (mr *MockSCSIMockRecorder) GetNVMEDeviceWWN(ctx, devices interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDMDeviceByChildren", reflect.TypeOf((*MockSCSI)(nil).GetDMDeviceByChildren), ctx, devices) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNVMEDeviceWWN", reflect.TypeOf((*MockSCSI)(nil).GetNVMEDeviceWWN), ctx, devices) } -// GetDMChildren mocks base method -func (m *MockSCSI) GetDMChildren(ctx context.Context, dmPath string) ([]string, error) { +// IsDeviceExist mocks base method. +func (m *MockSCSI) IsDeviceExist(ctx context.Context, device string) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDMChildren", ctx, dmPath) - ret0, _ := ret[0].([]string) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret := m.ctrl.Call(m, "IsDeviceExist", ctx, device) + ret0, _ := ret[0].(bool) + return ret0 } -// GetDMChildren indicates an expected call of GetDMChildren -func (mr *MockSCSIMockRecorder) GetDMChildren(ctx, dmPath interface{}) *gomock.Call { +// IsDeviceExist indicates an expected call of IsDeviceExist. +func (mr *MockSCSIMockRecorder) IsDeviceExist(ctx, device interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDMChildren", reflect.TypeOf((*MockSCSI)(nil).GetDMChildren), ctx, dmPath) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDeviceExist", reflect.TypeOf((*MockSCSI)(nil).IsDeviceExist), ctx, device) } -// CheckDeviceIsValid mocks base method -func (m *MockSCSI) CheckDeviceIsValid(ctx context.Context, device string) bool { +// RescanSCSIDeviceByHCTL mocks base method. +func (m *MockSCSI) RescanSCSIDeviceByHCTL(ctx context.Context, h scsi.HCTL) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CheckDeviceIsValid", ctx, device) - ret0, _ := ret[0].(bool) + ret := m.ctrl.Call(m, "RescanSCSIDeviceByHCTL", ctx, h) + ret0, _ := ret[0].(error) return ret0 } -// CheckDeviceIsValid indicates an expected call of CheckDeviceIsValid -func (mr *MockSCSIMockRecorder) CheckDeviceIsValid(ctx, device interface{}) *gomock.Call { +// RescanSCSIDeviceByHCTL indicates an expected call of RescanSCSIDeviceByHCTL. +func (mr *MockSCSIMockRecorder) RescanSCSIDeviceByHCTL(ctx, h interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CheckDeviceIsValid", reflect.TypeOf((*MockSCSI)(nil).CheckDeviceIsValid), ctx, device) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RescanSCSIDeviceByHCTL", reflect.TypeOf((*MockSCSI)(nil).RescanSCSIDeviceByHCTL), ctx, h) } -// GetDeviceNameByHCTL mocks base method -func (m *MockSCSI) GetDeviceNameByHCTL(ctx context.Context, h scsi.HCTL) (string, error) { +// RescanSCSIHostByHCTL mocks base method. +func (m *MockSCSI) RescanSCSIHostByHCTL(ctx context.Context, h scsi.HCTL) error { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetDeviceNameByHCTL", ctx, h) - ret0, _ := ret[0].(string) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret := m.ctrl.Call(m, "RescanSCSIHostByHCTL", ctx, h) + ret0, _ := ret[0].(error) + return ret0 } -// GetDeviceNameByHCTL indicates an expected call of GetDeviceNameByHCTL -func (mr *MockSCSIMockRecorder) GetDeviceNameByHCTL(ctx, h interface{}) *gomock.Call { +// RescanSCSIHostByHCTL indicates an expected call of RescanSCSIHostByHCTL. +func (mr *MockSCSIMockRecorder) RescanSCSIHostByHCTL(ctx, h interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetDeviceNameByHCTL", reflect.TypeOf((*MockSCSI)(nil).GetDeviceNameByHCTL), ctx, h) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RescanSCSIHostByHCTL", reflect.TypeOf((*MockSCSI)(nil).RescanSCSIHostByHCTL), ctx, h) } -// WaitUdevSymlink mocks base method +// WaitUdevSymlink mocks base method. func (m *MockSCSI) WaitUdevSymlink(ctx context.Context, deviceName, wwn string) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "WaitUdevSymlink", ctx, deviceName, wwn) @@ -215,8 +231,22 @@ func (m *MockSCSI) WaitUdevSymlink(ctx context.Context, deviceName, wwn string) return ret0 } -// WaitUdevSymlink indicates an expected call of WaitUdevSymlink +// WaitUdevSymlink indicates an expected call of WaitUdevSymlink. func (mr *MockSCSIMockRecorder) WaitUdevSymlink(ctx, deviceName, wwn interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitUdevSymlink", reflect.TypeOf((*MockSCSI)(nil).WaitUdevSymlink), ctx, deviceName, wwn) } + +// WaitUdevSymlinkNVMe mocks base method. +func (m *MockSCSI) WaitUdevSymlinkNVMe(ctx context.Context, deviceName, wwn string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WaitUdevSymlinkNVMe", ctx, deviceName, wwn) + ret0, _ := ret[0].(error) + return ret0 +} + +// WaitUdevSymlinkNVMe indicates an expected call of WaitUdevSymlinkNVMe. +func (mr *MockSCSIMockRecorder) WaitUdevSymlinkNVMe(ctx, deviceName, wwn interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitUdevSymlinkNVMe", reflect.TypeOf((*MockSCSI)(nil).WaitUdevSymlinkNVMe), ctx, deviceName, wwn) +} diff --git a/internal/wrappers/wrappers.go b/internal/wrappers/wrappers.go index 2095ec0..8d74985 100644 --- a/internal/wrappers/wrappers.go +++ b/internal/wrappers/wrappers.go @@ -69,8 +69,8 @@ type NVMeTCP interface { 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) + ListNamespaceDevices() map[gonvme.DevicePathAndNamespace][]string + GetNamespaceData(path string, namespaceID string) (string, string, error) } // wrappers diff --git a/nvme_tcp.go b/nvme_tcp.go index 2cba4d7..b30da41 100644 --- a/nvme_tcp.go +++ b/nvme_tcp.go @@ -254,12 +254,17 @@ func (c *NVMeTCPConnector) cleanConnection(ctx context.Context, force bool, info var devices []string wwn := info.WWN - namespaceDevices := c.nvmeTCPLib.ListNamespaceDevices() + DevicePathsAndNamespaces := c.nvmeTCPLib.ListNamespaceDevices() + var devicePath string + var namespace string - for devicePath := range namespaceDevices { - for _, namespace := range namespaceDevices[devicePath] { - nguid, _ := c.nvmeTCPLib.GetNamespaceData(devicePath, namespace) - if c.wwnMatches(nguid, wwn) { + for DevicePathAndNamespace := range DevicePathsAndNamespaces { + devicePath = DevicePathAndNamespace.DevicePath + namespace = DevicePathAndNamespace.Namespace + for _, namespaceID := range DevicePathsAndNamespaces[DevicePathAndNamespace] { + nguid, newnamespace, _ := c.nvmeTCPLib.GetNamespaceData(devicePath, namespaceID) + + if c.wwnMatches(nguid, wwn) && namespace == newnamespace { devices = append(devices, devicePath) } } @@ -456,14 +461,23 @@ func (c *NVMeTCPConnector) discoverDevice(ctx context.Context, wg *sync.WaitGrou defer wg.Done() wwn := info.WWN - namespaceDevices := c.nvmeTCPLib.ListNamespaceDevices() + DevicePathsAndNamespaces := c.nvmeTCPLib.ListNamespaceDevices() var devicePaths []string + var devicePath string + var namespace string + nguidResult := "" - for devicePath := range namespaceDevices { - for _, namespace := range namespaceDevices[devicePath] { - nguid, _ := c.nvmeTCPLib.GetNamespaceData(devicePath, namespace) - if c.wwnMatches(nguid, wwn) { + + for DevicePathAndNamespace := range DevicePathsAndNamespaces { + + devicePath = DevicePathAndNamespace.DevicePath + namespace = DevicePathAndNamespace.Namespace + + for _, namespaceID := range DevicePathsAndNamespaces[DevicePathAndNamespace] { + nguid, newnamespace, _ := c.nvmeTCPLib.GetNamespaceData(devicePath, namespaceID) + + if c.wwnMatches(nguid, wwn) && namespace == newnamespace { devicePaths = append(devicePaths, devicePath) nguidResult = nguid }