nb

package
v5.0.0-...-5e9b562 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package nb makes client API calls to noobaa servers.

Index

Constants

View Source
const (
	// RPCVersionNumber specifies the RPC version number
	RPCVersionNumber uint32 = 0xba000000

	// RPCMaxMessageSize is a limit to protect the process from allocating too much memory
	// for a single incoming message for example in case the connection is out of sync or other bugs.
	RPCMaxMessageSize = 64 * 1024 * 1024

	// RPCSendTimeout is a limit the time we wait for getting reply from the server
	RPCSendTimeout = 120 * time.Second
)
View Source
const (
	// CloudAuthMethodAwsV2 enum
	CloudAuthMethodAwsV2 CloudAuthMethod = "AWS_V2"
	// CloudAuthMethodAwsV4 enum
	CloudAuthMethodAwsV4 CloudAuthMethod = "AWS_V4"

	// EndpointTypeAws enum
	EndpointTypeAws EndpointType = "AWS"
	// EndpointTypeAzure enum
	EndpointTypeAzure EndpointType = "AZURE"
	// EndpointTypeGoogle enum
	EndpointTypeGoogle EndpointType = "GOOGLE"
	// EndpointTypeS3Compat enum
	EndpointTypeS3Compat EndpointType = "S3_COMPATIBLE"
	// EndpointTypeIBMCos enum
	EndpointTypeIBMCos EndpointType = "IBM_COS"

	// ExternalConnectionSuccess enum
	ExternalConnectionSuccess ExternalConnectionStatus = "SUCCESS"
	// ExternalConnectionTimeout enum
	ExternalConnectionTimeout ExternalConnectionStatus = "TIMEOUT"
	// ExternalConnectionInvalidEndpoint enum
	ExternalConnectionInvalidEndpoint ExternalConnectionStatus = "INVALID_ENDPOINT"
	// ExternalConnectionInvalidCredentials enum
	ExternalConnectionInvalidCredentials ExternalConnectionStatus = "INVALID_CREDENTIALS"
	// ExternalConnectionNotSupported enum
	ExternalConnectionNotSupported ExternalConnectionStatus = "NOT_SUPPORTED"
	// ExternalConnectionTimeSkew enum
	ExternalConnectionTimeSkew ExternalConnectionStatus = "TIME_SKEW"
	// ExternalConnectionUnknownFailure enum
	ExternalConnectionUnknownFailure ExternalConnectionStatus = "UNKNOWN_FAILURE"
)

Variables

This section is empty.

Functions

func BigIntToHumanBytes

func BigIntToHumanBytes(bi *BigInt) string

BigIntToHumanBytes returns a human readable bytes string

func FindPortByName

func FindPortByName(srv *corev1.Service, portName string) *corev1.ServicePort

FindPortByName returns the port in the service that matches the given name.

func GetAPIPortName

func GetAPIPortName(api string) string

GetAPIPortName maps every noobaa api name to the service port name that serves it.

func IntToHumanBytes

func IntToHumanBytes(bi int64) string

IntToHumanBytes returns a human readable bytes string

Types

type APIRouter

type APIRouter interface {
	GetAddress(api string) string
}

APIRouter should be able to map noobaa api names to actual addresses See implementations below: APIRouterNodePort, APIRouterPodPort, APIRouterServicePort

type APIRouterNodePort

type APIRouterNodePort struct {
	ServiceMgmt *corev1.Service
	NodeIP      string
}

APIRouterNodePort uses the service node port to route to NodeIP:NodePorts

func (*APIRouterNodePort) GetAddress

func (r *APIRouterNodePort) GetAddress(api string) string

GetAddress implements the router

type APIRouterPodPort

type APIRouterPodPort struct {
	ServiceMgmt *corev1.Service
	PodIP       string
}

APIRouterPodPort uses the service target port to route to PodIP:TargetPort

func (*APIRouterPodPort) GetAddress

func (r *APIRouterPodPort) GetAddress(api string) string

GetAddress implements the router

type APIRouterPortForward

type APIRouterPortForward struct {
	ServiceMgmt  *corev1.Service
	PodNamespace string
	PodName      string
	// Start() will setup these fields:
	PF                   *portforward.PortForwarder
	StopChan             chan struct{}
	MapRemotePortToLocal map[uint16]uint16
}

APIRouterPortForward uses portforwarding to the the pod

func (*APIRouterPortForward) GetAddress

func (r *APIRouterPortForward) GetAddress(api string) string

GetAddress implements the router

func (*APIRouterPortForward) Start

func (r *APIRouterPortForward) Start() error

Start initializes and runs portforwarding by listening on to local ports and forwarding their connections to the target pod ports See

func (*APIRouterPortForward) Stop

func (r *APIRouterPortForward) Stop()

Stop the port forwarding

type APIRouterServicePort

type APIRouterServicePort struct {
	ServiceMgmt *corev1.Service
}

APIRouterServicePort uses the service port to route to Srv.Namespace:Port

func (*APIRouterServicePort) GetAddress

func (r *APIRouterServicePort) GetAddress(api string) string

GetAddress implements the router

type AccountAllowedBuckets

type AccountAllowedBuckets struct {
	FullPermission bool     `json:"full_permission"`
	PermissionList []string `json:"permission_list"`
}

AccountAllowedBuckets is part of CreateAccountParams

type AccountInfo

type AccountInfo struct {
	Name               string         `json:"name"`
	Email              string         `json:"email"`
	IsSupport          bool           `json:"is_support"`
	HasLogin           bool           `json:"has_login"`
	HasS3Access        bool           `json:"has_s3_access"`
	CanCreateBuckets   bool           `json:"can_create_buckets"`
	NextPasswordChange int64          `json:"next_password_change"`
	DefaultResource    string         `json:"default_resource"`
	AccessKeys         []S3AccessKeys `json:"access_keys"`
	AllowedIPs         []struct {
		Start string `json:"start"`
		End   string `json:"end"`
	} `json:"allowed_ips"`
	ExternalConnections struct {
		Count       int                      `json:"count"`
		Connections []ExternalConnectionInfo `json:"connections"`
	} `json:"external_connections"`
	AllowedBuckets AllowedBuckets `json:"allowed_buckets"`
	Systems        []struct {
		Name  string   `json:"name"`
		Roles []string `json:"roles"`
	} `json:"systems"`
	Preferences struct {
		UITheme string `json:"ui_theme"`
	} `json:"preferences"`
}

AccountInfo is a struct of account info returned by the API

type AddExternalConnectionParams

type AddExternalConnectionParams struct {
	Name         string          `json:"name"`
	EndpointType EndpointType    `json:"endpoint_type"`
	Endpoint     string          `json:"endpoint"`
	Identity     string          `json:"identity"`
	Secret       string          `json:"secret"`
	AuthMethod   CloudAuthMethod `json:"auth_method,omitempty"`
}

AddExternalConnectionParams is the params of account_api.add_external_connection()

type AllowedBuckets

type AllowedBuckets struct {
	FullPermission bool     `json:"full_permission"`
	PermissionList []string `json:"permission_list"`
}

AllowedBuckets is a struct for setting which buckets an account can access

type BackingStoreInfo

type BackingStoreInfo struct {
	// Name describes backingstore name
	Name string `json:"name"`
	// Namespace describes backingstore namespace
	Namespace string `json:"namespace"`
}

BackingStoreInfo describes backingstore info

type BigInt

type BigInt struct {
	N    int64 `json:"n"`
	Peta int64 `json:"peta"`
}

BigInt is an api type to handle large integers that cannot be represented by JSON which is limited to 53 bits (less than 8 PB)

func UInt64ToBigInt

func UInt64ToBigInt(value uint64) BigInt

UInt64ToBigInt convert uint64 based value to BigInt value

func (BigInt) MarshalJSON

func (n BigInt) MarshalJSON() ([]byte, error)

MarshalJSON is custom marshalling because the json schema is oneOf integer or {n,peta}

func (*BigInt) UnmarshalJSON

func (n *BigInt) UnmarshalJSON(data []byte) error

UnmarshalJSON is custom unmarshalling because the json schema is oneOf integer or {n,peta}

type BucketClaimInfo

type BucketClaimInfo struct {
	BucketClass string `json:"bucket_class,omitempty"`
	Namespace   string `json:"namespace,omitempty"`
}

BucketClaimInfo is the params of bucket_api.create_bucket()

type BucketClassInfo

type BucketClassInfo struct {
	ErrorMessage   string                  `json:"error_message"`
	ShouldRevert   bool                    `json:"should_revert"`
	RevertToPolicy UpdateBucketClassParams `json:"revert_to_policy"`
}

BucketClassInfo is the is the reply of tiering_policy_api.update_bucket_class()

type BucketInfo

type BucketInfo struct {
	Name        string `json:"name"`
	BucketType  string `json:"bucket_type"`
	Mode        string `json:"mode"`
	Undeletable string `json:"undeletable"`

	BucketClaim  *BucketClaimInfo   `json:"bucket_claim,omitempty"`
	Tiering      *TieringPolicyInfo `json:"tiering,omitempty"`
	DataCapacity *struct {
		Size              *BigInt `json:"size,omitempty"`
		SizeReduced       *BigInt `json:"size_reduced,omitempty"`
		Free              *BigInt `json:"free,omitempty"`
		AvailableToUpload *BigInt `json:"available_for_upload,omitempty"`
		LastUpdate        int64   `json:"last_update"`
	} `json:"data,omitempty"`
	StorageCapacity *struct {
		Values     *StorageInfo `json:"values,omitempty"`
		LastUpdate int64        `json:"last_update"`
	} `json:"storage,omitempty"`
	NumObjects *struct {
		Value      int64 `json:"value"`
		LastUpdate int64 `json:"last_update"`
	} `json:"num_objects,omitempty"`
	Quota *struct {
		Size int64  `json:"size"`
		Unit string `json:"unit"`
	} `json:"quota,omitempty"`
	PolicyModes *struct {
		ResiliencyStatus string `json:"resiliency_status"`
		QuotaStatus      string `json:"quota_status"`
	} `json:"policy_modes,omitempty"`
	Namespace *NamespaceBucketInfo `json:"namespace,omitempty"`
}

BucketInfo is a struct of bucket info returned by the API

type BucketReplicationParams

type BucketReplicationParams struct {
	Name              string        `json:"name"`
	ReplicationPolicy []interface{} `json:"replication_policy"`
}

BucketReplicationParams is the params of bucket_api.put_bucket_replication()

type CacheSpec

type CacheSpec struct {
	// TTL specifies the cache ttl
	TTLMs int `json:"ttl_ms,omitempty"`
}

CacheSpec specifies the cache specifications for the bucket class

type CheckExternalConnectionReply

type CheckExternalConnectionReply struct {
	Status ExternalConnectionStatus `json:"status"`
	Error  struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error,omitempty"`
}

CheckExternalConnectionReply is the reply of account_api.check_external_connection()

type ChunkCoderConfig

type ChunkCoderConfig struct {
	DigestType     *string `json:"digest_type,omitempty"`
	FragDigestType *string `json:"frag_digest_type,omitempty"`
	CompressType   *string `json:"compress_type,omitempty"`
	CipherType     *string `json:"cipher_type,omitempty"`
	// Data Copies:
	Replicas *int64 `json:"replicas,omitempty"`
	// Erasure Coding:
	DataFrags   *int64  `json:"data_frags,omitempty"`
	ParityFrags *int64  `json:"parity_frags,omitempty"`
	ParityType  *string `json:"parity_type,omitempty"`
	// LRC:
	LrcGroup *int64  `json:"lrc_group,omitempty"`
	LrcFrags *int64  `json:"lrc_frags,omitempty"`
	LrcType  *string `json:"lrc_type,omitempty"`
}

ChunkCoderConfig defines a storage coding configuration

type ChunkSplitConfig

type ChunkSplitConfig struct {
	AvgChunk   int64 `json:"avg_chunk"`
	DeltaChunk int64 `json:"delta_chunk"`
}

ChunkSplitConfig defines a storage chunking (splitting objects) configuration

type Client

type Client interface {
	Call(req *RPCMessage, res RPCResponse) error

	SetAuthToken(token string)
	GetAuthToken() string

	ReadAuthAPI() (ReadAuthReply, error)
	ReadAccountAPI(ReadAccountParams) (AccountInfo, error)
	ReadSystemStatusAPI() (ReadySystemStatusReply, error)
	ReadSystemAPI() (SystemInfo, error)
	ReadBucketAPI(ReadBucketParams) (BucketInfo, error)
	ReadPoolAPI(ReadPoolParams) (PoolInfo, error)
	ReadNamespaceResourceAPI(ReadNamespaceResourceParams) (NamespaceResourceInfo, error)
	ReadNamespaceResourceOperatorInfoAPI(ReadNamespaceResourceParams) (NamespaceResourceOperatorInfo, error)
	SetNamespaceStoreInfo(NamespaceStoreInfo) error

	ListAccountsAPI() (ListAccountsReply, error)
	ListBucketsAPI() (ListBucketsReply, error)
	ListHostsAPI(ListHostsParams) (ListHostsReply, error)

	CreateAuthAPI(CreateAuthParams) (CreateAuthReply, error)
	CreateSystemAPI(CreateSystemParams) (CreateSystemReply, error)
	CreateAccountAPI(CreateAccountParams) (CreateAccountReply, error)
	CreateBucketAPI(CreateBucketParams) error
	UpdateBucketAPI(CreateBucketParams) error

	CreateHostsPoolAPI(CreateHostsPoolParams) (string, error)
	GetHostsPoolAgentConfigAPI(GetHostsPoolAgentConfigParams) (string, error)
	UpdateHostsPoolAPI(UpdateHostsPoolParams) error
	CreateCloudPoolAPI(CreateCloudPoolParams) error
	UpdateCloudPoolAPI(UpdateCloudPoolParams) error
	CreateTierAPI(CreateTierParams) error
	CreateNamespaceResourceAPI(CreateNamespaceResourceParams) error
	CreateTieringPolicyAPI(TieringPolicyInfo) error

	DeleteBucketAPI(DeleteBucketParams) error
	DeleteBucketAndObjectsAPI(DeleteBucketParams) error
	DeleteAccountAPI(DeleteAccountParams) error
	DeletePoolAPI(DeletePoolParams) error
	DeleteNamespaceResourceAPI(DeleteNamespaceResourceParams) error

	UpdateAccountS3Access(UpdateAccountS3AccessParams) error
	UpdateAllBucketsDefaultPool(UpdateDefaultResourceParams) error
	UpdateBucketClass(UpdateBucketClassParams) (BucketClassInfo, error)

	AddExternalConnectionAPI(AddExternalConnectionParams) error
	CheckExternalConnectionAPI(AddExternalConnectionParams) (CheckExternalConnectionReply, error)
	EditExternalConnectionCredentialsAPI(EditExternalConnectionCredentialsParams) error
	DeleteExternalConnectionAPI(DeleteExternalConnectionParams) error

	UpdateEndpointGroupAPI(UpdateEndpointGroupParams) error

	RegisterToCluster() error

	PutBucketReplicationAPI(BucketReplicationParams) error
	ValidateReplicationAPI(BucketReplicationParams) error
}

Client is the interface providing typed noobaa API calls

func NewClient

func NewClient(router APIRouter) Client

NewClient initializes an RPCClient with defaults

type CloudAuthMethod

type CloudAuthMethod string

CloudAuthMethod is an enum

type CreateAccountParams

type CreateAccountParams struct {
	Name              string                `json:"name"`
	Email             string                `json:"email"`
	HasLogin          bool                  `json:"has_login"`
	S3Access          bool                  `json:"s3_access"`
	AllowBucketCreate bool                  `json:"allow_bucket_creation"`
	AllowedBuckets    AccountAllowedBuckets `json:"allowed_buckets"`
	DefaultResource   string                `json:"default_resource,omitempty"`
	BucketClaimOwner  string                `json:"bucket_claim_owner,omitempty"`
}

CreateAccountParams is the params of account_api.create_account()

type CreateAccountReply

type CreateAccountReply struct {
	Token      string         `json:"token"`
	AccessKeys []S3AccessKeys `json:"access_keys"`
}

CreateAccountReply is the reply of account_api.create_account()

type CreateAuthParams

type CreateAuthParams struct {
	System   string `json:"system"`
	Role     string `json:"role"`
	Email    string `json:"email"`
	Password string `json:"password,omitempty"`
}

CreateAuthParams is the params of auth_api.create_auth()

type CreateAuthReply

type CreateAuthReply struct {
	Token string `json:"token"`
}

CreateAuthReply is the reply of auth_api.create_auth()

type CreateBucketParams

type CreateBucketParams struct {
	Name        string               `json:"name"`
	Tiering     string               `json:"tiering,omitempty"`
	BucketClaim *BucketClaimInfo     `json:"bucket_claim,omitempty"`
	Namespace   *NamespaceBucketInfo `json:"namespace,omitempty"`
}

CreateBucketParams is the params of bucket_api.create_bucket()

type CreateCloudPoolParams

type CreateCloudPoolParams struct {
	Name              string            `json:"name"`
	Connection        string            `json:"connection"`
	TargetBucket      string            `json:"target_bucket"`
	Backingstore      *BackingStoreInfo `json:"backingstore,omitempty"`
	AvailableCapacity *BigInt           `json:"available_capacity,omitempty"`
}

CreateCloudPoolParams is the params of pool_api.create_cloud_pool()

type CreateHostsPoolParams

type CreateHostsPoolParams struct {
	Name         string            `json:"name"`
	IsManaged    bool              `json:"is_managed"`
	HostCount    int               `json:"host_count"`
	HostConfig   PoolHostsInfo     `json:"host_config"`
	Backingstore *BackingStoreInfo `json:"backingstore,omitempty"`
}

CreateHostsPoolParams is the params of pool_api.create_hosts_pool()

type CreateNamespaceResourceParams

type CreateNamespaceResourceParams struct {
	Name           string              `json:"name"`
	Connection     string              `json:"connection"`
	TargetBucket   string              `json:"target_bucket"`
	NSFSConfig     *NSFSConfig         `json:"nsfs_config,omitempty"`
	NamespaceStore *NamespaceStoreInfo `json:"namespace_store,omitempty"`
}

CreateNamespaceResourceParams is the params of pool_api.create_cloud_pool()

type CreateSystemParams

type CreateSystemParams struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

CreateSystemParams is the params of system_api.create_system()

type CreateSystemReply

type CreateSystemReply struct {
	Token         string `json:"token"`
	OperatorToken string `json:"operator_token"`
}

CreateSystemReply is the reply of system_api.create_system()

type CreateTierParams

type CreateTierParams struct {
	Name             string            `json:"name"`
	DataPlacement    string            `json:"data_placement,omitempty"`
	AttachedPools    []string          `json:"attached_pools,omitempty"`
	ChunkCoderConfig *ChunkCoderConfig `json:"chunk_coder_config,omitempty"`
}

CreateTierParams is the reply of tier_api.create_tier()

type DeleteAccountParams

type DeleteAccountParams struct {
	Email string `json:"email"`
}

DeleteAccountParams is the params of account_api.delete_account()

type DeleteBucketParams

type DeleteBucketParams struct {
	Name string `json:"name"`
}

DeleteBucketParams is the params of bucket_api.delete_bucket()

type DeleteExternalConnectionParams

type DeleteExternalConnectionParams struct {
	Name string `json:"connection_name"`
}

DeleteExternalConnectionParams is the params of account_api.delete_external_connection()

type DeleteNamespaceResourceParams

type DeleteNamespaceResourceParams struct {
	Name string `json:"name"`
}

DeleteNamespaceResourceParams is the params of pool_api.delete_namespace_resource()

type DeletePoolParams

type DeletePoolParams struct {
	Name string `json:"name"`
}

DeletePoolParams is the params of pool_api.delete_pool()

type EditExternalConnectionCredentialsParams

type EditExternalConnectionCredentialsParams struct {
	Name     string `json:"name"`
	Identity string `json:"identity"`
	Secret   string `json:"secret"`
}

EditExternalConnectionCredentialsParams is the params of account_api.edit_external_connection_credentials()

type EndpointType

type EndpointType string

EndpointType is an enum

type ExternalConnectionInfo

type ExternalConnectionInfo struct {
	Name         string          `json:"name"`
	EndpointType EndpointType    `json:"endpoint_type"`
	Endpoint     string          `json:"endpoint"`
	Identity     string          `json:"identity"`
	AuthMethod   CloudAuthMethod `json:"auth_method,omitempty"`
	Usage        []struct {
		UsageType      string `json:"usage_type"`
		Entity         string `json:"entity"`
		ExternalEntity string `json:"external_entity"`
	} `json:"usage"`
}

ExternalConnectionInfo is a struct for reply with connection info

type ExternalConnectionStatus

type ExternalConnectionStatus string

ExternalConnectionStatus is an enum

type GetHostsPoolAgentConfigParams

type GetHostsPoolAgentConfigParams struct {
	Name         string            `json:"name"`
	Backingstore *BackingStoreInfo `json:"backingstore,omitempty"`
}

GetHostsPoolAgentConfigParams is the params of pool_api.get_hosts_pool_agent_config()

type HostInfo

type HostInfo struct {
	Name string `json:"name"`
}

HostInfo is the information of a host(partial)

type IntRange

type IntRange struct {
	Min int32 `json:"min"`
	Max int32 `json:"max"`
}

IntRange Hold a min/max integer range

type ListAccountsReply

type ListAccountsReply struct {
	Accounts []*AccountInfo `json:"accounts"`
}

ListAccountsReply is the reply to account_api.list_accounts()

type ListBucketsReply

type ListBucketsReply struct {
	Buckets []struct {
		Name string `json:"name"`
	} `json:"buckets"`
}

ListBucketsReply is the reply of bucket_api.list_buckets()

type ListHostsParams

type ListHostsParams struct {
	Query ListHostsQuery `json:"query"`
}

ListHostsParams is the params to host_api.list_hosts()

type ListHostsQuery

type ListHostsQuery struct {
	Pools []string `json:"pools"`
}

ListHostsQuery is the query params to host_api.list_hosts()

type ListHostsReply

type ListHostsReply struct {
	Hosts []HostInfo `json:"hosts"`
}

ListHostsReply is the reply of host_api.list_hosts()

type NSFSConfig

type NSFSConfig struct {
	FsBackend  string `json:"fs_backend,omitempty"`
	FsRootPath string `json:"fs_root_path,omitempty"`
}

NSFSConfig is the namespace fs config needed for creating namespace resource of type fs()

type NamespaceBucketInfo

type NamespaceBucketInfo struct {
	WriteResource NamespaceResourceFullConfig   `json:"write_resource"`
	ReadResources []NamespaceResourceFullConfig `json:"read_resources,omitempty"`
	Caching       *CacheSpec                    `json:"caching,omitempty"`
}

NamespaceBucketInfo is the information needed for creating namespace bucket

type NamespaceResourceFullConfig

type NamespaceResourceFullConfig struct {
	Resource string `json:"resource"`
	Path     string `json:"path,omitempty"`
}

NamespaceResourceFullConfig is the resource configuration for creating namespace bucket

type NamespaceResourceInfo

type NamespaceResourceInfo struct {
	Name         string          `json:"name"`
	Mode         string          `json:"mode,omitempty"`
	Undeletable  string          `json:"undeletable,omitempty"`
	EndpointType EndpointType    `json:"endpoint_type,omitempty"`
	Endpoint     string          `json:"endpoint,omitempty"`
	TargetBucket string          `json:"target_bucket,omitempty"`
	Identity     string          `json:"identity,omitempty"`
	AuthMethod   CloudAuthMethod `json:"auth_method,omitempty"`
	CpCode       string          `json:"cp_code,omitempty"`
}

NamespaceResourceInfo is a struct of namespace resource info returned by the API

type NamespaceResourceOperatorInfo

type NamespaceResourceOperatorInfo struct {
	AccessKey   string `json:"access_key,omitempty"`
	SecretKey   string `json:"secret_key,omitempty"`
	NeedK8sSync bool   `json:"need_k8s_sync,omitempty"`
}

NamespaceResourceOperatorInfo is a struct of namespace resource secrets returned by the API

type NamespaceStoreInfo

type NamespaceStoreInfo struct {
	// Name describes backingstore name
	Name string `json:"name"`
	// Namespace describes backingstore namespace
	Namespace string `json:"namespace"`
}

NamespaceStoreInfo describes namespacestore info

type PoolHostsInfo

type PoolHostsInfo struct {
	// TODO encode/decode BigInt
	VolumeSize int64 `json:"volume_size"`
}

PoolHostsInfo is the config/info of a hosts pool

type PoolInfo

type PoolInfo struct {
	Name         string `json:"name"`
	ResourceType string `json:"resource_type"`
	Mode         string `json:"mode,omitempty"`
	Region       string `json:"region,omitempty"`
	PoolNodeType string `json:"pool_node_type,omitempty"`
	Undeletable  string `json:"undeletable,omitempty"`
	CloudInfo    *struct {
		EndpointType EndpointType    `json:"endpoint_type,omitempty"`
		Endpoint     string          `json:"endpoint,omitempty"`
		TargetBucket string          `json:"target_bucket,omitempty"`
		Identity     string          `json:"identity,omitempty"`
		NodeName     string          `json:"node_name,omitempty"`
		CreatedBy    string          `json:"created_by,omitempty"`
		Host         string          `json:"host,omitempty"`
		AuthMethod   CloudAuthMethod `json:"auth_method,omitempty"`
	} `json:"cloud_info,omitempty"`
	MongoInfo *map[string]interface{} `json:"mongo_info,omitempty"`
	HostInfo  *PoolHostsInfo          `json:"host_info,omitempty"`
	Hosts     *struct {
		ConfiguredCount int64 `json:"configured_count"`
		Count           int64 `json:"count"`
	} `json:"hosts,omitempty"`
}

PoolInfo is a struct of pool info returned by the API

type RPC

type RPC struct {
	HTTPClient  http.Client
	ConnMap     map[string]RPCConn
	ConnMapLock sync.Mutex
	Handler     RPCHandler
}

RPC is a struct that describes the relevant fields upon handeling rpc protocol

var GlobalRPC *RPC

GlobalRPC is the global rpc

func NewRPC

func NewRPC() *RPC

NewRPC initializes an RPC with defaults

func (*RPC) GetConnection

func (r *RPC) GetConnection(address string) RPCConn

GetConnection finds the connection related to the pending request or creates a new one

func (*RPC) RemoveConnection

func (r *RPC) RemoveConnection(conn RPCConn)

RemoveConnection removes the connection from the RPC connections map and start reconnecting

type RPCBuffer

type RPCBuffer struct {
	Name   string `json:"name,omitempty"`
	Length int32  `json:"len,omitempty"`
	Buffer []byte `json:"-"`
}

RPCBuffer is a struct that describes the fields related to an rpc buffer

type RPCClient

type RPCClient struct {
	RPC       *RPC
	Router    APIRouter
	AuthToken string
}

RPCClient makes API calls to noobaa. Requests to noobaa are plain http requests with json request and json response.

func (*RPCClient) AddExternalConnectionAPI

func (c *RPCClient) AddExternalConnectionAPI(params AddExternalConnectionParams) error

AddExternalConnectionAPI calls account_api.add_external_connection()

func (*RPCClient) Call

func (c *RPCClient) Call(req *RPCMessage, res RPCResponse) error

Call an API method to noobaa over wss or https protocol The response type should be defined to include RPCResponse inline. This is needed in order for json.Unmarshal() to decode into the reply structure.

func (*RPCClient) CheckExternalConnectionAPI

func (c *RPCClient) CheckExternalConnectionAPI(params AddExternalConnectionParams) (CheckExternalConnectionReply, error)

CheckExternalConnectionAPI calls account_api.check_external_connection()

func (*RPCClient) CreateAccountAPI

func (c *RPCClient) CreateAccountAPI(params CreateAccountParams) (CreateAccountReply, error)

CreateAccountAPI calls account_api.create_account()

func (*RPCClient) CreateAuthAPI

func (c *RPCClient) CreateAuthAPI(params CreateAuthParams) (CreateAuthReply, error)

CreateAuthAPI calls auth_api.create_auth()

func (*RPCClient) CreateBucketAPI

func (c *RPCClient) CreateBucketAPI(params CreateBucketParams) error

CreateBucketAPI calls bucket_api.create_bucket()

func (*RPCClient) CreateCloudPoolAPI

func (c *RPCClient) CreateCloudPoolAPI(params CreateCloudPoolParams) error

CreateCloudPoolAPI calls pool_api.create_cloud_pool()

func (*RPCClient) CreateHostsPoolAPI

func (c *RPCClient) CreateHostsPoolAPI(params CreateHostsPoolParams) (string, error)

CreateHostsPoolAPI calls pool_api.create_hosts_pool()

func (*RPCClient) CreateNamespaceResourceAPI

func (c *RPCClient) CreateNamespaceResourceAPI(params CreateNamespaceResourceParams) error

CreateNamespaceResourceAPI calls pool_api.create_namespace_resource()

func (*RPCClient) CreateSystemAPI

func (c *RPCClient) CreateSystemAPI(params CreateSystemParams) (CreateSystemReply, error)

CreateSystemAPI calls system_api.create_system()

func (*RPCClient) CreateTierAPI

func (c *RPCClient) CreateTierAPI(params CreateTierParams) error

CreateTierAPI calls tier_api.create_tier()

func (*RPCClient) CreateTieringPolicyAPI

func (c *RPCClient) CreateTieringPolicyAPI(params TieringPolicyInfo) error

CreateTieringPolicyAPI calls tiering_policy_api.create_policy()

func (*RPCClient) DeleteAccountAPI

func (c *RPCClient) DeleteAccountAPI(params DeleteAccountParams) error

DeleteAccountAPI calls account_api.delete_account()

func (*RPCClient) DeleteBucketAPI

func (c *RPCClient) DeleteBucketAPI(params DeleteBucketParams) error

DeleteBucketAPI calls bucket_api.delete_bucket()

func (*RPCClient) DeleteBucketAndObjectsAPI

func (c *RPCClient) DeleteBucketAndObjectsAPI(params DeleteBucketParams) error

DeleteBucketAndObjectsAPI calls bucket_api.delete_bucket()

func (*RPCClient) DeleteExternalConnectionAPI

func (c *RPCClient) DeleteExternalConnectionAPI(params DeleteExternalConnectionParams) error

DeleteExternalConnectionAPI calls account_api.delete_external_connection()

func (*RPCClient) DeleteNamespaceResourceAPI

func (c *RPCClient) DeleteNamespaceResourceAPI(params DeleteNamespaceResourceParams) error

DeleteNamespaceResourceAPI calls pool_api.delete_namespace_resource()

func (*RPCClient) DeletePoolAPI

func (c *RPCClient) DeletePoolAPI(params DeletePoolParams) error

DeletePoolAPI calls pool_api.delete_pool()

func (*RPCClient) EditExternalConnectionCredentialsAPI

func (c *RPCClient) EditExternalConnectionCredentialsAPI(params EditExternalConnectionCredentialsParams) error

EditExternalConnectionCredentialsAPI calls account_api.edit_external_connection_credentials()

func (*RPCClient) GetAuthToken

func (c *RPCClient) GetAuthToken() string

GetAuthToken is getting the client token for next calls

func (*RPCClient) GetHostsPoolAgentConfigAPI

func (c *RPCClient) GetHostsPoolAgentConfigAPI(params GetHostsPoolAgentConfigParams) (string, error)

GetHostsPoolAgentConfigAPI calls pool_api.get_hosts_pool_agent_config()

func (*RPCClient) ListAccountsAPI

func (c *RPCClient) ListAccountsAPI() (ListAccountsReply, error)

ListAccountsAPI calls account_api.list_accounts()

func (*RPCClient) ListBucketsAPI

func (c *RPCClient) ListBucketsAPI() (ListBucketsReply, error)

ListBucketsAPI calls bucket_api.list_buckets()

func (*RPCClient) ListHostsAPI

func (c *RPCClient) ListHostsAPI(params ListHostsParams) (ListHostsReply, error)

ListHostsAPI calls host_api.list_hosts()

func (*RPCClient) PutBucketReplicationAPI

func (c *RPCClient) PutBucketReplicationAPI(params BucketReplicationParams) error

PutBucketReplicationAPI calls bucket_api.put_bucket_replication()

func (*RPCClient) ReadAccountAPI

func (c *RPCClient) ReadAccountAPI(params ReadAccountParams) (AccountInfo, error)

ReadAccountAPI calls account_api.read_account()

func (*RPCClient) ReadAuthAPI

func (c *RPCClient) ReadAuthAPI() (ReadAuthReply, error)

ReadAuthAPI calls auth_api.read_auth()

func (*RPCClient) ReadBucketAPI

func (c *RPCClient) ReadBucketAPI(params ReadBucketParams) (BucketInfo, error)

ReadBucketAPI calls bucket_api.read_bucket()

func (*RPCClient) ReadNamespaceResourceAPI

func (c *RPCClient) ReadNamespaceResourceAPI(params ReadNamespaceResourceParams) (NamespaceResourceInfo, error)

ReadNamespaceResourceAPI calls pool_api.read_namespace_resource()

func (*RPCClient) ReadNamespaceResourceOperatorInfoAPI

func (c *RPCClient) ReadNamespaceResourceOperatorInfoAPI(params ReadNamespaceResourceParams) (NamespaceResourceOperatorInfo, error)

ReadNamespaceResourceOperatorInfoAPI calls pool_api.get_namespace_resource_operator_info()

func (*RPCClient) ReadPoolAPI

func (c *RPCClient) ReadPoolAPI(params ReadPoolParams) (PoolInfo, error)

ReadPoolAPI calls pool_api.read_pool()

func (*RPCClient) ReadSystemAPI

func (c *RPCClient) ReadSystemAPI() (SystemInfo, error)

ReadSystemAPI calls system_api.read_system()

func (*RPCClient) ReadSystemStatusAPI

func (c *RPCClient) ReadSystemStatusAPI() (ReadySystemStatusReply, error)

ReadSystemStatusAPI calls system_api.get_system_status()

func (*RPCClient) RegisterToCluster

func (c *RPCClient) RegisterToCluster() error

RegisterToCluster calls redirector_api.RegisterToCluster()

func (*RPCClient) SetAuthToken

func (c *RPCClient) SetAuthToken(token string)

SetAuthToken is setting the client token for next calls

func (*RPCClient) SetNamespaceStoreInfo

func (c *RPCClient) SetNamespaceStoreInfo(info NamespaceStoreInfo) error

SetNamespaceStoreInfo calls pool_api.set_namespace_store_info()

func (*RPCClient) UpdateAccountS3Access

func (c *RPCClient) UpdateAccountS3Access(params UpdateAccountS3AccessParams) error

UpdateAccountS3Access calls account_api.update_account_s3_access()

func (*RPCClient) UpdateAllBucketsDefaultPool

func (c *RPCClient) UpdateAllBucketsDefaultPool(params UpdateDefaultResourceParams) error

UpdateAllBucketsDefaultPool calls bucket_api.update_all_buckets_default_pool()

func (*RPCClient) UpdateBucketAPI

func (c *RPCClient) UpdateBucketAPI(params CreateBucketParams) error

UpdateBucketAPI calls bucket_api.update_bucket()

func (*RPCClient) UpdateBucketClass

func (c *RPCClient) UpdateBucketClass(params UpdateBucketClassParams) (BucketClassInfo, error)

UpdateBucketClass calls bucket_api.update_bucket_class()

func (*RPCClient) UpdateCloudPoolAPI

func (c *RPCClient) UpdateCloudPoolAPI(params UpdateCloudPoolParams) error

UpdateCloudPoolAPI calls pool_api.update_cloud_pool()

func (*RPCClient) UpdateEndpointGroupAPI

func (c *RPCClient) UpdateEndpointGroupAPI(params UpdateEndpointGroupParams) error

UpdateEndpointGroupAPI updates the noobaa core about endpoint configuration changes

func (*RPCClient) UpdateHostsPoolAPI

func (c *RPCClient) UpdateHostsPoolAPI(params UpdateHostsPoolParams) error

UpdateHostsPoolAPI calls pool_api.scale_hosts_pool()

func (*RPCClient) ValidateReplicationAPI

func (c *RPCClient) ValidateReplicationAPI(params BucketReplicationParams) error

ValidateReplicationAPI calls bucket_api.validate_replication()

type RPCConn

type RPCConn interface {
	// GetAddress returns the connection address
	GetAddress() string
	// Reonnect should make sure the connection is ready to be used
	Reconnect()
	// Call sends request and receives the response
	Call(req *RPCMessage, res RPCResponse) error
}

RPCConn is a common connection interface implemented by http and ws

type RPCConnHTTP

type RPCConnHTTP struct {
	RPC     *RPC
	Address string
}

RPCConnHTTP is an http connection which is created per request since the actual http connection pooling is handled in the standard http library

func NewRPCConnHTTP

func NewRPCConnHTTP(r *RPC, address string) *RPCConnHTTP

NewRPCConnHTTP returns a new http connection

func (*RPCConnHTTP) Call

func (c *RPCConnHTTP) Call(req *RPCMessage, res RPCResponse) error

Call calls an API method to noobaa over https

func (*RPCConnHTTP) GetAddress

func (c *RPCConnHTTP) GetAddress() string

GetAddress returns the connection address

func (*RPCConnHTTP) Reconnect

func (c *RPCConnHTTP) Reconnect()

Reconnect is doing nothing for http connection

type RPCConnWS

type RPCConnWS struct {
	RPC             *RPC
	Address         string
	State           string
	WS              *websocket.Conn
	PendingRequests map[string]*RPCPendingRequest
	NextRequestID   uint64
	Lock            sync.Mutex
	ReconnectDelay  time.Duration
}

RPCConnWS is an websocket connection which is shared and multiplexed for all concurrent requests to the same address

func NewRPCConnWS

func NewRPCConnWS(r *RPC, address string) *RPCConnWS

NewRPCConnWS returns a new websocket connection

func (*RPCConnWS) Call

func (c *RPCConnWS) Call(req *RPCMessage, res RPCResponse) error

Call calls an API method to noobaa over wss

func (*RPCConnWS) Close

func (c *RPCConnWS) Close()

Close locks the connection and call close

func (*RPCConnWS) CloseUnderLock

func (c *RPCConnWS) CloseUnderLock()

CloseUnderLock closes the connection

func (*RPCConnWS) ConnectUnderLock

func (c *RPCConnWS) ConnectUnderLock() error

ConnectUnderLock is opening a ws connection for new connection or after the previous one closed it can delay the reconnect attempts in case of repeated failures such as when the host is unreachable, etc.

func (*RPCConnWS) GetAddress

func (c *RPCConnWS) GetAddress() string

GetAddress returns the connection address

func (*RPCConnWS) HandlePing

func (c *RPCConnWS) HandlePing(msg *RPCMessage)

HandlePing handles an incoming message of type ping

func (*RPCConnWS) HandleRequest

func (c *RPCConnWS) HandleRequest(req *RPCMessage)

HandleRequest handles an incoming message of type request

func (*RPCConnWS) HandleResponse

func (c *RPCConnWS) HandleResponse(msg *RPCMessage)

HandleResponse handles an incoming message of type response

func (*RPCConnWS) NewRequest

func (c *RPCConnWS) NewRequest(req *RPCMessage, res RPCResponse) chan error

NewRequest initializes the request id and register it on the connection pending requests

func (*RPCConnWS) ReadMessage

func (c *RPCConnWS) ReadMessage() (*RPCMessage, error)

ReadMessage handles a message

func (*RPCConnWS) ReadMessages

func (c *RPCConnWS) ReadMessages()

ReadMessages handles incoming messages

func (*RPCConnWS) Reconnect

func (c *RPCConnWS) Reconnect()

Reconnect connects after setting a delay

func (*RPCConnWS) SendMessage

func (c *RPCConnWS) SendMessage(msg interface{}) error

SendMessage sends the pending request

type RPCError

type RPCError struct {
	RPCCode string `json:"rpc_code,omitempty"`
	Message string `json:"message"`
}

RPCError is a struct sent by noobaa servers to denote an error response.

func (*RPCError) Error

func (e *RPCError) Error() string

Error is implementing the standard error type interface

type RPCHandler

type RPCHandler func(req *RPCMessage) (interface{}, error)

RPCHandler is the interface for RPCHandler struct

type RPCMessage

type RPCMessage struct {
	Op        string      `json:"op"`
	API       string      `json:"api,omitempty"`
	Method    string      `json:"method,omitempty"`
	RequestID string      `json:"reqid,omitempty"`
	AuthToken string      `json:"auth_token,omitempty"`
	Took      float64     `json:"took,omitempty"`
	Error     *RPCError   `json:"error,omitempty"`
	Params    interface{} `json:"params,omitempty"`
	Buffers   []RPCBuffer `json:"buffers,omitempty"`
	RawBytes  []byte      `json:"-"`
}

RPCMessage structure encoded in every RPC message

func (*RPCMessage) Response

func (msg *RPCMessage) Response() *RPCMessage

Response is implementing the RPCResponse interface

func (*RPCMessage) SetBuffers

func (msg *RPCMessage) SetBuffers(buffers []byte)

SetBuffers assigns the buffers from the message and slices them to the message buffers

type RPCMessageReply

type RPCMessageReply struct {
	RPCMessage `json:",inline"`
	Reply      interface{} `json:"reply,omitempty"`
}

RPCMessageReply structure encoded in every RPC message that contains reply

type RPCPendingRequest

type RPCPendingRequest struct {
	Conn      *RPCConnWS
	Req       *RPCMessage
	Res       RPCResponse
	ReplyChan chan error
}

RPCPendingRequest is a struct that describes the fields related to an rpc pending requests

type RPCResponse

type RPCResponse interface {
	Response() *RPCMessage
}

RPCResponse is the interface for response structs. RPCMessage is the only real implementor of it.

type ReadAccountParams

type ReadAccountParams struct {
	Email string `json:"email"`
}

ReadAccountParams is the params to account_api.read_account()

type ReadAuthReply

type ReadAuthReply struct {
	Account struct {
		Name               string `json:"name"`
		Email              string `json:"email"`
		IsSupport          bool   `json:"is_support"`
		MustChangePassword bool   `json:"must_change_password"`
	} `json:"account"`
	System struct {
		Name string `json:"name"`
	} `json:"system"`
	AuthorizedBy string                 `json:"authorized_by"`
	Role         string                 `json:"role"`
	Extra        map[string]interface{} `json:"extra"`
}

ReadAuthReply is the reply of auth_api.read_auth()

type ReadBucketParams

type ReadBucketParams struct {
	Name string `json:"name"`
}

ReadBucketParams is the params to bucket_api.read_bucket()

type ReadNamespaceResourceParams

type ReadNamespaceResourceParams struct {
	Name string `json:"name"`
}

ReadNamespaceResourceParams is the params to pool_api.read_namespace_resource()

type ReadPoolParams

type ReadPoolParams struct {
	Name string `json:"name"`
}

ReadPoolParams is the params to pool_api.read_pool()

type ReadySystemStatusReply

type ReadySystemStatusReply struct {
	State string `json:"state,omitempty"`
}

ReadySystemStatusReply is the reply to system_pai.get_system_status()

type S3AccessKeys

type S3AccessKeys struct {
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
}

S3AccessKeys is a struct holding S3 access and secret keys

type SimpleRouter

type SimpleRouter struct {
	Address string
}

SimpleRouter is a basic router

func (*SimpleRouter) GetAddress

func (r *SimpleRouter) GetAddress(api string) string

GetAddress implements the router

type StorageInfo

type StorageInfo struct {
	Total           *BigInt `json:"total,omitempty"`
	Free            *BigInt `json:"free,omitempty"`
	UnavailableFree *BigInt `json:"unavailable_free,omitempty"`
	UnavailableUsed *BigInt `json:"unavailable_used,omitempty"`
	Used            *BigInt `json:"used,omitempty"`
	UsedOther       *BigInt `json:"used_other,omitempty"`
	UsedReduced     *BigInt `json:"used_reduced,omitempty"`
	Alloc           *BigInt `json:"alloc,omitempty"`
	Limit           *BigInt `json:"limit,omitempty"`
	Reserved        *BigInt `json:"reserved,omitempty"`
	Real            *BigInt `json:"real,omitempty"`
}

StorageInfo contains storage capacity information with specific break down

type SystemInfo

type SystemInfo struct {
	Accounts           []AccountInfo           `json:"accounts"`
	Buckets            []BucketInfo            `json:"buckets"`
	Pools              []PoolInfo              `json:"pools"`
	Tiers              []TierInfo              `json:"tiers"`
	Version            string                  `json:"version"`
	NamespaceResources []NamespaceResourceInfo `json:"namespace_resources"`
}

SystemInfo is a struct of system info returned by the API

type TierInfo

type TierInfo struct {
	Name             string            `json:"name"`
	DataPlacement    string            `json:"data_placement,omitempty"`
	AttachedPools    []string          `json:"attached_pools,omitempty"`
	ChunkCoderConfig *ChunkCoderConfig `json:"chunk_coder_config,omitempty"`
	DataCapacity     *StorageInfo      `json:"data,omitempty"`
	StorageCapacity  *StorageInfo      `json:"storage,omitempty"`
}

TierInfo is the information of a tier

type TierItem

type TierItem struct {
	Order int64  `json:"order"`
	Tier  string `json:"tier"`
	Mode  string `json:"mode,omitempty"`
}

TierItem is an item in a tiering policy

type TieringPolicyInfo

type TieringPolicyInfo struct {
	Name             string            `json:"name"`
	Tiers            []TierItem        `json:"tiers"`
	ChunkSplitConfig *ChunkSplitConfig `json:"chunk_split_config,omitempty"`
	DataCapacity     *StorageInfo      `json:"data,omitempty"`
	StorageCapacity  *StorageInfo      `json:"storage,omitempty"`
	Mode             string            `json:"mode,omitempty"`
}

TieringPolicyInfo is the information of a tiering policy

type UpdateAccountS3AccessParams

type UpdateAccountS3AccessParams struct {
	Email               string          `json:"email"`
	S3Access            bool            `json:"s3_access"`
	DefaultResource     *string         `json:"default_resource,omitempty"`
	AllowBucketCreation *bool           `json:"allow_bucket_creation,omitempty"`
	AllowBuckets        *AllowedBuckets `json:"allowed_buckets,omitempty"`
}

UpdateAccountS3AccessParams is the params of account_api.update_account_s3_access()

type UpdateBucketClassParams

type UpdateBucketClassParams struct {
	Name   string            `json:"name"`
	Policy TieringPolicyInfo `json:"policy"`
	Tiers  []TierInfo        `json:"tiers"`
}

UpdateBucketClassParams is the params of tiering_policy_api.update_bucket_class()

type UpdateCloudPoolParams

type UpdateCloudPoolParams struct {
	Name              string  `json:"name"`
	AvailableCapacity *BigInt `json:"available_capacity,omitempty"`
}

UpdateCloudPoolParams is the params of pool_api.create_cloud_pool()

type UpdateDefaultResourceParams

type UpdateDefaultResourceParams struct {
	PoolName string `json:"pool_name"`
}

UpdateDefaultResourceParams is the params of bucket_api.update_all_buckets_default_pool()

type UpdateEndpointGroupParams

type UpdateEndpointGroupParams struct {
	GroupName     string   `json:"group_name"`
	IsRemote      bool     `json:"is_remote"`
	Region        string   `json:"region"`
	EndpointRange IntRange `json:"endpoint_range"`
}

UpdateEndpointGroupParams is the params of system_api.update_endpoint_group()

type UpdateHostsPoolParams

type UpdateHostsPoolParams struct {
	Name         string            `json:"name"`
	Backingstore *BackingStoreInfo `json:"backingstore,omitempty"`
}

UpdateHostsPoolParams is the params of pool_api.update_hosts_pool()

Jump to

Keyboard shortcuts

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