Version: v1.0.0 Latest Latest

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 10 Imported by: 0




View Source
const (
	ErrCreateRequest = "failed to create request"
	ErrRequest       = "failed to HTTP request"

Error values


This section is empty.


This section is empty.


type Client

type Client struct {
	User     string
	Password string

	URL        *url.URL
	HTTPClient *http.Client
	Logger     *log.Logger

Client is client of go-targetd

func New

func New(baseURL, username, password string, httpClient *http.Client, logger *log.Logger) (*Client, error)

New create go-targetd client

func (*Client) CopyVolume

func (c *Client) CopyVolume(ctx context.Context, poolName, originalVolumeName, newVolumeName string, sizeByte int) error

CopyVolume copy a volume. you need to set zfs_enable_copy if use ZFS backend.

func (*Client) CreateExport

func (c *Client) CreateExport(ctx context.Context, poolName, volumeName string, lunID int, initiatorWWN string) error

CreateExport create a export

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, poolName, volumeName string, sizeByte int) error

CreateVolume create a volume

func (*Client) DestroyExport

func (c *Client) DestroyExport(ctx context.Context, poolName, volumeName, initiatorWWN string) error

DestroyExport delete a export

func (*Client) DestroyVolume

func (c *Client) DestroyVolume(ctx context.Context, poolName, volumeName string) error

DestroyVolume delete a volume

func (*Client) GetPool

func (c *Client) GetPool(ctx context.Context, poolName string) (*Pool, error)

GetPool retrieve pool from name of pool

func (*Client) GetPoolList

func (c *Client) GetPoolList(ctx context.Context) ([]Pool, error)

GetPoolList retrieve list of volume pool

func (*Client) GetVolume

func (c *Client) GetVolume(ctx context.Context, poolName, volumeName string) (*Volume, error)

GetVolume retrieve volume from volume name

func (*Client) GetVolumeList

func (c *Client) GetVolumeList(ctx context.Context, poolName string) ([]Volume, error)

GetVolumeList retrieve list of volume in pool

func (*Client) ListExport

func (c *Client) ListExport(ctx context.Context) ([]Export, error)

ListExport retrieve list of export

type ErrorResp

type ErrorResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`

ErrorResp is error response structure from targetd

func (ErrorResp) Error

func (e ErrorResp) Error() error

Error is interface for fmt.Error

type Export

type Export struct {
	InitiatorWwn string `json:"initiator_wwn"`
	LUN          int    `json:"lun"`
	VolName      string `json:"vol_name"`
	Pool         string `json:"pool"`
	VolUUID      string `json:"vol_uuid"`
	VolSize      int    `json:"vol_size"`

Export is volume export

type Pool

type Pool struct {
	Name     string `json:"name"`
	Size     int64  `json:"size"`
	FreeSize int64  `json:"free_size"`
	Type     string `json:"type"`
	UUID     int64  `json:"uuid"`

Pool is volume pool

type Response

type Response struct {
	Result  interface{} `json:"result,omitempty"`
	Error   ErrorResp   `json:"error,omitempty"`
	ID      int         `json:"id"`
	JSONRPC string      `json:"jsonrpc"`

Response is http Response from targetd

type Volume

type Volume struct {
	Name string `json:"name"`
	Size int    `json:"size"`
	UUID string `json:"uuid"`

Volume is volume

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL