resources

package
v21.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package resources ...

Package resources ...

Index

Constants

View Source
const (
	MarkSecurityGroupAsDefault      = true  // mark the Security Group as a default
	MarkSecurityGroupAsSupplemental = false // mark the Security Group as supplemental
	KeepCurrentSecurityGroupMark    = false // Do not change current Security Group mark
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket interface {
	Metadata
	data.Identifiable
	cache.Cacheable
	observer.Observable

	Browse(ctx context.Context, callback func(bucket *abstract.ObjectStorageBucket) fail.Error) fail.Error
	Create(ctx context.Context, name string) fail.Error
	Delete(ctx context.Context) fail.Error
	Mount(ctx context.Context, hostname string, path string) fail.Error
	ToProtocol() (*protocol.BucketResponse, fail.Error)
	Unmount(ctx context.Context, hostname string) fail.Error
}

Bucket GetBucket defines the interface to manipulate Object Storage buckets

type Callback

type Callback = func(data.Clonable, *serialize.JSONProperties) fail.Error

Callback describes the function prototype to use to inspect metadata

type Cluster

type Cluster interface {
	Metadata
	Targetable
	observer.Observable
	cache.Cacheable

	AddFeature(ctx context.Context, name string, vars data.Map, settings FeatureSettings) (Results, fail.Error)             // adds feature on cluster
	AddNodes(ctx context.Context, count uint, def abstract.HostSizingRequirements, keepOnFailure bool) ([]Host, fail.Error) // adds several nodes
	Browse(ctx context.Context, callback func(*abstract.ClusterIdentity) fail.Error) fail.Error                             // browse in metadata clusters and execute a callback on each entry
	CheckFeature(ctx context.Context, name string, vars data.Map, settings FeatureSettings) (Results, fail.Error)           // checks feature on cluster
	CountNodes(ctx context.Context) (uint, fail.Error)                                                                      // counts the nodes of the cluster
	Create(ctx context.Context, req abstract.ClusterRequest) fail.Error                                                     // creates a new cluster and save its metadata
	DeleteSpecificNode(ctx context.Context, hostID string, selectedMasterID string) fail.Error                              // deletes a node identified by its ID
	Delete(ctx context.Context, force bool) fail.Error                                                                      // deletes the cluster (Delete is not used to not collision with metadata)
	FindAvailableMaster(ctx context.Context) (Host, fail.Error)                                                             // returns ID of the first master available to execute order
	FindAvailableNode(ctx context.Context) (Host, fail.Error)                                                               // returns node instance of the first node available to execute order
	GetIdentity() (abstract.ClusterIdentity, fail.Error)                                                                    // returns Cluster Identity
	GetFlavor() (clusterflavor.Enum, fail.Error)                                                                            // returns the flavor of the cluster
	GetComplexity() (clustercomplexity.Enum, fail.Error)                                                                    // returns the complexity of the cluster
	GetAdminPassword() (string, fail.Error)                                                                                 // returns the password of the cluster admin account
	GetKeyPair() (abstract.KeyPair, fail.Error)                                                                             // returns the key pair used in the cluster
	GetNetworkConfig() (*propertiesv3.ClusterNetwork, fail.Error)                                                           // returns network configuration of the cluster
	GetState() (clusterstate.Enum, fail.Error)                                                                              // returns the current state of the cluster
	IsFeatureInstalled(ctx context.Context, name string) (found bool, xerr fail.Error)                                      // tells if a feature is installed in Cluster using only metadata
	ListInstalledFeatures(ctx context.Context) ([]Feature, fail.Error)                                                      // returns the list of installed features
	ListMasters(ctx context.Context) (IndexedListOfClusterNodes, fail.Error)                                                // lists the node instances corresponding to masters (if there is such masters in the flavor...)
	ListMasterIDs(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                              // lists the IDs of masters (if there is such masters in the flavor...)
	ListMasterIPs(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                              // lists the IPs of masters (if there is such masters in the flavor...)
	ListMasterNames(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                            // lists the names of the master nodes in the Cluster
	ListNodes(ctx context.Context) (IndexedListOfClusterNodes, fail.Error)                                                  // lists node instances corresponding to the nodes in the cluster
	ListNodeIDs(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                                // lists the IDs of the nodes in the cluster
	ListNodeIPs(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                                // lists the IPs of the nodes in the cluster
	ListNodeNames(ctx context.Context) (data.IndexedListOfStrings, fail.Error)                                              // lists the names of the nodes in the Cluster
	LookupNode(ctx context.Context, ref string) (bool, fail.Error)                                                          // tells if the ID of the host passed as parameter is a node
	RemoveFeature(ctx context.Context, name string, vars data.Map, settings FeatureSettings) (Results, fail.Error)          // removes feature from cluster
	Shrink(ctx context.Context, count uint) ([]*propertiesv3.ClusterNode, fail.Error)                                       // reduce the size of the cluster of 'count' nodes (the last created)
	Start(ctx context.Context) fail.Error                                                                                   // starts the cluster
	Stop(ctx context.Context) fail.Error                                                                                    // stops the cluster
	ToProtocol() (*protocol.ClusterResponse, fail.Error)
}

Cluster is the interface of all cluster object instances

type Feature

type Feature interface {
	data.Clonable
	data.Identifiable

	Add(ctx context.Context, t Targetable, v data.Map, fs FeatureSettings) (Results, fail.Error)    // Add installs the feature on the target
	Applyable(Targetable) bool                                                                      // Applyable tells if the feature is installable on the target
	GetDisplayFilename() string                                                                     // GetDisplayFilename displays the filename of display (optionally adding '[embedded]' for embedded features)
	GetFilename() string                                                                            // GetFilename returns the filename of the feature
	GetRequirements() (map[string]struct{}, fail.Error)                                             // GetRequirements returns the other features needed as requirements
	Check(ctx context.Context, t Targetable, v data.Map, fs FeatureSettings) (Results, fail.Error)  // Check if feature is installed on target
	Remove(ctx context.Context, t Targetable, v data.Map, fs FeatureSettings) (Results, fail.Error) // Remove uninstalls the feature from the target
	ToProtocol() *protocol.FeatureResponse
}

Feature defines the interface of feature

type FeatureSettings

type FeatureSettings struct {
	SkipProxy               bool // to tell not to try to set reverse proxy
	Serialize               bool // force not to parallel hosts in step
	SkipFeatureRequirements bool // tells not to install required features
	SkipSizingRequirements  bool // tells not to check sizing requirements
	AddUnconditionally      bool // tells to not check before addition (no effect for check or removal)
	IgnoreSuitability       bool // allows to not check if the feature is suitable for the target
}

FeatureSettings are used to tune the feature

type Host

type Host interface {
	Metadata
	Targetable
	observer.Observable
	cache.Cacheable

	BindSecurityGroup(ctx context.Context, sg SecurityGroup, enable SecurityGroupActivation) fail.Error                                // Binds a security group to host
	Browse(ctx context.Context, callback func(*abstract.HostCore) fail.Error) fail.Error                                               // ...
	Create(ctx context.Context, hostReq abstract.HostRequest, hostDef abstract.HostSizingRequirements) (*userdata.Content, fail.Error) // creates a new host and its metadata
	Delete(ctx context.Context) fail.Error
	DisableSecurityGroup(ctx context.Context, sg SecurityGroup) fail.Error                                                                       // disables a binded security group on host
	EnableSecurityGroup(ctx context.Context, sg SecurityGroup) fail.Error                                                                        // enables a binded security group on host
	ForceGetState(ctx context.Context) (hoststate.Enum, fail.Error)                                                                              // returns the real current state of the host, with error handling
	GetAccessIP() (string, fail.Error)                                                                                                           // returns the IP to reach the host, with error handling
	GetDefaultSubnet() (Subnet, fail.Error)                                                                                                      // returns the resources.Subnet instance corresponding to the default subnet of the host, with error handling
	GetMounts() (*propertiesv1.HostMounts, fail.Error)                                                                                           // returns the mounts on the host
	GetPrivateIP() (ip string, err fail.Error)                                                                                                   // returns the IP address of the host on the default subnet, with error handling
	GetPrivateIPOnSubnet(subnetID string) (ip string, err fail.Error)                                                                            // returns the IP address of the host on the requested subnet, with error handling
	GetPublicIP() (ip string, err fail.Error)                                                                                                    // returns the public IP address of the host, with error handling
	GetShare(shareRef string) (*propertiesv1.HostShare, fail.Error)                                                                              // returns a clone of the propertiesv1.HostShare corresponding to share 'shareRef'
	GetShares() (*propertiesv1.HostShares, fail.Error)                                                                                           // returns the shares hosted on the host
	GetSSHConfig() (*system.SSHConfig, fail.Error)                                                                                               // loads SSH configuration for host from metadata
	GetState() hoststate.Enum                                                                                                                    // returns the current state of the host, with error handling
	GetVolumes() (*propertiesv1.HostVolumes, fail.Error)                                                                                         // returns the volumes attached to the host
	IsClusterMember() (bool, fail.Error)                                                                                                         // returns true if the host is member of a cluster
	IsFeatureInstalled(f string) (bool, fail.Error)                                                                                              // tells if a feature is installed on Host, using only metadata
	IsGateway() (bool, fail.Error)                                                                                                               // tells of  the host acts as a gateway
	IsSingle() (bool, fail.Error)                                                                                                                // tells of  the host acts as a gateway
	ListSecurityGroups(state securitygroupstate.Enum) ([]*propertiesv1.SecurityGroupBond, fail.Error)                                            // returns a slice of properties.SecurityGroupBond corresponding to bound Security Group of the host
	Pull(ctx context.Context, target, source string, timeout time.Duration) (int, string, string, fail.Error)                                    // downloads a file from host
	Push(ctx context.Context, source, target, owner, mode string, timeout time.Duration) (int, string, string, fail.Error)                       // uploads a file to host
	PushStringToFile(ctx context.Context, content string, filename string) fail.Error                                                            // creates a file 'filename' on remote 'host' with the content 'content'
	PushStringToFileWithOwnership(ctx context.Context, content string, filename string, owner, mode string) fail.Error                           // creates a file 'filename' on remote 'host' with the content 'content' and apply ownership to it
	Reboot(ctx context.Context, soft bool) fail.Error                                                                                            // reboots the host
	Resize(ctx context.Context, hostSize abstract.HostSizingRequirements) fail.Error                                                             // resize the host (probably not yet implemented on some proviers if not all)
	Run(ctx context.Context, cmd string, outs outputs.Enum, connectionTimeout, executionTimeout time.Duration) (int, string, string, fail.Error) // tries to execute command 'cmd' on the host
	Start(ctx context.Context) fail.Error                                                                                                        // starts the host
	Stop(ctx context.Context) fail.Error                                                                                                         // stops the host
	ToProtocol() (*protocol.Host, fail.Error)                                                                                                    // converts a host to equivalent gRPC message
	UnbindSecurityGroup(ctx context.Context, sg SecurityGroup) fail.Error                                                                        // Unbinds a security group from host
	WaitSSHReady(ctx context.Context, timeout time.Duration) (status string, err fail.Error)                                                     // Wait for remote SSH to respond
}

Host links Object Storage folder and Host

type IndexedListOfClusterNodes

type IndexedListOfClusterNodes map[uint]*propertiesv3.ClusterNode

IndexedListOfClusterNodes ...

type Metadata

type Metadata interface {
	cache.Cacheable

	IsNull() bool
	Alter(callback Callback, options ...data.ImmutableKeyValue) fail.Error // protects the data for exclusive write
	BrowseFolder(callback func(buf []byte) fail.Error) fail.Error          // walks through host folder and executes a callback for each entries
	Deserialize(buf []byte) fail.Error                                     // Transforms a slice of bytes in struct
	GetService() iaas.Service                                              // returns the iaas.Service used
	Inspect(callback Callback) fail.Error                                  // protects the data for shared read with first reloading data from Object Storage
	Review(callback Callback) fail.Error                                   // protects the data for shared read without reloading first (uses in-memory data); use with caution
	Read(ref string) fail.Error                                            // reads the data from Object Storage using ref as id or name
	ReadByID(id string) fail.Error                                         // reads the data from Object Storage by id
	Reload() fail.Error                                                    // Reloads the metadata from the Object Storage, overriding what is in the object
	Serialize() ([]byte, fail.Error)
}

Metadata contains the core functions of a persistent object

type Network

type Network interface {
	Metadata
	data.Identifiable
	observer.Observable
	cache.Cacheable

	AbandonSubnet(ctx context.Context, subnetID string) fail.Error                      // used to detach a Subnet from the Network
	AdoptSubnet(ctx context.Context, subnet Subnet) fail.Error                          // used to attach a Subnet to the Network
	Browse(ctx context.Context, callback func(*abstract.Network) fail.Error) fail.Error // call the callback for each entry of the metadata folder of Networks
	Create(ctx context.Context, req abstract.NetworkRequest) fail.Error                 // creates a Network
	Delete(ctx context.Context) fail.Error
	Import(ctx context.Context, ref string) fail.Error
	InspectSubnet(subnetRef string) (Subnet, fail.Error) // returns the Subnet instance corresponding to Subnet reference (ID or name) provided (if Subnet is attached to the Network)
	ToProtocol() (*protocol.Network, fail.Error)         // converts the network to protobuf message
}

Network links Object Storage folder and Network

type Results

type Results interface {
	Add(string, UnitResults) error
	AddOne(string, string, UnitResult) error
	Successful() bool
	AllErrorMessages() string
	ErrorMessagesOfUnit(name string) string
	ErrorMessagesOfKey(name string) string
	ResultsOfKey(key string) UnitResults
	Keys() []string
}

Results ...

type SecurityGroup

type SecurityGroup interface {
	Metadata
	data.Identifiable
	observer.Observable
	cache.Cacheable

	AddRule(ctx context.Context, _ *abstract.SecurityGroupRule) fail.Error                                         // returns true if the host is member of a cluster
	AddRules(ctx context.Context, _ abstract.SecurityGroupRules) fail.Error                                        // returns true if the host is member of a cluster
	BindToHost(ctx context.Context, host Host, _ SecurityGroupActivation, _ SecurityGroupMark) fail.Error          // binds a security group to a host
	BindToSubnet(ctx context.Context, _ Subnet, _ SecurityGroupActivation, _ SecurityGroupMark) fail.Error         // binds a security group to a network
	Browse(ctx context.Context, callback func(*abstract.SecurityGroup) fail.Error) fail.Error                      // browses the metadata folder of Security Groups and call the callback on each entry
	Clear(ctx context.Context) fail.Error                                                                          // removes rules from the security group
	Create(ctx context.Context, networkID, name, description string, rules abstract.SecurityGroupRules) fail.Error // creates a new host and its metadata
	Delete(ctx context.Context, force bool) fail.Error                                                             // deletes the Security Group
	DeleteRule(ctx context.Context, rule *abstract.SecurityGroupRule) fail.Error                                   // deletes a rule from a Security Group
	GetBoundHosts(ctx context.Context) ([]*propertiesv1.SecurityGroupBond, fail.Error)                             // returns a slice of bonds corresponding to hosts bound to the security group
	GetBoundSubnets(ctx context.Context) ([]*propertiesv1.SecurityGroupBond, fail.Error)                           // returns a slice of bonds corresponding to networks bound to the security group
	Reset(ctx context.Context) fail.Error                                                                          // resets the rules of the security group from the ones registered in metadata
	ToProtocol() (*protocol.SecurityGroupResponse, fail.Error)                                                     // converts a SecurityGroup to equivalent gRPC message
	UnbindFromHost(ctx context.Context, _ Host) fail.Error                                                         // unbinds a Security Group from Host
	UnbindFromHostByReference(ctx context.Context, _ string) fail.Error                                            // unbinds a Security Group from Host
	UnbindFromSubnet(ctx context.Context, _ Subnet) fail.Error                                                     // unbinds a Security Group from Subnet
	UnbindFromSubnetByReference(ctx context.Context, _ string) fail.Error                                          // unbinds a Security group from a Subnet identified by reference (ID or name)
}

SecurityGroup links Object Storage folder and SecurityGroup

type SecurityGroupActivation

type SecurityGroupActivation bool

SecurityGroupActivation represents activation state of a Security Group

const (
	// SecurityGroupEnable means the security group is enabled
	SecurityGroupEnable SecurityGroupActivation = true
	// SecurityGroupDisable means the security group is disabled
	SecurityGroupDisable SecurityGroupActivation = false
)

type SecurityGroupMark

type SecurityGroupMark bool

type Share

type Share interface {
	Metadata
	data.Identifiable
	observer.Observable
	cache.Cacheable

	Browse(ctx context.Context, callback func(hostName string, shareID string) fail.Error) fail.Error
	Create(ctx context.Context, shareName string, host Host, path string, options string) fail.Error // creates a share on host
	Delete(ctx context.Context) fail.Error
	GetServer() (Host, fail.Error)                                                                                 // returns the *Host acting as share server, with error handling
	Mount(ctx context.Context, host Host, path string, withCache bool) (*propertiesv1.HostRemoteMount, fail.Error) // mounts a share on a local directory of a host
	Unmount(ctx context.Context, host Host) fail.Error                                                             // unmounts a share from local directory of a host
	ToProtocol() (*protocol.ShareMountList, fail.Error)
}

Share contains information to maintain in Object Storage a list of shared folders

type Subnet

type Subnet interface {
	Metadata
	data.Identifiable
	observer.Observable
	cache.Cacheable

	DetachHost(ctx context.Context, hostID string) fail.Error                                                                    // unlinks host ID from subnet
	AttachHost(ctx context.Context, _ Host) fail.Error                                                                           // links Host to the Subnet
	BindSecurityGroup(ctx context.Context, _ SecurityGroup, _ SecurityGroupActivation) fail.Error                                // binds a Security Group to the Subnet
	Browse(ctx context.Context, callback func(*abstract.Subnet) fail.Error) fail.Error                                           // ...
	Create(ctx context.Context, req abstract.SubnetRequest, gwname string, gwSizing *abstract.HostSizingRequirements) fail.Error // creates a Subnet
	Delete(ctx context.Context) fail.Error                                                                                       // deletes a Subnet
	DisableSecurityGroup(ctx context.Context, _ SecurityGroup) fail.Error                                                        // disables a bound Security Group on Subnet
	EnableSecurityGroup(ctx context.Context, _ SecurityGroup) fail.Error                                                         // enables a bound Security Group on Subnet
	GetGatewayPublicIP(primary bool) (string, fail.Error)                                                                        // returns the gateway related to Subnet
	GetGatewayPublicIPs() ([]string, fail.Error)                                                                                 // returns the gateway IPs of the Subnet
	GetDefaultRouteIP() (string, fail.Error)                                                                                     // returns the private IP of the default route of the Subnet
	GetEndpointIP() (string, fail.Error)                                                                                         // returns the public IP to reach the Subnet from Internet
	GetState() (subnetstate.Enum, fail.Error)                                                                                    // gives the current state of the Subnet
	HasVirtualIP() (bool, fail.Error)                                                                                            // tells if the Subnet is using a VIP as default route
	InspectGateway(primary bool) (Host, fail.Error)                                                                              // returns the gateway related to Subnet
	InspectGatewaySecurityGroup() (SecurityGroup, fail.Error)                                                                    // returns the SecurityGroup responsible of network security on Gateway
	InspectInternalSecurityGroup() (SecurityGroup, fail.Error)                                                                   // returns the SecurityGroup responsible of internal network security
	InspectPublicIPSecurityGroup() (SecurityGroup, fail.Error)                                                                   // returns the SecurityGroup responsible of Hosts with Public IP (excluding gateways)
	InspectNetwork() (Network, fail.Error)                                                                                       // returns the instance of the parent Network of the Subnet
	ListHosts(ctx context.Context) ([]Host, fail.Error)                                                                          // returns the list of Host attached to the subnet (excluding gateway)
	ListSecurityGroups(ctx context.Context, state securitygroupstate.Enum) ([]*propertiesv1.SecurityGroupBond, fail.Error)       // lists the security groups bound to the subnet
	ToProtocol() (*protocol.Subnet, fail.Error)                                                                                  // converts the subnet to protobuf message
	UnbindSecurityGroup(ctx context.Context, _ SecurityGroup) fail.Error                                                         // unbinds a security group from the subnet
}

Subnet links Object Storage folder and Network

type Targetable

type Targetable interface {
	data.Identifiable

	ComplementFeatureParameters(ctx context.Context, v data.Map) fail.Error        // adds parameters corresponding to the Target in preparation of feature installation
	UnregisterFeature(f string) fail.Error                                         // unregisters a Feature from Target in metadata
	InstalledFeatures() []string                                                   // returns a list of installed features
	InstallMethods() map[uint8]installmethod.Enum                                  // returns a list of installation methods useable on the target, ordered from upper to lower preference (1 = highest preference)
	RegisterFeature(f Feature, requiredBy Feature, clusterContext bool) fail.Error // registers a feature on target in metadata
	TargetType() featuretargettype.Enum                                            // returns the type of the target
}

Targetable is an interface that target must satisfy to be able to install something on it

type UnitResult

type UnitResult interface {
	Successful() bool
	Completed() bool
	Error() error
	ErrorMessage() string
}

UnitResult ...

type UnitResults

type UnitResults interface {
	AddOne(string, UnitResult)
	Completed() bool
	Uncompleted() []string
	ErrorMessages() string
	Successful() bool
	Keys() []string
	ResultOfKey(key string) UnitResult
}

UnitResults ...

type Volume

type Volume interface {
	Metadata
	data.Identifiable
	observer.Observable
	cache.Cacheable

	Attach(ctx context.Context, host Host, path, format string, doNotFormat, doNotMount bool) fail.Error // attaches a volume to a host
	Browse(ctx context.Context, callback func(*abstract.Volume) fail.Error) fail.Error                   // walks through all the metadata objects in network
	Create(ctx context.Context, req abstract.VolumeRequest) fail.Error                                   // creates a volume
	Delete(ctx context.Context) fail.Error                                                               // deletes a volume
	Detach(ctx context.Context, host Host) fail.Error                                                    // detaches the volume identified by ref, ref can be the name or the id
	GetAttachments() (*propertiesv1.VolumeAttachments, fail.Error)                                       // returns the property containing where the volume is attached
	GetSize() (int, fail.Error)                                                                          // returns the size of volume in GB
	GetSpeed() (volumespeed.Enum, fail.Error)                                                            // returns the speed of the volume (more or less the type of hardware)
	ToProtocol() (*protocol.VolumeInspectResponse, fail.Error)                                           // converts volume to equivalent protocol message
}

Volume links Object Storage folder and getVolumes

Directories

Path Synopsis
enums
clusterstate
Package clusterstate is an enumeration of the possible states of a Cluster
Package clusterstate is an enumeration of the possible states of a Cluster
volumespeed
Package volumespeed defines an enum to represents Volume type
Package volumespeed defines an enum to represents Volume type
volumestate
Package volumestate defines an enum to represents Volume states life cycle
Package volumestate defines an enum to represents Volume states life cycle
factories
network
Package network contains functions to list, create, load instances of resources.Network
Package network contains functions to list, create, load instances of resources.Network
subnet
Package subnet contains methods to load or create instance of resources.Subnet
Package subnet contains methods to load or create instance of resources.Subnet
properties
v1
v2
v3

Jump to

Keyboard shortcuts

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