workloads

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 29 Imported by: 7

Documentation

Overview

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads is the terraform provider

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Package workloads includes workloads types (vm, zdb, QSFS, public IP, gateway name, gateway fqdn, disk)

Index

Constants

View Source
const (
	ZDBModeUser = "user"
	ZDBModeSeq  = "seq"
)

Variables

View Source
var (
	// VMType for deployment date of vms
	VMType = "vm"
	// GatewayNameType for deployment date of name gateway
	GatewayNameType = "Gateway Name"
	// GatewayFQDNType for deployment date of fqdn gateway
	GatewayFQDNType = "Gateway Fqdn"
	// K8sType for deployment date of k8s
	K8sType = "kubernetes"
	// NetworkType for deployment date of network
	NetworkType = "network"
)
View Source
var ExternalSKZeroValue = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="

ExternalSKZeroValue as its not empty when it is zero

View Source
var K8sFlist = "https://hub.grid.tf/tf-official-apps/threefolddev-k3s-v1.31.0.flist"

old: https://hub.grid.tf/tf-official-apps/threefoldtech-k3s-latest.flist

Functions

func ConstructK8sPublicIPWorkload added in v0.16.0

func ConstructK8sPublicIPWorkload(workloadName string, ipv4 bool, ipv6 bool) gridtypes.Workload

ConstructPublicIPWorkload constructs a public IP workload

func ConstructPublicIPWorkload

func ConstructPublicIPWorkload(workloadName string, ipv4 bool, ipv6 bool) zos.Workload

ConstructPublicIPWorkload constructs a public IP workload

func Contains

func Contains[T comparable](elements []T, element T) bool

Contains check if a slice contains an element

func Delete

func Delete[T comparable](elements []T, element T) []T

Delete removes an element from a slice

func FlistChecksumURL

func FlistChecksumURL(url string) string

FlistChecksumURL returns flist check sum url format

func GenerateWGConfig

func GenerateWGConfig(Address string, AccessPrivatekey string, NodePublicKey string, NodeEndpoint string, NetworkIPRange string) string

GenerateWGConfig generates wireguard configs

func GetFlistChecksum

func GetFlistChecksum(url string) (string, error)

GetFlistChecksum gets flist check sum url

func GetUsedIPs

func GetUsedIPs(dl zos.Deployment, nodeID uint32) ([]byte, error)

GetUsedIPs returns used IPs for a deployment

func IPNet

func IPNet(a, b, c, d, msk byte) zos.IPNet

IPNet returns an IP net type

func NewGridDeployment

func NewGridDeployment(twin uint32, contractID uint64, workloads []zos.Workload) zos.Deployment

NewGridDeployment generates a new grid deployment

func NewIPRange

func NewIPRange(n net.IPNet) zos.IPNet

NewIPRange generates a new IPRange from the given network IP

func NewWorkloadFromMap

func NewWorkloadFromMap(wlMap map[string]interface{}, result interface{}) (interface{}, error)

NewWorkloadFromMap converts a map (dict) to a workload

func NewZosBackends

func NewZosBackends(bks []string) (backends []zos.Backend)

NewZosBackends generates new zos backends for the given string backends

func RandomMyceliumIPSeed added in v0.13.22

func RandomMyceliumIPSeed() ([]byte, error)

func RandomMyceliumKey added in v0.13.22

func RandomMyceliumKey() ([]byte, error)

func ToMap

func ToMap(workload interface{}) (map[string]interface{}, error)

ToMap converts workload data to a map (dict)

func ValidateFlist added in v0.15.12

func ValidateFlist(flistUrl, flistChecksum string) error

func WgIP

func WgIP(ip zos.IPNet) zos.IPNet

WgIP return wireguard IP network

Types

type Backend

type Backend zosTypes.ZdbBackend

Backend is a zos backend

type Backends

type Backends []Backend

Backends is a list of backends

func BackendsFromZos

func BackendsFromZos(bs []zos.ZdbBackend) (backends Backends)

BackendsFromZos gets backends from zos

type Deployment

type Deployment struct {
	Name             string
	NodeID           uint32
	SolutionType     string
	SolutionProvider *uint64
	// TODO: remove
	NetworkName string

	Disks    []Disk
	Zdbs     []ZDB
	Vms      []VM
	VmsLight []VMLight
	QSFS     []QSFS
	Volumes  []Volume

	// computed
	NodeDeploymentID map[uint32]uint64
	ContractID       uint64
	IPrange          string
}

Deployment struct

func NewDeployment

func NewDeployment(name string, nodeID uint32,
	solutionType string, solutionProvider *uint64,
	NetworkName string,
	disks []Disk,
	zdbs []ZDB,
	vms []VM,
	vmsLight []VMLight,
	QSFS []QSFS,
	volumes []Volume,
) Deployment

NewDeployment generates a new deployment

func NewDeploymentFromZosDeployment

func NewDeploymentFromZosDeployment(d zos.Deployment, nodeID uint32) (Deployment, error)

NewDeploymentFromZosDeployment generates deployment from zos deployment

func (*Deployment) GenerateMetadata

func (d *Deployment) GenerateMetadata() (string, error)

GenerateMetadata generates deployment metadata

func (*Deployment) Match

func (d *Deployment) Match(disks []Disk, QSFS []QSFS, zdbs []ZDB, vms []VM, vmsLight []VMLight, volumes []Volume)

Match objects to match the input

func (*Deployment) Nullify

func (d *Deployment) Nullify()

Nullify resets deployment

func (*Deployment) Validate

func (d *Deployment) Validate() error

Validate validates a deployment

func (*Deployment) ZosDeployment

func (d *Deployment) ZosDeployment(twin uint32) (zos.Deployment, error)

ZosDeployment generates a new zos deployment from a deployment

type DeploymentData

type DeploymentData struct {
	Version     int    `json:"version"`
	Type        string `json:"type"`
	Name        string `json:"name"`
	ProjectName string `json:"projectName"`
}

DeploymentData for deployments meta data

func ParseDeploymentData

func ParseDeploymentData(deploymentMetaData string) (DeploymentData, error)

ParseDeploymentData parses the deployment metadata

type Disk

type Disk struct {
	Name        string `json:"name"`
	SizeGB      uint64 `json:"size"`
	Description string `json:"description"`
}

Disk struct

func NewDiskFromWorkload

func NewDiskFromWorkload(wl *zosTypes.Workload) (Disk, error)

NewDiskFromWorkload generates a new disk from a workload

func (*Disk) Validate added in v0.15.12

func (d *Disk) Validate() error

func (*Disk) ZosWorkload

func (d *Disk) ZosWorkload() zosTypes.Workload

ZosWorkload generates a workload from a disk

type GatewayFQDNProxy

type GatewayFQDNProxy struct {
	// required
	NodeID uint32
	// Backends are list of backend ips
	Backends []zos.Backend
	// FQDN deployed on the node
	FQDN string
	// Name is the workload name
	Name string

	// optional
	// Passthrough whether to pass tls traffic or not
	TLSPassthrough bool
	// Network name to join
	Network      string
	Description  string
	SolutionType string

	// computed
	ContractID       uint64
	NodeDeploymentID map[uint32]uint64
}

GatewayFQDNProxy for gateway FQDN proxy

func NewGatewayFQDNProxyFromZosWorkload

func NewGatewayFQDNProxyFromZosWorkload(wl gridtypes.Workload) (GatewayFQDNProxy, error)

NewGatewayFQDNProxyFromZosWorkload generates a gateway FQDN proxy from a zos workload

func (*GatewayFQDNProxy) GenerateMetadata

func (g *GatewayFQDNProxy) GenerateMetadata() (string, error)

GenerateMetadata generates gateway deployment metadata

func (*GatewayFQDNProxy) Validate added in v0.15.12

func (g *GatewayFQDNProxy) Validate() error

Validate validates gateway data

func (*GatewayFQDNProxy) ZosWorkload

func (g *GatewayFQDNProxy) ZosWorkload() gridtypes.Workload

ZosWorkload generates a zos workload from GatewayFQDNProxy

type GatewayNameProxy

type GatewayNameProxy struct {
	// Required
	NodeID uint32
	// Name the fully qualified domain name to use (cannot be present with Name)
	Name string
	// Backends are list of backend ips
	Backends []zos.Backend

	// Optional
	// Passthrough whether to pass tls traffic or not
	TLSPassthrough bool
	// Network name to join
	Network      string
	Description  string
	SolutionType string

	// computed
	// FQDN deployed on the node
	NodeDeploymentID map[uint32]uint64
	FQDN             string
	NameContractID   uint64
	ContractID       uint64
}

GatewayNameProxy struct for gateway name proxy

func NewGatewayNameProxyFromZosWorkload

func NewGatewayNameProxyFromZosWorkload(wl gridtypes.Workload) (GatewayNameProxy, error)

NewGatewayNameProxyFromZosWorkload generates a gateway name proxy from a zos workload

func (*GatewayNameProxy) GenerateMetadata

func (g *GatewayNameProxy) GenerateMetadata() (string, error)

GenerateMetadata generates gateway deployment metadata

func (*GatewayNameProxy) Validate added in v0.15.12

func (g *GatewayNameProxy) Validate() error

Validate validates gateway data

func (*GatewayNameProxy) ZosWorkload

func (g *GatewayNameProxy) ZosWorkload() gridtypes.Workload

ZosWorkload generates a zos workload from GatewayNameProxy

type Group

type Group struct {
	Backends Backends `json:"backends"`
}

Group is a zos group

type Groups

type Groups []Group

Groups is a list of groups

func GroupsFromZos

func GroupsFromZos(gs []zos.ZdbGroup) (groups Groups)

GroupsFromZos gets groups from zos

type K8sCluster

type K8sCluster struct {
	Master      *K8sNode
	Workers     []K8sNode
	Token       string
	NetworkName string

	Flist         string `json:"flist"`
	FlistChecksum string `json:"flist_checksum"`
	Entrypoint    string `json:"entry_point"`

	// optional
	SolutionType string
	SSHKey       string

	// computed
	NodesIPRange     map[uint32]gridtypes.IPNet
	NodeDeploymentID map[uint32]uint64
}

K8sCluster struct for k8s cluster

func (*K8sCluster) GenerateMetadata

func (k *K8sCluster) GenerateMetadata() (string, error)

GenerateMetadata generates deployment metadata

func (*K8sCluster) InvalidateBrokenAttributes

func (k *K8sCluster) InvalidateBrokenAttributes(sub subi.SubstrateExt) error

InvalidateBrokenAttributes removes outdated attrs and deleted contracts

func (*K8sCluster) Validate added in v0.15.12

func (k *K8sCluster) Validate() error

func (*K8sCluster) ValidateIPranges

func (k *K8sCluster) ValidateIPranges() error

ValidateIPranges validates NodesIPRange of master && workers of k8s cluster

func (*K8sCluster) ValidateToken

func (k *K8sCluster) ValidateToken() error

ValidateToken validate cluster token

func (*K8sCluster) ZosWorkloads

func (k *K8sCluster) ZosWorkloads() ([]gridtypes.Workload, error)

ZosWorkloads generates k8s workloads from a k8s cluster

type K8sNode

type K8sNode struct {
	*VM
	DiskSizeGB uint64 `json:"disk_size"`
}

K8sNode kubernetes data

func NewK8sNodeFromWorkload

func NewK8sNodeFromWorkload(wl gridtypes.Workload, nodeID uint32, diskSize uint64, computedIP string, computedIP6 string) (K8sNode, error)

NewK8sNodeFromWorkload generates a new k8s from a workload

func (*K8sNode) MasterZosWorkload

func (k *K8sNode) MasterZosWorkload(cluster *K8sCluster) (K8sWorkloads []gridtypes.Workload)

MasterZosWorkload generates a k8s master workload from a k8s node

func (*K8sNode) WorkerZosWorkload

func (k *K8sNode) WorkerZosWorkload(cluster *K8sCluster) (K8sWorkloads []gridtypes.Workload)

WorkerZosWorkload generates a k8s worker workload from a k8s node

type Metadata

type Metadata struct {
	Type                string   `json:"type"`
	Prefix              string   `json:"prefix"`
	EncryptionAlgorithm string   `json:"encryption_algorithm"`
	EncryptionKey       string   `json:"encryption_key"`
	Backends            Backends `json:"backends"`
}

Metadata for QSFS

type Mount

type Mount struct {
	Name       string `json:"name"`
	MountPoint string `yaml:"mount_point" json:"mount_point"`
}

Mount disks/volumes struct

func (*Mount) Validate added in v0.15.12

func (m *Mount) Validate() error

type Network added in v0.16.0

type Network interface {
	Validate() error
	GetVersion() Version
	ZosWorkload(subnet zos.IPNet, wgPrivateKey string, wgListenPort uint16, peers []zos.Peer, metadata string, myceliumKey []byte) zos.Workload
	GenerateMetadata() (string, error)
	InvalidateBrokenAttributes(subConn subi.SubstrateExt, ncPool client.NodeClientGetter) error
	GenerateVersionlessDeployments(
		ctx context.Context,
		ncPool client.NodeClientGetter,
		subConn subi.SubstrateExt,
		twinID, publicNode uint32,
		allNodes map[uint32]struct{},
		endpoints map[uint32]net.IP,
		nodeUsedPorts map[uint32][]uint16,
	) (map[uint32]zos.Deployment, error)
	ReadNodesConfig(ctx context.Context, nodeDeployments map[uint32]zos.Deployment) error

	GetNodes() []uint32
	GetNodeDeploymentID() map[uint32]uint64
	GetPublicNodeID() uint32
	GetNodesIPRange() map[uint32]zos.IPNet
	GetName() string
	GetSolutionType() string
	GetDescription() string
	GetAddWGAccess() bool
	GetMyceliumKeys() map[uint32][]byte
	GetIPRange() zos.IPNet
	GetAccessWGConfig() string
	GetExternalIP() *zos.IPNet
	GetExternalSK() wgtypes.Key

	SetNodeDeploymentID(nodeDeploymentsIDs map[uint32]uint64)
	SetNodes(nodes []uint32)
	SetMyceliumKeys(keys map[uint32][]byte)
	SetKeys(keys map[uint32]wgtypes.Key)
	SetNodesIPRange(nodesIPRange map[uint32]zos.IPNet)
	SetWGPort(wgPort map[uint32]int)
	SetAccessWGConfig(accessWGConfig string)
	SetExternalIP(ip *zos.IPNet)
	SetExternalSK(key wgtypes.Key)
	SetPublicNodeID(node uint32)
}

type NetworkMetaData

type NetworkMetaData struct {
	Version      int          `json:"version"`
	UserAccesses []UserAccess `json:"user_accesses"`
}

NetworkMetaData is added to network workloads to help rebuilding networks when retrieved from the grid

func (*NetworkMetaData) UnmarshalJSON added in v0.14.7

func (m *NetworkMetaData) UnmarshalJSON(data []byte) error

type QSFS

type QSFS struct {
	Name                 string   `json:"name"`
	Description          string   `json:"description"`
	Cache                int      `json:"cache"`
	MinimalShards        uint32   `json:"minimal_shards"`
	ExpectedShards       uint32   `json:"expected_shards"`
	RedundantGroups      uint32   `json:"redundant_groups"`
	RedundantNodes       uint32   `json:"redundant_nodes"`
	MaxZDBDataDirSize    uint32   `json:"max_zdb_data_dir_size"`
	EncryptionAlgorithm  string   `json:"encryption_algorithm"`
	EncryptionKey        string   `json:"encryption_key"`
	CompressionAlgorithm string   `json:"compression_algorithm"`
	Metadata             Metadata `json:"metadata"`
	Groups               Groups   `json:"groups"`

	// OUTPUT
	MetricsEndpoint string `json:"metrics_endpoint"`
}

QSFS struct

func NewQSFSFromWorkload

func NewQSFSFromWorkload(wl *zosTypes.Workload) (QSFS, error)

NewQSFSFromWorkload generates a new QSFS from a workload

func (*QSFS) UpdateFromWorkload

func (q *QSFS) UpdateFromWorkload(wl *zosTypes.Workload) error

UpdateFromWorkload updates a QSFS from a workload TODO: no updates, should construct itself from the workload

func (*QSFS) Validate added in v0.15.12

func (q *QSFS) Validate() error

func (*QSFS) ZosWorkload

func (q *QSFS) ZosWorkload() (zosTypes.Workload, error)

ZosWorkload generates a zos workload

type UserAccess

type UserAccess struct {
	Subnet     string `json:"subnet"`
	PrivateKey string `json:"private_key"`
	NodeID     uint32 `json:"node_id"`
}

UserAccess struct

type VM

type VM struct {
	Name          string `json:"name"`
	NodeID        uint32 `json:"node"`
	NetworkName   string `json:"network_name"`
	Description   string `json:"description"`
	Flist         string `json:"flist"`
	FlistChecksum string `json:"flist_checksum"`
	Entrypoint    string `json:"entrypoint"`
	PublicIP      bool   `json:"publicip"`
	PublicIP6     bool   `json:"publicip6"`
	Planetary     bool   `json:"planetary"`
	Corex         bool   `json:"corex"` // TODO: Is it works ??
	IP            string `json:"ip"`
	// used to get the same mycelium ip for the vm.
	MyceliumIPSeed []byte            `json:"mycelium_ip_seed"`
	GPUs           []zosTypes.GPU    `json:"gpus"`
	CPU            uint8             `json:"cpu"`
	MemoryMB       uint64            `json:"memory"`
	RootfsSizeMB   uint64            `json:"rootfs_size"`
	Mounts         []Mount           `json:"mounts"`
	Zlogs          []Zlog            `json:"zlogs"`
	EnvVars        map[string]string `json:"env_vars"`

	// OUTPUT
	ComputedIP  string `json:"computedip"`
	ComputedIP6 string `json:"computedip6"`
	PlanetaryIP string `json:"planetary_ip"`
	MyceliumIP  string `json:"mycelium_ip"`
	ConsoleURL  string `json:"console_url"`
}

VM is a virtual machine struct

func NewVMFromWorkload

func NewVMFromWorkload(wl *zosTypes.Workload, dl *zosTypes.Deployment, nodeID uint32) (VM, error)

NewVMFromWorkload generates a new vm from given workloads and deployment

func (*VM) AssignPrivateIP added in v0.16.0

func (vm *VM) AssignPrivateIP(
	networkName,
	ipRange string,
	nodeID uint32,
	ipRangeCIDR *net.IPNet,
	ip net.IP,
	curHostID byte,
	usedHosts map[string]map[uint32][]byte,
) (string, error)

func (*VM) LoadFromVM

func (vm *VM) LoadFromVM(vm2 *VM)

LoadFromVM compares the vm with another given vm

func (*VM) MinRootSize added in v0.15.12

func (vm *VM) MinRootSize() uint64

func (*VM) Validate

func (vm *VM) Validate() error

Validate validates a virtual machine data

func (*VM) ZosWorkload

func (vm *VM) ZosWorkload() []zosTypes.Workload

ZosWorkload generates zos vm workloads

type VMLight added in v0.16.0

type VMLight struct {
	Name          string `json:"name"`
	NodeID        uint32 `json:"node"`
	NetworkName   string `json:"network_name"`
	Description   string `json:"description"`
	Flist         string `json:"flist"`
	FlistChecksum string `json:"flist_checksum"`
	Entrypoint    string `json:"entrypoint"`
	Corex         bool   `json:"corex"`
	IP            string `json:"ip"`
	// used to get the same mycelium ip for the vm.
	MyceliumIPSeed []byte            `json:"mycelium_ip_seed"`
	GPUs           []zos.GPU         `json:"gpus"`
	CPU            uint8             `json:"cpu"`
	MemoryMB       uint64            `json:"memory"`
	RootfsSizeMB   uint64            `json:"rootfs_size"`
	Mounts         []Mount           `json:"mounts"`
	Zlogs          []Zlog            `json:"zlogs"`
	EnvVars        map[string]string `json:"env_vars"`

	// OUTPUT
	MyceliumIP string `json:"mycelium_ip"`
	ConsoleURL string `json:"console_url"`
}

VMLight is a virtual machine struct

func NewVMLightFromWorkload added in v0.16.0

func NewVMLightFromWorkload(wl *zos.Workload, dl *zos.Deployment, nodeID uint32) (VMLight, error)

NewVMLightFromWorkload generates a new vm from given workloads and deployment

func (*VMLight) AssignPrivateIP added in v0.16.0

func (vm *VMLight) AssignPrivateIP(
	networkName,
	ipRange string,
	nodeID uint32,
	ipRangeCIDR *net.IPNet,
	ip net.IP,
	curHostID byte,
	usedHosts map[string]map[uint32][]byte,
) (string, error)

func (*VMLight) LoadFromVM added in v0.16.0

func (vm *VMLight) LoadFromVM(vm2 *VMLight)

LoadFromVM compares the vm with another given vm

func (*VMLight) MinRootSize added in v0.16.0

func (vm *VMLight) MinRootSize() uint64

func (*VMLight) Validate added in v0.16.0

func (vm *VMLight) Validate() error

Validate validates a virtual machine data

func (*VMLight) ZosWorkload added in v0.16.0

func (vm *VMLight) ZosWorkload() []zos.Workload

ZosWorkload generates zos vm workloads

type Version added in v0.14.7

type Version int
const (
	Version3 Version = 3
	Version4 Version = 4
)

type Volume added in v0.15.12

type Volume struct {
	Name        string `json:"name"`
	SizeGB      uint64 `json:"size"`
	Description string `json:"description"`
}

Volume struct

func NewVolumeFromWorkload added in v0.15.12

func NewVolumeFromWorkload(wl *zosTypes.Workload) (Volume, error)

NewVolumeFromWorkload generates a new volume from a workload

func (*Volume) Validate added in v0.15.12

func (v *Volume) Validate() error

func (*Volume) ZosWorkload added in v0.15.12

func (v *Volume) ZosWorkload() zosTypes.Workload

ZosWorkload generates a workload from a volume

type ZDB

type ZDB struct {
	Name        string `json:"name"`
	Password    string `json:"password"`
	Public      bool   `json:"public"`
	SizeGB      uint64 `json:"size"`
	Description string `json:"description"`
	Mode        string `json:"mode"`

	// OUTPUT
	IPs       []string `json:"ips"`
	Port      uint32   `json:"port"`
	Namespace string   `json:"namespace"`
}

ZDB workload struct

func NewZDBFromWorkload

func NewZDBFromWorkload(wl *zosTypes.Workload) (ZDB, error)

NewZDBFromWorkload generates a new zdb from a workload

func (*ZDB) Validate added in v0.15.12

func (z *ZDB) Validate() error

func (*ZDB) ZosWorkload

func (z *ZDB) ZosWorkload() zosTypes.Workload

ZosWorkload generates a workload from a zdb

type ZNet

type ZNet struct {
	Name         string
	Description  string
	Nodes        []uint32
	IPRange      zos.IPNet
	AddWGAccess  bool
	MyceliumKeys map[uint32][]byte
	SolutionType string

	// computed
	AccessWGConfig   string
	ExternalIP       *zos.IPNet
	ExternalSK       wgtypes.Key
	PublicNodeID     uint32
	NodesIPRange     map[uint32]zos.IPNet
	NodeDeploymentID map[uint32]uint64

	WGPort map[uint32]int
	Keys   map[uint32]wgtypes.Key
}

ZNet is zos network workload

func NewNetworkFromWorkload

func NewNetworkFromWorkload(wl zos.Workload, nodeID uint32) (ZNet, error)

NewNetworkFromWorkload generates a new znet from a workload

func (*ZNet) AssignNodesIPs

func (znet *ZNet) AssignNodesIPs(nodes []uint32) error

AssignNodesIPs assign network nodes ips

func (*ZNet) AssignNodesWGKey

func (znet *ZNet) AssignNodesWGKey(nodes []uint32) error

AssignNodesWGKey assign network nodes wireguard key

func (*ZNet) AssignNodesWGPort

func (znet *ZNet) AssignNodesWGPort(ctx context.Context, sub subi.SubstrateExt, ncPool client.NodeClientGetter, nodes []uint32, usedPorts map[uint32][]uint16) error

AssignNodesWGPort assign network nodes wireguard port

func (*ZNet) GenerateMetadata

func (znet *ZNet) GenerateMetadata() (string, error)

GenerateMetadata generates deployment metadata

func (*ZNet) GenerateVersionlessDeployments added in v0.16.0

func (znet *ZNet) GenerateVersionlessDeployments(
	ctx context.Context,
	ncPool client.NodeClientGetter,
	subConn subi.SubstrateExt,
	twinID, publicNode uint32,
	allNodes map[uint32]struct{},
	endpoints map[uint32]net.IP,
	nodeUsedPorts map[uint32][]uint16,
) (map[uint32]zos.Deployment, error)

GenerateVersionlessDeployments generates deployments for network without versions.

func (*ZNet) GetAccessWGConfig added in v0.16.0

func (znet *ZNet) GetAccessWGConfig() string

func (*ZNet) GetAddWGAccess added in v0.16.0

func (znet *ZNet) GetAddWGAccess() bool

func (*ZNet) GetDescription added in v0.16.0

func (znet *ZNet) GetDescription() string

func (*ZNet) GetExternalIP added in v0.16.0

func (znet *ZNet) GetExternalIP() *zos.IPNet

func (*ZNet) GetExternalSK added in v0.16.0

func (znet *ZNet) GetExternalSK() wgtypes.Key

func (*ZNet) GetIPRange added in v0.16.0

func (znet *ZNet) GetIPRange() zos.IPNet

func (*ZNet) GetMyceliumKeys added in v0.16.0

func (znet *ZNet) GetMyceliumKeys() map[uint32][]byte

func (*ZNet) GetName added in v0.16.0

func (znet *ZNet) GetName() string

func (*ZNet) GetNodeDeploymentID added in v0.16.0

func (znet *ZNet) GetNodeDeploymentID() map[uint32]uint64

func (*ZNet) GetNodes added in v0.16.0

func (znet *ZNet) GetNodes() []uint32

func (*ZNet) GetNodesIPRange added in v0.16.0

func (znet *ZNet) GetNodesIPRange() map[uint32]zos.IPNet

func (*ZNet) GetPublicNodeID added in v0.16.0

func (znet *ZNet) GetPublicNodeID() uint32

func (*ZNet) GetSolutionType added in v0.16.0

func (znet *ZNet) GetSolutionType() string

func (*ZNet) GetVersion added in v0.16.0

func (znet *ZNet) GetVersion() Version

func (*ZNet) InvalidateBrokenAttributes added in v0.16.0

func (znet *ZNet) InvalidateBrokenAttributes(subConn subi.SubstrateExt, ncPool client.NodeClientGetter) error

InvalidateBrokenAttributes removes outdated attrs and deleted contracts

func (*ZNet) ReadNodesConfig added in v0.16.0

func (znet *ZNet) ReadNodesConfig(ctx context.Context, nodeDeployments map[uint32]zos.Deployment) error

ReadNodesConfig reads the configuration of a network

func (*ZNet) SetAccessWGConfig added in v0.16.0

func (znet *ZNet) SetAccessWGConfig(accessWGConfig string)

func (*ZNet) SetExternalIP added in v0.16.0

func (znet *ZNet) SetExternalIP(ip *zos.IPNet)

func (*ZNet) SetExternalSK added in v0.16.0

func (znet *ZNet) SetExternalSK(key wgtypes.Key)

func (*ZNet) SetKeys added in v0.16.0

func (znet *ZNet) SetKeys(keys map[uint32]wgtypes.Key)

func (*ZNet) SetMyceliumKeys added in v0.16.0

func (znet *ZNet) SetMyceliumKeys(keys map[uint32][]byte)

func (*ZNet) SetNodeDeploymentID added in v0.16.0

func (znet *ZNet) SetNodeDeploymentID(nodeDeploymentsIDs map[uint32]uint64)

func (*ZNet) SetNodes added in v0.16.0

func (znet *ZNet) SetNodes(nodes []uint32)

func (*ZNet) SetNodesIPRange added in v0.16.0

func (znet *ZNet) SetNodesIPRange(nodesIPRange map[uint32]zos.IPNet)

func (*ZNet) SetPublicNodeID added in v0.16.0

func (znet *ZNet) SetPublicNodeID(node uint32)

func (*ZNet) SetWGPort added in v0.16.0

func (znet *ZNet) SetWGPort(wgPort map[uint32]int)

func (*ZNet) Validate

func (znet *ZNet) Validate() error

Validate validates a network data

func (*ZNet) ZosWorkload

func (znet *ZNet) ZosWorkload(subnet zos.IPNet, wgPrivateKey string, wgListenPort uint16, peers []zos.Peer, metadata string, myceliumKey []byte) zos.Workload

ZosWorkload generates a zos workload from a network

type ZNetLight added in v0.16.0

type ZNetLight struct {
	Name         string
	Description  string
	SolutionType string
	Nodes        []uint32
	IPRange      zos.IPNet
	MyceliumKeys map[uint32][]byte

	// computed
	PublicNodeID     uint32
	NodesIPRange     map[uint32]zos.IPNet
	NodeDeploymentID map[uint32]uint64
}

ZNetLight is zos network light workload

func NewNetworkLightFromWorkload added in v0.16.0

func NewNetworkLightFromWorkload(wl zos.Workload, nodeID uint32) (ZNetLight, error)

NewNetworkFromWorkload generates a new znet from a workload

func (*ZNetLight) AssignNodesIPs added in v0.16.0

func (znet *ZNetLight) AssignNodesIPs(nodes []uint32) error

AssignNodesIPs assign network nodes ips

func (*ZNetLight) GenerateMetadata added in v0.16.0

func (znet *ZNetLight) GenerateMetadata() (string, error)

GenerateMetadata generates deployment metadata

func (*ZNetLight) GenerateVersionlessDeployments added in v0.16.0

func (znet *ZNetLight) GenerateVersionlessDeployments(
	ctx context.Context,
	ncPool client.NodeClientGetter,
	subConn subi.SubstrateExt,
	twinID, publicNode uint32,
	allNodes map[uint32]struct{},
	_ map[uint32]net.IP,
	_ map[uint32][]uint16,
) (map[uint32]zos.Deployment, error)

GenerateVersionlessDeployments generates deployments for network without versions.

func (*ZNetLight) GetAccessWGConfig added in v0.16.0

func (znet *ZNetLight) GetAccessWGConfig() string

func (*ZNetLight) GetAddWGAccess added in v0.16.0

func (znet *ZNetLight) GetAddWGAccess() bool

func (*ZNetLight) GetDescription added in v0.16.0

func (znet *ZNetLight) GetDescription() string

func (*ZNetLight) GetExternalIP added in v0.16.0

func (znet *ZNetLight) GetExternalIP() *zos.IPNet

func (*ZNetLight) GetExternalSK added in v0.16.0

func (znet *ZNetLight) GetExternalSK() wgtypes.Key

func (*ZNetLight) GetIPRange added in v0.16.0

func (znet *ZNetLight) GetIPRange() zos.IPNet

func (*ZNetLight) GetMyceliumKeys added in v0.16.0

func (znet *ZNetLight) GetMyceliumKeys() map[uint32][]byte

func (*ZNetLight) GetName added in v0.16.0

func (znet *ZNetLight) GetName() string

func (*ZNetLight) GetNodeDeploymentID added in v0.16.0

func (znet *ZNetLight) GetNodeDeploymentID() map[uint32]uint64

func (*ZNetLight) GetNodes added in v0.16.0

func (znet *ZNetLight) GetNodes() []uint32

func (*ZNetLight) GetNodesIPRange added in v0.16.0

func (znet *ZNetLight) GetNodesIPRange() map[uint32]zos.IPNet

func (*ZNetLight) GetPublicNodeID added in v0.16.0

func (znet *ZNetLight) GetPublicNodeID() uint32

func (*ZNetLight) GetSolutionType added in v0.16.0

func (znet *ZNetLight) GetSolutionType() string

func (*ZNetLight) GetVersion added in v0.16.0

func (znet *ZNetLight) GetVersion() Version

func (*ZNetLight) InvalidateBrokenAttributes added in v0.16.0

func (znet *ZNetLight) InvalidateBrokenAttributes(subConn subi.SubstrateExt, ncPool client.NodeClientGetter) error

InvalidateBrokenAttributes removes outdated attrs and deleted contracts

func (*ZNetLight) ReadNodesConfig added in v0.16.0

func (znet *ZNetLight) ReadNodesConfig(ctx context.Context, nodeDeployments map[uint32]zos.Deployment) error

ReadNodesConfig reads the configuration of a network

func (*ZNetLight) SetAccessWGConfig added in v0.16.0

func (znet *ZNetLight) SetAccessWGConfig(accessWGConfig string)

func (*ZNetLight) SetExternalIP added in v0.16.0

func (znet *ZNetLight) SetExternalIP(ip *zos.IPNet)

func (*ZNetLight) SetExternalSK added in v0.16.0

func (znet *ZNetLight) SetExternalSK(key wgtypes.Key)

func (*ZNetLight) SetKeys added in v0.16.0

func (znet *ZNetLight) SetKeys(keys map[uint32]wgtypes.Key)

func (*ZNetLight) SetMyceliumKeys added in v0.16.0

func (znet *ZNetLight) SetMyceliumKeys(keys map[uint32][]byte)

func (*ZNetLight) SetNodeDeploymentID added in v0.16.0

func (znet *ZNetLight) SetNodeDeploymentID(nodeDeploymentsIDs map[uint32]uint64)

func (*ZNetLight) SetNodes added in v0.16.0

func (znet *ZNetLight) SetNodes(nodes []uint32)

func (*ZNetLight) SetNodesIPRange added in v0.16.0

func (znet *ZNetLight) SetNodesIPRange(nodesIPRange map[uint32]zos.IPNet)

func (*ZNetLight) SetPublicNodeID added in v0.16.0

func (znet *ZNetLight) SetPublicNodeID(node uint32)

func (*ZNetLight) SetWGPort added in v0.16.0

func (znet *ZNetLight) SetWGPort(wgPort map[uint32]int)

func (*ZNetLight) Validate added in v0.16.0

func (znet *ZNetLight) Validate() error

Validate validates a network light data

func (*ZNetLight) ZosWorkload added in v0.16.0

func (znet *ZNetLight) ZosWorkload(subnet zos.IPNet, _ string, _ uint16, _ []zos.Peer, metadata string, myceliumKey []byte) zos.Workload

ZosWorkload generates a zos workload from a network

type Zlog

type Zlog struct {
	Zmachine string `json:"zmachine"`
	Output   string `json:"output"`
}

Zlog logger struct

func (*Zlog) Validate added in v0.15.12

func (z *Zlog) Validate() error

func (*Zlog) ZosWorkload

func (zlog *Zlog) ZosWorkload() zosTypes.Workload

ZosWorkload generates a zlog workload

Jump to

Keyboard shortcuts

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