chapi

package
v4.6.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Hosts represents collection of hosts
	Hosts model.Hosts
	// DeviceURIfmt represents particular device endpoint format for GET  and POST requests
	DeviceURIfmt = "%sdevices/%s"
	// HostURIfmt represents hosts endpoint format for GET requests
	HostURIfmt = "/hosts/%s/"
	// MountURIfmt represents mounts endpoint format for GET and POST requests
	MountURIfmt = "%smounts/%s"
	// DevicesURIfmt represents devices endpoint format for GET requests
	DevicesURIfmt = "%sdevices"
	// UnmountURIfmt represents particular mount endpoint for POST requests
	UnmountURIfmt = "%smounts/%s"
	// CreateFSURIfmt represents devices endpoint format for POST requests
	CreateFSURIfmt = "%sdevices/%s/%s"
	// NetworksURIfmt represents networks endpoint format for GET requests
	NetworksURIfmt = "%snetworks"
	// InitiatorsURIfmt represents initiators endpoint for GET requests
	InitiatorsURIfmt = "%sinitiators"
	// HostnameURIfmt represents hostname endpoint for GET requests
	HostnameURIfmt = "%shostname"
	// ChapInfoURIfmt represents endpoint to obtain initiator CHAP credentials
	ChapInfoURIfmt = "%schapinfo"
	// LogLevel of the chapi client
	LogLevel = "info"
)
View Source
var (

	//ChapidSocketPath : the directory for chapid socket
	ChapidSocketPath = "/opt/hpe-storage/etc/"
	//ChapidSocketName : chapid socket name
	ChapidSocketName = "chapid"
)

Functions

func CheckFsCreationInProgress

func CheckFsCreationInProgress(device model.Device) (inProgress bool, err error)

CheckFsCreationInProgress checks if mkfs process is using the device

func GetHostURL

func GetHostURL(hostName string, port uint64) string

GetHostURL to consruct HTTP URL of the form "hostname:port"

func GetSocketName

func GetSocketName() string

GetSocketName returns unix socket name (per process)

func IsChapidRunning

func IsChapidRunning(chapidSocket string) bool

IsChapidRunning return true if chapid is running as part of service listening on given socket

func NewRouter

func NewRouter() *mux.Router

NewRouter creates a new mux.Router

func Run

func Run() (err error)

Run will invoke a new chapid listener with socket filename containing current process ID

func RunNimbled

func RunNimbled(c chan error)

RunNimbled :

func StopChapid

func StopChapid() error

StopChapid will stop the given http listener

Types

type AccessKeyPath

type AccessKeyPath struct {
	Path string `json:"path"`
}

AccessKeyPath struct

type Client

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

Client defines client for chapid and corresponding socket file or http:port info

func NewChapiClient

func NewChapiClient() (*Client, error)

NewChapiClient returns the chapi client that communicates over the required unix socket(per process or common service)

func NewChapiClientWithTimeout

func NewChapiClientWithTimeout(timeout time.Duration) (*Client, error)

NewChapiClientWithTimeout returns the chapi client with timeout configuration that communicates over the required unix socket(per process or common service)

func NewChapiHTTPClient

func NewChapiHTTPClient(hostName string, port uint64) (*Client, error)

NewChapiHTTPClient to create chapi http client

func NewChapiHTTPClientWithTimeout

func NewChapiHTTPClientWithTimeout(hostName string, port uint64, timeout time.Duration) (*Client, error)

NewChapiHTTPClientWithTimeout to create chapi http client with timeout

func NewChapiHTTPClientWithTimeoutAndHeader

func NewChapiHTTPClientWithTimeoutAndHeader(hostName string, port uint64, timeout time.Duration, header map[string]string) (*Client, error)

NewChapiHTTPClientWithTimeoutAndHeader to create chapi http client with timeout and headers

func NewChapiSocketClient

func NewChapiSocketClient() (*Client, error)

NewChapiSocketClient to create chapi socket client

func NewChapiSocketClientWithTimeout

func NewChapiSocketClientWithTimeout(timeout time.Duration) (*Client, error)

NewChapiSocketClientWithTimeout to create chapi socket client with timeout

func (*Client) AddHeader

func (chapiClient *Client) AddHeader(header map[string]string) error

AddHeader to insert HTTP headers to chapi client

func (*Client) AttachAndMountDevice

func (chapiClient *Client) AttachAndMountDevice(volume *model.Volume, mountPath string) (err error)

AttachAndMountDevice will attach the given os device for given volume and mounts the filesystem on the host

func (*Client) AttachDevice

func (chapiClient *Client) AttachDevice(volumes []*model.Volume) (devices []*model.Device, err error)

AttachDevice will attach the given os device for given volume on the host

func (*Client) CreateFilesystem

func (chapiClient *Client) CreateFilesystem(device *model.Device, vol *model.Volume, filesystem string) (err error)

CreateFilesystem calls chapi server to create filesystem

func (*Client) DeleteDevice

func (chapiClient *Client) DeleteDevice(device *model.Device) (err error)

DeleteDevice : delete the os device on the host nolint : Remove this once 'DetachDevice' from chapiclient_windows.go is removed

func (*Client) GetChapInfo

func (chapiClient *Client) GetChapInfo() (chapInfo *model.ChapInfo, err error)

GetChapInfo will return host initiator CHAP details

func (*Client) GetDeviceFromVolume

func (chapiClient *Client) GetDeviceFromVolume(volume *model.Volume) (device *model.Device, err error)

GetDeviceFromVolume will return os device for given storage volume

func (*Client) GetDevices

func (chapiClient *Client) GetDevices() (devices []*model.Device, err error)

GetDevices will return all the OS devices on the host

func (*Client) GetHostID

func (chapiClient *Client) GetHostID() (string, error)

GetHostID will retrieve the host uuid from host

func (*Client) GetHostName

func (chapiClient *Client) GetHostName() (host *model.Host, err error)

GetHostName returns hostname and domain name of given host

func (*Client) GetInitiators

func (chapiClient *Client) GetInitiators() (initiators []*model.Initiator, err error)

GetInitiators will return host initiator list (WWPNs in case of FC)

func (*Client) GetMounts

func (chapiClient *Client) GetMounts(respMount *[]*model.Mount, serialNumber string) (err error)

GetMounts will return all mountpoints of a volume with given serial

func (*Client) GetNetworks

func (chapiClient *Client) GetNetworks() (networks []*model.NetworkInterface, err error)

GetNetworks return list of host network interface details

func (*Client) Mount

func (chapiClient *Client) Mount(reqMount *model.Mount, respMount *model.Mount) (err error)

Mount makes a POST request to chapi to mount filesystem on the host

func (*Client) MountFilesystem

func (chapiClient *Client) MountFilesystem(volume *model.Volume, mountPoint string) error

MountFilesystem calls POST on mounts for chapi to mount volume on host

func (*Client) OfflineDevice

func (chapiClient *Client) OfflineDevice(device *model.Device) (err error)

OfflineDevice : offline the device in preparation of removing ACL to avoid race-condition to be discovered again

func (*Client) Print

func (chapiClient *Client) Print()

Print to dump chapi client struct

func (*Client) SetupFilesystemAndPermissions

func (chapiClient *Client) SetupFilesystemAndPermissions(device *model.Device, vol *model.Volume, filesystem string) error

SetupFilesystemAndPermissions creates filesystem and applies permissions if present

func (*Client) Unmount

func (chapiClient *Client) Unmount(reqMount *model.Mount, respMount *model.Mount) (err error)

Unmount make a DELETE request to chapi to unmount filesystem on the host

func (*Client) UnmountDevice

func (chapiClient *Client) UnmountDevice(volume *model.Volume) error

UnmountDevice performs the host side workflow to unmount a volume

type Driver

type Driver interface {
	GetHosts() (*model.Hosts, error)
	GetHostInfo() (*model.Host, error)
	GetHostInitiators() ([]*model.Initiator, error)
	GetHostNetworks() ([]*model.NetworkInterface, error)
	GetHostNameAndDomain() ([]string, error)
	CreateDevices(volumes []*model.Volume) ([]*model.Device, error)
	GetDevice(volume *model.Volume) (*model.Device, error)
	DeleteDevice(device *model.Device) error
	OfflineDevice(device *model.Device) error
	MountDevice(device *model.Device, mountPoint string, mountOptions []string, fsOpts *model.FilesystemOpts) (*model.Mount, error) // Idempotent
	MountNFSVolume(source string, target string, mountOptions []string, nfsType string) error                                       // Idempotent
	BindMount(mountPoint string, newMountPoint string, rbind bool) error                                                            // Idempotent
	BindUnmount(mountPoint string) error                                                                                            // Idempotent
	UnmountDevice(device *model.Device, mountPoint string) (*model.Mount, error)                                                    // Idempotent
	UnmountFileSystem(mountPoint string) (*model.Mount, error)                                                                      // Idempotent
	GetMounts(serialNumber string) ([]*model.Mount, error)
	GetMountsForDevice(device *model.Device) ([]*model.Mount, error)
	ExpandDevice(targetPath string, volAccessType model.VolumeAccessType) error
	IsBlockDevice(devicePath string) (bool, error)
	GetBlockSizeBytes(devicePath string) (int64, error)
}

Driver provides a common interface for host related operations

type ErrorResponse

type ErrorResponse struct {
	Info string `json:"info,omitempty"`
}

ErrorResponse struct

type FakeDriver

type FakeDriver struct {
}

FakeDriver ... the name says it all

func (*FakeDriver) BindMount

func (driver *FakeDriver) BindMount(mountPoint string, newMountPoint string, rbind bool) error

BindMount binds the existing mountpoint to another mountpoint

func (*FakeDriver) BindUnmount

func (driver *FakeDriver) BindUnmount(mountPoint string) error

BindUnmount unmounts the given bind mount

func (*FakeDriver) CreateDevices

func (driver *FakeDriver) CreateDevices(volumes []*model.Volume) ([]*model.Device, error)

CreateDevices will create devices on this host based on the volume details provided

func (*FakeDriver) CreateFilesystemOnDevice

func (driver *FakeDriver) CreateFilesystemOnDevice(device *model.Device, filesytemType string) error

CreateFilesystemOnDevice writes the given filesystem to the device with the given serial number

func (*FakeDriver) DeleteDevice

func (driver *FakeDriver) DeleteDevice(device *model.Device) error

DeleteDevice will delete the given device from the host

func (*FakeDriver) ExpandDevice

func (driver *FakeDriver) ExpandDevice(targetPath string, volAccessType model.VolumeAccessType) error

ExpandDevice will expand the given device/filesystem on the host

func (*FakeDriver) GetBlockSizeBytes

func (driver *FakeDriver) GetBlockSizeBytes(devicePath string) (int64, error)

GetBlockSizeBytes returns the size of the block device

func (*FakeDriver) GetDevice

func (driver *FakeDriver) GetDevice(volume *model.Volume) (*model.Device, error)

GetDevice will return device matching given volume serial

func (*FakeDriver) GetFilesystemOptionsFromDevice

func (driver *FakeDriver) GetFilesystemOptionsFromDevice(device *model.Device, mountPoint string) (*model.FilesystemOpts, error)

GetFilesystemOptionsFromDevice retrieves the filesystem options from the filesystem on the device

func (*FakeDriver) GetHostInfo

func (driver *FakeDriver) GetHostInfo() (*model.Host, error)

GetHostInfo returns host name, domain, and network interfaces

func (*FakeDriver) GetHostInitiators

func (driver *FakeDriver) GetHostInitiators() ([]*model.Initiator, error)

GetHostInitiators reports the initiators on this host

func (*FakeDriver) GetHostNameAndDomain

func (driver *FakeDriver) GetHostNameAndDomain() ([]string, error)

GetHostNameAndDomain reports the host name and domain

func (*FakeDriver) GetHostNetworks

func (driver *FakeDriver) GetHostNetworks() ([]*model.NetworkInterface, error)

GetHostNetworks reports the networks on this host

func (*FakeDriver) GetHosts

func (driver *FakeDriver) GetHosts() (*model.Hosts, error)

GetHosts returns information about this host within an array. Not sure why but we should probably fix that.

func (*FakeDriver) GetMountOptions

func (driver *FakeDriver) GetMountOptions(device *model.Device, mountPoint string) ([]string, error)

GetMountOptions retrieves the mount options of the mountpoint of the device

func (*FakeDriver) GetMounts

func (driver *FakeDriver) GetMounts(serialNumber string) ([]*model.Mount, error)

GetMounts reports all mounts on this host

func (*FakeDriver) GetMountsForDevice

func (driver *FakeDriver) GetMountsForDevice(device *model.Device) ([]*model.Mount, error)

GetMountsForDevice reports all mounts for the device on this host

func (*FakeDriver) IsBlockDevice

func (driver *FakeDriver) IsBlockDevice(devicePath string) (bool, error)

IsBlockDevice will check if the given path is a block device

func (*FakeDriver) MountDevice

func (driver *FakeDriver) MountDevice(device *model.Device, mountPoint string, options []string, fsOpts *model.FilesystemOpts) (*model.Mount, error)

MountDevice mounts the given device to the given mount point

func (*FakeDriver) MountNFSVolume

func (driver *FakeDriver) MountNFSVolume(source string, targetPath string, mountOptions []string, nfsType string) error

MountNFSVolume mounts NFS share onto given target path

func (*FakeDriver) OfflineDevice

func (driver *FakeDriver) OfflineDevice(device *model.Device) error

OfflineDevice will offline the given device from the host

func (*FakeDriver) SetFilesystemOptions

func (driver *FakeDriver) SetFilesystemOptions(mountPoint string, fsOpts *model.FilesystemOpts) error

SetFilesystemOptions applies given filesystem options to the filesystem on the device

func (*FakeDriver) SetMountOptions

func (driver *FakeDriver) SetMountOptions(device *model.Device, mountPoint string, options []string) error

SetMountOptions applies the mount options to the mountpoint of the device

func (*FakeDriver) UnmountDevice

func (driver *FakeDriver) UnmountDevice(device *model.Device, mountPoint string) (*model.Mount, error)

UnmountDevice unmounts the given device from the given mount point

func (*FakeDriver) UnmountFileSystem

func (driver *FakeDriver) UnmountFileSystem(mountPoint string) (*model.Mount, error)

UnmountFileSystem will unmount the given mount point

type LinuxDriver

type LinuxDriver struct {
}

LinuxDriver ... Linux implementation of the CHAPI driver

func (*LinuxDriver) BindMount

func (driver *LinuxDriver) BindMount(mountPoint string, newMountPoint string, rbind bool) error

BindMount bind mounts the existing mountpoint to the given mount point

func (*LinuxDriver) BindUnmount

func (driver *LinuxDriver) BindUnmount(mountPoint string) error

BindUnmount unmounts the given bind mount

func (*LinuxDriver) CreateDevices

func (driver *LinuxDriver) CreateDevices(volumes []*model.Volume) ([]*model.Device, error)

CreateDevices will create devices on this host based on the volume details provided

func (*LinuxDriver) CreateFilesystemOnDevice

func (driver *LinuxDriver) CreateFilesystemOnDevice(device *model.Device, filesystemType string) error

CreateFilesystemOnDevice writes the given filesystem on the given device

func (*LinuxDriver) DeleteDevice

func (driver *LinuxDriver) DeleteDevice(device *model.Device) error

DeleteDevice will delete the given device from the host

func (*LinuxDriver) ExpandDevice

func (driver *LinuxDriver) ExpandDevice(targetPath string, volAccessType model.VolumeAccessType) error

ExpandDevice will expand the given device/filesystem on the host

func (*LinuxDriver) GetBlockSizeBytes

func (driver *LinuxDriver) GetBlockSizeBytes(devicePath string) (int64, error)

GetBlockSizeBytes returns the size of the block device

func (*LinuxDriver) GetDevice

func (driver *LinuxDriver) GetDevice(volume *model.Volume) (*model.Device, error)

func (*LinuxDriver) GetFilesystemFromDevice

func (driver *LinuxDriver) GetFilesystemFromDevice(device *model.Device) (*model.FilesystemOpts, error)

GetFilesystemFromDevice writes the given filesystem on the given device

func (*LinuxDriver) GetHostInfo

func (driver *LinuxDriver) GetHostInfo() (*model.Host, error)

GetHostInfo returns host name, domain, and network interfaces

func (*LinuxDriver) GetHostInitiators

func (driver *LinuxDriver) GetHostInitiators() ([]*model.Initiator, error)

GetHostInitiators reports the initiators on this host

func (*LinuxDriver) GetHostNameAndDomain

func (driver *LinuxDriver) GetHostNameAndDomain() ([]string, error)

GetHostNameAndDomain reports the host name and domain

func (*LinuxDriver) GetHostNetworks

func (driver *LinuxDriver) GetHostNetworks() ([]*model.NetworkInterface, error)

GetHostNetworks reports the networks on this host

func (*LinuxDriver) GetHosts

func (driver *LinuxDriver) GetHosts() (*model.Hosts, error)

GetHosts returns information about this host within an array. Not sure why but we should probably fix that.

func (*LinuxDriver) GetMounts

func (driver *LinuxDriver) GetMounts(serialNumber string) ([]*model.Mount, error)

GetMounts reports all mounts on this host

func (*LinuxDriver) GetMountsForDevice

func (driver *LinuxDriver) GetMountsForDevice(device *model.Device) ([]*model.Mount, error)

GetMountsForDevice reports all mounts for the given device on the host

func (*LinuxDriver) IsBlockDevice

func (driver *LinuxDriver) IsBlockDevice(devicePath string) (bool, error)

IsBlockDevice will check if the given path is a block device

func (*LinuxDriver) MountDevice

func (driver *LinuxDriver) MountDevice(device *model.Device, mountPoint string, mountOptions []string, fsOpts *model.FilesystemOpts) (*model.Mount, error)

MountDevice mounts the given device to the given mount point. This must be idempotent.

func (*LinuxDriver) MountNFSVolume

func (driver *LinuxDriver) MountNFSVolume(source string, targetPath string, mountOptions []string, nfsType string) error

func (*LinuxDriver) OfflineDevice

func (driver *LinuxDriver) OfflineDevice(device *model.Device) error

OfflineDevice will offline the given device from the host

func (*LinuxDriver) SetFilesystemOptions

func (driver *LinuxDriver) SetFilesystemOptions(mountPoint string, options *model.FilesystemOpts) error

SetFilesystemOptions applies the given FS options on the filesystem of the device

func (*LinuxDriver) UnmountDevice

func (driver *LinuxDriver) UnmountDevice(device *model.Device, mountPoint string) (*model.Mount, error)

UnmountDevice unmounts the given device from the given mount point

func (*LinuxDriver) UnmountFileSystem

func (driver *LinuxDriver) UnmountFileSystem(mountPoint string) (*model.Mount, error)

UnmountFileSystem will unmount the given mount point

type Response

type Response struct {
	Data interface{} `json:"data,omitempty"`
	Err  interface{} `json:"errors,omitempty"`
}

Response :

Jump to

Keyboard shortcuts

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