resources

package
v19.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 13 Imported by: 62

Documentation

Index

Constants

View Source
const (
	// DefaultUser Default Host user
	DefaultUser = "safescale"

	// DefaultVolumeMountPoint Default mount point for volumes
	DefaultVolumeMountPoint = "/data/"

	// DefaultBucketMountPoint Default mount point for containers
	DefaultBucketMountPoint = "/buckets/"

	// DefaultShareExportedPath Default path to be exported by nfs server
	DefaultShareExportedPath = "/shared/data"

	// DefaultShareMountPath Default path to be mounted to access a nfs directory
	DefaultShareMountPath = "/shared"

	// SingleHostNetworkName is the name to use to create the network owning single hosts (not attached to a named network)
	SingleHostNetworkName = "net-safescale"
)

Variables

This section is empty.

Functions

func ResourceDuplicateError

func ResourceDuplicateError(resource, name string) scerr.ErrDuplicate

ResourceDuplicateError creates a ResourceAlreadyExists error

func ResourceForbiddenError

func ResourceForbiddenError(resource, name string) scerr.ErrForbidden

ResourceForbiddenError creates a ErrResourceForbidden error

func ResourceInvalidRequestError

func ResourceInvalidRequestError(resource, reason string) scerr.ErrInvalidRequest

ResourceInvalidRequestError creates a ErrResourceInvalidRequest error

func ResourceNotAvailableError

func ResourceNotAvailableError(resource, name string) scerr.ErrNotAvailable

ResourceNotAvailableError creates a ResourceNotAvailable error

func ResourceNotFoundError

func ResourceNotFoundError(resource, name string) scerr.ErrNotFound

ResourceNotFoundError creates a ErrNotFound error

func ResourceTimeoutError

func ResourceTimeoutError(resource, name string, dur time.Duration) scerr.ErrTimeout

ResourceTimeoutError creates a ErrTimeout error

func TimeoutError

func TimeoutError(message string, dur time.Duration) scerr.ErrTimeout

TimeoutError creates a ErrTimeout error

Types

type Bucket

type Bucket struct {
	ID         string `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Host       string `json:"host,omitempty"`
	MountPoint string `json:"mountPoint,omitempty"`
}

Bucket describes a Bucket

type Config

type Config interface {
	// Config gets a string configuration value and a
	// bool indicating whether the value was present or not.
	Config(name string) (interface{}, bool)
	//Get is an alias to Config()
	Get(name string) (interface{}, bool)
	//Set sets the configuration name to specified value
	Set(name string, value interface{})
	//GetString returns a string corresponding to the key, empty string if it doesn't exist
	GetString(name string) string
	//GetSliceOfStrings returns a slice of strings corresponding to the key, empty string slice if it doesn't exist
	GetSliceOfStrings(name string) []string
	//GetMapOfStrings returns a string map of strings correspondong to the key, empty map if it doesn't exist
	GetMapOfStrings(name string) map[string]string
	//GetInteger returns an integer corresponding to the key, 0 if it doesn't exist
	GetInteger(name string) int
}

Config represents key/value configuration.

type ConfigMap

type ConfigMap map[string]interface{}

ConfigMap is a map[string]string that implements the Config method.

func (ConfigMap) Config

func (c ConfigMap) Config(name string) (interface{}, bool)

Config gets a string configuration value and a bool indicating whether the value was present or not.

func (ConfigMap) Get

func (c ConfigMap) Get(name string) (interface{}, bool)

Get is an alias to Config()

func (ConfigMap) GetInteger

func (c ConfigMap) GetInteger(name string) int

GetInteger returns an integer corresponding to the key, 0 if it doesn't exist

func (ConfigMap) GetMapOfStrings

func (c ConfigMap) GetMapOfStrings(name string) map[string]string

GetMapOfStrings returns a string map of strings correspondong to the key, empty map if it doesn't exist

func (ConfigMap) GetSliceOfStrings

func (c ConfigMap) GetSliceOfStrings(name string) []string

GetSliceOfStrings returns a string slice corresponding to the key, empty string slice if it doesn't exist

func (ConfigMap) GetString

func (c ConfigMap) GetString(name string) string

GetString returns a string corresponding to the key, empty string if it doesn't exist

func (ConfigMap) Set

func (c ConfigMap) Set(name string, value interface{})

Set sets name configuration to value

type GatewayRequest

type GatewayRequest struct {
	Network *Network
	CIDR    string
	// TemplateID the UUID of the template used to size the host (see SelectTemplates)
	TemplateID string
	// ImageID is the UUID of the image that contains the server's OS and initial state.
	ImageID string
	KeyPair *KeyPair
	// Name is the name to give to the gateway
	Name string
}

GatewayRequest to create a Gateway into a network

type Host

type Host struct {
	ID         string                    `json:"id,omitempty"`
	Name       string                    `json:"name,omitempty"`
	LastState  HostState.Enum            `json:"state,omitempty"`
	PrivateKey string                    `json:"private_key,omitempty"`
	Password   string                    `json:"password,omitempty"`
	Properties *serialize.JSONProperties `json:"properties,omitempty"`
}

Host contains the information about a host

func NewHost

func NewHost() *Host

NewHost ...

func (*Host) Deserialize

func (h *Host) Deserialize(buf []byte) error

Deserialize reads json code and reinstantiates an Host

func (*Host) GetAccessIP

func (h *Host) GetAccessIP() string

GetAccessIP returns the IP to reach the host

func (*Host) GetPrivateIP

func (h *Host) GetPrivateIP() string

GetPrivateIP ...

func (*Host) GetPublicIP

func (h *Host) GetPublicIP() string

GetPublicIP computes public IP of the host

func (*Host) IsConsistent

func (h *Host) IsConsistent() bool

IsConsistent tells if host struct is consistent

func (*Host) OK

func (h *Host) OK() bool

OK ...

func (*Host) Serialize

func (h *Host) Serialize() ([]byte, error)

Serialize serializes Host instance into bytes (output json code)

type HostDefinition

type HostDefinition struct {
	Cores     int     `json:"cores,omitempty"`
	RAMSize   float32 `json:"ram_size,omitempty"`
	DiskSize  int     `json:"disk_size,omitempty"`
	GPUNumber int     `json:"gpu_number,omitempty"`
	GPUType   string  `json:"gpu_type,omitempty"`
	CPUFreq   float32 `json:"cpu_freq,omitempty"`
	ImageID   string  `json:"image_id,omitempty"`
	//TODO: implement the handling of this field (will need to introduce provider capabilities to know if a specific provider allows this kind of host)
	Replaceable bool `json:"replaceable,omitempty"` // Tells if we accept server that could be removed without notice (AWS proposes such kind of server with SPOT
}

HostDefinition ...

type HostRequest

type HostRequest struct {
	// ResourceName contains the name of the compute resource
	ResourceName string
	// HostName contains the hostname on the system (if empty, will use ResourceName)
	HostName string
	// Networks lists the networks the host must be connected to
	Networks []*Network
	// DefaultRouteIP is the IP used as default route
	DefaultRouteIP string
	// DefaultGateway is the host used as default gateway
	DefaultGateway *Host
	// PublicIP a flag telling if the host must have a public IP
	PublicIP bool
	// TemplateID is the UUID of the template used to size the host (see SelectTemplates)
	TemplateID string
	// ImageID is the UUID of the image that contains the server's OS and initial state.
	ImageID string
	// KeyPair is the (optional) specific KeyPair to use (if not provided, a new KeyPair will be generated)
	KeyPair *KeyPair
	// Password contains the safescale password usable on host console only
	Password string
	// DiskSize allows to ask for a specific size for system disk (in GB)
	DiskSize int
}

HostRequest represents requirements to create host

type HostTemplate

type HostTemplate struct {
	Cores     int     `json:"cores,omitempty"`
	RAMSize   float32 `json:"ram_size,omitempty"`
	DiskSize  int     `json:"disk_size,omitempty"`
	GPUNumber int     `json:"gpu_number,omitempty"`
	GPUType   string  `json:"gpu_type,omitempty"`
	CPUFreq   float32 `json:"cpu_freq,omitempty"`
	ID        string  `json:"id,omitempty"`
	Name      string  `json:"name,omitempty"`
}

HostTemplate ...

type Image

type Image struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	URL  string
}

Image represents an OS image

type KeyPair

type KeyPair struct {
	ID         string `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	PrivateKey string `json:"private_key,omitempty"`
	PublicKey  string `json:"public_key,omitempty"`
}

KeyPair represents a SSH key pair

type Network

type Network struct {
	ID                 string                    `json:"id,omitempty"`                   // ID for the network (from provider)
	Name               string                    `json:"name,omitempty"`                 // Name of the network
	CIDR               string                    `json:"mask,omitempty"`                 // network in CIDR notation
	GatewayID          string                    `json:"gateway_id,omitempty"`           // contains the id of the host acting as primary gateway for the network
	SecondaryGatewayID string                    `json:"secondary_gateway_id,omitempty"` // contains the id of the host acting as secondary gateway for the network
	VIP                *VIP                      `json:"vip,omitempty"`                  // contains the VIP of the network if created with HA
	IPVersion          IPVersion.Enum            `json:"ip_version,omitempty"`           // IPVersion is IPv4 or IPv6 (see IPVersion)
	Properties         *serialize.JSONProperties `json:"properties,omitempty"`           // contains optional supplemental information
}

Network representes a virtual network

func NewNetwork

func NewNetwork() *Network

NewNetwork ...

func (*Network) Deserialize

func (n *Network) Deserialize(buf []byte) error

Deserialize reads json code and reinstantiates an Host

func (*Network) OK

func (n *Network) OK() bool

OK ...

func (*Network) Serialize

func (n *Network) Serialize() ([]byte, error)

Serialize serializes Host instance into bytes (output json code)

type NetworkRequest

type NetworkRequest struct {
	Name string
	// IPVersion must be IPv4 or IPv6 (see IPVersion)
	IPVersion IPVersion.Enum
	// CIDR mask
	CIDR string
	// DNSServers
	DNSServers []string
	// HA tells if 2 gateways and a VIP needs to be created; the VIP IP address will be used as gateway
	HA bool
}

NetworkRequest represents network requirements to create a subnet where Mask is defined in CIDR notation like "192.0.2.0/24" or "2001:db8::/32", as defined in RFC 4632 and RFC 4291.

type Object

type Object struct {
	ID            string                       `json:"id,omitempty"`
	Name          string                       `json:"name,omitempty"`
	DeleteAt      time.Time                    `json:"delete_at,omitempty"`
	Date          time.Time                    `json:"date,omitempty"`
	ContentType   string                       `json:"content_type,omitempty"`
	ContentLength int64                        `json:"content_length,omitempty"`
	Content       io.ReadSeeker                `json:"content,omitempty"`
	Size          int64                        `json:"size,omitempty"`
	Metadata      objectstorage.ObjectMetadata `json:"metadata,omitempty"`
	LastModified  time.Time                    `json:"last_modified,omitempty"`
	ETag          string                       `json:"etag,omitempty"`
}

Object object to put in a container

type ObjectFilter

type ObjectFilter struct {
	Path   string `json:"path,omitempty"`
	Prefix string `json:"prefix,omitempty"`
}

ObjectFilter filter object

type Range

type Range struct {
	From *int `json:"from,omitempty"`
	To   *int `json:"to,omitempty"`
}

Range Defines a range of bytes

func NewRange

func NewRange(from, to int) Range

NewRange creates a range

func (*Range) OK

func (r *Range) OK() bool

OK ...

func (Range) String

func (r Range) String() string

type SizingRequirements

type SizingRequirements struct {
	MinCores    int     `json:"min_cores,omitempty"`
	MaxCores    int     `json:"max_cores,omitempty"`
	MinRAMSize  float32 `json:"min_ram_size,omitempty"`
	MaxRAMSize  float32 `json:"max_ram_size,omitempty"`
	MinDiskSize int     `json:"min_disk_size,omitempty"`
	MinGPU      int     `json:"min_gpu,omitempty"`
	MinFreq     float32 `json:"min_freq,omitempty"`
	Replaceable bool    `json:"replaceable,omitempty"` // Tells if we accept server that could be removed without notice (AWS proposes such kind of server with SPOT
}

SizingRequirements represents host sizing requirements to fulfil

type StoredCPUInfo

type StoredCPUInfo struct {
	ID           string `bow:"key"`
	TenantName   string `json:"tenant_name,omitempty"`
	TemplateID   string `json:"template_id,omitempty"`
	TemplateName string `json:"template_name,omitempty"`
	ImageID      string `json:"image_id,omitempty"`
	ImageName    string `json:"image_name,omitempty"`
	LastUpdated  string `json:"last_updated,omitempty"`

	NumberOfCPU    int     `json:"number_of_cpu,omitempty"`
	NumberOfCore   int     `json:"number_of_core,omitempty"`
	NumberOfSocket int     `json:"number_of_socket,omitempty"`
	CPUFrequency   float64 `json:"cpu_frequency_Ghz,omitempty"`
	CPUArch        string  `json:"cpu_arch,omitempty"`
	Hypervisor     string  `json:"hypervisor,omitempty"`
	CPUModel       string  `json:"cpu_model,omitempty"`
	RAMSize        float64 `json:"ram_size_Gb,omitempty"`
	RAMFreq        float64 `json:"ram_freq,omitempty"`
	GPU            int     `json:"gpu,omitempty"`
	GPUModel       string  `json:"gpu_model,omitempty"`
	DiskSize       int64   `json:"disk_size_Gb,omitempty"`
	MainDiskType   string  `json:"main_disk_type"`
	MainDiskSpeed  float64 `json:"main_disk_speed_MBps"`
	SampleNetSpeed float64 `json:"sample_net_speed_KBps"`
	EphDiskSize    int64   `json:"eph_disk_size_Gb"`
	PricePerHour   float64 `json:"price_in_dollars_hour"`
}

StoredCPUInfo ...

type VIP

type VIP struct {
	ID        string
	Name      string
	NetworkID string
	PrivateIP string
	PublicIP  string
	Hosts     []*Host
}

VIP is a structure containing information needed to manage VIP (virtual IP)

type Volume

type Volume struct {
	ID         string                    `json:"id,omitempty"`
	Name       string                    `json:"name,omitempty"`
	Size       int                       `json:"size,omitempty"`
	Speed      VolumeSpeed.Enum          `json:"speed,omitempty"`
	State      VolumeState.Enum          `json:"state,omitempty"`
	Properties *serialize.JSONProperties `json:"properties,omitempty"`
}

Volume represents a block volume

func NewVolume

func NewVolume() *Volume

NewVolume ...

func (*Volume) Deserialize

func (v *Volume) Deserialize(buf []byte) error

Deserialize reads json code and restores an Host

func (*Volume) OK

func (v *Volume) OK() bool

OK ...

func (*Volume) Serialize

func (v *Volume) Serialize() ([]byte, error)

Serialize serializes Host instance into bytes (output json code)

type VolumeAttachment

type VolumeAttachment struct {
	ID         string `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	VolumeID   string `json:"volume,omitempty"`
	ServerID   string `json:"host,omitempty"`
	Device     string `json:"device,omitempty"`
	MountPoint string `json:"mountpoint,omitempty"`
	Format     string `json:"format,omitempty"`
}

VolumeAttachment represents a volume attachment

type VolumeAttachmentRequest

type VolumeAttachmentRequest struct {
	Name     string `json:"name,omitempty"`
	VolumeID string `json:"volume_id,omitempty"`
	HostID   string `json:"host_id,omitempty"`
}

VolumeAttachmentRequest represents a volume attachment request

type VolumeRequest

type VolumeRequest struct {
	Name  string           `json:"name,omitempty"`
	Size  int              `json:"size,omitempty"`
	Speed VolumeSpeed.Enum `json:"speed,omitempty"`
}

VolumeRequest represents a volume request

Directories

Path Synopsis
enums
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
filters
v1

Jump to

Keyboard shortcuts

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