gonvme

package module
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 17 Imported by: 4

README ¶

🔒 Important Notice

Starting with the release of Container Storage Modules v1.16.0, this repository will no longer be maintained as an open source project. Future development will continue under a closed source model. This change reflects our commitment to delivering even greater value to our customers by enabling faster innovation and more deeply integrated features with the Dell storage portfolio.
For existing customers using Dell’s Container Storage Modules, you will continue to receive:

  • Ongoing Support & Community Engagement
    You will continue to receive high-quality support through Dell Support and our community channels. Your experience of engaging with the Dell community remains unchanged.
  • Streamlined Deployment & Updates
    Deployment and update processes will remain consistent, ensuring a smooth and familiar experience.
  • Access to Documentation & Resources
    All documentation and related materials will remain publicly accessible, providing transparency and technical guidance.
  • Continued Access to Current Open Source Version
    The current open-source version will remain available under its existing license for those who rely on it.

Moving to a closed source model allows Dell’s development team to accelerate feature delivery and enhance integration across our Enterprise Kubernetes Storage solutions ultimately providing a more seamless and robust experience.
We deeply appreciate the contributions of the open source community and remain committed to supporting our customers through this transition.

For questions or access requests, please contact the maintainers via Dell Support.

gonvme

A portable go module for nvme operations

Features

The following features are supported:

  • Discover nvme targets provided by a specific portal, optionally log into each target
  • Discover the nvme connectors defined on the local system
  • Log into a specific portal/target
  • Log out of a specific portal/target

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	// MockNumberOfInitiators controls the number of initiators found in mock mode
	MockNumberOfInitiators = "numberOfInitiators"
	// MockNumberOfTCPTargets controls the number of NVMeTCP targets found in mock mode
	MockNumberOfTCPTargets = "numberOfTCPTargets"
	// MockNumberOfFCTargets controls the number of NVMeFC targets found in mock mode
	MockNumberOfFCTargets = "numberOfFCTargets"
	// MockNumberOfSessions controls the number of  NVMe sessions found in mock mode
	MockNumberOfSessions = "numberOfSession"
	// MockNumberOfNamespaceDevices controls the number of  NVMe Namespace Devices found in mock mode
	MockNumberOfNamespaceDevices = "numberOfNamespaceDevices"
)
View Source
const (
	// ChrootDirectory allows the nvme commands to be run within a chrooted path, helpful for containerized services
	ChrootDirectory = "chrootDirectory"

	// NVMePort - port number
	NVMePort = "4420"

	// NVMeNoObjsFoundExitCode exit code indicates that no records/targets/sessions/portals
	// found to execute operation on
	NVMeNoObjsFoundExitCode = 21
)
View Source
const (
	// NVMeTransportTypeTCP - Placeholder for NVMe Transport type TCP
	NVMeTransportTypeTCP = "tcp"

	// NVMeTransportTypeFC - Placeholder for NVMe Transport type FC
	NVMeTransportTypeFC = "fc"

	// NVMESessionStateLive indicates the NVMe connection state as live
	NVMESessionStateLive NVMESessionState = "live"
	// NVMESessionStateDeleting indicates the NVMe connection state as deleting
	NVMESessionStateDeleting NVMESessionState = "deleting"
	// NVMESessionStateConnecting indicates the NVMe connection state as connecting
	NVMESessionStateConnecting NVMESessionState = "connecting"

	// NVMETransportNameTCP indicates the NVMe protocol as tcp
	NVMETransportNameTCP NVMETransportName = "tcp"
	// NVMETransportNameFC indicates the NVMe protocol as fc
	NVMETransportNameFC NVMETransportName = "fc"
	// NVMETransportNameRDMA indicates the NVMe protocol as rdma
	NVMETransportNameRDMA NVMETransportName = "rdma"
)

Variables ¶

View Source
var (

	// DefaultInitiatorNameFile is the default file which contains the initiator nqn
	DefaultInitiatorNameFile = "/etc/nvme/hostnqn"
)
View Source
var GONVMEMock struct {
	InduceDiscoveryError               bool
	InduceInitiatorError               bool
	InduceTCPLoginError                bool
	InduceFCLoginError                 bool
	InduceLogoutError                  bool
	InduceGetSessionsError             bool
	InducedNVMeDeviceAndNamespaceError bool
	InducedNVMeNamespaceIDError        bool
	InducedNVMeDeviceDataError         bool
}

GONVMEMock is a struct controlling induced errors

Functions ¶

func SetLogger ¶

func SetLogger(customLogger Logger)

SetLogger set custom logger for gonvme

func SetTracer ¶

func SetTracer(customTracer Tracer)

SetTracer set custom tracer for gonvme

Types ¶

type DevicePathAndNamespace ¶

type DevicePathAndNamespace struct {
	DevicePath string
	Namespace  string
}

DevicePathAndNamespace defines the device path and namespace of a device

type FCHBAInfo ¶ added in v1.1.0

type FCHBAInfo struct {
	PortName string
	NodeName string
}

FCHBAInfo holds information about host NVMe/FC ports

type Logger ¶

type Logger = logger.Logger

Logger - Placeholder for logger

type MockNVMe ¶ added in v1.1.0

type MockNVMe struct {
	NVMeType
}

MockNVMe provides a mock implementation of an NVMe client

func NewMockNVMe ¶ added in v1.1.0

func NewMockNVMe(opts map[string]string) *MockNVMe

NewMockNVMe - returns a mock NVMe client

func (*MockNVMe) DeviceRescan ¶ added in v1.9.0

func (nvme *MockNVMe) DeviceRescan(device string) error

DeviceRescan rescan the NVMe device

func (*MockNVMe) DiscoverNVMeFCTargets ¶ added in v1.1.0

func (nvme *MockNVMe) DiscoverNVMeFCTargets(address string, login bool) ([]NVMeTarget, error)

DiscoverNVMeFCTargets runs an NVMe discovery and returns a list of targets.

func (*MockNVMe) DiscoverNVMeTCPTargets ¶ added in v1.1.0

func (nvme *MockNVMe) DiscoverNVMeTCPTargets(address string, login bool) ([]NVMeTarget, error)

DiscoverNVMeTCPTargets runs an NVMe discovery and returns a list of targets.

func (*MockNVMe) GetInitiators ¶ added in v1.1.0

func (nvme *MockNVMe) GetInitiators(filename string) ([]string, error)

GetInitiators returns a list of NVMe initiators on the local system.

func (*MockNVMe) GetNVMeDeviceData ¶ added in v1.2.0

func (nvme *MockNVMe) GetNVMeDeviceData(_ string) (string, string, error)

GetNVMeDeviceData returns the information (nguid and namespace) of an NVME device path

func (*MockNVMe) GetSessions ¶ added in v1.1.0

func (nvme *MockNVMe) GetSessions() ([]NVMESession, error)

GetSessions Queries NVMe session info

func (*MockNVMe) ListNVMeDeviceAndNamespace ¶ added in v1.2.0

func (nvme *MockNVMe) ListNVMeDeviceAndNamespace() ([]DevicePathAndNamespace, error)

ListNVMeDeviceAndNamespace returns the Device Paths and Namespace of each NVMe device and each output content

func (*MockNVMe) ListNVMeNamespaceID ¶ added in v1.2.0

func (nvme *MockNVMe) ListNVMeNamespaceID(_ []DevicePathAndNamespace) (map[DevicePathAndNamespace][]string, error)

ListNVMeNamespaceID returns the namespace IDs for each NVME device path

func (*MockNVMe) NVMeDisconnect ¶ added in v1.1.0

func (nvme *MockNVMe) NVMeDisconnect(target NVMeTarget) error

NVMeDisconnect will attempt to log out of an NVMe target

func (*MockNVMe) NVMeFCConnect ¶ added in v1.1.0

func (nvme *MockNVMe) NVMeFCConnect(target NVMeTarget, duplicateConnect bool) error

NVMeFCConnect will attempt to log into an NVMe target

func (*MockNVMe) NVMeTCPConnect ¶ added in v1.1.0

func (nvme *MockNVMe) NVMeTCPConnect(target NVMeTarget, duplicateConnect bool) error

NVMeTCPConnect will attempt to log into an NVMe target

type NVMESession ¶

type NVMESession struct {
	Target            string
	Portal            string
	Name              string
	NVMESessionState  NVMESessionState
	NVMETransportName NVMETransportName
}

NVMESession defines an iSCSI session info

type NVMESessionState ¶

type NVMESessionState string

NVMESessionState defines the NVMe connection state

type NVMETransportName ¶

type NVMETransportName string

NVMETransportName defines the NMVe protocol

type NVMEinterface ¶

type NVMEinterface interface {
	// DiscoverNVMeTCPTargets discovers the targets exposed via a given portal
	// returns an array of NVMeTCP Target instances
	DiscoverNVMeTCPTargets(address string, login bool) ([]NVMeTarget, error)

	// DiscoverNVMeFCTargets discovers the targets exposed via a given portal
	// returns an array of NVMeFC Target instances
	DiscoverNVMeFCTargets(address string, login bool) ([]NVMeTarget, error)

	// GetInitiators get a list of NVMe initiators defined in a specified file
	// To use the system default file of "/etc/nvme/hostnqn", provide a filename of ""
	GetInitiators(filename string) ([]string, error)

	// NVMeTCPConnect connects into a specified NVMeTCP target
	NVMeTCPConnect(target NVMeTarget, duplicateConnect bool) error

	// NVMeFCConnect connects into a specified NVMeFC target
	NVMeFCConnect(target NVMeTarget, duplicateConnect bool) error

	// NVMeDisconnect disconnect from the specified NVMe target
	NVMeDisconnect(target NVMeTarget) error

	// ListNVMeDeviceAndNamespace returns the NVME Device Paths and Namespace of each of the NVME device
	ListNVMeDeviceAndNamespace() ([]DevicePathAndNamespace, error)

	// ListNVMeNamespaceID returns the namespace IDs for each NVME device path
	ListNVMeNamespaceID(NVMeDeviceNamespace []DevicePathAndNamespace) (map[DevicePathAndNamespace][]string, error)

	// GetNVMeDeviceData returns the information (nguid and namespace) of an NVME device path
	GetNVMeDeviceData(path string) (string, string, error)

	// GetSessions queries information about NVMe sessions
	GetSessions() ([]NVMESession, error)

	// DeviceRescan rescan the NVMe controller device
	DeviceRescan(device string) error
	// contains filtered or unexported methods
}

NVMEinterface is the interface that provides the NVMe client functionality

type NVMe ¶ added in v1.1.0

type NVMe struct {
	NVMeType

	NVMeCommand string
	// contains filtered or unexported fields
}

NVMe provides many nvme-specific functions

func NewNVMe ¶ added in v1.1.0

func NewNVMe(opts map[string]string) *NVMe

NewNVMe - returns a new NVMe client

func (*NVMe) DeviceRescan ¶ added in v1.9.0

func (nvme *NVMe) DeviceRescan(device string) error

DeviceRescan rescan the NVMe controller device

func (*NVMe) DiscoverNVMeFCTargets ¶ added in v1.1.0

func (nvme *NVMe) DiscoverNVMeFCTargets(targetAddress string, login bool) ([]NVMeTarget, error)

DiscoverNVMeFCTargets - runs nvme discovery and returns a list of NVMeFC targets.

func (*NVMe) DiscoverNVMeTCPTargets ¶ added in v1.1.0

func (nvme *NVMe) DiscoverNVMeTCPTargets(address string, login bool) ([]NVMeTarget, error)

DiscoverNVMeTCPTargets - runs nvme discovery and returns a list of NVMeTCP targets.

func (*NVMe) GetInitiators ¶ added in v1.1.0

func (nvme *NVMe) GetInitiators(filename string) ([]string, error)

GetInitiators returns a list of initiators on the local system.

func (*NVMe) GetNVMeDeviceData ¶ added in v1.2.0

func (nvme *NVMe) GetNVMeDeviceData(path string) (string, string, error)

GetNVMeDeviceData returns the information (nguid and namespace) of an NVME device path

func (*NVMe) GetSessions ¶ added in v1.1.0

func (nvme *NVMe) GetSessions() ([]NVMESession, error)

GetSessions queries information about NVMe sessions

func (*NVMe) ListNVMeDeviceAndNamespace ¶ added in v1.2.0

func (nvme *NVMe) ListNVMeDeviceAndNamespace() ([]DevicePathAndNamespace, error)

ListNVMeDeviceAndNamespace returns the NVMe device paths and namespace of each of the NVMe device.

func (*NVMe) ListNVMeNamespaceID ¶ added in v1.2.0

func (nvme *NVMe) ListNVMeNamespaceID(NVMeDeviceAndNamespace []DevicePathAndNamespace) (map[DevicePathAndNamespace][]string, error)

ListNVMeNamespaceID returns the namespace IDs for each NVME device path

func (*NVMe) NVMeDisconnect ¶ added in v1.1.0

func (nvme *NVMe) NVMeDisconnect(target NVMeTarget) error

NVMeDisconnect will attempt to disconnect from a given nvme target

func (*NVMe) NVMeFCConnect ¶ added in v1.1.0

func (nvme *NVMe) NVMeFCConnect(target NVMeTarget, duplicateConnect bool) error

NVMeFCConnect will attempt to connect into a given NVMeFC target

func (*NVMe) NVMeTCPConnect ¶ added in v1.1.0

func (nvme *NVMe) NVMeTCPConnect(target NVMeTarget, duplicateConnect bool) error

NVMeTCPConnect will attempt to connect into a given NVMeTCP target

type NVMeSessionParser ¶

type NVMeSessionParser interface {
	Parse([]byte) []NVMESession
}

NVMeSessionParser defines an NVMe session parser

type NVMeTarget ¶

type NVMeTarget struct {
	Portal     string // traddr
	TargetNqn  string // subnqn
	TrType     string // trtype
	AdrFam     string // adrfam
	SubType    string // subtype
	Treq       string // treq
	PortID     string // portid
	TrsvcID    string // trsvcid
	SecType    string // sectype
	TargetType string // trtype
	HostAdr    string // host_traddr
}

NVMeTarget defines an NVMe target

type NVMeType ¶

type NVMeType struct {
	// contains filtered or unexported fields
}

NVMeType is the base structure for each platform implementation

type SubSysResponse ¶ added in v1.8.0

type SubSysResponse struct {
	HostNQN    string       `json:"HostNQN"`
	HostID     string       `json:"HostID"`
	Subsystems []subsystems `json:"Subsystems"`
}

SubSysResponse of subsystems.

type Tracer ¶

type Tracer = tracer.Tracer

Tracer - Placeholder for tracer

Directories ¶

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL