host

package
v0.0.0-...-1c5d739 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 19 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSizeTooBig = errors.New("calculated memory exceeds base value")
View Source
var (

	//MAPPING is the elastic mapping for a host
	MAPPING, _ = elastic.NewMapping(mappingString)
)

Functions

func GetRAMLimit

func GetRAMLimit(value string, base uint64) (mem uint64, err error)

func GetType

func GetType() string

GetType return the Host's type (also referred to as kind). It return returns the type as a string.

func HostKey

func HostKey(id string) datastore.Key

HostKey creates a Key suitable for getting, putting and deleting Hosts

Types

type Host

type Host struct {
	ID              string // Unique identifier, default to hostid
	Name            string // A label for the host, eg hostname, role
	PoolID          string // Pool that the Host belongs to
	IPAddr          string // The IP address the host can be reached at from a serviced master
	RPCPort         int    // The RPC port of the host
	Cores           int    // Number of cores available to serviced
	Memory          uint64 // Amount of RAM (bytes) available to serviced
	CoresCommitment int    // Number of CPU shares (cores) allocated by the user
	RAMCommitment   uint64 // DEPRECATED: Amount of RAM (bytes) allocated by the user
	RAMLimit        string // Amount of RAM (size, %) allocated by the user
	PrivateNetwork  string // The private network where containers run, eg 172.16.42.0/24
	CreatedAt       time.Time
	UpdatedAt       time.Time
	IPs             []HostIPResource // The static IP resources available on the host
	KernelVersion   string
	KernelRelease   string
	ServiceD        struct {
		Version   string
		Date      string
		Gitcommit string
		Gitbranch string
		Buildtag  string
		Release   string
	}
	MonitoringProfile domain.MonitorProfile
	datastore.VersionedEntity
	NatIP string
}

Host that runs the control center agent.

func Build

func Build(ip string, rpcport string, poolid string, memory string, ipAddrs ...string) (*Host, error)

Build creates a Host type from the current host machine, filling out fields using the current machines attributes. The IP param is a routable IP used to connect to to the Host, if empty an IP from the available IPs will be used. The poolid param is the pool the host should belong to. Optional list of IP address strings to set as available IP resources, if not set the IP used for the host will be given as an IP Resource. If any IP is not a valid IP on the machine return error.

func New

func New() *Host

New creates a new empty host

func UpdateHostInfo

func UpdateHostInfo(h Host) (Host, error)

UpdateHostInfo returns a new host with updated hardware and software info. Does not update port or IP information

func (*Host) Equals

func (a *Host) Equals(b *Host) bool

Equals verifies whether two host objects are equal

func (*Host) GetID

func (h *Host) GetID() string

GetID returns the receiver host's ID. It returns the ID as a string

func (*Host) GetType

func (h *Host) GetType() string

GetType returns the receiver host's type. It returns the type as a string

func (*Host) TotalRAM

func (a *Host) TotalRAM() (mem uint64)

func (*Host) ValidEntity

func (h *Host) ValidEntity() error

ValidEntity validates Host fields

type HostIPResource

type HostIPResource struct {
	HostID        string
	IPAddress     string
	InterfaceName string
	MACAddress    string
}

HostIPResource contains information about a specific IP available as a resource

type HostStatus

type HostStatus struct {
	HostID        string
	HostName      string
	MemoryUsage   service.Usage
	Active        bool
	Authenticated bool
}

type InvalidIPAddress

type InvalidIPAddress string

InvalidIPAddress is an error for Invalid IPs

func (InvalidIPAddress) Error

func (err InvalidIPAddress) Error() string

type IsLoopbackError

type IsLoopbackError string

IsLoopbackError is an error type for IP addresses that are loopback.

func (IsLoopbackError) Error

func (err IsLoopbackError) Error() string

type ReadHost

type ReadHost struct {
	ID            string
	Name          string
	PoolID        string
	Cores         int
	Memory        uint64
	RAMLimit      string
	KernelVersion string
	KernelRelease string
	ServiceD      ReadServiced
	IPs           []HostIPResource
	CreatedAt     time.Time
	UpdatedAt     time.Time
}

ReadHost is a minimal representation of hosts.

type ReadServiced

type ReadServiced struct {
	Version string
	Date    string
	Release string
}

type Store

type Store interface {
	datastore.EntityStore

	// FindHostsWithPoolID returns all hosts with the given poolid.
	FindHostsWithPoolID(ctx datastore.Context, poolID string) ([]Host, error)

	// GetHostByIP looks up a host by the given ip address
	GetHostByIP(ctx datastore.Context, hostIP string) (*Host, error)

	// GetN returns all hosts up to limit.
	GetN(ctx datastore.Context, limit uint64) ([]Host, error)
}

Store type for interacting with Host persistent storage

func NewStore

func NewStore() Store

NewStore creates a HostStore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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