driver

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Package driver is a generated GoMock package.

Index

Constants

View Source
const (
	DefaultCSIEndpoint = "unix://tmp/csi.sock"

	// Parameters for StorageClass.
	VolumeTypeKey = "type"
)

constants for default command line flag values

View Source
const (
	// DriverName is name for this CSI
	DriverName = "disk.csi.hatoba.nifcloud.com"
	// TopologyKey is key
	TopologyKey = "topology." + DriverName + "/zone"
)
View Source
const (
	// FSTypeExt2 represents the ext2 filesystem type
	FSTypeExt2 = "ext2"
	// FSTypeExt3 represents the ext3 filesystem type
	FSTypeExt3 = "ext3"
	// FSTypeExt4 represents the ext4 filesystem type
	FSTypeExt4 = "ext4"
	// FSTypeXfs represents te xfs filesystem type
	FSTypeXfs = "xfs"
)
View Source
const (
	VolumeOperationAlreadyExistsFmt = "An operation with the given Volume ID %s already exists"
)

Variables

View Source
var (
	// ValidFSTypes is valid filesystem type.
	ValidFSTypes = map[string]struct{}{
		FSTypeExt2: {},
		FSTypeExt3: {},
		FSTypeExt4: {},
		FSTypeXfs:  {},
	}
)

Functions

func GetVersionJSON

func GetVersionJSON() (string, error)

GetVersionJSON returns the version info json

func WithEndpoint

func WithEndpoint(endpoint string) func(*Options)

WithEndpoint sets the endpoint

func WithMode

func WithMode(mode Mode) func(*Options)

WithMode sets the driver mode

Types

type Driver

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

Driver is CSI driver object

func NewDriver

func NewDriver(options ...func(*Options)) (*Driver, error)

NewDriver creates the new CSI driver

func (*Driver) ControllerExpandVolume

func (d *Driver) ControllerExpandVolume(ctx context.Context, req *csi.ControllerExpandVolumeRequest) (*csi.ControllerExpandVolumeResponse, error)

func (*Driver) ControllerGetCapabilities

func (d *Driver) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error)

func (*Driver) ControllerGetVolume

func (d *Driver) ControllerGetVolume(ctx context.Context, req *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error)

func (*Driver) ControllerPublishVolume

func (d *Driver) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error)

func (*Driver) ControllerUnpublishVolume

func (d *Driver) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error)

func (*Driver) CreateSnapshot

func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error)

func (*Driver) CreateVolume

func (d *Driver) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error)

func (*Driver) DeleteSnapshot

func (d *Driver) DeleteSnapshot(ctx context.Context, req *csi.DeleteSnapshotRequest) (*csi.DeleteSnapshotResponse, error)

func (*Driver) DeleteVolume

func (d *Driver) DeleteVolume(ctx context.Context, req *csi.DeleteVolumeRequest) (*csi.DeleteVolumeResponse, error)

func (*Driver) GetCapacity

func (d *Driver) GetCapacity(ctx context.Context, req *csi.GetCapacityRequest) (*csi.GetCapacityResponse, error)

func (*Driver) GetPluginInfo

func (d *Driver) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error)

func (*Driver) ListSnapshots

func (d *Driver) ListSnapshots(ctx context.Context, req *csi.ListSnapshotsRequest) (*csi.ListSnapshotsResponse, error)

func (*Driver) ListVolumes

func (d *Driver) ListVolumes(ctx context.Context, req *csi.ListVolumesRequest) (*csi.ListVolumesResponse, error)

func (*Driver) NodeExpandVolume

func (n *Driver) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandVolumeRequest) (*csi.NodeExpandVolumeResponse, error)

func (*Driver) NodeGetCapabilities

func (n *Driver) NodeGetCapabilities(ctx context.Context, req *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error)

func (*Driver) NodeGetInfo

func (n *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error)

func (*Driver) NodeGetVolumeStats

func (n *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeStatsRequest) (*csi.NodeGetVolumeStatsResponse, error)

func (*Driver) NodePublishVolume

func (n *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error)

func (*Driver) NodeStageVolume

func (n *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRequest) (*csi.NodeStageVolumeResponse, error)

func (*Driver) NodeUnpublishVolume

func (n *Driver) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error)

func (*Driver) NodeUnstageVolume

func (n *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolumeRequest) (*csi.NodeUnstageVolumeResponse, error)

func (*Driver) Probe

func (d *Driver) Probe(ctx context.Context, req *csi.ProbeRequest) (*csi.ProbeResponse, error)

func (*Driver) Run

func (d *Driver) Run() error

Run runs the gRPC server

func (*Driver) Stop

func (d *Driver) Stop()

Stop stops the server

func (*Driver) ValidateVolumeCapabilities

func (d *Driver) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error)

type MockMounter

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

MockMounter is a mock of Mounter interface.

func NewMockMounter

func NewMockMounter(ctrl *gomock.Controller) *MockMounter

NewMockMounter creates a new mock instance.

func (*MockMounter) EXPECT

func (m *MockMounter) EXPECT() *MockMounterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockMounter) ExistsPath

func (m *MockMounter) ExistsPath(filename string) (bool, error)

ExistsPath mocks base method.

func (*MockMounter) FindDevicePath

func (m *MockMounter) FindDevicePath(scsiID string) (string, error)

FindDevicePath mocks base method.

func (*MockMounter) FormatAndMount

func (m *MockMounter) FormatAndMount(source, target, fstype string, options []string) error

FormatAndMount mocks base method.

func (*MockMounter) GetDeviceName

func (m *MockMounter) GetDeviceName(mountPath string) (string, int, error)

GetDeviceName mocks base method.

func (*MockMounter) GetMountRefs

func (m *MockMounter) GetMountRefs(pathname string) ([]string, error)

GetMountRefs mocks base method.

func (*MockMounter) IsCorruptedMnt

func (m *MockMounter) IsCorruptedMnt(err error) bool

IsCorruptedMnt mocks base method.

func (*MockMounter) IsLikelyNotMountPoint

func (m *MockMounter) IsLikelyNotMountPoint(file string) (bool, error)

IsLikelyNotMountPoint mocks base method.

func (*MockMounter) List

func (m *MockMounter) List() ([]mount_utils.MountPoint, error)

List mocks base method.

func (*MockMounter) MakeDir

func (m *MockMounter) MakeDir(pathname string) error

MakeDir mocks base method.

func (*MockMounter) MakeFile

func (m *MockMounter) MakeFile(pathname string) error

MakeFile mocks base method.

func (*MockMounter) Mount

func (m *MockMounter) Mount(source, target, fstype string, options []string) error

Mount mocks base method.

func (*MockMounter) MountSensitive

func (m *MockMounter) MountSensitive(source, target, fstype string, options, sensitiveOptions []string) error

MountSensitive mocks base method.

func (*MockMounter) MountSensitiveWithoutSystemd

func (m *MockMounter) MountSensitiveWithoutSystemd(source, target, fstype string, options, sensitiveOptions []string) error

MountSensitiveWithoutSystemd mocks base method.

func (*MockMounter) MountSensitiveWithoutSystemdWithMountFlags

func (m *MockMounter) MountSensitiveWithoutSystemdWithMountFlags(source, target, fstype string, options, sensitiveOptions, mountFlags []string) error

MountSensitiveWithoutSystemdWithMountFlags mocks base method.

func (*MockMounter) NeedResize

func (m *MockMounter) NeedResize(devicePath, deviceMountPath string) (bool, error)

NeedResize mocks base method.

func (*MockMounter) NewResizeFs

func (m *MockMounter) NewResizeFs() (Resizefs, error)

NewResizeFs mocks base method.

func (*MockMounter) RemoveStorageDevice

func (m *MockMounter) RemoveStorageDevice(dev string) error

RemoveStorageDevice mocks base method.

func (*MockMounter) RescanStorageDevice

func (m *MockMounter) RescanStorageDevice(dev string) error

RescanStorageDevice mocks base method.

func (*MockMounter) ScanStorageDevices

func (m *MockMounter) ScanStorageDevices() error

ScanStorageDevices mocks base method.

func (*MockMounter) Unmount

func (m *MockMounter) Unmount(target string) error

Unmount mocks base method.

type MockMounterMockRecorder

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

MockMounterMockRecorder is the mock recorder for MockMounter.

func (*MockMounterMockRecorder) ExistsPath

func (mr *MockMounterMockRecorder) ExistsPath(filename interface{}) *gomock.Call

ExistsPath indicates an expected call of ExistsPath.

func (*MockMounterMockRecorder) FindDevicePath

func (mr *MockMounterMockRecorder) FindDevicePath(scsiID interface{}) *gomock.Call

FindDevicePath indicates an expected call of FindDevicePath.

func (*MockMounterMockRecorder) FormatAndMount

func (mr *MockMounterMockRecorder) FormatAndMount(source, target, fstype, options interface{}) *gomock.Call

FormatAndMount indicates an expected call of FormatAndMount.

func (*MockMounterMockRecorder) GetDeviceName

func (mr *MockMounterMockRecorder) GetDeviceName(mountPath interface{}) *gomock.Call

GetDeviceName indicates an expected call of GetDeviceName.

func (*MockMounterMockRecorder) GetMountRefs

func (mr *MockMounterMockRecorder) GetMountRefs(pathname interface{}) *gomock.Call

GetMountRefs indicates an expected call of GetMountRefs.

func (*MockMounterMockRecorder) IsCorruptedMnt

func (mr *MockMounterMockRecorder) IsCorruptedMnt(err interface{}) *gomock.Call

IsCorruptedMnt indicates an expected call of IsCorruptedMnt.

func (*MockMounterMockRecorder) IsLikelyNotMountPoint

func (mr *MockMounterMockRecorder) IsLikelyNotMountPoint(file interface{}) *gomock.Call

IsLikelyNotMountPoint indicates an expected call of IsLikelyNotMountPoint.

func (*MockMounterMockRecorder) List

func (mr *MockMounterMockRecorder) List() *gomock.Call

List indicates an expected call of List.

func (*MockMounterMockRecorder) MakeDir

func (mr *MockMounterMockRecorder) MakeDir(pathname interface{}) *gomock.Call

MakeDir indicates an expected call of MakeDir.

func (*MockMounterMockRecorder) MakeFile

func (mr *MockMounterMockRecorder) MakeFile(pathname interface{}) *gomock.Call

MakeFile indicates an expected call of MakeFile.

func (*MockMounterMockRecorder) Mount

func (mr *MockMounterMockRecorder) Mount(source, target, fstype, options interface{}) *gomock.Call

Mount indicates an expected call of Mount.

func (*MockMounterMockRecorder) MountSensitive

func (mr *MockMounterMockRecorder) MountSensitive(source, target, fstype, options, sensitiveOptions interface{}) *gomock.Call

MountSensitive indicates an expected call of MountSensitive.

func (*MockMounterMockRecorder) MountSensitiveWithoutSystemd

func (mr *MockMounterMockRecorder) MountSensitiveWithoutSystemd(source, target, fstype, options, sensitiveOptions interface{}) *gomock.Call

MountSensitiveWithoutSystemd indicates an expected call of MountSensitiveWithoutSystemd.

func (*MockMounterMockRecorder) MountSensitiveWithoutSystemdWithMountFlags

func (mr *MockMounterMockRecorder) MountSensitiveWithoutSystemdWithMountFlags(source, target, fstype, options, sensitiveOptions, mountFlags interface{}) *gomock.Call

MountSensitiveWithoutSystemdWithMountFlags indicates an expected call of MountSensitiveWithoutSystemdWithMountFlags.

func (*MockMounterMockRecorder) NeedResize

func (mr *MockMounterMockRecorder) NeedResize(devicePath, deviceMountPath interface{}) *gomock.Call

NeedResize indicates an expected call of NeedResize.

func (*MockMounterMockRecorder) NewResizeFs

func (mr *MockMounterMockRecorder) NewResizeFs() *gomock.Call

NewResizeFs indicates an expected call of NewResizeFs.

func (*MockMounterMockRecorder) RemoveStorageDevice

func (mr *MockMounterMockRecorder) RemoveStorageDevice(dev interface{}) *gomock.Call

RemoveStorageDevice indicates an expected call of RemoveStorageDevice.

func (*MockMounterMockRecorder) RescanStorageDevice

func (mr *MockMounterMockRecorder) RescanStorageDevice(dev interface{}) *gomock.Call

RescanStorageDevice indicates an expected call of RescanStorageDevice.

func (*MockMounterMockRecorder) ScanStorageDevices

func (mr *MockMounterMockRecorder) ScanStorageDevices() *gomock.Call

ScanStorageDevices indicates an expected call of ScanStorageDevices.

func (*MockMounterMockRecorder) Unmount

func (mr *MockMounterMockRecorder) Unmount(target interface{}) *gomock.Call

Unmount indicates an expected call of Unmount.

type MockResizefs

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

MockResizefs is a mock of Resizefs interface.

func NewMockResizefs

func NewMockResizefs(ctrl *gomock.Controller) *MockResizefs

NewMockResizefs creates a new mock instance.

func (*MockResizefs) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockResizefs) Resize

func (m *MockResizefs) Resize(devicePath, deviceMountPath string) (bool, error)

Resize mocks base method.

type MockResizefsMockRecorder

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

MockResizefsMockRecorder is the mock recorder for MockResizefs.

func (*MockResizefsMockRecorder) Resize

func (mr *MockResizefsMockRecorder) Resize(devicePath, deviceMountPath interface{}) *gomock.Call

Resize indicates an expected call of Resize.

type Mode

type Mode string

Mode is the operating mode of the CSI driver.

const (
	// ControllerMode is the mode that only starts the controller service.
	ControllerMode Mode = "controller"
	// NodeMode is the mode that only starts the node service.
	NodeMode Mode = "node"
	// AllMode is the mode that only starts both the controller and the node service.
	AllMode Mode = "all"
)

type Mounter

type Mounter interface {
	mountutils.Interface

	FormatAndMount(source string, target string, fstype string, options []string) error
	GetDeviceName(mountPath string) (string, int, error)
	MakeFile(pathname string) error
	MakeDir(pathname string) error
	ExistsPath(filename string) (bool, error)
	IsCorruptedMnt(err error) bool
	NeedResize(devicePath string, deviceMountPath string) (bool, error)
	NewResizeFs() (Resizefs, error)
	FindDevicePath(scsiID string) (string, error)
	ScanStorageDevices() error
	RemoveStorageDevice(dev string) error
	RescanStorageDevice(dev string) error
}

Mounter is an interface for mount operations

type NodeMounter

type NodeMounter struct {
	mountutils.SafeFormatAndMount
}

NodeMounter mount the devices.

func (*NodeMounter) ExistsPath

func (m *NodeMounter) ExistsPath(filename string) (bool, error)

func (*NodeMounter) FindDevicePath

func (m *NodeMounter) FindDevicePath(scsiID string) (string, error)

func (*NodeMounter) GetDeviceName

func (m *NodeMounter) GetDeviceName(mountPath string) (string, int, error)

GetDeviceName returns the device name from path

func (*NodeMounter) IsCorruptedMnt

func (m *NodeMounter) IsCorruptedMnt(err error) bool

func (*NodeMounter) MakeDir

func (m *NodeMounter) MakeDir(pathname string) error

func (*NodeMounter) MakeFile

func (m *NodeMounter) MakeFile(pathname string) error

func (*NodeMounter) NeedResize

func (m *NodeMounter) NeedResize(devicePath string, deviceMountPath string) (bool, error)

func (*NodeMounter) NewResizeFs

func (m *NodeMounter) NewResizeFs() (Resizefs, error)

func (*NodeMounter) RemoveStorageDevice

func (m *NodeMounter) RemoveStorageDevice(dev string) error

RemoveStorageDevice online detach the specified storage More info: https://pfs.nifcloud.com/guide/cp/login/detach_linux.htm

func (*NodeMounter) RescanStorageDevice

func (m *NodeMounter) RescanStorageDevice(dev string) error

RescanStorageDevice online rescan the specified storage More info: https://pfs.nifcloud.com/guide/cp/login/extend_partition_linux.htm

func (*NodeMounter) ScanStorageDevices

func (m *NodeMounter) ScanStorageDevices() error

ScanStorageDevices online scan the new storage device More info: https://pfs.nifcloud.com/guide/cp/login/mount_linux.htm

type Options

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

Options is option for CSI driver.

type Resizefs

type Resizefs interface {
	Resize(devicePath, deviceMountPath string) (bool, error)
}

type VersionInfo

type VersionInfo struct {
	DriverVersion string `json:"driverVersion"`
	GitCommit     string `json:"gitCommit"`
	BuildDate     string `json:"buildDate"`
	GoVersion     string `json:"goVersion"`
	Compiler      string `json:"compiler"`
	Platform      string `json:"platform"`
}

VersionInfo is version information of this driver.

func GetVersion

func GetVersion() VersionInfo

GetVersion returns the version info

type VolumeLocks

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

VolumeLocks implements a map with atomic operations. It stores a set of all volume IDs with an ongoing operation.

func NewVolumeLocks

func NewVolumeLocks() *VolumeLocks

func (*VolumeLocks) Release

func (vl *VolumeLocks) Release(volumeID string)

func (*VolumeLocks) TryAcquire

func (vl *VolumeLocks) TryAcquire(volumeID string) bool

TryAcquire tries to acquire the lock for operating on volumeID and returns true if successful. If another operation is already using volumeID, returns false.

Jump to

Keyboard shortcuts

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