threefold.tfgrid3deployer #
tfgrid3deployer
To get started
import freeflowuniverse.crystallib.clients. tfgrid3deployer
mut client:= tfgrid3deployer.get()!
client...
example heroscript
!!tfgrid3deployer.configure
secret: '...'
host: 'localhost'
port: 8888
Constants #
const version = '1.0.0'
fn filter_nodes #
fn filter_nodes(filter gridproxy_models.NodeFilter) ![]gridproxy_models.Node
fn get #
fn get(args_ ArgsGet) !&TFGridDeployer
fn get_deployment #
fn get_deployment(name string) !TFDeployment
fn heroscript_default #
fn heroscript_default() !string
fn new_deployment #
fn new_deployment(name string) !TFDeployment
fn play #
fn play(args_ PlayArgs) !
fn switch #
fn switch(name string)
switch instance to be used for tfgrid3deployer
enum Network #
enum Network {
dev
main
test
qa
}
struct ArgsGet #
struct ArgsGet {
pub mut:
name string = 'default'
}
///////FACTORY
struct ContractGetArgs #
struct ContractGetArgs {
pub mut:
active bool = true
twin_id u64
}
struct DeployArgs #
struct DeployArgs {
pub mut:
reset bool // careful will delete existing machine if true
}
NetworkInfo struct to represent network details
struct KVStoreFS #
struct KVStoreFS {}
Will be changed when we support the logic of the TFChain one
struct Mycelium #
struct Mycelium {
hex_seed string = rand.hex(12)
}
struct NetworkSpecs #
struct NetworkSpecs {
pub mut:
name string = 'net' + rand.string(5)
ip_range string = '10.10.0.0/16'
mycelium string = rand.hex(64)
}
NetworkInfo struct to represent network details
struct PlayArgs #
struct PlayArgs {
pub mut:
name string = 'default'
heroscript string // if filled in then plbook will be made out of it
plbook ?playbook.PlayBook
reset bool
start bool
stop bool
restart bool
delete bool
configure bool // make sure there is at least one installed
}
struct RecoverArgs #
struct RecoverArgs {
pub mut:
reinstall bool // reinstall if needed and run heroscript
}
NetworkInfo struct to represent network details
struct TFDeployment #
struct TFDeployment {
pub mut:
name string
description string
vms []VMachine
zdbs []ZDB
webnames []WebName
network NetworkSpecs
mut:
// Set the deployed contracts on the deployment and save the full deployment to be able to delete the whole deployment when need.
contracts GridContracts
deployer &grid.Deployer @[skip; str: skip]
kvstore KVStoreFS @[skip; str: skip]
}
fn (TFDeployment) add_machine #
fn (mut self TFDeployment) add_machine(requirements VMRequirements)
Set a new machine on the deployment.
fn (TFDeployment) add_webname #
fn (mut self TFDeployment) add_webname(requirements WebNameRequirements)
Set a new webname on the deployment.
fn (TFDeployment) add_zdb #
fn (mut self TFDeployment) add_zdb(zdb ZDBRequirements)
Set a new zdb on the deployment.
fn (TFDeployment) deploy #
fn (mut self TFDeployment) deploy() !
fn (TFDeployment) list_deployments #
fn (mut self TFDeployment) list_deployments() !map[u32]grid_models.Deployment
lists deployments used with vms, zdbs, and webnames
fn (TFDeployment) load #
fn (mut self TFDeployment) load() !
fn (TFDeployment) remove_machine #
fn (mut self TFDeployment) remove_machine(name string) !
fn (TFDeployment) remove_webname #
fn (mut self TFDeployment) remove_webname(name string) !
fn (TFDeployment) remove_zdb #
fn (mut self TFDeployment) remove_zdb(name string) !
fn (TFDeployment) tfchain_contracts #
fn (mut self TFDeployment) tfchain_contracts(args ContractGetArgs) ![]proxy_models.Contract
Retrieves all contracts (active and inactive) on the selected grid network.
This function interacts with the Grid Proxy to retrieve all contracts associated with the twin ID of the current deployer (from GridClient).
Returns:- An array of gridproxy.Contract
containing contract information.
fn (TFDeployment) vm_get #
fn (mut self TFDeployment) vm_get(vm_name string) !VMachine
fn (TFDeployment) webname_get #
fn (mut self TFDeployment) webname_get(wn_name string) !WebName
fn (TFDeployment) zdb_get #
fn (mut self TFDeployment) zdb_get(zdb_name string) !ZDB
struct TFGridDeployer #
struct TFGridDeployer {
pub mut:
name string = 'default'
ssh_key string
mnemonic string
network Network
}
struct VMRequirements #
struct VMRequirements {
pub mut:
name string
description string
cpu int // vcores
size u64
memory int // gbyte
public_ip4 bool
public_ip6 bool
planetary bool
mycelium ?Mycelium
flist string = 'https://hub.grid.tf/tf-official-vms/ubuntu-24.04-latest.flist'
entrypoint string = '/sbin/zinit init'
env map[string]string
nodes []u32 // if set will chose a node from the list to deploy on
}
MachineNetworkReq struct to represent network access configuration
struct VMachine #
struct VMachine {
pub mut:
tfchain_id string
contract_id u64
requirements VMRequirements
node_id u32
planetary_ip string
mycelium_ip string
public_ip4 string
wireguard_ip string
public_ip6 string
}
MachineModel struct to represent a machine and its associat ed details
fn (VMachine) healthcheck #
fn (self VMachine) healthcheck() !bool
struct WebName #
struct WebName {
pub mut:
fqdn string
name_contract_id u64
node_contract_id u64
requirements WebNameRequirements
node_id u32
}
struct WebNameRequirements #
struct WebNameRequirements {
pub mut:
name string @[required]
node_id ?u32
// must be in the format ip:port if tls_passthrough is set, otherwise the format should be http://ip[:port]
backend string @[required]
tls_passthrough bool
}
struct ZDB #
struct ZDB {
pub mut:
ips []string
port u32
namespace string
contract_id u64
requirements ZDBRequirements
node_id u32
}
struct ZDBRequirements #
struct ZDBRequirements {
pub mut:
name string @[required]
password string @[required]
size int @[required]
node_id ?u32
description string
mode grid_models.ZdbMode = 'user'
public bool
}
- README
- Constants
- fn filter_nodes
- fn get
- fn get_deployment
- fn heroscript_default
- fn new_deployment
- fn play
- fn switch
- enum Network
- struct ArgsGet
- struct ContractGetArgs
- struct DeployArgs
- struct KVStoreFS
- struct Mycelium
- struct NetworkSpecs
- struct PlayArgs
- struct RecoverArgs
- struct TFDeployment
- struct TFGridDeployer
- struct VMRequirements
- struct VMachine
- struct WebName
- struct WebNameRequirements
- struct ZDB
- struct ZDBRequirements