manager

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: MIT Imports: 7 Imported by: 0

README

QNAP Disk Manager API for Go

This library provides access to the QNAP Disk Manager and iSCSI API (http://www.qnap.com).

The scope is to allow management of iSCSI disks to be utilized as Kubernetes storage.

Click here to open the documentation.

Usage

To use the API, simply create a new session:

import "github.com/nine-lives-later/go-qnap-disk-manager"

func main() {
    session, _ := manager.Connect("storage:8443", "admin", "admin", nil)

    session.Logout()
}

Authors

We thank all the authors who provided code to this library:

  • Felix Kollmann

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package manager provides access to the QNAP Disk Management and iSCSI API (http://www.qnap.com).

More information is available on the project website: https://github.com/nine-lives-later/go-qnap-disk-manager/

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigOptions

type ConfigOptions struct {
	APICallTimeout              time.Duration
	IgnoreInvalidSSLCertificate bool
}

ConfigOptions contains some advanced settings on server communication.

type ISCSITarget

type ISCSITarget struct {
	TargetIndex  int    `xml:"targetIndex"`
	TargetName   string `xml:"targetName"`
	TargetIQN    string `xml:"targetIQN"`
	TargetAlias  string `xml:"targetAlias"`
	TargetStatus int    `xml:"targetStatus"`
}

type LUN

type LUN struct {
	LUNIndex            int    `xml:"LUNIndex"`
	LUNName             string `xml:"LUNName"`
	LUNPath             string `xml:"LUNPath"`
	LUNStatus           int    `xml:"LUNStatus"`
	LUNThinAllocate     bool   `xml:"LUNThinAllocate"`
	LUNAttachedTarget   int    `xml:"LUNAttachedTarget"`
	LUNNumber           int    `xml:"LUNNumber"`
	LUNSerialNum        string `xml:"LUNSerialNum"`
	LUNBackupStatus     int    `xml:"LUNBackupStatus"`
	IsSnap              int    `xml:"isSnap"`
	IsRemoving          int    `xml:"isRemoving"`
	BMap                int    `xml:"bMap"`
	CapacityBytes       int64  `xml:"capacity_bytes"`
	VolumeBase          string `xml:"VolumeBase"`
	WCEnable            bool   `xml:"WCEnable"`
	FUAEnable           bool   `xml:"FUAEnable"`
	LUNThresholdPercent int    `xml:"LUNThreshold"`
	LUNNAA              string `xml:"LUNNAA"`
	LUNSectorSize       int    `xml:"LUNSectorSize"`
	SsdCache            string `xml:"ssd_cache"`
	PoolID              int    `xml:"poolID"`
	PoolVjbod           bool   `xml:"pool_vjbod"`
	VolumeID            int    `xml:"volno"`
	BlockSize           int64  `xml:"block_size"`
	LUNTargetList       struct {
		SingleRow *struct {
			TargetIndex int  `xml:"targetIndex"`
			LUNNumber   int  `xml:"LUNNumber"`
			LUNEnable   bool `xml:"LUNEnable"`
		} `xml:"row"`
	} `xml:"LUNTargetList"`
	LUNInitiatorList struct {
		LUNInitInfo []struct {
			InitiatorIndex int    `xml:"initiatorIndex"`
			InitiatorIQN   string `xml:"initiatorIQN"`
			AccessMode     int    `xml:"accessMode"`
		} `xml:"LUNInitInfo"`
	} `xml:"LUNInitList"`
}

type LUNAllocateMode

type LUNAllocateMode string
const (
	LUNAllocateMode_Thin  LUNAllocateMode = "1"
	LUNAllocateMode_Thick LUNAllocateMode = "0"
)

type QnapSession

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

QnapSession is a container for our session state.

func Connect

func Connect(host, username, password string, configOptions *ConfigOptions) (*QnapSession, error)

Connect sets up our connection to the QNAP system.

func (*QnapSession) AssignLUN

func (s *QnapSession) AssignLUN(lunIndex int, targetIndex int) error

AssignLUN assigns an existing LUN to an existing iSCSI target

func (*QnapSession) Close

func (s *QnapSession) Close() error

func (*QnapSession) CreateBlockBasedLUN

func (s *QnapSession) CreateBlockBasedLUN(storagePoolID int, name string, capacityGB int, allocateMode LUNAllocateMode, useSSDCache bool, alertThresoldPercent int) (*LUN, error)

CreateBlockBasedLUN creates a new block-based volume inside a storage pool and returns the new LUN.

func (*QnapSession) DeleteLUN

func (s *QnapSession) DeleteLUN(lunID int) error

DeleteLUN retrieves the a storage LUN by its LUN ID (not volume ID!)

func (*QnapSession) GetISCSITargets

func (s *QnapSession) GetISCSITargets() ([]*ISCSITarget, error)

GetISCSITargets retrieves the list of all iSCSI targets.

func (*QnapSession) GetLUNByIndex

func (s *QnapSession) GetLUNByIndex(lunIndex int) (*LUN, error)

GetLUNByIndex retrieves the a storage LUN by its LUN ID (not volume ID!)

func (*QnapSession) GetLUNs

func (s *QnapSession) GetLUNs() ([]*LUN, error)

GetLUNs retrieves the list of all storage LUNs.

func (*QnapSession) GetStoragePools

func (s *QnapSession) GetStoragePools() ([]*StoragePool, error)

GetStoragePools retrieves the list of storage pools.

func (*QnapSession) Login

func (s *QnapSession) Login(username, password string) error

Login perform the authentication against the QNAP storage. Any existing session will be logged-out, first.

func (*QnapSession) Logout

func (s *QnapSession) Logout() error

Logout invalidates the session.

func (*QnapSession) String

func (s *QnapSession) String() string

String returns the session's hostname.

func (*QnapSession) WaitForLUNVolume

func (s *QnapSession) WaitForLUNVolume(lunID int) (*LUN, error)

WaitForLUNVolume waits for the volume of the LUN to become ready.

type StoragePool

type StoragePool struct {
	PoolID                       int   `xml:"poolID"`
	PoolTiering                  int   `xml:"pool_tiering"`
	TierThinPool                 int   `xml:"tier_thin_pool"`
	PoolVjbod                    int   `xml:"pool_vjbod"`
	AllowSysVol                  int   `xml:"allow_sys_vol"`
	PoolTr                       int   `xml:"pool_tr"`
	SedPool                      int   `xml:"sed_pool"`
	RemovingType                 int   `xml:"removing_type"`
	PoolStatus                   int   `xml:"pool_status"`
	PoolType                     int   `xml:"pool_type"`
	PoolOverThreshold            int   `xml:"pool_over_threshold"`
	PoolFullType                 int   `xml:"pool_full_type"`
	CapacityBytes                int64 `xml:"capacity_bytes"`
	AllocatedBytes               int64 `xml:"allocated_bytes"`
	FreesizeBytes                int64 `xml:"freesize_bytes"`
	UnutilizedSpaceBytes         int64 `xml:"unutilized_space_bytes"`
	MaxThickCreateSizeBytes      int64 `xml:"max_thick_create_size_bytes"`
	TpReservedSizeBytes          int64 `xml:"tp_reserved_size_bytes"`
	SnapshotReservedEnable       int   `xml:"snapshot_reserved_enable"`
	SnapshotReserved             int   `xml:"snapshot_reserved"`
	SetSnapshotReservedBytes     int64 `xml:"set_snapshot_reserved_bytes"`
	RealFreesizeBytes            int64 `xml:"real_freesize_bytes"`
	SnapshotBytes                int64 `xml:"snapshot_bytes"`
	SnapshotReservedBytes        int64 `xml:"snapshot_reserved_bytes"`
	PoolAllocatedNoSnapshotBytes int64 `xml:"pool_allocated_no_snapshot_bytes"`
	VolAllocating                int   `xml:"vol_allocating"`
	TieringProcessing            int   `xml:"tiering_processing"`
	RecoverFromReadDeleteKb      int64 `xml:"recover_from_read_delete_kb"`
	OpTotalReserveSpaceKb        int64 `xml:"op_total_reserve_space_kb"`
	PoolStripe                   int   `xml:"pool_stripe"`
	IsTrRaid                     int   `xml:"is_tr_raid"`
	VolRemove                    int   `xml:"vol_remove"`
}

Jump to

Keyboard shortcuts

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