pkg

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CodeGenericError = iota - 1
	CodeNoError
	CodeNotFound
	CodeBurnTransactionNotFound
	CodeRefundTransactionNotFound
	CodeFailedToDecode
	CodeInvalidVersion
	CodeUnknownVersion
	CodeIsUsurped
	CodeAccountNotFound
	CodeDepositFeeNotFound
	CodeMintTransactionNotFound
)
View Source
const (
	RootFSPropagationSlave    = "slave"
	RootFSPropagationRslave   = "rslave"
	RootFSPropagationShared   = "shared"
	RootFSPropagationRshared  = "rshared"
	RootFSPropagationPrivate  = "private"
	RootFSPropagationRprivate = "rprivate"
)

Variables

View Source
var (
	//DefaultMountOptions has sane values for mount
	DefaultMountOptions = MountOptions{
		ReadOnly: false,
		Limit:    256 * gridtypes.Megabyte,
	}

	//ReadOnlyMountOptions shortcut for readonly mount options
	ReadOnlyMountOptions = MountOptions{
		ReadOnly: true,
	}
)
View Source
var DefaultSysCall = &defaultSysCall{}
View Source
var DefaultSystemOS = &defaultFileSystem{}

instance of default filesystem

Functions

This section is empty.

Types

type Address

type Address string

func (Address) String

func (s Address) String() string

type Boot

type Boot struct {
	Type BootType
	Path string
}

Boot structure

type BootType

type BootType uint8

BootType for vm

const (
	// BootDisk booting from a virtual disk
	BootDisk BootType = iota
	// BootVirtioFS booting from a virtiofs mount
	BootVirtioFS
)

type BrokenDevice

type BrokenDevice struct {
	// Path to allow identification of the disk
	Path string
	// Err returned which lead to the disk being marked as faulty
	Err error
}

BrokenDevice is a disk which is somehow not fully functional. Storage keeps track of disks which have failed at some point, so they are not used, and to be able to later report this to other daemons.

type BrokenPool

type BrokenPool struct {
	// Label of the broken pool
	Label string
	// Err returned by the action which let to the pool being marked as broken
	Err error
}

BrokenPool contains info about a malfunctioning storage pool

type Container

type Container struct {
	// Name of container
	Name string
	// path to the rootfs of the container
	RootFS string
	// Env env variables to container in format {'KEY=VALUE', 'KEY2=VALUE2'}
	Env []string
	// WorkingDir of the entrypoint command
	WorkingDir string
	// Network network info for container
	Network NetworkInfo
	// Mounts extra mounts for container
	Mounts []MountInfo
	// Entrypoint the process to start inside the container
	Entrypoint string
	// Interactivity enable Core X as PID 1 on the container
	Interactive bool
	// CPU count limit
	CPU uint
	// Memory limit in
	Memory gridtypes.Unit
	// Logs backends
	Logs []logger.Logs
	// Stats container metrics backend
	Stats []Stats
	// Elevated privileges (to use fuse inside)
	Elevated bool
	// CreatedAt time
	CreatedAt time.Time
	// RootfsPropagation root fs propagation mode (rshared,shared,slave,...)
	RootFsPropagation RootFSPropagation
	// How much time to wait for the container to gracefully shutdown before sending a SIGKILL (default: 5)
	ShutdownTimeout time.Duration
}

Container creation info

type ContainerID

type ContainerID string

ContainerID type

type ContainerModule

type ContainerModule interface {
	// Run creates and starts a container on the node. It also auto
	// starts command defined by `entrypoint` inside the container
	// ns: tenant namespace
	// data: Container info
	Run(ns string, data Container) (ContainerID, error)

	// Exec executes a command in the container
	// stdout and stderr is ignored
	Exec(ns string, containerID string, timeout time.Duration, args ...string) error
	// ListNS list the name of all the container namespaces
	ListNS() ([]string, error)

	// List all the existing container IDs from a certain namespace ns
	// if ns is empty, then the container IDs from all existing namespaces will be return
	List(ns string) ([]ContainerID, error)

	// Inspect, return information about the container, given its container id
	Inspect(ns string, id ContainerID) (Container, error)
	SignalDelete(ns string, id ContainerID) error
	Delete(ns string, id ContainerID) error

	// Get logs of the container
	Logs(ns string, containerID string) (logs string, err error)
}

ContainerModule defines rpc interface to containerd

type ContainerNetworkConfig

type ContainerNetworkConfig struct {
	IPs         []string
	PublicIP6   bool
	YggdrasilIP bool
}

ContainerNetworkConfig defines how to construct the network namespace of a container

type ContractCancelledEvent

type ContractCancelledEvent struct {
	Contract uint64
	TwinId   uint32
}

ContractCancelledEvent a contract has been cancelled, The type specify if this is just notification of the reconnection, or actual event has been received.

type ContractLockedEvent

type ContractLockedEvent struct {
	Contract uint64
	TwinId   uint32
	Lock     bool
}

ContractLockedEvent is raised when a contract is locked/unlocked. On locking the Lock flag will be set to true. If Kind is EventSubscribed it means event stream has been reconnected and might be events loss. It's up to the handler of this event type to make sure contracts are synched with the grid.

type Counters

type Counters struct {
	// Total system capacity
	Total gridtypes.Capacity `json:"total"`
	// Used capacity this include user + system resources
	Used gridtypes.Capacity `json:"used"`
	// System resource reserved by zos
	System gridtypes.Capacity `json:"system"`
	// Users statistics by zos
	Users UsersCounters `json:"users"`
	// OpenConnecions number of open connections in the node
	OpenConnecions int `json:"open_connections"`
}

type Device

type Device struct {
	Path  string
	ID    string
	Usage Usage
}

Device struct is a full hdd

type DeviceType

type DeviceType = zos.DeviceType

DeviceType is the actual type of hardware that the storage device runs on, i.e. SSD or HDD

type DiskIOCountersStat

type DiskIOCountersStat struct {
	disk.IOCountersStat
	Time time.Time
}

DiskIOCountersStat struct

func (*DiskIOCountersStat) String

func (s *DiskIOCountersStat) String() string

type DisksIOCountersStat

type DisksIOCountersStat map[string]DiskIOCountersStat

DisksIOCountersStat alias for map[string]IOCountersStat required by zbus

type ErrInvalidDeviceType

type ErrInvalidDeviceType struct {
	DeviceType DeviceType
}

ErrInvalidDeviceType raised when trying to allocate space on unsupported device type

func (ErrInvalidDeviceType) Error

func (e ErrInvalidDeviceType) Error() string

type ErrNotEnoughSpace

type ErrNotEnoughSpace struct {
	DeviceType DeviceType
}

ErrNotEnoughSpace indicates that there is not enough space in a pool of the requested type to create the filesystem

func (ErrNotEnoughSpace) Error

func (e ErrNotEnoughSpace) Error() string

type ExitDevice

type ExitDevice struct {
	// IsSingle is set to true if br-pub
	// is connected to zos bridge
	IsSingle bool `json:"is_single"`
	// IsDual is set to true if br-pub is
	// connected to a physical nic
	IsDual bool `json:"is_dual"`
	// AsDualInterface is set to the physical
	// interface name if IsDual is true
	AsDualInterface string `json:"dual_interface"`
}

func (*ExitDevice) String

func (e *ExitDevice) String() string

type FarmID

type FarmID uint32

FarmID is the identification of a farm

type Flister

type Flister interface {
	// Mount mounts an flist located at url using the 0-db located at storage
	// in a RO mode. note that there is no way u can unmount a ro flist because
	// it can be shared by many users, it's then up to system to decide if the
	// mount is not needed anymore and clean it up
	Mount(name, url string, opt MountOptions) (path string, err error)

	// UpdateMountSize change the mount size
	UpdateMountSize(name string, limit gridtypes.Unit) (path string, err error)

	// Umount a RW mount. this only unmounts the RW layer and remove the assigned
	// volume.
	Unmount(name string) error

	// HashFromRootPath returns flist hash from a running g8ufs mounted with NamedMount
	HashFromRootPath(name string) (string, error)

	// FlistHash returns md5 of flist if available (requesting the hub)
	FlistHash(url string) (string, error)

	Exists(name string) (bool, error)
}

Flister is the interface for the flist module

type GPUInfo

type GPUInfo struct {
	ID       string `json:"id"`
	Vendor   string `json:"vendor"`
	Device   string `json:"device"`
	Contract uint64 `json:"contract"`
}

type Gateway

type Gateway interface {
	SetNamedProxy(wlID string, config zos.GatewayNameProxy) (string, error)
	SetFQDNProxy(wlID string, config zos.GatewayFQDNProxy) error
	DeleteNamedProxy(wlID string) error
	Metrics() (GatewayMetrics, error)
}

type GatewayMetrics

type GatewayMetrics struct {
	Request  map[string]float64
	Response map[string]float64
}

func (*GatewayMetrics) Nu

func (m *GatewayMetrics) Nu(service string) (result uint64)

type HostMonitor

type HostMonitor interface {
	Uptime(ctx context.Context) <-chan time.Duration
}

HostMonitor interface (provided by noded)

type Identifier

type Identifier interface {
	Identity() string
}

Identifier is the interface that defines how an object can be used as an identity

type IdentityManager

type IdentityManager interface {
	// Store returns the key store kind
	StoreKind() string

	// NodeID returns the node id (public key)
	NodeID() StrIdentifier

	// Address return the node address (SS58Address address)
	Address() (Address, error)

	// FarmID return the farm id this node is part of. this is usually a configuration
	// that the node is booted with. An error is returned if the farmer id is not configured
	FarmID() (FarmID, error)

	// Farm returns name of the farm. Or error
	Farm() (string, error)

	//FarmSecret get the farm secret as defined in the boot params
	FarmSecret() (string, error)

	// Sign signs the message with privateKey and returns a signature.
	Sign(message []byte) ([]byte, error)

	// Verify reports whether sig is a valid signature of message by publicKey.
	Verify(message, sig []byte) error

	// Encrypt encrypts message with the public key of the node
	Encrypt(message []byte) ([]byte, error)

	// Decrypt decrypts message with the private of the node
	Decrypt(message []byte) ([]byte, error)

	// EncryptECDH aes encrypt msg using a shared key derived from private key of the node and public key of the other party using Elliptic curve Diffie Helman algorithm
	// the nonce if prepended to the encrypted message
	EncryptECDH(msg []byte, publicKey []byte) ([]byte, error)

	// DecryptECDH decrypt aes encrypted msg using a shared key derived from private key of the node and public key of the other party using Elliptic curve Diffie Helman algorithm
	DecryptECDH(msg []byte, publicKey []byte) ([]byte, error)

	// PrivateKey sends the keypair
	PrivateKey() []byte
}

IdentityManager interface.

type IfaceType

type IfaceType string

IfaceType define the different public interface supported

const (
	// VlanIface means we use vlan for the public interface
	VlanIface IfaceType = "vlan"
	// MacVlanIface means we use macvlan for the public interface
	MacVlanIface IfaceType = "macvlan"
)

type Interface

type Interface struct {
	Name string
	IPs  []net.IPNet
	Mac  string
}

type Interfaces

type Interfaces struct {
	Interfaces map[string]Interface
}

Interfaces struct to bypass zbus generation error where it generate a stub with map as interface instead of map

type KernelArgs

type KernelArgs map[string]string

KernelArgs are arguments passed to the kernel

func (KernelArgs) Extend

func (s KernelArgs) Extend(k KernelArgs)

Extend the arguments with set of extra arguments

func (KernelArgs) String

func (s KernelArgs) String() string

String builds commandline string

type MachineInfo

type MachineInfo struct {
	ConsoleURL string
}

type MachineMetric

type MachineMetric struct {
	Private NetMetric
	Public  NetMetric
}

MachineMetric is a container for metrics from multiple networks currently only grouped as private (wireguard + yggdrasil), and public (public Ips)

type MachineMetrics

type MachineMetrics map[string]MachineMetric

MachineMetrics container for metrics from multiple machines

type MountInfo

type MountInfo struct {
	Source string // source of the mount point on the host
	Target string // target of mount inside the container
}

MountInfo defines a mount point

type MountOptions

type MountOptions struct {
	// ReadOnly
	ReadOnly bool
	// Limit size of read-write layer
	Limit gridtypes.Unit
	// optional storage url (default to hub storage)
	Storage string
	// PersistedVolume used in RW mode. If not provided
	// one that will be created automatically with `Limit` that uses the same mount
	// name, and will be delete (by name) on Unmount. If provided, make sure
	// use use a different name than the mount id, or it will also get deleted
	// on unmount.
	PersistedVolume string
}

MountOptions struct

type NetID

type NetID = zos.NetID

NetID type

type NetMetric

type NetMetric struct {
	NetRxPackets uint64 `json:"net_rx_packets"`
	NetRxBytes   uint64 `json:"net_rx_bytes"`
	NetTxPackets uint64 `json:"net_tx_packets"`
	NetTxBytes   uint64 `json:"net_tx_bytes"`
}

NetMetric aggregated metrics from a single network

func (*NetMetric) Nu

func (n *NetMetric) Nu() float64

Nu calculate network units

type NetResourceMetrics

type NetResourceMetrics map[string]NetMetric

type NetlinkAddress

type NetlinkAddress netlink.Addr

NetlinkAddress alias

type NetlinkAddresses

type NetlinkAddresses []stdnet.IPNet

NetlinkAddresses alias for [][]NetlinkAddress

type Network

type Network struct {
	zos.Network
	NetID NetID `json:"net_id"`
}

Network type

type NetworkInfo

type NetworkInfo struct {

	// Containers don't need to know about anything about bridges,
	// IPs, wireguards since this is all is only known by the network
	// resource which is out of the scope of this module
	Namespace string
}

NetworkInfo defines a network configuration for a container

type Networker

type Networker interface {
	// Ready return nil is networkd is ready to operate
	// This function is used by other deamon to test if networkd is done booting
	Ready() error

	// Create a new network resource
	CreateNR(wl gridtypes.WorkloadID, network Network) (string, error)
	// Delete a network resource
	DeleteNR(wl gridtypes.WorkloadID) error

	// Namespace returns the namespace name for given netid.
	// it doesn't check if network exists.
	Namespace(id zos.NetID) string

	// EnsureZDBPrepare ensures a network namespace is created with a macvlan
	// interface into it to allow the 0-db container to be publicly accessible
	// it returns the name of the network namespace created
	// id is the zdb id (should be unique) is used to drive the hw mac
	// address for the interface so they always get the same IP
	EnsureZDBPrepare(id string) (string, error)

	// ZDBDestroy is the opposite of ZDPrepare, it makes sure network setup done
	// for zdb is rewind. ns param is the namespace return by the ZDBPrepare
	ZDBDestroy(ns string) error

	// MigrateZdbMacvlanToVeth migrate the zdb setup to use veth instead of macvlan
	MigrateZdbMacvlanToVeth() error

	// QSFSNamespace returns the namespace of the qsfs workload
	QSFSNamespace(id string) string

	// QSFSYggIP returns the ygg ip of the qsfs workload
	QSFSYggIP(id string) (string, error)

	// QSFSPrepare creates a network namespace with a macvlan interface into it
	// to allow qsfs container to reach the internet but not be reachable itself
	// it return the name of the network namespace created, and the ygg ip.
	// the id should be unique.
	QSFSPrepare(id string) (string, string, error)

	// QSFSDestroy rewind setup by QSFSPrepare
	QSFSDestroy(id string) error

	// SetupPrivTap sets up a tap device in the network namespace for the networkID. It is hooked
	// to the network bridge. The name of the tap interface is returned
	SetupPrivTap(networkID NetID, name string) (tap string, err error)

	// SetupMyceliumTap creates a new mycelium tap device attached to this network resource with deterministic IP address
	SetupMyceliumTap(name string, netID zos.NetID, config zos.MyceliumIP) (PlanetaryTap, error)

	// SetupYggTap sets up a tap device in the host namespace for the yggdrasil ip
	SetupYggTap(name string) (PlanetaryTap, error)

	// TapExists checks if the tap device with the given name exists already
	TapExists(name string) (bool, error)

	// RemoveTap removes the tap device with the given name
	RemoveTap(name string) error

	// PublicIPv4Support enabled on this node for reservations
	PublicIPv4Support() bool

	// SetupPubTap sets up a tap device in the host namespace for the public ip
	// reservation id. It is hooked to the public bridge. The name of the tap
	// interface is returned
	SetupPubTap(name string) (string, error)

	// PubTapExists checks if the tap device for the public network exists already
	PubTapExists(name string) (bool, error)

	// RemovePubTap removes the public tap device from the host namespace
	RemovePubTap(name string) error

	// SetupPubIPFilter sets up filter for this public ip
	SetupPubIPFilter(filterName string, iface string, ipv4 net.IP, ipv6 net.IP, mac string) error

	// RemovePubIPFilter removes the filter setted up by SetupPubIPFilter
	RemovePubIPFilter(filterName string) error

	// PubIPFilterExists checks if there is a filter installed with that name
	PubIPFilterExists(filterName string) bool
	// DisconnectPubTap disconnects the public tap from the network. The interface
	// itself is not removed and will need to be cleaned up later
	DisconnectPubTap(name string) error

	// GetSubnet of the network with the given ID on the local node
	GetSubnet(networkID NetID) (net.IPNet, error)

	// GetNet returns the full network range of the network
	GetNet(networkID NetID) (net.IPNet, error)

	// GetPublicIPv6Subnet returns the IPv6 prefix op the public subnet of the host
	GetPublicIPv6Subnet() (net.IPNet, error)

	// GetPublicIPV6Gateway gets the gateway for public IPv6 that can be used
	// by the VMs
	GetPublicIPV6Gateway() (net.IP, error)

	// GetDefaultGwIP returns the IPs of the default gateways inside the network
	// resource identified by the network ID on the local node, for IPv4 and IPv6
	// respectively
	GetDefaultGwIP(networkID NetID) (net.IP, net.IP, error)

	// GetIPv6From4 generates an IPv6 address from a given IPv4 address in a NR
	GetIPv6From4(networkID NetID, ip net.IP) (net.IPNet, error)

	// Addrs return the IP addresses of interface
	// if the interface is in a network namespace netns needs to be not empty
	// if iface is empty, return ALL interfaces in the given namespace
	// if they are physical
	Interfaces(iface string, netns string) (Interfaces, error)

	// Addrs return the IP addresses of interface
	// if the interface is in a network namespace netns needs to be not empty
	// [obsolete] please use Interfaces instead
	Addrs(iface string, netns string) (ips []net.IP, mac string, err error)

	WireguardPorts() ([]uint, error)

	// Set node public namespace config.
	SetPublicConfig(cfg PublicConfig) error

	// UnsetPublicConfig removes public config from node
	UnsetPublicConfig() error

	// Get node public namespace config
	GetPublicConfig() (PublicConfig, error)

	// GetPublicExitDevice either return "singe" or "dual(<nic>)"
	GetPublicExitDevice() (ExitDevice, error)

	SetPublicExitDevice(iface string) error

	Metrics() (NetResourceMetrics, error)

	// ZOSAddresses monitoring streams for ZOS bridge IPs
	ZOSAddresses(ctx context.Context) <-chan NetlinkAddresses

	// DMZAddresses monitoring streams for dmz public interface
	DMZAddresses(ctx context.Context) <-chan NetlinkAddresses

	// YggAddresses monitoring streams for yggdrasil interface
	YggAddresses(ctx context.Context) <-chan NetlinkAddresses

	PublicAddresses(ctx context.Context) <-chan OptionPublicConfig
}

Networker is the interface for the network module

type NetworkerLight

type NetworkerLight interface {
	Create(name string, privateNet net.IPNet, seed []byte) error
	Delete(name string) error
	AttachPrivate(name, id string, vmIp net.IP) (device TapDevice, err error)
	AttachMycelium(name, id string, seed []byte) (device TapDevice, err error)
	Detach(id string) error
	Interfaces(iface string, netns string) (Interfaces, error)
	AttachZDB(id string) (string, error)
	ZDBIPs(namespace string) ([]net.IP, error)
	Namespace(id string) string
	Ready() error
	ZOSAddresses(ctx context.Context) <-chan NetlinkAddresses
	GetSubnet(networkID NetID) (net.IPNet, error)
}

NetworkerLight is the interface for the network light module

type NicIOCounterStat

type NicIOCounterStat struct {
	net.IOCountersStat
	RateOut uint64
	RateIn  uint64
}

NicIOCounterStat counter for a nic

type NicsIOCounterStat

type NicsIOCounterStat []NicIOCounterStat

NicsIOCounterStat alias for []NicIOCounterStat

type NodeFeature

type NodeFeature string

Types of workloads can be deployed depending on the network manager running on the node

type OptionPublicConfig

type OptionPublicConfig struct {
	PublicConfig
	HasPublicConfig bool
}

type PerformanceMonitor

type PerformanceMonitor interface {
	Get(taskName string) (TaskResult, error)
	GetAll() ([]TaskResult, error)
}

type PlanetaryTap

type PlanetaryTap struct {
	Name    string
	HW      net.HardwareAddr
	IP      net.IPNet
	Gateway net.IPNet
}

PlanetaryTap structure

type PoolMetrics

type PoolMetrics struct {
	Name string         `json:"name"`
	Type DeviceType     `json:"type"`
	Size gridtypes.Unit `json:"size"`
	Used gridtypes.Unit `json:"used"`
}

type PoolStats

type PoolStats struct {
	disk.UsageStat
	// Counters IO counter for each pool device
	Counters map[string]disk.IOCountersStat `json:"counters"`
}

PoolStats is pool statistics reported by storaged

type PoolsStats

type PoolsStats map[string]PoolStats

PoolsStats alias for map[string]PoolStats

type PowerTargetChangeEvent

type PowerTargetChangeEvent struct {
	FarmID FarmID
	NodeID uint32
	Target substrate.Power
}

type Provision

type Provision interface {
	DecommissionCached(id string, reason string) error
	// GetWorkloadStatus: returns status, bool(true if workload exits otherwise it is false), error
	GetWorkloadStatus(id string) (gridtypes.ResultState, bool, error)
	CreateOrUpdate(twin uint32, deployment gridtypes.Deployment, update bool) error
	Get(twin uint32, contractID uint64) (gridtypes.Deployment, error)
	List(twin uint32) ([]gridtypes.Deployment, error)
	Changes(twin uint32, contractID uint64) ([]gridtypes.Workload, error)
	ListPublicIPs() ([]string, error)
	ListPrivateIPs(twin uint32, network gridtypes.Name) ([]string, error)
}

Provision interface

type PublicConfig

type PublicConfig struct {
	// Type define if we need to use
	// the Vlan field or the MacVlan
	Type IfaceType `json:"type"`

	IPv4 gridtypes.IPNet `json:"ipv4"`
	IPv6 gridtypes.IPNet `json:"ipv6"`

	GW4 net.IP `json:"gw4"`
	GW6 net.IP `json:"gw6"`

	// Domain is the node domain name like gent01.devnet.grid.tf
	// or similar
	Domain string `json:"domain"`
}

PublicConfig is the configuration of the interface that is connected to the public internet

func PublicConfigFrom

func PublicConfigFrom(cfg substrate.PublicConfig) (pub PublicConfig, err error)

func (PublicConfig) Equal

func (p PublicConfig) Equal(cfg PublicConfig) bool

func (*PublicConfig) IsEmpty

func (p *PublicConfig) IsEmpty() bool

type PublicConfigEvent

type PublicConfigEvent struct {
	PublicConfig substrate.OptionPublicConfig
}

PublicConfigEvent pubic config event received. The type specify if this is just notification of the reconnection, or actual event has been received.

type QSFSD

type QSFSD interface {
	Mount(wlID string, cfg zos.QuantumSafeFS) (QSFSInfo, error)
	UpdateMount(wlID string, cfg zos.QuantumSafeFS) (QSFSInfo, error)
	SignalDelete(wlID string) error
	Metrics() (QSFSMetrics, error)
}

type QSFSInfo

type QSFSInfo struct {
	Path            string
	MetricsEndpoint string
}

type QSFSMetrics

type QSFSMetrics struct {
	Consumption map[string]NetMetric
}

func (*QSFSMetrics) Nu

func (q *QSFSMetrics) Nu(wlID string) (result uint64)

type Registrar

type Registrar interface {
	NodeID() (uint32, error)
	TwinID() (uint32, error)
}

type RootFSPropagation

type RootFSPropagation string

RootFSPropagation defines how the submounts are propagated to its mountpoint peers

type Route

type Route struct {
	Net net.IPNet
	// Gateway can be nil, in that
	// case the device is used as a dev instead
	Gateway net.IP
}

Route structure

type SharedDir

type SharedDir struct {
	// ID unique qsfs identifier
	ID string
	// Path raw disk path
	Path string
	// Target is mount point. Only in container mode
	Target string
}

SharedDir specifies virtio shared dir params

type Statistics

type Statistics interface {
	ReservedStream(ctx context.Context) <-chan gridtypes.Capacity
	Current() (gridtypes.Capacity, error)
	Total() gridtypes.Capacity
	Workloads() (int, error)
	GetCounters() (Counters, error)
	ListGPUs() ([]GPUInfo, error)
}

type Stats

type Stats struct {
	Type     string `bson:"type" json:"type"`
	Endpoint string `bson:"endpoint" json:"endpoint"`
}

Stats endpoints

type StorageModule

type StorageModule interface {
	// Cache method return information about zos cache volume
	Cache() (Volume, error)

	// Total gives the total amount of storage available for a device type
	Total(kind DeviceType) (uint64, error)
	// BrokenPools lists the broken storage pools that have been detected
	BrokenPools() []BrokenPool
	// BrokenDevices lists the broken devices that have been detected
	BrokenDevices() []BrokenDevice
	//Monitor returns stats stream about pools
	Monitor(ctx context.Context) <-chan PoolsStats

	// VolumeCreate creates a new volume
	VolumeCreate(name string, size gridtypes.Unit) (Volume, error)

	// VolumeUpdate updates the size of an existing volume
	VolumeUpdate(name string, size gridtypes.Unit) error

	// VolumeLookup return volume information for given name
	VolumeLookup(name string) (Volume, error)

	// VolumeExists checks if a volume exists and returns error if the lookup failed
	VolumeExists(name string) (bool, error)

	// VolumeDelete deletes a volume by name
	VolumeDelete(name string) error

	// VolumeList list all volumes
	VolumeList() ([]Volume, error)

	// DiskCreate creates a virtual disk given name and size
	DiskCreate(name string, size gridtypes.Unit) (VDisk, error)

	// DiskResize resizes the disk to given size
	DiskResize(name string, size gridtypes.Unit) (VDisk, error)

	// DiskWrite writes the given raw image to disk
	DiskWrite(name string, image string) error

	// DiskFormat makes sure disk has filesystem, if it already formatted nothing happens
	DiskFormat(name string) error

	// DiskLookup looks up vdisk by name
	DiskLookup(name string) (VDisk, error)

	// DiskExists checks if disk exists
	DiskExists(name string) bool

	// DiskDelete deletes a disk
	DiskDelete(name string) error

	DiskList() ([]VDisk, error)

	//Devices list all "allocated" devices
	Devices() ([]Device, error)

	// DeviceAllocate allocates a new device (formats and give a new ID)
	DeviceAllocate(min gridtypes.Unit) (Device, error)

	// DeviceLookup inspects a previously allocated device
	DeviceLookup(name string) (Device, error)

	// Capacity
	Metrics() ([]PoolMetrics, error)
}

StorageModule is the storage subsystem interface this should allow you to work with the following types of storage medium - full disks (device) (these are used by zdb) - subvolumes these are used as a read-write layers for 0-fs mounts - vdisks are used by zmachines this works as following: a storage module maintains a list of ALL disks on the system separated in 2 sets of pools (SSDs, and HDDs) ssd pools can only be used for - subvolumes - vdisks hdd pools are only used by zdb as one disk

type StrIdentifier

type StrIdentifier string

StrIdentifier is a helper type that implement the Identifier interface on top of simple string

func (StrIdentifier) Identity

func (s StrIdentifier) Identity() string

Identity implements the Identifier interface

type Stream

type Stream struct {
	//ID stream ID must be unique
	ID string
	// Network namespace where the streamer will
	// run
	Namespace string
	// Output URL as accepted by the streamer tool
	Output string
}

func (*Stream) Valid

func (s *Stream) Valid() error

type SubstrateError

type SubstrateError struct {
	Err  error
	Code int
}

func (*SubstrateError) IsCode

func (e *SubstrateError) IsCode(codes ...int) bool

func (*SubstrateError) IsError

func (e *SubstrateError) IsError() bool

type SubstrateGateway

type SubstrateGateway interface {
	CreateNode(node substrate.Node) (uint32, error)
	CreateTwin(relay string, pk []byte) (uint32, error)
	EnsureAccount(activationURL []string, termsAndConditionsLink string, termsAndConditionsHash string) (info substrate.AccountInfo, err error)
	GetContract(id uint64) (substrate.Contract, SubstrateError)
	GetContractIDByNameRegistration(name string) (uint64, SubstrateError)
	GetFarm(id uint32) (substrate.Farm, error)
	GetNode(id uint32) (substrate.Node, error)
	GetNodeByTwinID(twin uint32) (uint32, SubstrateError)
	GetNodeContracts(node uint32) ([]types.U64, error)
	GetNodeRentContract(node uint32) (uint64, SubstrateError)
	GetNodes(farmID uint32) ([]uint32, error)
	GetPowerTarget(nodeID uint32) (power substrate.NodePower, err error)
	GetTwin(id uint32) (substrate.Twin, error)
	GetTwinByPubKey(pk []byte) (uint32, SubstrateError)
	Report(consumptions []substrate.NruConsumption) (types.Hash, error)
	SetContractConsumption(resources ...substrate.ContractResources) error
	SetNodePowerState(up bool) (hash types.Hash, err error)
	UpdateNode(node substrate.Node) (uint32, error)
	UpdateNodeUptimeV2(uptime uint64, timestampHint uint64) (hash types.Hash, err error)
	GetTime() (time.Time, error)
	GetZosVersion() (string, error)
}

type SystemCall

type SystemCall interface {
	Mount(string, string, string, uintptr, string) error
}

type SystemMonitor

type SystemMonitor interface {
	NodeID() uint32
	Memory(ctx context.Context) <-chan VirtualMemoryStat
	CPU(ctx context.Context) <-chan TimesStat
	Disks(ctx context.Context) <-chan DisksIOCountersStat
	Nics(ctx context.Context) <-chan NicsIOCounterStat
	GetNodeFeatures() []NodeFeature
}

SystemMonitor interface (provided by noded)

type SystemOS

type SystemOS interface {
	Create(string) (io.ReadCloser, error)
	MkdirAll(string, fs.FileMode) error
	Mkdir(string, fs.FileMode) error
	Stat(string) (fs.FileInfo, error)
	RemoveAll(string) error
	IsNotExist(error) bool
}

SystemOS interface to mock actual OS operations.

type SystemOSMock

type SystemOSMock struct {
	mock.Mock
}

SystemOSMock used to mock the filesystem object

func (*SystemOSMock) Create

func (os *SystemOSMock) Create(path string) (io.ReadCloser, error)

func (*SystemOSMock) IsNotExist

func (os *SystemOSMock) IsNotExist(err error) bool

func (*SystemOSMock) Mkdir

func (os *SystemOSMock) Mkdir(path string, perm fs.FileMode) error

func (*SystemOSMock) MkdirAll

func (os *SystemOSMock) MkdirAll(path string, perm fs.FileMode) error

func (*SystemOSMock) Mount

func (os *SystemOSMock) Mount(source string, target string, fstype string, flags uintptr, data string) error

func (*SystemOSMock) RemoveAll

func (os *SystemOSMock) RemoveAll(path string) error

func (*SystemOSMock) Stat

func (os *SystemOSMock) Stat(path string) (fs.FileInfo, error)

type TapDevice

type TapDevice struct {
	Name   string
	Mac    net.HardwareAddr
	IP     *net.IPNet
	Routes []Route
}

type TaskResult

type TaskResult struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Timestamp   uint64      `json:"timestamp"`
	Result      interface{} `json:"result"`
}

TaskResult the result test schema

type TimesStat

type TimesStat struct {
	cpu.TimesStat
	Percent float64
	Time    time.Time
}

TimesStat struct

func (*TimesStat) String

func (s *TimesStat) String() string

type Usage

type Usage struct {
	Size gridtypes.Unit
	Used gridtypes.Unit
}

Usage struct

type UsersCounters

type UsersCounters struct {
	// Total deployments count
	Deployments int `json:"deployments"`
	// Total workloads count
	Workloads int `json:"workloads"`
	// Last deployment timestamp
	LastDeploymentTimestamp gridtypes.Timestamp `json:"last_deployment_timestamp"`
}

UsersCounters the expected counters for deployments and workloads

type VDisk

type VDisk struct {
	// Path to disk
	Path string
	// Size in bytes
	Size int64
}

VDisk info returned by a call to inspect

func (*VDisk) Name

func (d *VDisk) Name() string

Name returns the Name part of the disk path

type VM

type VM struct {
	// virtual machine name, or ID
	Name string
	// CPU is number of cores assigned to the VM
	CPU uint8
	// Memory size
	Memory gridtypes.Unit
	// Network is network info
	Network VMNetworkInfo
	// KernelImage path to uncompressed linux kernel ELF
	KernelImage string
	// InitrdImage (optional) path to initrd disk
	InitrdImage string
	// KernelArgs to override the default kernel arguments. (default: "ro console=ttyS0 noapic reboot=k panic=1 pci=off nomodules")
	KernelArgs KernelArgs
	// Entrypoint a shell-compatible command to execute as the init process
	Entrypoint string
	// Disks are a list of disks that are going to
	// be auto allocated on the provided storage path
	Disks []VMDisk
	// Shared are a list of qsfs that are going to
	Shared []SharedDir
	// Boot options
	Boot Boot
	// Environment is injected to the VM via container mechanism (virtiofs)
	// otherwise it's added to the kernel arguments
	Environment map[string]string
	// If this flag is set, the VM module will not auto start
	// this machine hence, also no auto clean up when it exits
	// it's up to the caller to check for the machine status
	// and do clean up (module.Delete(vm)) when needed
	NoKeepAlive bool
	// Hostname for the vm
	Hostname string

	// extra PCI devices to be attached to
	// the virtual machine the strings
	// has to be a valid pci bus ids
	// in the format 0000:01:00.0
	Devices []string
}

VM config structure

func (*VM) Validate

func (vm *VM) Validate() error

Validate vm data

type VMDisk

type VMDisk struct {
	// Path raw disk path
	Path string
	// Target is mount point. Only in container mode
	Target string
}

VMDisk specifies vm disk params

type VMIface

type VMIface struct {
	// Tap device name
	Tap string
	// Mac address of the device
	MAC string
	// ips assigned to this interface
	IPs []net.IPNet
	// extra routes on this interface
	Routes []Route
	// IP4DefaultGateway address for ipv4
	IP4DefaultGateway net.IP
	// IP6DefaultGateway address for ipv6
	IP6DefaultGateway net.IP
	// PublicIPv4 holds a public IPv4
	PublicIPv4 bool
	// PublicIPv4 holds a public Ipv6
	PublicIPv6 bool
	// NetId holds network id (for private network only)
	NetID zos.NetID
}

VMIface structure

type VMInfo

type VMInfo struct {
	// Flag for enabling/disabling Hyperthreading
	// Required: true
	HtEnabled bool

	// Memory size of VM
	// Required: true
	Memory int64

	// Number of vCPUs (either 1 or an even number)
	CPU int64
}

VMInfo returned by the inspect method

type VMModule

type VMModule interface {
	Run(vm VM) (MachineInfo, error)
	Inspect(name string) (VMInfo, error)
	Delete(name string) error
	Exists(name string) bool
	Logs(name string) (string, error)
	List() ([]string, error)
	Metrics() (MachineMetrics, error)
	// Lock set lock on VM (pause,resume)
	Lock(name string, lock bool) error

	// StreamCreate creates a stream for vm `name`
	StreamCreate(name string, stream Stream) error
	// delete stream by stream id.
	StreamDelete(id string) error
}

VMModule defines the virtual machine module interface

type VMNetworkInfo

type VMNetworkInfo struct {
	// Interfaces for the vm network
	Ifaces []VMIface
	// Nameservers dns servers
	Nameservers []net.IP
}

VMNetworkInfo structure

type VersionMonitor

type VersionMonitor interface {
	GetVersion() semver.Version
	Version(ctx context.Context) <-chan semver.Version
}

VersionMonitor interface (provided by identityd)

type VirtualMemoryStat

type VirtualMemoryStat mem.VirtualMemoryStat

VirtualMemoryStat struct

type Volume

type Volume struct {
	Name  string
	Path  string
	Usage Usage
}

Volume struct is a btrfs subvolume

type ZUI

type ZUI interface {
	PushErrors(label string, errors []string) error
}

Directories

Path Synopsis
dmi
zos
store
Key store implements different methods of storing the node identity seed on disk
Key store implements different methods of storing the node identity seed on disk
nft
options
Package options abstract setting common networking sys flags on the selected namespaces
Package options abstract setting common networking sys flags on the selected namespaces
nft
nr
options
Package options abstract setting common networking sys flags on the selected namespaces
Package options abstract setting common networking sys flags on the selected namespaces
vm
zdb
Package provision exposes the Engine type.
Package provision exposes the Engine type.
common
Package common hold logic that is used by both the provision and primitive package it purpose is mainly to avoid circular dependencies
Package common hold logic that is used by both the provision and primitive package it purpose is mainly to avoid circular dependencies
mw
* rotate package provides a very simple tool to truncate a given file to 0 after it copies the last *configurable* part of this file to a new file with suffix .tail
* rotate package provides a very simple tool to truncate a given file to 0 after it copies the last *configurable* part of this file to a new file with suffix .tail
hub
vm
Package zdb implements a client to 0-db: https://github.com/threefoldtech/0-DB
Package zdb implements a client to 0-db: https://github.com/threefoldtech/0-DB
Package zinit exposes function to interat with zinit service life cyle management
Package zinit exposes function to interat with zinit service life cyle management

Jump to

Keyboard shortcuts

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