Documentation
¶
Index ¶
- Constants
- func MustMarshal(data interface{}) json.RawMessage
- type Bytes
- type Capacity
- type Deployment
- func (d *Deployment) ByType(typ ...string) []*WorkloadWithID
- func (d *Deployment) Challenge(w io.Writer) error
- func (d *Deployment) ChallengeHash() ([]byte, error)
- func (d *Deployment) Get(name string) (*WorkloadWithID, error)
- func (d *Deployment) Sign(twin uint32, sk Signer) error
- func (d *Deployment) Valid() error
- type Encryption
- type EncryptionAlgorithm
- type EncryptionKey
- type GPU
- type IPNet
- type MachineCapacity
- type MachineInterface
- type MachineMount
- type MachineNetwork
- type MachineNetworkLight
- type Mycelium
- type MyceliumIP
- type Network
- type NetworkLight
- type Peer
- type PublicIP
- type QuantumCompression
- type QuantumSafeConfig
- type QuantumSafeFS
- type QuantumSafeFSConfig
- type QuantumSafeMeta
- type QuatumSafeFSResult
- type Result
- type ResultState
- type Signature
- type SignatureRequest
- type SignatureRequirement
- type Signer
- type Volume
- type Workload
- func (wl *Workload) Capacity() (Capacity, error)
- func (wl *Workload) Challenge(w io.Writer) error
- func (wl *Workload) NetworkLightWorkload() (*zos.NetworkLight, error)
- func (wl *Workload) NetworkWorkload() (*zos.Network, error)
- func (w Workload) WithResults(result Result) Workload
- func (wl *Workload) Workload() *gridtypes.Workload
- func (wl *Workload) ZMachineLightWorkload() (*zos.ZMachineLight, error)
- func (wl *Workload) ZMachineWorkload() (*zos.ZMachine, error)
- type WorkloadID
- type WorkloadWithID
- type ZDB
- type ZDBResult
- type ZLogs
- type ZMachine
- type ZMachineLight
- type ZMachineLightResult
- type ZMachineResult
- type ZMount
- type ZdbBackend
- type ZdbGroup
- type ZosDeployment
Constants ¶
const ( MyceliumKeyLen = 32 MyceliumIPSeedLen = 6 // Kilobyte unit multiplier Kilobyte uint64 = 1024 // Megabyte unit multiplier Megabyte uint64 = 1024 * Kilobyte // Gigabyte unit multiplier Gigabyte uint64 = 1024 * Megabyte // Terabyte unit multiplier Terabyte uint64 = 1024 * Gigabyte )
const ( // ZMountType type ZMountType string = "zmount" // NetworkType type NetworkType string = "network" // NetworkLightType type NetworkLightType string = "network-light" // ZDBType type ZDBType string = "zdb" // ZMachineType type ZMachineType string = "zmachine" // ZMachineLightType type ZMachineLightType string = "zmachine-light" // VolumeType type VolumeType string = "volume" //PublicIPv4Type type [deprecated] PublicIPv4Type string = "ipv4" //PublicIPType type is the new way to assign public ips // to a VM. this has flags (V4, and V6) that has to be set. PublicIPType string = "ip" // GatewayNameProxyType type GatewayNameProxyType string = "gateway-name-proxy" // GatewayFQDNProxyType type GatewayFQDNProxyType string = "gateway-fqdn-proxy" // QuantumSafeFSType type QuantumSafeFSType string = "qsfs" // ZLogsType type ZLogsType string = "zlogs" )
Variables ¶
This section is empty.
Functions ¶
func MustMarshal ¶
func MustMarshal(data interface{}) json.RawMessage
MustMarshal is a utility function to quickly serialize workload data
Types ¶
type Bytes ¶
type Bytes []byte
Bytes value that is represented as hex when serialized to json
func (Bytes) MarshalText ¶
func (*Bytes) UnmarshalText ¶
type Capacity ¶
type Deployment ¶
type Deployment struct {
// Version must be set to 0 on deployment creation. And then it has to
// be incremented with each call to update.
Version uint32 `json:"version"`
// TwinID is the id of the twin sending the deployment. A twin then can only
// `get` status about deployments he owns.
TwinID uint32 `json:"twin_id"`
// ContractID the contract must be "pre created" on substrate before the deployment is
// sent to the node. The node will then validate that this deployment hash, will match the
// hash attached to this contract.
// the flow should go as follows:
// - fill in ALL deployment details (metadata, and workloads)
// - calculate the deployment hash (by calling ChallengeHash method)
// - create the contract with the right hash
// - set the contract id on the deployment object
// - send deployment to node.
ContractID uint64 `json:"contract_id"`
// Metadata is user specific meta attached to deployment, can be used to link this
// deployment to other external systems for automation
Metadata string `json:"metadata"`
// Description is human readable description of the deployment
Description string `json:"description"`
// Expiration [deprecated] is not used
Expiration int64 `json:"expiration"`
// SignatureRequirement specifications
SignatureRequirement SignatureRequirement `json:"signature_requirement"`
// Workloads is a list of workloads associated with this deployment
Workloads []Workload `json:"workloads"`
}
Deployment structure
func NewGridDeployment ¶
func NewGridDeployment(twin uint32, workloads []Workload) Deployment
func (*Deployment) ByType ¶
func (d *Deployment) ByType(typ ...string) []*WorkloadWithID
func (*Deployment) ChallengeHash ¶
func (d *Deployment) ChallengeHash() ([]byte, error)
func (*Deployment) Get ¶
func (d *Deployment) Get(name string) (*WorkloadWithID, error)
Get a workload by name
func (*Deployment) Valid ¶
func (d *Deployment) Valid() error
type Encryption ¶
type Encryption struct {
Algorithm EncryptionAlgorithm `json:"algorithm" toml:"algorithm"`
Key EncryptionKey `json:"key" toml:"key"`
}
type EncryptionAlgorithm ¶
type EncryptionAlgorithm string
type EncryptionKey ¶
type EncryptionKey []byte
func (EncryptionKey) MarshalText ¶
func (k EncryptionKey) MarshalText() ([]byte, error)
func (*EncryptionKey) UnmarshalText ¶
func (k *EncryptionKey) UnmarshalText(data []byte) error
type IPNet ¶
func MustParseIPNet ¶
func (IPNet) MarshalJSON ¶
MarshalJSON dumps iprange as a string
func (IPNet) MarshalText ¶
MarshalText dumps iprange as a string
func (*IPNet) UnmarshalText ¶
UnmarshalText loads IPRange from string
type MachineCapacity ¶
MachineCapacity structure
type MachineInterface ¶
type MachineInterface struct {
// Network name (znet name) to join
Network string `json:"network"`
// IP of the zmachine on this network must be a valid Ip in the
// selected network
IP net.IP `json:"ip"`
}
MachineInterface structure
type MachineMount ¶
type MachineMount struct {
// Name is name of a zmount. The name must be a valid zmount
// in the same deployment as the zmachine
Name string `json:"name"`
// MountPoint inside the container. Not used if the zmachine
// is running in a vm mode.
Mountpoint string `json:"mountpoint"`
}
MachineMount structure
type MachineNetwork ¶
type MachineNetwork struct {
// PublicIP optional public IP attached to this machine. If set
// it must be a valid name of a PublicIP workload in the same deployment
PublicIP string `json:"public_ip"`
// Planetary support planetary network
Planetary bool `json:"planetary"`
// Mycelium IP config, if planetary is true, but Mycelium is not set we fall back
// to yggdrasil support. Otherwise (if mycelium is set) a mycelium ip is used instead.
Mycelium *MyceliumIP `json:"mycelium,omitempty"`
// Interfaces list of user znets to join
Interfaces []MachineInterface `json:"interfaces"`
}
MachineNetwork structure
type MachineNetworkLight ¶
type MachineNetworkLight struct {
// Mycelium IP config, if planetary is true, but Mycelium is not set we fall back
// to yggdrasil support. Otherwise (if mycelium is set) a mycelium ip is used instead.
Mycelium *MyceliumIP `json:"mycelium,omitempty"`
// Interfaces list of user zNets to join
Interfaces []MachineInterface `json:"interfaces"`
}
MachineNetworkLight structure
type Mycelium ¶
type Mycelium struct {
// Key is the key of the mycelium peer in the mycelium node
// associated with this network.
// It's provided by the user so it can be later moved to other nodes
// without losing the key.
Key Bytes `json:"hex_key"`
// An optional mycelium peer list to be used with this node, otherwise
// the default peer list is used.
Peers []string `json:"peers"`
}
type MyceliumIP ¶
type MyceliumIP struct {
// Network name (znet name) to join
Network string
// Seed is a six bytes random number that is used
// as a seed to derive a vm mycelium IP.
//
// This means that a VM "ip" can be moved to another VM if needed
// by simply using the same seed.
// This of course will only work if the network mycelium setup is using
// the same HexKey
Seed Bytes `json:"hex_seed"`
}
type Network ¶
type Network struct {
// IP range of the network, must be an IPv4 /16
// for example a 10.1.0.0/16
NetworkIPRange IPNet `json:"ip_range"`
// IPV4 subnet for this network resource
// this must be a valid subnet of the entire network ip range.
// for example 10.1.1.0/24
Subnet IPNet `json:"subnet"`
// The private wg key of this node (this peer) which is installing this
// network workload right now.
// This has to be filled in by the user (and not generated for example)
// because other peers need to be installed as well (with this peer public key)
// hence it's easier to configure everything one time at the user side and then
// apply everything on all nodes at once
WGPrivateKey string `json:"wireguard_private_key"`
// WGListenPort is the wireguard listen port on this node. this has
// to be filled in by the user for same reason as private key (other nodes need to know about it)
// To find a free port you have to ask the node first by a call over RMB about which ports are possible
// to use.
WGListenPort uint16 `json:"wireguard_listen_port"`
// Peers is a list of other peers in this network
Peers []Peer `json:"peers"`
// Optional mycelium configuration. If provided
// VMs in this network can use the mycelium feature.
// if no mycelium configuration is provided, vms can't
// get mycelium IPs.
Mycelium *Mycelium `json:"mycelium,omitempty"`
}
Network is the description of a part of a network local to a specific node. A network workload defines a wireguard network that is usually spans multiple nodes. One of the nodes must work as an access node in other words, it must be reachable from other nodes, hence it needs to have a `PublicConfig`. Since the user library creates all deployments upfront then all wireguard keys, and ports must be pre-deterministic and must be also created upfront. A network structure basically must consist of - The network information (IP range) must be an ipv4 /16 range - The local (node) peer definition (subnet of the network ip range, wireguard secure key, wireguard port if any) - List of other peers that are part of the same network with their own config - For each PC or a laptop (for each wireguard peer) there must be a peer in the peer list (on all nodes) This is why this can get complicated.
type NetworkLight ¶
type NetworkLight struct {
// IPV4 subnet for this network resource
// this must be a valid subnet of the entire network ip range.
// for example 10.1.1.0/24
Subnet IPNet `json:"subnet"`
// Optional mycelium configuration. If provided
// VMs in this network can use the mycelium feature.
// if no mycelium configuration is provided, vms can't
// get mycelium IPs.
Mycelium Mycelium `json:"mycelium,omitempty"`
}
NetworkLight is the description of a part of a network local to a specific node. A network workload defines a wireguard network that is usually spans multiple nodes. One of the nodes must work as an access node in other words, it must be reachable from other nodes, hence it needs to have a `PublicConfig`. Since the user library creates all deployments upfront then all wireguard keys, and ports must be pre-deterministic and must be also created upfront. A network structure basically must consist of - The network information (IP range) must be an ipv4 /16 range - The local (node) peer definition (subnet of the network ip range, wireguard secure key, wireguard port if any) - List of other peers that are part of the same network with their own config - For each PC or a laptop (for each wireguard peer) there must be a peer in the peer list (on all nodes) This is why this can get complicated.
type Peer ¶
type Peer struct {
// IPV4 subnet of the network resource of the peer
Subnet IPNet `json:"subnet"`
// WGPublicKey of the peer (driven from its private key)
WGPublicKey string `json:"wireguard_public_key"`
// Allowed Ips is related to his subnet.
// todo: remove and derive from subnet
AllowedIPs []IPNet `json:"allowed_ips"`
// Entrypoint of the peer
Endpoint string `json:"endpoint"`
}
Peer is the description of a peer of a NetResource
type QuantumCompression ¶
type QuantumCompression struct {
Algorithm string `json:"algorithm" toml:"algorithm"`
}
type QuantumSafeConfig ¶
type QuantumSafeConfig struct {
Prefix string `json:"prefix" toml:"prefix"`
Encryption Encryption `json:"encryption" toml:"encryption"`
Backends []ZdbBackend `json:"backends" toml:"backends"`
}
type QuantumSafeFS ¶
type QuantumSafeFS struct {
Cache uint64 `json:"cache"`
Config QuantumSafeFSConfig `json:"config"`
}
type QuantumSafeFSConfig ¶
type QuantumSafeFSConfig struct {
MinimalShards uint32 `json:"minimal_shards" toml:"minimal_shards"`
ExpectedShards uint32 `json:"expected_shards" toml:"expected_shards"`
RedundantGroups uint32 `json:"redundant_groups" toml:"redundant_groups"`
RedundantNodes uint32 `json:"redundant_nodes" toml:"redundant_nodes"`
MaxZDBDataDirSize uint32 `json:"max_zdb_data_dir_size" toml:"max_zdb_data_dir_size"`
Encryption Encryption `json:"encryption" toml:"encryption"`
Meta QuantumSafeMeta `json:"meta" toml:"meta"`
Groups []ZdbGroup `json:"groups" toml:"groups"`
Compression QuantumCompression `json:"compression" toml:"compression"`
}
type QuantumSafeMeta ¶
type QuantumSafeMeta struct {
Type string `json:"type" toml:"type"`
Config QuantumSafeConfig `json:"config" toml:"config"`
}
type QuatumSafeFSResult ¶
type Result ¶
type Result struct {
// Time when the result is sent
Created int64 `json:"created"`
// State of the deployment (ok,error)
State ResultState `json:"state"`
// if State is "error", then this field contains the error
// otherwise it's nil
Error string `json:"message"`
// Data is the information generated by the provisioning of the workload
// its type depend on the reservation type
Data json.RawMessage `json:"data"`
}
Result is the struct filled by the node after a reservation object has been processed
type ResultState ¶
type ResultState string
ResultState type
const ( // StateInit is the first state of the workload on storage StateInit ResultState = "init" // StateUnChanged is a special error state it means there was an error // running the action, but this error did not break previous state. StateUnChanged ResultState = "unchanged" // StateError constant StateError ResultState = "error" // StateOk constant StateOk ResultState = "ok" // StateDeleted constant StateDeleted ResultState = "deleted" // StatePaused constant StatePaused ResultState = "paused" )
func (ResultState) IsAny ¶
func (s ResultState) IsAny(state ...ResultState) bool
func (ResultState) IsOkay ¶
func (s ResultState) IsOkay() bool
type Signature ¶
type Signature struct {
TwinID uint32 `json:"twin_id"`
Signature string `json:"signature"`
SignatureType string `json:"signature_type"`
}
Signature struct
type SignatureRequest ¶
type SignatureRequest struct {
TwinID uint32 `json:"twin_id"`
Required bool `json:"required"`
Weight uint `json:"weight"`
}
SignatureRequest struct a signature request of a twin
type SignatureRequirement ¶
type SignatureRequirement struct {
Requests []SignatureRequest `json:"requests"`
WeightRequired uint `json:"weight_required"`
Signatures []Signature `json:"signatures"`
SignatureStyle string `json:"signature_style"`
}
this means that twin3 must sign + one of either (twin1 or twin2) to have the right signature weight
type Workload ¶
type Workload struct {
// Version is version of reservation object. On deployment creation, version must be 0
// then only workloads that need to be updated must match the version of the deployment object.
// if a deployment update message is sent to a node it does the following:
// - validate deployment version
// - check workloads list, if a version is not matching the new deployment version, the workload is untouched
// - if a workload version is same as deployment, the workload is "updated"
// - if a workload is removed, the workload is deleted.
Version uint32 `json:"version"`
//Name is unique workload name per deployment (required)
Name string `json:"name"`
// Type of the reservation (container, zdb, vm, etc...)
Type string `json:"type"`
// Data is the reservation type arguments.
Data json.RawMessage `json:"data"`
// Metadata is user specific meta attached to deployment, can be used to link this
// deployment to other external systems for automation
Metadata string `json:"metadata"`
//Description human readable description of the workload
Description string `json:"description"`
// Result of reservation, set by the node
Result Result `json:"result"`
}
func (*Workload) NetworkLightWorkload ¶
func (wl *Workload) NetworkLightWorkload() (*zos.NetworkLight, error)
func (Workload) WithResults ¶
func (*Workload) ZMachineLightWorkload ¶
func (wl *Workload) ZMachineLightWorkload() (*zos.ZMachineLight, error)
type WorkloadID ¶
type WorkloadID string
type WorkloadWithID ¶
type WorkloadWithID struct {
*Workload
ID WorkloadID
}
WorkloadWithID wrapper around workload type that holds the global workload ID Note: you never need to construct this manually
type ZDB ¶
type ZDB struct {
Size uint64 `json:"size"`
Mode string `json:"mode"`
Password string `json:"password"`
Public bool `json:"public"`
}
ZDB namespace creation info
type ZMachine ¶
type ZMachine struct {
// Flist of the zmachine, must be a valid url to an flist.
FList string `json:"flist"`
// Network configuration for machine network
Network MachineNetwork `json:"network"`
// Size of zmachine disk
Size uint64 `json:"size"`
// ComputeCapacity configuration for machine cpu+memory
ComputeCapacity MachineCapacity `json:"compute_capacity"`
// Mounts configure mounts/disks attachments to this machine
Mounts []MachineMount `json:"mounts"`
// Entrypoint entrypoint of the container, if not set the configured one from the flist
// is going to be used
Entrypoint string `json:"entrypoint"`
// Env variables available for a container
Env map[string]string `json:"env"`
// Corex works in container mode which forces replace the
// entrypoint of the container to use `corex`
Corex bool `json:"corex"`
// GPU attached to the VM
// the list of the GPUs ids must:
// - Exist, obviously
// - Not used by other VMs
// - Only possible on `dedicated` nodes
GPU []GPU `json:"gpu,omitempty"`
}
ZMachine reservation data
type ZMachineLight ¶
type ZMachineLight struct {
// Flist of the zmachine, must be a valid url to an flist.
FList string `json:"flist"`
// Network configuration for machine network
Network MachineNetworkLight `json:"network"`
// Size of zmachine disk
Size uint64 `json:"size"`
// ComputeCapacity configuration for machine cpu+memory
ComputeCapacity MachineCapacity `json:"compute_capacity"`
// Mounts configure mounts/disks attachments to this machine
Mounts []MachineMount `json:"mounts"`
// Entrypoint entrypoint of the container, if not set the configured one from the flist
// is going to be used
Entrypoint string `json:"entrypoint"`
// Env variables available for a container
Env map[string]string `json:"env"`
// Corex works in container mode which forces replace the
// entrypoint of the container to use `corex`
Corex bool `json:"corex"`
// GPU attached to the VM
// the list of the GPUs ids must:
// - Exist, obviously
// - Not used by other VMs
// - Only possible on `dedicated` nodes
GPU []GPU `json:"gpu,omitempty"`
}
type ZMachineLightResult ¶
type ZMachineLightResult struct {
ID string `json:"id"`
IP string `json:"ip"`
MyceliumIP string `json:"mycelium_ip"`
ConsoleURL string `json:"console_url"`
}
ZMachineLightResult result returned by VM reservation
type ZMachineResult ¶
type ZMachineResult struct {
ID string `json:"id"`
IP string `json:"ip"`
PlanetaryIP string `json:"planetary_ip"`
MyceliumIP string `json:"mycelium_ip"`
ConsoleURL string `json:"console_url"`
}
ZMachineResult result returned by VM reservation
func (*ZMachineResult) UnmarshalJSON ¶
func (r *ZMachineResult) UnmarshalJSON(data []byte) error
type ZdbBackend ¶
type ZdbGroup ¶
type ZdbGroup struct {
Backends []ZdbBackend `json:"backends" toml:"backends"`
}