client

package
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package client provides oceandisk storage client

Package client provides oceandisk storage client

Package client provides oceandisk storage client

Index

Constants

View Source
const (

	// NamespaceType is Associated object type of Namespace
	NamespaceType = "11"
	// AssociateObjTypeNamespace Namespace type
	AssociateObjTypeNamespace = 11
	// AssociateObjTypeNamespaceGroup Namespace group type
	AssociateObjTypeNamespaceGroup = 256
)
View Source
const (
	// DefaultParallelCount defines default parallel count
	DefaultParallelCount int = 30

	// MaxParallelCount defines max parallel count
	MaxParallelCount int = 30

	// MinParallelCount defines min parallel count
	MinParallelCount int = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateNamespaceParams

type CreateNamespaceParams struct {
	Name           string
	ParentId       string
	Capacity       int64
	Description    string
	WorkLoadTypeId string
}

CreateNamespaceParams defines create namespace params

func MakeCreateNamespaceParams

func MakeCreateNamespaceParams(params map[string]interface{}) (*CreateNamespaceParams, error)

MakeCreateNamespaceParams used to make parameters for CreateNamespace

type Namespace

type Namespace interface {
	// GetNamespaceByName used for get namespace by name
	GetNamespaceByName(ctx context.Context, name string) (map[string]interface{}, error)
	// GetNamespaceByID used for get namespace by id
	GetNamespaceByID(ctx context.Context, id string) (map[string]interface{}, error)
	// GetNamespaceCountOfHost used for get namespace count of host
	GetNamespaceCountOfHost(ctx context.Context, hostID string) (int64, error)
	// GetNamespaceCountOfMapping used for get namespace count of mapping by mapping id
	GetNamespaceCountOfMapping(ctx context.Context, mappingID string) (int64, error)
	// DeleteNamespace used for delete namespace by namespace id
	DeleteNamespace(ctx context.Context, id string) error
	// ExtendNamespace used for extend namespace
	ExtendNamespace(ctx context.Context, namespaceID string, newCapacity int64) error
	// CreateNamespace used for create namespace
	CreateNamespace(ctx context.Context, params CreateNamespaceParams) (map[string]interface{}, error)
	// GetHostNamespaceId used for get host namespace id
	GetHostNamespaceId(ctx context.Context, hostID, namespaceID string) (string, error)
	// UpdateNamespace used for update namespace
	UpdateNamespace(ctx context.Context, namespaceID string, params map[string]interface{}) error
}

Namespace defines interfaces for namespace operations

type NamespaceGroup

type NamespaceGroup interface {
	// QueryAssociateNamespaceGroup used for query associate namespace group by object type and object id
	QueryAssociateNamespaceGroup(ctx context.Context, objType int, objID string) ([]interface{}, error)
	// GetNamespaceGroupByName used for get namespace group by name
	GetNamespaceGroupByName(ctx context.Context, name string) (map[string]interface{}, error)
	// DeleteNamespaceGroup used for delete namespace group by namespace group id
	DeleteNamespaceGroup(ctx context.Context, id string) error
	// RemoveNamespaceFromGroup used for remove namespace from group
	RemoveNamespaceFromGroup(ctx context.Context, namespaceID, groupID string) error
	// AddNamespaceToGroup used for add namespace to group
	AddNamespaceToGroup(ctx context.Context, namespaceID string, groupID string) error
	// CreateNamespaceGroup used for create namespace group
	CreateNamespaceGroup(ctx context.Context, name string) (map[string]interface{}, error)
}

NamespaceGroup defines interfaces for namespacegroup operations

type NewClientConfig

type NewClientConfig struct {
	Urls            []string
	User            string
	SecretName      string
	SecretNamespace string
	ParallelNum     string
	BackendID       string
	UseCert         bool
	CertSecretMeta  string
	Storage         string
	Name            string
}

NewClientConfig stores the information needed to create a new oceandisk client

type OceandiskClient

OceandiskClient implements OceandiskClientInterface

func NewClient

func NewClient(ctx context.Context, param *NewClientConfig) (*OceandiskClient, error)

NewClient inits a new client of oceandisk client

func (*OceandiskClient) AddNamespaceToGroup

func (cli *OceandiskClient) AddNamespaceToGroup(ctx context.Context, namespaceID string, groupID string) error

AddNamespaceToGroup used for add namespace to group

func (*OceandiskClient) CreateNamespace

func (cli *OceandiskClient) CreateNamespace(ctx context.Context,
	params CreateNamespaceParams) (map[string]interface{}, error)

CreateNamespace used for create namespace

func (*OceandiskClient) CreateNamespaceGroup

func (cli *OceandiskClient) CreateNamespaceGroup(ctx context.Context, name string) (map[string]interface{}, error)

CreateNamespaceGroup used for create namespace group

func (*OceandiskClient) DeleteNamespace

func (cli *OceandiskClient) DeleteNamespace(ctx context.Context, id string) error

DeleteNamespace used for delete namespace by namespace id

func (*OceandiskClient) DeleteNamespaceGroup

func (cli *OceandiskClient) DeleteNamespaceGroup(ctx context.Context, id string) error

DeleteNamespaceGroup used for delete namespace group by namespace group id

func (*OceandiskClient) ExtendNamespace

func (cli *OceandiskClient) ExtendNamespace(ctx context.Context, namespaceID string, newCapacity int64) error

ExtendNamespace used for extend namespace

func (*OceandiskClient) GetHostNamespaceId

func (cli *OceandiskClient) GetHostNamespaceId(ctx context.Context, hostID, namespaceID string) (string, error)

GetHostNamespaceId used for get host namespace id

func (*OceandiskClient) GetNamespaceByID

func (cli *OceandiskClient) GetNamespaceByID(ctx context.Context, id string) (map[string]interface{}, error)

GetNamespaceByID used for get namespace by id

func (*OceandiskClient) GetNamespaceByName

func (cli *OceandiskClient) GetNamespaceByName(ctx context.Context, name string) (map[string]interface{}, error)

GetNamespaceByName used for get namespace by name

func (*OceandiskClient) GetNamespaceCountOfHost

func (cli *OceandiskClient) GetNamespaceCountOfHost(ctx context.Context, hostID string) (int64, error)

GetNamespaceCountOfHost used for get namespace count of host

func (*OceandiskClient) GetNamespaceCountOfMapping

func (cli *OceandiskClient) GetNamespaceCountOfMapping(ctx context.Context, mappingID string) (int64, error)

GetNamespaceCountOfMapping used for get namespace count of mapping by mapping id

func (*OceandiskClient) GetNamespaceGroupByName

func (cli *OceandiskClient) GetNamespaceGroupByName(ctx context.Context, name string) (map[string]interface{}, error)

GetNamespaceGroupByName used for get namespace group by name

func (*OceandiskClient) QueryAssociateNamespaceGroup

func (cli *OceandiskClient) QueryAssociateNamespaceGroup(ctx context.Context,
	objType int, objID string) ([]interface{}, error)

QueryAssociateNamespaceGroup used for query associate namespace group by object type and object id

func (*OceandiskClient) RemoveNamespaceFromGroup

func (cli *OceandiskClient) RemoveNamespaceFromGroup(ctx context.Context, namespaceID, groupID string) error

RemoveNamespaceFromGroup used for remove namespace from group

func (*OceandiskClient) UpdateNamespace

func (cli *OceandiskClient) UpdateNamespace(ctx context.Context,
	namespaceID string, params map[string]interface{}) error

UpdateNamespace used for update namespace

func (*OceandiskClient) ValidateLogin

func (cli *OceandiskClient) ValidateLogin(ctx context.Context) error

ValidateLogin validates the login info

type OceandiskClientInterface

type OceandiskClientInterface interface {
	base.RestClientInterface
	base.ApplicationType
	base.FC
	base.Host
	base.Iscsi
	base.Mapping
	base.Qos
	base.RoCE
	base.System

	Namespace
	NamespaceGroup

	GetBackendID() string
	GetDeviceSN() string
	GetStorageVersion() string
}

OceandiskClientInterface defines interfaces for base client operations

type RestClient

type RestClient struct {
	Client base.HTTP
	Url    string
	Urls   []string

	User            string
	SecretNamespace string
	SecretName      string
	StorageVersion  string
	BackendID       string
	Storage         string
	DeviceId        string
	Token           string

	SystemInfoRefreshing uint32
	ReLoginMutex         sync.Mutex
	RequestSemaphore     *utils.Semaphore
}

RestClient defines client implements the rest interface

func NewRestClient

func NewRestClient(ctx context.Context, param *NewClientConfig) (*RestClient, error)

NewRestClient inits a new rest client

func (*RestClient) BaseCall

func (cli *RestClient) BaseCall(ctx context.Context,
	method string, url string, data map[string]interface{}) (base.Response, error)

BaseCall provides base call for request

func (*RestClient) Call

func (cli *RestClient) Call(ctx context.Context,
	method string, url string, data map[string]interface{}) (base.Response, error)

Call provides call for restful request

func (*RestClient) Delete

func (cli *RestClient) Delete(ctx context.Context, url string, data map[string]interface{}) (base.Response, error)

Delete provides http request of DELETE method

func (*RestClient) Get

func (cli *RestClient) Get(ctx context.Context, url string, data map[string]interface{}) (base.Response, error)

Get provides http request of GET method

func (*RestClient) GetBackendID

func (cli *RestClient) GetBackendID() string

GetBackendID get backend id of client

func (*RestClient) GetDeviceSN

func (cli *RestClient) GetDeviceSN() string

GetDeviceSN used for get device sn

func (*RestClient) GetRequest

func (cli *RestClient) GetRequest(ctx context.Context,
	method string, url string, data map[string]interface{}) (*http.Request, error)

GetRequest return the request info

func (*RestClient) GetStorageVersion

func (cli *RestClient) GetStorageVersion() string

GetStorageVersion used for get storage version

func (*RestClient) GetSystem

func (cli *RestClient) GetSystem(ctx context.Context) (map[string]interface{}, error)

GetSystem used for get system info

func (*RestClient) Login

func (cli *RestClient) Login(ctx context.Context) error

Login login and set data from response

func (*RestClient) Logout

func (cli *RestClient) Logout(ctx context.Context)

Logout logout

func (*RestClient) Post

func (cli *RestClient) Post(ctx context.Context, url string, data map[string]interface{}) (base.Response, error)

Post provides http request of POST method

func (*RestClient) Put

func (cli *RestClient) Put(ctx context.Context, url string, data map[string]interface{}) (base.Response, error)

Put provides http request of PUT method

func (*RestClient) ReLogin

func (cli *RestClient) ReLogin(ctx context.Context) error

ReLogin logout and login again

func (*RestClient) SetSystemInfo

func (cli *RestClient) SetSystemInfo(ctx context.Context) error

SetSystemInfo set system info the mutex lock is required for re-login. Therefore, the internal query of the login interface cannot be performed.

Jump to

Keyboard shortcuts

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