client

package
v0.33.4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Overview

Example (Error)
package main

import (
	"context"
	"fmt"
	"net/url"

	"github.com/LINBIT/golinstor/client"
	log "github.com/sirupsen/logrus"
)

func main() {
	ctx := context.TODO()

	u, err := url.Parse("http://controller:3370")
	if err != nil {
		log.Fatal(err)
	}

	c, err := client.NewClient(client.BaseURL(u), client.Log(log.StandardLogger()))
	if err != nil {
		log.Fatal(err)
	}

	rs, err := c.Resources.GetAll(ctx, "foo")
	if errs, ok := err.(client.ApiCallError); ok {
		log.Error("A LINSTOR API error occurred:")
		for i, e := range errs {
			log.Errorf("  Message #%d:", i)
			log.Errorf("    Code: %d", e.RetCode)
			log.Errorf("    Message: %s", e.Message)
			log.Errorf("    Cause: %s", e.Cause)
			log.Errorf("    Details: %s", e.Details)
			log.Errorf("    Correction: %s", e.Correction)
			log.Errorf("    Error Reports: %v", e.ErrorReportIds)
		}
		return
	}
	if err != nil {
		log.Fatalf("Some other error occurred: %s", err.Error())
	}

	for _, r := range rs {
		fmt.Printf("Resource with name '%s' on node with name '%s'\n", r.Name, r.NodeName)
	}
}
Output:

Example (Events)
package main

import (
	"context"
	"fmt"
	"net/url"

	"github.com/LINBIT/golinstor/client"
	log "github.com/sirupsen/logrus"
)

func main() {
	ctx := context.TODO()

	u, err := url.Parse("http://controller:3370")
	if err != nil {
		log.Fatal(err)
	}

	c, err := client.NewClient(client.BaseURL(u))
	if err != nil {
		log.Fatal(err)
	}

	mayPromoteStream, err := c.Events.DRBDPromotion(ctx, "")
	if err != nil {
		log.Fatal(err)
	}
	defer mayPromoteStream.Close()

	for ev := range mayPromoteStream.Events {
		fmt.Printf("Resource '%s' on node with name '%s' may promote: %t\n", ev.ResourceName, ev.NodeName, ev.MayPromote)
	}
}
Output:

Example (Https)
package main

import (
	"context"
	"crypto/tls"
	"fmt"
	"net/http"
	"net/url"

	"github.com/LINBIT/golinstor/client"
	log "github.com/sirupsen/logrus"
)

func main() {
	ctx := context.TODO()

	u, err := url.Parse("https://controller:3371")
	if err != nil {
		log.Fatal(err)
	}

	// Be careful if that is really what you want!
	trSkipVerify := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	httpClient := &http.Client{
		Transport: trSkipVerify,
	}

	c, err := client.NewClient(client.BaseURL(u), client.HTTPClient(httpClient))
	if err != nil {
		log.Fatal(err)
	}

	rs, err := c.Resources.GetAll(ctx, "foo")
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range rs {
		fmt.Printf("Resource with name '%s' on node with name '%s'\n", r.Name, r.NodeName)
	}
}
Output:

Example (Httpsauth)
package main

import (
	"context"
	"crypto/tls"
	"fmt"
	"net/http"
	"net/url"

	"github.com/LINBIT/golinstor/client"
	log "github.com/sirupsen/logrus"
)

func main() {
	ctx := context.TODO()

	u, err := url.Parse("https://controller:3371")
	if err != nil {
		log.Fatal(err)
	}

	// Be careful if that is really what you want!
	trSkipVerify := &http.Transport{
		TLSClientConfig: &tls.Config{
			InsecureSkipVerify: true,
		},
	}
	httpClient := &http.Client{
		Transport: trSkipVerify,
	}

	c, err := client.NewClient(client.BaseURL(u), client.HTTPClient(httpClient),
		client.BasicAuth(&client.BasicAuthCfg{Username: "Username", Password: "Password"}))
	if err != nil {
		log.Fatal(err)
	}

	rs, err := c.Resources.GetAll(ctx, "foo")
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range rs {
		fmt.Printf("Resource with name '%s' on node with name '%s'\n", r.Name, r.NodeName)
	}
}
Output:

Example (Simple)
package main

import (
	"context"
	"fmt"
	"net/url"

	"github.com/LINBIT/golinstor/client"
	log "github.com/sirupsen/logrus"
)

func main() {
	ctx := context.TODO()

	u, err := url.Parse("http://controller:3370")
	if err != nil {
		log.Fatal(err)
	}

	c, err := client.NewClient(client.BaseURL(u), client.Log(log.StandardLogger()))
	if err != nil {
		log.Fatal(err)
	}

	rs, err := c.Resources.GetAll(ctx, "foo")
	if err != nil {
		log.Fatal(err)
	}

	for _, r := range rs {
		fmt.Printf("Resource with name '%s' on node with name '%s'\n", r.Name, r.NodeName)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// NotFoundError is the error type returned in case of a 404 error. This is required to test for this kind of error.
	NotFoundError = clientError("404 Not Found")
	// Name of the environment variable that stores the certificate used for TLS client authentication
	UserCertEnv = "LS_USER_CERTIFICATE"
	// Name of the environment variable that stores the key used for TLS client authentication
	UserKeyEnv = "LS_USER_KEY"
	// Name of the environment variable that stores the certificate authority for the LINSTOR HTTPS API
	RootCAEnv = "LS_ROOT_CA"
	// Name of the environment variable that holds the URL(s) of LINSTOR controllers
	ControllerUrlEnv = "LS_CONTROLLERS"
	// Name of the environment variable that holds the username for authentication
	UsernameEnv = "LS_USERNAME"
	// Name of the environment variable that holds the password for authentication
	PasswordEnv = "LS_PASSWORD"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiCallError

type ApiCallError []ApiCallRc

func (ApiCallError) Error

func (e ApiCallError) Error() string

func (ApiCallError) Is

func (e ApiCallError) Is(mask uint64) bool

Is is a shorthand for checking all ApiCallRcs of an ApiCallError against a given mask.

type ApiCallRc

type ApiCallRc struct {
	// A masked error number
	RetCode int64  `json:"ret_code"`
	Message string `json:"message"`
	// Cause of the error
	Cause string `json:"cause,omitempty"`
	// Details to the error message
	Details string `json:"details,omitempty"`
	// Possible correction options
	Correction string `json:"correction,omitempty"`
	// List of error report ids related to this api call return code.
	ErrorReportIds []string `json:"error_report_ids,omitempty"`
	// Map of objection that have been involved by the operation.
	ObjRefs map[string]string `json:"obj_refs,omitempty"`
}

ApiCallRc represents the struct returned by LINSTOR, when accessing its REST API.

func (ApiCallRc) Is

func (r ApiCallRc) Is(mask uint64) bool

Is can be used to check the return code against a given mask. Since LINSTOR return codes are designed to be machine readable, this can be used to check for a very specific type of error. Refer to package apiconsts.go in package linstor for a list of possible mask values.

func (*ApiCallRc) String

func (rc *ApiCallRc) String() string

type AutoPlaceRequest

type AutoPlaceRequest struct {
	DisklessOnRemaining bool             `json:"diskless_on_remaining,omitempty"`
	SelectFilter        AutoSelectFilter `json:"select_filter,omitempty"`
	LayerList           []LayerType      `json:"layer_list,omitempty"`
}

AutoPlaceRequest is a struct to store the paramters for the linstor auto-place command

type AutoSelectFilter

type AutoSelectFilter struct {
	PlaceCount           int32    `json:"place_count,omitempty"`
	NodeNameList         []string `json:"node_name_list,omitempty"`
	StoragePool          string   `json:"storage_pool,omitempty"`
	StoragePoolList      []string `json:"storage_pool_list,omitempty"`
	NotPlaceWithRsc      []string `json:"not_place_with_rsc,omitempty"`
	NotPlaceWithRscRegex string   `json:"not_place_with_rsc_regex,omitempty"`
	ReplicasOnSame       []string `json:"replicas_on_same,omitempty"`
	ReplicasOnDifferent  []string `json:"replicas_on_different,omitempty"`
	LayerStack           []string `json:"layer_stack,omitempty"`
	ProviderList         []string `json:"provider_list,omitempty"`
	DisklessOnRemaining  bool     `json:"diskless_on_remaining,omitempty"`
}

AutoSelectFilter is a struct used to have information about the auto-select function

type BasicAuthCfg

type BasicAuthCfg struct {
	Username, Password string
}

type CacheResource

type CacheResource struct {
	CacheVolumes []CacheVolume `json:"cache_volumes,omitempty"`
}

type CacheVolume

type CacheVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath string `json:"device_path,omitempty"`
	// block device path used as cache device
	DevicePathCache string `json:"device_path_cache,omitempty"`
	// block device path used as meta device
	DeviceMetaCache  string `json:"device_meta_cache,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
}

type Candidate

type Candidate struct {
	StoragePool string `json:"storage_pool,omitempty"`
	// maximum size in KiB
	MaxVolumeSizeKib int64    `json:"max_volume_size_kib,omitempty"`
	NodeNames        []string `json:"node_names,omitempty"`
	AllThin          bool     `json:"all_thin,omitempty"`
}

Candidate struct for Candidate

type Client

type Client struct {
	Nodes                  *NodeService
	ResourceDefinitions    *ResourceDefinitionService
	Resources              *ResourceService
	ResourceGroups         *ResourceGroupService
	StoragePoolDefinitions *StoragePoolDefinitionService
	Encryption             *EncryptionService
	Controller             *ControllerService
	Events                 *EventService
	// contains filtered or unexported fields
}

Client is a struct representing a LINSTOR REST client.

func NewClient

func NewClient(options ...Option) (*Client, error)

NewClient takes an arbitrary number of options and returns a Client or an error. It recognizes several environment variables which can be used to configure the client at runtime:

- LS_CONTROLLERS: a comma-separated list of LINSTOR controllers to connect to. Currently, golinstor will only use the first one.

- LS_USERNAME, LS_PASSWORD: can be used to authenticate against the LINSTOR controller using HTTP basic authentication.

- LS_USER_CERTIFICATE, LS_USER_KEY, LS_ROOT_CA: can be used to enable TLS on the HTTP client, enabling encrypted communication with the LINSTOR controller.

Options passed to NewClient take precedence over options passed in via environment variables.

type ControllerConfig

type ControllerConfig struct {
	Config ControllerConfigConfig `json:"config,omitempty" toml:"config,omitempty,omitzero"`
	Debug  ControllerConfigDebug  `json:"debug,omitempty" toml:"debug,omitempty,omitzero"`
	Log    ControllerConfigLog    `json:"log,omitempty" toml:"log,omitempty,omitzero"`
	Db     ControllerConfigDb     `json:"db,omitempty" toml:"db,omitempty,omitzero"`
	Http   ControllerConfigHttp   `json:"http,omitempty" toml:"http,omitempty,omitzero"`
	Https  ControllerConfigHttps  `json:"https,omitempty" toml:"https,omitempty,omitzero"`
	Ldap   ControllerConfigLdap   `json:"ldap,omitempty" toml:"ldap,omitempty,omitzero"`
}

type ControllerConfigConfig

type ControllerConfigConfig struct {
	Dir string `json:"dir,omitempty" toml:"dir,omitempty,omitzero"`
}

type ControllerConfigDb

type ControllerConfigDb struct {
	ConnectionUrl        string                 `json:"connection_url,omitempty" toml:"connection_url,omitempty,omitzero"`
	CaCertificate        string                 `json:"ca_certificate,omitempty" toml:"ca_certificate,omitempty,omitzero"`
	ClientCertificate    string                 `json:"client_certificate,omitempty" toml:"client_certificate,omitempty,omitzero"`
	ClientKeyPkcs8Pem    string                 `json:"client_key_pkcs8_pem,omitempty" toml:"client_key_pkcs8_pem,omitempty,omitzero"`
	InMemory             string                 `json:"in_memory,omitempty" toml:"in_memory,omitempty,omitzero"`
	VersionCheckDisabled bool                   `json:"version_check_disabled,omitempty" toml:"version_check_disabled,omitempty,omitzero"`
	Etcd                 ControllerConfigDbEtcd `json:"etcd,omitempty" toml:"etcd,omitempty,omitzero"`
}

type ControllerConfigDbEtcd

type ControllerConfigDbEtcd struct {
	OperationsPerTransaction int32  `json:"operations_per_transaction,omitempty" toml:"operations_per_transaction,omitempty,omitzero"`
	Prefix                   string `json:"prefix,omitempty" toml:"prefix,omitempty,omitzero"`
}

type ControllerConfigDebug

type ControllerConfigDebug struct {
	ConsoleEnabled bool `json:"console_enabled,omitempty" toml:"console_enabled,omitempty,omitzero"`
}

type ControllerConfigHttp

type ControllerConfigHttp struct {
	Enabled       bool   `json:"enabled,omitempty" toml:"enabled,omitempty,omitzero"`
	ListenAddress string `json:"listen_address,omitempty" toml:"listen_address,omitempty,omitzero"`
	Port          int32  `json:"port,omitempty" toml:"port,omitempty,omitzero"`
}

type ControllerConfigHttps

type ControllerConfigHttps struct {
	Enabled            bool   `json:"enabled,omitempty" toml:"enabled,omitempty,omitzero"`
	ListenAddress      string `json:"listen_address,omitempty" toml:"listen_address,omitempty,omitzero"`
	Port               int32  `json:"port,omitempty" toml:"port,omitempty,omitzero"`
	Keystore           string `json:"keystore,omitempty" toml:"keystore,omitempty,omitzero"`
	KeystorePassword   string `json:"keystore_password,omitempty" toml:"keystore_password,omitempty,omitzero"`
	Truststore         string `json:"truststore,omitempty" toml:"truststore,omitempty,omitzero"`
	TruststorePassword string `json:"truststore_password,omitempty" toml:"truststore_password,omitempty,omitzero"`
}

type ControllerConfigLdap

type ControllerConfigLdap struct {
	Enabled             bool   `json:"enabled,omitempty" toml:"enabled,omitempty,omitzero"`
	PublicAccessAllowed bool   `json:"public_access_allowed,omitempty" toml:"public_access_allowed,omitempty,omitzero"`
	Uri                 string `json:"uri,omitempty" toml:"uri,omitempty,omitzero"`
	Dn                  string `json:"dn,omitempty" toml:"dn,omitempty,omitzero"`
	SearchBase          string `json:"search_base,omitempty" toml:"search_base,omitempty,omitzero"`
	SearchFilter        string `json:"search_filter,omitempty" toml:"search_filter,omitempty,omitzero"`
}

type ControllerConfigLog

type ControllerConfigLog struct {
	PrintStackTrace    bool     `json:"print_stack_trace,omitempty" toml:"print_stack_trace,omitempty,omitzero"`
	Directory          string   `json:"directory,omitempty" toml:"directory,omitempty,omitzero"`
	Level              LogLevel `json:"level,omitempty" toml:"level,omitempty,omitzero"`
	LevelGlobal        LogLevel `json:"level_global,omitempty" toml:"level_global,omitempty,omitzero"`
	LevelLinstor       LogLevel `json:"level_linstor,omitempty" toml:"level_linstor,omitempty,omitzero"`
	LevelLinstorGlobal LogLevel `json:"level_linstor_global,omitempty" toml:"level_linstor_global,omitempty,omitzero"`
	RestAccessLogPath  string   `json:"rest_access_log_path,omitempty" toml:"rest_access_log_path,omitempty,omitzero"`
	RestAccessMode     string   `json:"rest_access_mode,omitempty" toml:"rest_access_mode,omitempty,omitzero"`
}

type ControllerProps

type ControllerProps map[string]string

type ControllerService

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

ControllerService is the service that deals with the LINSTOR controller.

func (*ControllerService) CreateSOSReport

func (s *ControllerService) CreateSOSReport(ctx context.Context, opts ...*ListOpts) error

CreateSOSReport creates an SOS report in the log directory of the controller

func (*ControllerService) DeleteErrorReports

func (s *ControllerService) DeleteErrorReports(ctx context.Context, del ErrorReportDelete) error

DeleteErrorReports deletes error reports as specified by the ErrorReportDelete struct.

func (*ControllerService) DeleteProp

func (s *ControllerService) DeleteProp(ctx context.Context, prop string) error

DeleteProp deletes the given property/key from the controller object.

func (*ControllerService) DownloadSOSReport

func (s *ControllerService) DownloadSOSReport(ctx context.Context, opts ...*ListOpts) error

DownloadSOSReport request sos report to download

func (*ControllerService) GetConfig

func (s *ControllerService) GetConfig(ctx context.Context, opts ...*ListOpts) (ControllerConfig, error)

GetConfig queries the configuration of a controller

func (*ControllerService) GetErrorReport

func (s *ControllerService) GetErrorReport(ctx context.Context, id string, opts ...*ListOpts) (ErrorReport, error)

GetErrorReport returns a specific error report, including its text.

func (*ControllerService) GetErrorReports

func (s *ControllerService) GetErrorReports(ctx context.Context, opts ...*ListOpts) ([]ErrorReport, error)

GetErrorReports returns all error reports. The Text field is not populated, use GetErrorReport to get the text of an error report.

func (*ControllerService) GetErrorReportsSince

func (s *ControllerService) GetErrorReportsSince(ctx context.Context, since time.Time, opts ...*ListOpts) ([]ErrorReport, error)

GetErrorReportsSince returns all error reports created after a certain point in time.

func (*ControllerService) GetProps

func (s *ControllerService) GetProps(ctx context.Context, opts ...*ListOpts) (ControllerProps, error)

GetProps gets all properties of a controller

func (*ControllerService) GetSatelliteConfig

func (s *ControllerService) GetSatelliteConfig(ctx context.Context, node string) (SatelliteConfig, error)

func (*ControllerService) GetVersion

func (s *ControllerService) GetVersion(ctx context.Context, opts ...*ListOpts) (ControllerVersion, error)

GetVersion queries version information for the controller.

func (*ControllerService) Modify

Modify modifies the controller node and sets/deletes the given properties.

func (*ControllerService) ModifySatelliteConfig

func (s *ControllerService) ModifySatelliteConfig(ctx context.Context, node string, cfg SatelliteConfig) error

type ControllerVersion

type ControllerVersion struct {
	Version        string `json:"version,omitempty"`
	GitHash        string `json:"git_hash,omitempty"`
	BuildTime      string `json:"build_time,omitempty"`
	RestApiVersion string `json:"rest_api_version,omitempty"`
}

ControllerVersion represents version information of the LINSTOR controller

type DRBDMayPromoteStream

type DRBDMayPromoteStream struct {
	Events chan EventMayPromoteChange
	// contains filtered or unexported fields
}

DRBDMayPromoteStream is a struct that contains a channel of EventMayPromoteChange events It has a Close() method that needs to be called/defered.

func (*DRBDMayPromoteStream) Close

func (dmp *DRBDMayPromoteStream) Close()

Close is used to close the underlying stream and all Go routines

type DeleteNamespaces

type DeleteNamespaces []string

Namespaces to delete

type DeleteProps

type DeleteProps []string

DeleteProps is a slice of properties to delete.

type DrbdConnection

type DrbdConnection struct {
	Connected bool `json:"connected,omitempty"`
	// DRBD connection status
	Message string `json:"message,omitempty"`
}

DrbdConnection is a struct representing the DRBD connection status

type DrbdProxyModify

type DrbdProxyModify struct {
	// Compression type used by the proxy.
	CompressionType string `json:"compression_type,omitempty"`
	// A string to string property map.
	CompressionProps map[string]string `json:"compression_props,omitempty"`
	GenericPropsModify
}

type DrbdResource

type DrbdResource struct {
	DrbdResourceDefinition DrbdResourceDefinitionLayer `json:"drbd_resource_definition,omitempty"`
	NodeId                 int32                       `json:"node_id,omitempty"`
	PeerSlots              int32                       `json:"peer_slots,omitempty"`
	AlStripes              int32                       `json:"al_stripes,omitempty"`
	AlSize                 int64                       `json:"al_size,omitempty"`
	Flags                  []string                    `json:"flags,omitempty"`
	DrbdVolumes            []DrbdVolume                `json:"drbd_volumes,omitempty"`
	Connections            map[string]DrbdConnection   `json:"connections,omitempty"`
	PromotionScore         int32                       `json:"promotion_score,omitempty"`
	MayPromote             bool                        `json:"may_promote,omitempty"`
}

DrbdResource is a struct used to give linstor drbd properties for a resource

type DrbdResourceDefinitionLayer

type DrbdResourceDefinitionLayer struct {
	ResourceNameSuffix string `json:"resource_name_suffix,omitempty"`
	PeerSlots          int32  `json:"peer_slots,omitempty"`
	AlStripes          int64  `json:"al_stripes,omitempty"`
	// used drbd port for this resource
	Port          int32  `json:"port,omitempty"`
	TransportType string `json:"transport_type,omitempty"`
	// drbd resource secret
	Secret string `json:"secret,omitempty"`
	Down   bool   `json:"down,omitempty"`
}

DrbdResourceDefinitionLayer is a struct which contains the information about the layertype of a resource-definition on drbd level

type DrbdVolume

type DrbdVolume struct {
	DrbdVolumeDefinition DrbdVolumeDefinition `json:"drbd_volume_definition,omitempty"`
	// drbd device path e.g. '/dev/drbd1000'
	DevicePath string `json:"device_path,omitempty"`
	// block device used by drbd
	BackingDevice    string `json:"backing_device,omitempty"`
	MetaDisk         string `json:"meta_disk,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
	// Storage pool name used for external meta data; null for internal
	ExtMetaStorPool string `json:"ext_meta_stor_pool,omitempty"`
}

DrbdVolume is a struct for linstor to get inormation about a drbd-volume

type DrbdVolumeDefinition

type DrbdVolumeDefinition struct {
	ResourceNameSuffix string `json:"resource_name_suffix,omitempty"`
	VolumeNumber       int32  `json:"volume_number,omitempty"`
	MinorNumber        int32  `json:"minor_number,omitempty"`
}

DrbdVolumeDefinition is a struct containing volume-definition on drbd level

type EncryptionService

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

EncryptionService is the service that deals with encyrption related tasks.

func (*EncryptionService) Create

func (n *EncryptionService) Create(ctx context.Context, passphrase Passphrase) error

Create creates an encryption with the given passphrase

func (*EncryptionService) Enter

func (n *EncryptionService) Enter(ctx context.Context, password string) error

Enter is used to enter a password so that content can be decrypted

func (*EncryptionService) Modify

func (n *EncryptionService) Modify(ctx context.Context, passphrase Passphrase) error

Modify modifies an existing passphrase

type ErrorReport

type ErrorReport struct {
	NodeName  string `json:"node_name,omitempty"`
	ErrorTime int64  `json:"error_time"`
	// Filename of the error report on the server.  Format is: “`ErrorReport-{instanceid}-{nodeid}-{sequencenumber}.log“`
	Filename string `json:"filename,omitempty"`
	// Contains the full text of the error report file.
	Text string `json:"text,omitempty"`
	// Which module this error occurred.
	Module string `json:"module,omitempty"`
	// Linstor version this error report was created.
	Version string `json:"version,omitempty"`
	// Peer client that was involved.
	Peer string `json:"peer,omitempty"`
	// Exception that occurred
	Exception string `json:"exception,omitempty"`
	// Exception message
	ExceptionMessage string `json:"exception_message,omitempty"`
	// Origin file of the exception
	OriginFile string `json:"origin_file,omitempty"`
	// Origin method where the exception occurred
	OriginMethod string `json:"origin_method,omitempty"`
	// Origin line number
	OriginLine int32 `json:"origin_line,omitempty"`
}

ErrorReport struct for ErrorReport

type ErrorReportDelete

type ErrorReportDelete struct {
	// timestamp in millis start date to delete
	Since int64 `json:"since,omitempty"`
	// timestamp in millis for the end date to delete
	To int64 `json:"to,omitempty"`
	// on which nodes to delete error-reports, if empty/null all nodes
	Nodes []string `json:"nodes,omitempty"`
	// delete all error reports with the given exception
	Exception string `json:"exception,omitempty"`
	// delete all error reports from the given version
	Version string `json:"version,omitempty"`
	// error report ids to delete
	Ids []string `json:"ids,omitempty"`
}

type EventMayPromoteChange

type EventMayPromoteChange struct {
	ResourceName string `json:"resource_name,omitempty"`
	NodeName     string `json:"node_name,omitempty"`
	MayPromote   bool   `json:"may_promote,omitempty"`
}

type EventService

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

EventService is the service that deals with LINSTOR server side event streams.

func (*EventService) DRBDPromotion

func (e *EventService) DRBDPromotion(ctx context.Context, lastEventId string) (*DRBDMayPromoteStream, error)

DRBDPromotion is used to subscribe to LINSTOR DRBD Promotion events

type GenericPropsModify

type GenericPropsModify struct {
	DeleteProps      DeleteProps      `json:"delete_props,omitempty"`
	OverrideProps    OverrideProps    `json:"override_props,omitempty"`
	DeleteNamespaces DeleteNamespaces `json:"delete_namespaces,omitempty"`
}

GenericPropsModify is a struct combining DeleteProps and OverrideProps

type LayerType

type LayerType string

LayerType initialized as string

const (
	DRBD       LayerType = "DRBD"
	LUKS       LayerType = "LUKS"
	STORAGE    LayerType = "STORAGE"
	NVME       LayerType = "NVME"
	WRITECACHE LayerType = "WRITECACHE"
	CACHE      LayerType = "CACHE"
	OPENFLEX   LayerType = "OPENFLEX"
)

List of LayerType

type LeveledLogger

type LeveledLogger interface {
	Errorf(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
	Warnf(string, ...interface{})
}

LeveledLogger interface implements the basic methods that a logger library needs

type ListOpts

type ListOpts struct {
	// Number of items to skip. Only used if Limit is a positive value
	Offset int `url:"offset"`
	// Maximum number of items to retrieve
	Limit int `url:"limit"`

	StoragePool []string `url:"storage_pools"`
	Resource    []string `url:"resources"`
	Node        []string `url:"nodes"`
	Prop        []string `url:"props"`
	Snapshots   []string `url:"snapshots"`
	Status      string   `url:"status,omitempty"`
}

ListOpts is a struct primarily used to define parameters used for pagination. It is also used for filtering (e.g., the /view/ calls)

type LogLevel

type LogLevel string
const (
	ERROR LogLevel = "ERROR"
	WARN  LogLevel = "WARN"
	INFO  LogLevel = "INFO"
	DEBUG LogLevel = "DEBUG"
	TRACE LogLevel = "TRACE"
)

List of LogLevel

type Logger

type Logger interface {
	Printf(string, ...interface{})
}

Logger represents a standard logger interface

type LuksResource

type LuksResource struct {
	StorageVolumes []LuksVolume `json:"storage_volumes,omitempty"`
}

LuksResource is a struct to store storage-volumes for a luks-resource

type LuksVolume

type LuksVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath string `json:"device_path,omitempty"`
	// block device used by luks
	BackingDevice    string `json:"backing_device,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
	Opened    bool   `json:"opened,omitempty"`
}

LuksVolume is a struct used for information about a luks-volume

type MaxVolumeSizes

type MaxVolumeSizes struct {
	Candidates                      []Candidate `json:"candidates,omitempty"`
	DefaultMaxOversubscriptionRatio float64     `json:"default_max_oversubscription_ratio,omitempty"`
}

MaxVolumeSizes struct for MaxVolumeSizes

type NetInterface

type NetInterface struct {
	Name                    string `json:"name"`
	Address                 string `json:"address"`
	SatellitePort           int32  `json:"satellite_port,omitempty"`
	SatelliteEncryptionType string `json:"satellite_encryption_type,omitempty"`
	// Defines if this netinterface should be used for the satellite connection
	IsActive bool `json:"is_active,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
}

NetInterface represents a node's network interface.

type Node

type Node struct {
	Name  string   `json:"name"`
	Type  string   `json:"type"`
	Flags []string `json:"flags,omitempty"`
	// A string to string property map.
	Props         map[string]string `json:"props,omitempty"`
	NetInterfaces []NetInterface    `json:"net_interfaces,omitempty"`
	// Enum describing the current connection status.
	ConnectionStatus string `json:"connection_status,omitempty"`
	// unique object id
	Uuid                 string                    `json:"uuid,omitempty"`
	StorageProviders     []ProviderKind            `json:"storage_providers,omitempty"`
	ResourceLayers       []LayerType               `json:"resource_layers,omitempty"`
	UnsupportedProviders map[ProviderKind][]string `json:"unsupported_providers,omitempty"`
	UnsupportedLayers    map[LayerType][]string    `json:"unsupported_layers,omitempty"`
}

Node represents a node in LINSTOR

type NodeModify

type NodeModify struct {
	NodeType string `json:"node_type,omitempty"`
	// A string to string property map.
	GenericPropsModify
}

type NodeService

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

NodeService is the service that deals with node related tasks.

func (*NodeService) Create

func (n *NodeService) Create(ctx context.Context, node Node) error

Create creates a new node object.

func (*NodeService) CreateDevicePool

func (n *NodeService) CreateDevicePool(ctx context.Context, nodeName string, psc PhysicalStorageCreate) error

CreateDevicePool creates an LVM, LVM-thin or ZFS pool, optional VDO under it on a given node.

func (*NodeService) CreateNetInterface

func (n *NodeService) CreateNetInterface(ctx context.Context, nodeName string, nif NetInterface) error

CreateNetInterface creates the given network interface on a given node.

func (*NodeService) CreateStoragePool

func (n *NodeService) CreateStoragePool(ctx context.Context, nodeName string, sp StoragePool) error

CreateStoragePool creates a storage pool on a given node.

func (*NodeService) Delete

func (n *NodeService) Delete(ctx context.Context, nodeName string) error

Delete deletes the given node.

func (*NodeService) DeleteNetinterface

func (n *NodeService) DeleteNetinterface(ctx context.Context, nodeName, nifName string) error

DeleteNetinterface deletes the given network interface on a given node.

func (*NodeService) DeleteStoragePool

func (n *NodeService) DeleteStoragePool(ctx context.Context, nodeName, spName string) error

DeleteStoragePool deletes a storage pool on a given node.

func (*NodeService) Get

func (n *NodeService) Get(ctx context.Context, nodeName string, opts ...*ListOpts) (Node, error)

Get gets information for a particular node.

func (*NodeService) GetAll

func (n *NodeService) GetAll(ctx context.Context, opts ...*ListOpts) ([]Node, error)

GetAll gets information for all registered nodes.

func (*NodeService) GetNetInterface

func (n *NodeService) GetNetInterface(ctx context.Context, nodeName, nifName string, opts ...*ListOpts) (NetInterface, error)

GetNetInterface gets information about a particular network interface on a given node.

func (*NodeService) GetNetInterfaces

func (n *NodeService) GetNetInterfaces(ctx context.Context, nodeName string, opts ...*ListOpts) ([]NetInterface, error)

GetNetInterfaces gets information about all network interfaces of a given node.

func (*NodeService) GetPhysicalStorage

func (n *NodeService) GetPhysicalStorage(ctx context.Context, opts ...*ListOpts) ([]PhysicalStorage, error)

GetPhysicalStorage gets a grouped list of physical storage that can be turned into a LINSTOR storage-pool

func (*NodeService) GetStoragePool

func (n *NodeService) GetStoragePool(ctx context.Context, nodeName, spName string, opts ...*ListOpts) (StoragePool, error)

GetStoragePool gets information about a specific storage pool on a given node.

func (*NodeService) GetStoragePoolView

func (n *NodeService) GetStoragePoolView(ctx context.Context, opts ...*ListOpts) ([]StoragePool, error)

GetStoragePoolView gets information about all storage pools in the cluster.

func (*NodeService) GetStoragePools

func (n *NodeService) GetStoragePools(ctx context.Context, nodeName string, opts ...*ListOpts) ([]StoragePool, error)

GetStoragePools gets information about all storage pools on a given node.

func (*NodeService) Lost

func (n *NodeService) Lost(ctx context.Context, nodeName string) error

Lost marks the given node as lost to delete an unrecoverable node.

func (*NodeService) Modify

func (n *NodeService) Modify(ctx context.Context, nodeName string, props NodeModify) error

Modify modifies the given node and sets/deletes the given properties.

func (*NodeService) ModifyNetInterface

func (n *NodeService) ModifyNetInterface(ctx context.Context, nodeName, nifName string, nif NetInterface) error

ModifyNetInterface modifies the given network interface on a given node.

func (*NodeService) ModifyStoragePool

func (n *NodeService) ModifyStoragePool(ctx context.Context, nodeName, spName string, sp StoragePool) error

ModifyStoragePool modifies a storage pool on a given node.

func (*NodeService) Reconnect

func (n *NodeService) Reconnect(ctx context.Context, nodeName string) error

Reconnect reconnects a node to the controller.

type NvmeResource

type NvmeResource struct {
	NvmeVolumes []NvmeVolume `json:"nvme_volumes,omitempty"`
}

type NvmeVolume

type NvmeVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath string `json:"device_path,omitempty"`
	// block device used by nvme
	BackingDevice    string `json:"backing_device,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
}

type OneOfDrbdResourceDefinitionLayerOpenflexResourceDefinitionLayer

type OneOfDrbdResourceDefinitionLayerOpenflexResourceDefinitionLayer interface {
	// contains filtered or unexported methods
}

OneOfDrbdResourceDefinitionLayerOpenflexResourceDefinitionLayer is used to limit to these layer types

type OneOfDrbdVolumeDefinition

type OneOfDrbdVolumeDefinition interface {
	// contains filtered or unexported methods
}

OneOfDrbdVolumeDefinition is used to prevent other layertypes than drbd-volume-defintion

type OneOfDrbdVolumeLuksVolumeStorageVolumeNvmeVolumeWritecacheVolumeCacheVolume

type OneOfDrbdVolumeLuksVolumeStorageVolumeNvmeVolumeWritecacheVolumeCacheVolume interface {
	// contains filtered or unexported methods
}

OneOfDrbdVolumeLuksVolumeStorageVolumeNvmeVolumeWritecacheVolumeCacheVolume is used to prevent that other types than drbd- luks- and storage-volume are used for a VolumeLayer

type OpenflexResource

type OpenflexResource struct {
	OpenflexResourceDefinition OpenflexResourceDefinitionLayer `json:"openflex_resource_definition,omitempty"`
	OpenflexVolumes            []OpenflexVolume                `json:"openflex_volumes,omitempty"`
}

OpenflexResource represents an Openflex resource

type OpenflexResourceDefinitionLayer

type OpenflexResourceDefinitionLayer struct {
	ResourceNameSuffix string `json:"resource_name_suffix,omitempty"`
	Nqn                string `json:"nqn,omitempty"`
}

OpenflexResourceDefinitionLayer represents the Openflex resource definition layer

type OpenflexVolume

type OpenflexVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath       string `json:"device_path,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
}

OpenflexVolume represents an Openflex volume

type Option

type Option func(*Client) error

Option configures a LINSTOR Client

func BaseURL

func BaseURL(URL *url.URL) Option

BaseURL is a client's option to set the baseURL of the REST client.

func BasicAuth

func BasicAuth(basicauth *BasicAuthCfg) Option

BasicAuth is a client's option to set username and password for the REST client.

func HTTPClient

func HTTPClient(httpClient *http.Client) Option

HTTPClient is a client's option to set a specific http.Client.

func Limit

func Limit(r rate.Limit, b int) Option

Limit is the client's option to set number of requests per second and max number of bursts.

func Log

func Log(logger interface{}) Option

Log is a client's option to set a Logger

type OverrideProps

type OverrideProps map[string]string

OverrideProps is a map of properties to modify (key/value pairs)

type Passphrase

type Passphrase struct {
	NewPassphrase string `json:"new_passphrase,omitempty"`
	OldPassphrase string `json:"old_passphrase,omitempty"`
}

Passphrase represents a LINSTOR passphrase

type PhysicalStorage

type PhysicalStorage struct {
	Size       int64                              `json:"size,omitempty"`
	Rotational bool                               `json:"rotational,omitempty"`
	Nodes      map[string][]PhysicalStorageDevice `json:"nodes,omitempty"`
}

PhysicalStorage is a view on a physical storage on multiple nodes.

type PhysicalStorageCreate

type PhysicalStorageCreate struct {
	ProviderKind ProviderKind `json:"provider_kind"`
	DevicePaths  []string     `json:"device_paths"`
	// RAID level to use for pool.
	RaidLevel         string                           `json:"raid_level,omitempty"`
	PoolName          string                           `json:"pool_name,omitempty"`
	VdoEnable         bool                             `json:"vdo_enable,omitempty"`
	VdoSlabSizeKib    int32                            `json:"vdo_slab_size_kib,omitempty"`
	VdoLogicalSizeKib int32                            `json:"vdo_logical_size_kib,omitempty"`
	WithStoragePool   PhysicalStorageStoragePoolCreate `json:"with_storage_pool,omitempty"`
}

PhysicalStorageCreate is a configuration struct used to represent pysical storage on a given node. If with_storage_pool is set a linstor storage pool will also be created using this device pool

type PhysicalStorageDevice

type PhysicalStorageDevice struct {
	Device string `json:"device,omitempty"`
	Model  string `json:"model,omitempty"`
	Serial string `json:"serial,omitempty"`
	Wwn    string `json:"wwn,omitempty"`
}

PhysicalStorageDevice represents a physical storage device on a a node.

type PhysicalStorageStoragePoolCreate

type PhysicalStorageStoragePoolCreate struct {
	// Name of the linstor storage pool
	Name string `json:"name,omitempty"`
	// A string to string property map.
	Props map[string]string `json:"props,omitempty"`
}

PhysicalStorageStoragePoolCreate is used for create physical-storage

type ProviderKind

type ProviderKind string

ProviderKind is a type that represents various types of storage.

const (
	DISKLESS        ProviderKind = "DISKLESS"
	LVM             ProviderKind = "LVM"
	LVM_THIN        ProviderKind = "LVM_THIN"
	ZFS             ProviderKind = "ZFS"
	ZFS_THIN        ProviderKind = "ZFS_THIN"
	OPENFLEX_TARGET ProviderKind = "OPENFLEX_TARGET"
	FILE            ProviderKind = "FILE"
	FILE_THIN       ProviderKind = "FILE_THIN"
	SPDK            ProviderKind = "SPDK"
)

List of ProviderKind

type Resource

type Resource struct {
	Name     string `json:"name,omitempty"`
	NodeName string `json:"node_name,omitempty"`
	// A string to string property map.
	Props       map[string]string `json:"props,omitempty"`
	Flags       []string          `json:"flags,omitempty"`
	LayerObject ResourceLayer     `json:"layer_object,omitempty"`
	State       ResourceState     `json:"state,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
	// milliseconds since unix epoch in UTC
	CreateTimestamp int64 `json:"create_timestamp,omitempty"`
}

Resource is a struct which holds the information of a resource

type ResourceConnection

type ResourceConnection struct {
	// source node of the connection
	NodeA string `json:"node_a,omitempty"`
	// target node of the connection
	NodeB string `json:"node_b,omitempty"`
	// A string to string property map.
	Props map[string]string `json:"props,omitempty"`
	Flags []string          `json:"flags,omitempty"`
	Port  int32             `json:"port,omitempty"`
}

ResourceConnection is a struct which holds information about a connection between to nodes

type ResourceCreate

type ResourceCreate struct {
	Resource   Resource    `json:"resource,omitempty"`
	LayerList  []LayerType `json:"layer_list,omitempty"`
	DrbdNodeId int32       `json:"drbd_node_id,omitempty"`
}

ResourceCreate is a struct where the properties of a resource are stored to create it

type ResourceDefinition

type ResourceDefinition struct {
	Name string `json:"name,omitempty"`
	// External name can be used to have native resource names. If you need to store a non Linstor compatible resource name use this field and Linstor will generate a compatible name.
	ExternalName string `json:"external_name,omitempty"`
	// A string to string property map.
	Props     map[string]string         `json:"props,omitempty"`
	Flags     []string                  `json:"flags,omitempty"`
	LayerData []ResourceDefinitionLayer `json:"layer_data,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
	// name of the linked resource group, if there is a link
	ResourceGroupName string `json:"resource_group_name,omitempty"`
}

ResourceDefinition is a struct to store the information about a resource-definition

type ResourceDefinitionCreate

type ResourceDefinitionCreate struct {
	// drbd port for resources
	DrbdPort int32 `json:"drbd_port,omitempty"`
	// drbd resource secret
	DrbdSecret         string             `json:"drbd_secret,omitempty"`
	DrbdTransportType  string             `json:"drbd_transport_type,omitempty"`
	ResourceDefinition ResourceDefinition `json:"resource_definition"`
}

ResourceDefinitionCreate is a struct for holding the data needed to create a resource-defintion

type ResourceDefinitionLayer

type ResourceDefinitionLayer struct {
	Type LayerType                                                       `json:"type,omitempty"`
	Data OneOfDrbdResourceDefinitionLayerOpenflexResourceDefinitionLayer `json:"data,omitempty"`
}

ResourceDefinitionLayer is a struct for the storing the layertype of a resource-defintion

func (*ResourceDefinitionLayer) UnmarshalJSON

func (rd *ResourceDefinitionLayer) UnmarshalJSON(b []byte) error

UnmarshalJSON is needed for the unmarshal interface for ResourceDefinitionLayer types

type ResourceDefinitionModify

type ResourceDefinitionModify struct {
	// drbd port for resources
	DrbdPort int32 `json:"drbd_port,omitempty"`
	// drbd peer slot number
	DrbdPeerSlots int32       `json:"drbd_peer_slots,omitempty"`
	LayerStack    []LayerType `json:"layer_stack,omitempty"`
	// change resource group to the given group name
	ResourceGroup string `json:"resource_group,omitempty"`
	GenericPropsModify
}

type ResourceDefinitionService

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

ResourceDefinitionService is a struct for the client pointer

func (*ResourceDefinitionService) Create

Create adds a new resource-definition

func (*ResourceDefinitionService) CreateVolumeDefinition

func (n *ResourceDefinitionService) CreateVolumeDefinition(ctx context.Context, resDefName string, volDef VolumeDefinitionCreate) error

CreateVolumeDefinition adds a volume-definition to a resource-definition. Only the size is required.

func (*ResourceDefinitionService) Delete

func (n *ResourceDefinitionService) Delete(ctx context.Context, resDefName string) error

Delete completely deletes a resource-definition

func (*ResourceDefinitionService) DeleteVolumeDefinition

func (n *ResourceDefinitionService) DeleteVolumeDefinition(ctx context.Context, resDefName string, volNr int) error

DeleteVolumeDefinition deletes a specific volume-definition

func (*ResourceDefinitionService) Get

func (n *ResourceDefinitionService) Get(ctx context.Context, resDefName string, opts ...*ListOpts) (ResourceDefinition, error)

Get return information about a resource-defintion

func (*ResourceDefinitionService) GetAll

GetAll lists all resource-definitions

func (*ResourceDefinitionService) GetVolumeDefinition

func (n *ResourceDefinitionService) GetVolumeDefinition(ctx context.Context, resDefName string, volNr int, opts ...*ListOpts) (VolumeDefinition, error)

GetVolumeDefinition shows the properties of a specific volume-definition

func (*ResourceDefinitionService) GetVolumeDefinitions

func (n *ResourceDefinitionService) GetVolumeDefinitions(ctx context.Context, resDefName string, opts ...*ListOpts) ([]VolumeDefinition, error)

GetVolumeDefinitions returns all volume-definitions of a resource-definition

func (*ResourceDefinitionService) Modify

func (n *ResourceDefinitionService) Modify(ctx context.Context, resDefName string, props GenericPropsModify) error

Modify allows to modify a resource-definition

func (*ResourceDefinitionService) ModifyVolumeDefinition

func (n *ResourceDefinitionService) ModifyVolumeDefinition(ctx context.Context, resDefName string, volNr int, props VolumeDefinitionModify) error

ModifyVolumeDefinition give the abilty to modify a specific volume-definition

type ResourceGroup

type ResourceGroup struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	// A string to string property map.
	Props        map[string]string `json:"props,omitempty"`
	SelectFilter AutoSelectFilter  `json:"select_filter,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
}

type ResourceGroupModify

type ResourceGroupModify struct {
	Description string `json:"description,omitempty"`
	// A string to string property map.
	OverrideProps    map[string]string `json:"override_props,omitempty"`
	DeleteProps      []string          `json:"delete_props,omitempty"`
	DeleteNamespaces []string          `json:"delete_namespaces,omitempty"`
	SelectFilter     AutoSelectFilter  `json:"select_filter,omitempty"`
}

type ResourceGroupService

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

ResourceGroupService is the service that deals with resource group related tasks.

func (*ResourceGroupService) Create

func (n *ResourceGroupService) Create(ctx context.Context, resGrp ResourceGroup) error

Create adds a new resource-group

func (*ResourceGroupService) CreateVolumeGroup

func (n *ResourceGroupService) CreateVolumeGroup(ctx context.Context, resGrpName string, volGrp VolumeGroup) error

Create adds a new volume-group to a resource-group

func (*ResourceGroupService) Delete

func (n *ResourceGroupService) Delete(ctx context.Context, resGrpName string) error

Delete deletes a resource-group

func (*ResourceGroupService) DeleteVolumeGroup

func (n *ResourceGroupService) DeleteVolumeGroup(ctx context.Context, resGrpName string, volNr int) error

func (*ResourceGroupService) Get

func (n *ResourceGroupService) Get(ctx context.Context, resGrpName string, opts ...*ListOpts) (ResourceGroup, error)

Get return information about a resource-defintion

func (*ResourceGroupService) GetAll

func (n *ResourceGroupService) GetAll(ctx context.Context, opts ...*ListOpts) ([]ResourceGroup, error)

GetAll lists all resource-groups

func (*ResourceGroupService) GetVolumeGroup

func (n *ResourceGroupService) GetVolumeGroup(ctx context.Context, resGrpName string, volNr int, opts ...*ListOpts) (VolumeGroup, error)

GetVolumeGroup lists a volume-group for a resource-group

func (*ResourceGroupService) GetVolumeGroups

func (n *ResourceGroupService) GetVolumeGroups(ctx context.Context, resGrpName string, opts ...*ListOpts) ([]VolumeGroup, error)

GetVolumeGroups lists all volume-groups for a resource-group

func (*ResourceGroupService) Modify

func (n *ResourceGroupService) Modify(ctx context.Context, resGrpName string, props ResourceGroupModify) error

Modify allows to modify a resource-group

func (*ResourceGroupService) ModifyVolumeGroup

func (n *ResourceGroupService) ModifyVolumeGroup(ctx context.Context, resGrpName string, volNr int, props VolumeGroupModify) error

Modify allows to modify a volume-group of a resource-group

func (*ResourceGroupService) Spawn

func (n *ResourceGroupService) Spawn(ctx context.Context, resGrpName string, resGrpSpwn ResourceGroupSpawn) error

Spawn creates a new resource-definition and auto-deploys if configured to do so

type ResourceGroupSpawn

type ResourceGroupSpawn struct {
	// name of the resulting resource-definition
	ResourceDefinitionName string `json:"resource_definition_name"`
	// External name can be used to have native resource names. If you need to store a non Linstor compatible resource name use this field and Linstor will generate a compatible name.
	ResourceDefinitionExternalName string `json:"resource_definition_external_name,omitempty"`
	// sizes (in kib) of the resulting volume-definitions
	VolumeSizes  []int64          `json:"volume_sizes,omitempty"`
	SelectFilter AutoSelectFilter `json:"select_filter,omitempty"`
	// If false, the length of the vlm_sizes has to match the number of volume-groups or an error is returned.  If true and there are more vlm_sizes than volume-groups, the additional volume-definitions will simply have no pre-set properties (i.e. \"empty\" volume-definitions) If true and there are less vlm_sizes than volume-groups, the additional volume-groups won't be used.  If the count of vlm_sizes matches the number of volume-groups, this \"partial\" parameter has no effect.
	Partial bool `json:"partial,omitempty"`
	// If true, the spawn command will only create the resource-definition with the volume-definitions but will not perform an auto-place, even if it is configured.
	DefinitionsOnly bool `json:"definitions_only,omitempty"`
}

type ResourceLayer

type ResourceLayer struct {
	Children           []ResourceLayer    `json:"children,omitempty"`
	ResourceNameSuffix string             `json:"resource_name_suffix,omitempty"`
	Type               LayerType          `json:"type,omitempty"`
	Drbd               DrbdResource       `json:"drbd,omitempty"`
	Luks               LuksResource       `json:"luks,omitempty"`
	Storage            StorageResource    `json:"storage,omitempty"`
	Nvme               NvmeResource       `json:"nvme,omitempty"`
	Openflex           OpenflexResource   `json:"openflex,omitempty"`
	Writecache         WritecacheResource `json:"writecache,omitempty"`
	Cache              CacheResource      `json:"cache,omitempty"`
}

ResourceLayer is a struct to store layer-information abour a resource

type ResourceService

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

ResourceService is a struct which contains the pointer of the client

func (*ResourceService) Autoplace

func (n *ResourceService) Autoplace(ctx context.Context, resName string, apr AutoPlaceRequest) error

Autoplace places a resource on your nodes autmatically

func (*ResourceService) Create

func (n *ResourceService) Create(ctx context.Context, res ResourceCreate) error

Create is used to create a resource on a node

func (*ResourceService) CreateSnapshot

func (n *ResourceService) CreateSnapshot(ctx context.Context, snapshot Snapshot) error

CreateSnapshot creates a snapshot of a resource

func (*ResourceService) Delete

func (n *ResourceService) Delete(ctx context.Context, resName, nodeName string) error

Delete deletes a resource on a specific node

func (*ResourceService) DeleteSnapshot

func (n *ResourceService) DeleteSnapshot(ctx context.Context, resName, snapName string) error

DeleteSnapshot deletes a snapshot by its name

func (*ResourceService) DisableDRBDProxy

func (n *ResourceService) DisableDRBDProxy(ctx context.Context, resName, nodeAName, nodeBName string) error

DisableDRBDProxy is used to disable drbd-proxy with the rest-api call from the function enableDisableDRBDProxy

func (*ResourceService) Diskful

func (n *ResourceService) Diskful(ctx context.Context, resName, nodeName, storagePoolName string) error

Diskful toggles a resource to diskful - the parameter storagepool can be set if its needed

func (*ResourceService) Diskless

func (n *ResourceService) Diskless(ctx context.Context, resName, nodeName, disklessPoolName string) error

Diskless toggles a resource on a node to diskless - the parameter disklesspool can be set if its needed

func (*ResourceService) EnableDRBDProxy

func (n *ResourceService) EnableDRBDProxy(ctx context.Context, resName, nodeAName, nodeBName string) error

EnableDRBDProxy is used to enable drbd-proxy with the rest-api call from the function enableDisableDRBDProxy

func (*ResourceService) EnableSnapshotShipping

func (n *ResourceService) EnableSnapshotShipping(ctx context.Context, resName string, ship SnapshotShipping) error

EnableSnapshotShipping enables snapshot shipping for a resource

func (*ResourceService) Get

func (n *ResourceService) Get(ctx context.Context, resName, nodeName string, opts ...*ListOpts) (Resource, error)

Get returns information about a resource on a specific node

func (*ResourceService) GetAll

func (n *ResourceService) GetAll(ctx context.Context, resName string, opts ...*ListOpts) ([]Resource, error)

GetAll returns all resources for a resource-definition

func (*ResourceService) GetConnections

func (n *ResourceService) GetConnections(ctx context.Context, resName, nodeAName, nodeBName string, opts ...*ListOpts) ([]ResourceConnection, error)

GetConnections lists all resource connections if no node-names are given- if two node-names are given it shows the connection between them

func (*ResourceService) GetResourceView

func (n *ResourceService) GetResourceView(ctx context.Context, opts ...*ListOpts) ([]ResourceWithVolumes, error)

GetResourceView returns all resources in the cluster. Filters can be set via ListOpts.

func (*ResourceService) GetSnapshot

func (n *ResourceService) GetSnapshot(ctx context.Context, resName, snapName string, opts ...*ListOpts) (Snapshot, error)

GetSnapshot returns information about a specific Snapshot by its name

func (*ResourceService) GetSnapshotShippings

func (n *ResourceService) GetSnapshotShippings(ctx context.Context, opts ...*ListOpts) ([]SnapshotShippingStatus, error)

GetSnapshotShippings gets a view of all snapshot shippings

func (*ResourceService) GetSnapshotView

func (r *ResourceService) GetSnapshotView(ctx context.Context, opts ...*ListOpts) ([]Snapshot, error)

GetSnapshotView gets information about all snapshots

func (*ResourceService) GetSnapshots

func (n *ResourceService) GetSnapshots(ctx context.Context, resName string, opts ...*ListOpts) ([]Snapshot, error)

GetSnapshots lists all snapshots of a resource

func (*ResourceService) GetVolume

func (n *ResourceService) GetVolume(ctx context.Context, resName, nodeName string, volNr int, opts ...*ListOpts) (Volume, error)

GetVolume returns information about a specific volume defined by it resource,node and volume-number

func (*ResourceService) GetVolumes

func (n *ResourceService) GetVolumes(ctx context.Context, resName, nodeName string, opts ...*ListOpts) ([]Volume, error)

GetVolumes lists als volumes of a resource

func (*ResourceService) Migrate

func (n *ResourceService) Migrate(ctx context.Context, resName, fromNodeName, toNodeName, storagePoolName string) error

Migrate mirgates a resource from one node to another node

func (*ResourceService) Modify

func (n *ResourceService) Modify(ctx context.Context, resName, nodeName string, props ResourceDefinitionModify) error

Modify gives the ability to modify a resource on a node

func (*ResourceService) ModifyConnection

func (n *ResourceService) ModifyConnection(ctx context.Context, resName, nodeAName, nodeBName string, props GenericPropsModify) error

ModifyConnection allows to modify the connection between two nodes

func (*ResourceService) ModifyDRBDProxy

func (n *ResourceService) ModifyDRBDProxy(ctx context.Context, resName string, props DrbdProxyModify) error

ModifyDRBDProxy is used to modify drbd-proxy properties

func (*ResourceService) ModifyVolume

func (n *ResourceService) ModifyVolume(ctx context.Context, resName, nodeName string, volNr int, props GenericPropsModify) error

ModifyVolume modifies an existing volume with the given props

func (*ResourceService) QueryMaxVolumeSize

func (n *ResourceService) QueryMaxVolumeSize(ctx context.Context, filter AutoSelectFilter) (MaxVolumeSizes, error)

QueryMaxVolumeSize finds the maximum size of a volume for a given filter

func (*ResourceService) RestoreSnapshot

func (n *ResourceService) RestoreSnapshot(ctx context.Context, origResName, snapName string, snapRestoreConf SnapshotRestore) error

RestoreSnapshot restores a snapshot on a resource

func (*ResourceService) RestoreVolumeDefinitionSnapshot

func (n *ResourceService) RestoreVolumeDefinitionSnapshot(ctx context.Context, origResName, snapName string, snapRestoreConf SnapshotRestore) error

RestoreVolumeDefinitionSnapshot restores a volume-definition-snapshot on a resource

func (*ResourceService) RollbackSnapshot

func (n *ResourceService) RollbackSnapshot(ctx context.Context, resName, snapName string) error

RollbackSnapshot rolls back a snapshot from a specific resource

type ResourceState

type ResourceState struct {
	InUse bool `json:"in_use,omitempty"`
}

ResourceState is a struct for getting the status of a resource

type ResourceWithVolumes

type ResourceWithVolumes struct {
	Resource
	// milliseconds since unix epoch in UTC
	CreateTimestamp int64    `json:"create_timestamp,omitempty"`
	Volumes         []Volume `json:"volumes,omitempty"`
}

type SatelliteConfig

type SatelliteConfig struct {
	Config               ControllerConfigConfig `json:"config,omitempty"`
	Debug                ControllerConfigDebug  `json:"debug,omitempty"`
	Log                  SatelliteConfigLog     `json:"log,omitempty"`
	StltOverrideNodeName string                 `json:"stlt_override_node_name,omitempty"`
	Openflex             bool                   `json:"openflex,omitempty"`
	DrbdKeepResPattern   string                 `json:"drbd_keep_res_pattern,omitempty"`
	Net                  SatelliteConfigNet     `json:"net,omitempty"`
}

SatelliteConfig struct for SatelliteConfig

type SatelliteConfigLog

type SatelliteConfigLog struct {
	PrintStackTrace bool     `json:"print_stack_trace,omitempty"`
	Directory       string   `json:"directory,omitempty"`
	Level           LogLevel `json:"level,omitempty"`
	LevelLinstor    LogLevel `json:"level_linstor,omitempty"`
}

SatelliteConfigLog struct for SatelliteConfigLog

type SatelliteConfigNet

type SatelliteConfigNet struct {
	BindAddress string `json:"bind_address,omitempty"`
	Port        int32  `json:"port,omitempty"`
	ComType     string `json:"com_type,omitempty"`
}

SatelliteConfigNet struct for SatelliteConfigNet

type Snapshot

type Snapshot struct {
	Name         string   `json:"name,omitempty"`
	ResourceName string   `json:"resource_name,omitempty"`
	Nodes        []string `json:"nodes,omitempty"`
	// A string to string property map.
	Props             map[string]string          `json:"props,omitempty"`
	Flags             []string                   `json:"flags,omitempty"`
	VolumeDefinitions []SnapshotVolumeDefinition `json:"volume_definitions,omitempty"`
	// unique object id
	Uuid      string         `json:"uuid,omitempty"`
	Snapshots []SnapshotNode `json:"snapshots,omitempty"`
}

Snapshot is a struct for information about a snapshot

type SnapshotNode

type SnapshotNode struct {
	// Snapshot name this snapshots belongs to
	SnapshotName string `json:"snapshot_name,omitempty"`
	// Node name where this snapshot was taken
	NodeName string `json:"node_name,omitempty"`
	// milliseconds since unix epoch in UTC
	CreateTimestamp int64    `json:"create_timestamp,omitempty"`
	Flags           []string `json:"flags,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
}

SnapshotNode Actual snapshot data from a node

type SnapshotRestore

type SnapshotRestore struct {
	// Resource where to restore the snapshot
	ToResource string `json:"to_resource"`
	// List of nodes where to place the restored snapshot
	Nodes []string `json:"nodes,omitempty"`
}

SnapshotRestore is a struct used to hold the information about where a Snapshot has to be restored

type SnapshotShipping

type SnapshotShipping struct {
	// Node where to ship the snapshot from
	FromNode string `json:"from_node"`
	// NetInterface of the source node
	FromNic string `json:"from_nic,omitempty"`
	// Node where to ship the snapshot
	ToNode string `json:"to_node"`
	// NetInterface of the destination node
	ToNic string `json:"to_nic,omitempty"`
}

SnapshotShipping struct for SnapshotShipping

type SnapshotShippingStatus

type SnapshotShippingStatus struct {
	Snapshot     Snapshot `json:"snapshot,omitempty"`
	FromNodeName string   `json:"from_node_name,omitempty"`
	ToNodeName   string   `json:"to_node_name,omitempty"`
	Status       string   `json:"status,omitempty"`
}

SnapshotShippingStatus struct for SnapshotShippingStatus

type SnapshotVolumeDefinition

type SnapshotVolumeDefinition struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// Volume size in KiB
	SizeKib uint64 `json:"size_kib,omitempty"`
}

SnapshotVolumeDefinition is a struct to store the properties of a volume from a snapshot

type StoragePool

type StoragePool struct {
	StoragePoolName string       `json:"storage_pool_name"`
	NodeName        string       `json:"node_name,omitempty"`
	ProviderKind    ProviderKind `json:"provider_kind"`
	// A string to string property map.
	Props map[string]string `json:"props,omitempty"`
	// read only map of static storage pool traits
	StaticTraits map[string]string `json:"static_traits,omitempty"`
	// Kibi - read only
	FreeCapacity int64 `json:"free_capacity,omitempty"`
	// Kibi - read only
	TotalCapacity int64 `json:"total_capacity,omitempty"`
	// read only
	FreeSpaceMgrName string `json:"free_space_mgr_name,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
	// Currently known report messages for this storage pool
	Reports []ApiCallRc `json:"reports,omitempty"`
	// true if the storage pool supports snapshots. false otherwise
	SupportsSnapshots bool `json:"supports_snapshots,omitempty"`
}

StoragePool represents a nodes storage pool as defined in LINSTOR.

type StoragePoolDefinition

type StoragePoolDefinition struct {
	StoragePoolName string `json:"storage_pool_name,omitempty"`
	// A string to string property map.
	Props map[string]string `json:"props,omitempty"`
}

StoragePoolDefinition represents a storage pool definition in LINSTOR

type StoragePoolDefinitionModify

type StoragePoolDefinitionModify struct {
	GenericPropsModify
}

StoragePoolDefinitionModify holds properties of a storage pool definition to modify such a definition.

type StoragePoolDefinitionService

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

StoragePoolDefinitionService is the service that deals with storage pool definition related tasks.

func (*StoragePoolDefinitionService) Create

Create creates a new storage pool definition

func (*StoragePoolDefinitionService) Delete

func (s *StoragePoolDefinitionService) Delete(ctx context.Context, spdName string) error

Delete deletes the given storage pool definition.

func (*StoragePoolDefinitionService) Get

Get gets information for a particular storage pool definition.

func (*StoragePoolDefinitionService) GetAll

GetAll gets information for all existing storage pool definitions.

func (*StoragePoolDefinitionService) Modify

Modify modifies the given storage pool definition and sets/deletes the given properties.

type StorageResource

type StorageResource struct {
	StorageVolumes []StorageVolume `json:"storage_volumes,omitempty"`
}

StorageResource is a struct which contains the storage-volumes for a storage-resource

type StorageVolume

type StorageVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath       string `json:"device_path,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
}

StorageVolume is a struct to store standard poperties of a Volume

type Volume

type Volume struct {
	VolumeNumber     int32        `json:"volume_number,omitempty"`
	StoragePoolName  string       `json:"storage_pool_name,omitempty"`
	ProviderKind     ProviderKind `json:"provider_kind,omitempty"`
	DevicePath       string       `json:"device_path,omitempty"`
	AllocatedSizeKib int64        `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64        `json:"usable_size_kib,omitempty"`
	// A string to string property map.
	Props         map[string]string `json:"props,omitempty"`
	Flags         []string          `json:"flags,omitempty"`
	State         VolumeState       `json:"state,omitempty"`
	LayerDataList []VolumeLayer     `json:"layer_data_list,omitempty"`
	// unique object id
	Uuid    string      `json:"uuid,omitempty"`
	Reports []ApiCallRc `json:"reports,omitempty"`
}

Volume is a struct which holds the information about a linstor-volume

type VolumeDefinition

type VolumeDefinition struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// Size of the volume in Kibi.
	SizeKib uint64 `json:"size_kib"`
	// A string to string property map.
	Props     map[string]string       `json:"props,omitempty"`
	Flags     []string                `json:"flags,omitempty"`
	LayerData []VolumeDefinitionLayer `json:"layer_data,omitempty"`
	// unique object id
	Uuid string `json:"uuid,omitempty"`
}

VolumeDefinition is a struct which is used to store volume-definition properties

type VolumeDefinitionCreate

type VolumeDefinitionCreate struct {
	VolumeDefinition VolumeDefinition `json:"volume_definition"`
	DrbdMinorNumber  int32            `json:"drbd_minor_number,omitempty"`
}

VolumeDefinitionCreate is a struct used for creating volume-definitions

type VolumeDefinitionLayer

type VolumeDefinitionLayer struct {
	Type LayerType                 `json:"type"`
	Data OneOfDrbdVolumeDefinition `json:"data,omitempty"`
}

VolumeDefinitionLayer is a struct for the layer-type of a volume-definition

func (*VolumeDefinitionLayer) UnmarshalJSON

func (vd *VolumeDefinitionLayer) UnmarshalJSON(b []byte) error

UnmarshalJSON is needed for the unmarshal interface for VolumeDefinitionLayer types

type VolumeDefinitionModify

type VolumeDefinitionModify struct {
	SizeKib uint64 `json:"size_kib,omitempty"`
	GenericPropsModify
	// To add a flag just specify the flag name, to remove a flag prepend it with a '-'.  Flags:   * GROSS_SIZE
	Flags []string `json:"flags,omitempty"`
}

type VolumeGroup

type VolumeGroup struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// A string to string property map.
	Props map[string]string `json:"props,omitempty"`
	// unique object id
	Uuid  string   `json:"uuid,omitempty"`
	Flags []string `json:"flags,omitempty"`
}

type VolumeGroupModify

type VolumeGroupModify struct {
	// A string to string property map.
	OverrideProps map[string]string `json:"override_props,omitempty"`
	// To add a flag just specify the flag name, to remove a flag prepend it with a '-'.  Flags:   * GROSS_SIZE
	Flags            []string `json:"flags,omitempty"`
	DeleteProps      []string `json:"delete_props,omitempty"`
	DeleteNamespaces []string `json:"delete_namespaces,omitempty"`
}

type VolumeLayer

type VolumeLayer struct {
	Type LayerType                                                                   `json:"type,omitempty"`
	Data OneOfDrbdVolumeLuksVolumeStorageVolumeNvmeVolumeWritecacheVolumeCacheVolume `json:"data,omitempty"`
}

VolumeLayer is a struct for storing the layer-properties of a linstor-volume

func (*VolumeLayer) UnmarshalJSON

func (v *VolumeLayer) UnmarshalJSON(b []byte) error

UnmarshalJSON fulfills the unmarshal interface for the VolumeLayer type

type VolumeState

type VolumeState struct {
	DiskState string `json:"disk_state,omitempty"`
}

VolumeState is a struct which contains the disk-state for volume

type WritecacheResource

type WritecacheResource struct {
	WritecacheVolumes []WritecacheVolume `json:"writecache_volumes,omitempty"`
}

type WritecacheVolume

type WritecacheVolume struct {
	VolumeNumber int32 `json:"volume_number,omitempty"`
	// block device path
	DevicePath string `json:"device_path,omitempty"`
	// block device path used as cache device
	DevicePathCache  string `json:"device_path_cache,omitempty"`
	AllocatedSizeKib int64  `json:"allocated_size_kib,omitempty"`
	UsableSizeKib    int64  `json:"usable_size_kib,omitempty"`
	// String describing current volume state
	DiskState string `json:"disk_state,omitempty"`
}

Jump to

Keyboard shortcuts

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