formatting
This commit is contained in:
@@ -17,23 +17,23 @@ fn test_create_and_update_deployment() ! {
|
||||
twin_id := deployer.client.get_user_twin()!
|
||||
println('your wireguard privatekey is ${user_privkey[0]}')
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
wireguard_private_key: node_privkey[0] // node private key
|
||||
wireguard_listen_port: 3012
|
||||
peers: [
|
||||
peers: [
|
||||
models.Peer{
|
||||
subnet: '10.1.2.0/24'
|
||||
subnet: '10.1.2.0/24'
|
||||
wireguard_public_key: user_privkey[1] // user public key
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
},
|
||||
]
|
||||
}
|
||||
mut znet_workload := models.Workload{
|
||||
version: 0
|
||||
name: 'networkaa'
|
||||
type_: models.workload_types.network
|
||||
data: json.encode_pretty(network)
|
||||
version: 0
|
||||
name: 'networkaa'
|
||||
type_: models.workload_types.network
|
||||
data: json.encode_pretty(network)
|
||||
description: 'test network2'
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ fn test_create_and_update_deployment() ! {
|
||||
zmount_workload := zmount.to_workload(name: disk_name)
|
||||
|
||||
mount := models.Mount{
|
||||
name: disk_name
|
||||
name: disk_name
|
||||
mountpoint: '/disk1'
|
||||
}
|
||||
|
||||
@@ -55,39 +55,39 @@ fn test_create_and_update_deployment() ! {
|
||||
ip_workload := ip.to_workload(name: public_ip_name)
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: public_ip_name
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: public_ip_name
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: 'networkaa'
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
planetary: true
|
||||
planetary: true
|
||||
}
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: 1
|
||||
cpu: 1
|
||||
memory: i64(1024) * 1024 * 1024 * 2
|
||||
}
|
||||
env: {
|
||||
env: {
|
||||
'SSH_KEY': pubkey
|
||||
}
|
||||
mounts: [mount]
|
||||
mounts: [mount]
|
||||
}
|
||||
|
||||
mut zmachine_workload := models.Workload{
|
||||
version: 0
|
||||
name: 'vm2'
|
||||
type_: models.workload_types.zmachine
|
||||
data: json.encode(zmachine)
|
||||
version: 0
|
||||
name: 'vm2'
|
||||
type_: models.workload_types.zmachine
|
||||
data: json.encode(zmachine)
|
||||
description: 'zmachine test'
|
||||
}
|
||||
|
||||
zlogs := models.ZLogs{
|
||||
zmachine: 'vm2'
|
||||
output: 'wss://example_ip.com:9000'
|
||||
output: 'wss://example_ip.com:9000'
|
||||
}
|
||||
zlogs_workload := zlogs.to_workload(name: 'myzlogswl')
|
||||
|
||||
@@ -98,17 +98,17 @@ fn test_create_and_update_deployment() ! {
|
||||
zdb_workload := zdb.to_workload(name: 'myzdb')
|
||||
|
||||
mut deployment := models.Deployment{
|
||||
version: 0
|
||||
twin_id: twin_id
|
||||
description: 'zm kjasdf1nafvbeaf1234t21'
|
||||
workloads: [znet_workload, zmount_workload, zmachine_workload, zlogs_workload, zdb_workload,
|
||||
ip_workload]
|
||||
version: 0
|
||||
twin_id: twin_id
|
||||
description: 'zm kjasdf1nafvbeaf1234t21'
|
||||
workloads: [znet_workload, zmount_workload, zmachine_workload, zlogs_workload,
|
||||
zdb_workload, ip_workload]
|
||||
signature_requirement: models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -133,7 +133,7 @@ fn test_create_and_update_deployment() ! {
|
||||
}
|
||||
|
||||
gw_name := models.GatewayNameProxy{
|
||||
name: 'mygwname1'
|
||||
name: 'mygwname1'
|
||||
backends: ['http://[${zmachine_planetary_ip}]:9000']
|
||||
}
|
||||
gw_name_wl := gw_name.to_workload(name: 'mygwname1')
|
||||
|
||||
@@ -17,8 +17,8 @@ fn main() {
|
||||
|
||||
gw := models.GatewayFQDNProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://1.1.1.1:9000']
|
||||
fqdn: 'domaind.gridtesting.xyz'
|
||||
backends: ['http://1.1.1.1:9000']
|
||||
fqdn: 'domaind.gridtesting.xyz'
|
||||
}
|
||||
wl := gw.to_workload(name: 'mywlname')
|
||||
node_id := u32(14)
|
||||
@@ -30,16 +30,16 @@ fn main() {
|
||||
logger.info('preparing the deployment..')
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -17,8 +17,8 @@ fn main() {
|
||||
|
||||
gw := models.GatewayNameProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://1.1.1.1']
|
||||
name: 'hamada_gw'
|
||||
backends: ['http://1.1.1.1']
|
||||
name: 'hamada_gw'
|
||||
}
|
||||
|
||||
wl := gw.to_workload(name: 'hamada_gw')
|
||||
@@ -28,17 +28,17 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -17,38 +17,38 @@ fn main() {
|
||||
network_name := 'network1'
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
ip_range: '10.1.0.0/16'
|
||||
subnet: '10.1.1.0/24'
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE='
|
||||
wireguard_listen_port: wg_port
|
||||
peers: [
|
||||
peers: [
|
||||
models.Peer{
|
||||
subnet: '10.1.2.0/24'
|
||||
subnet: '10.1.2.0/24'
|
||||
wireguard_public_key: '4KTvZS2KPWYfMr+GbiUUly0ANVg8jBC7xP9Bl79Z8zM='
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
allowed_ips: ['10.1.2.0/24', '100.64.1.2/32']
|
||||
},
|
||||
]
|
||||
}
|
||||
mut znet_workload := network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/threefoldtech-ubuntu-22.04.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: ''
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/threefoldtech-ubuntu-22.04.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
public_ip: ''
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
planetary: true
|
||||
planetary: true
|
||||
}
|
||||
entrypoint: '/sbin/zinit init'
|
||||
entrypoint: '/sbin/zinit init'
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: 1
|
||||
cpu: 1
|
||||
memory: i64(1024) * 1024 * 1024 * 2
|
||||
}
|
||||
env: {
|
||||
env: {
|
||||
'SSH_KEY': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTwULSsUubOq3VPWL6cdrDvexDmjfznGydFPyaNcn7gAL9lRxwFbCDPMj7MbhNSpxxHV2+/iJPQOTVJu4oc1N7bPP3gBCnF51rPrhTpGCt5pBbTzeyNweanhedkKDsCO2mIEh/92Od5Hg512dX4j7Zw6ipRWYSaepapfyoRnNSriW/s3DH/uewezVtL5EuypMdfNngV/u2KZYWoeiwhrY/yEUykQVUwDysW/xUJNP5o+KSTAvNSJatr3FbuCFuCjBSvageOLHePTeUwu6qjqe+Xs4piF1ByO/6cOJ8bt5Vcx0bAtI8/MPApplUU/JWevsPNApvnA/ntffI+u8DCwgP'
|
||||
}
|
||||
}
|
||||
@@ -56,18 +56,18 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'test deployment'
|
||||
workloads: [znet_workload, zmachine_workload]
|
||||
twin_id: deployer.twin_id
|
||||
description: 'test deployment'
|
||||
workloads: [znet_workload, zmachine_workload]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
|
||||
@@ -15,7 +15,7 @@ fn test_deploy_vm_hight_level(node_id u32) ! {
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_network, mut logger)!
|
||||
|
||||
vm := models.VM{
|
||||
name: 'vm1'
|
||||
name: 'vm1'
|
||||
env_vars: {
|
||||
'SSH_KEY': 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTwULSsUubOq3VPWL6cdrDvexDmjfznGydFPyaNcn7gAL9lRxwFbCDPMj7MbhNSpxxHV2+/iJPQOTVJu4oc1N7bPP3gBCnF51rPrhTpGCt5pBbTzeyNweanhedkKDsCO2mIEh/92Od5Hg512dX4j7Zw6ipRWYSaepapfyoRnNSriW/s3DH/uewezVtL5EuypMdfNngV/u2KZYWoeiwhrY/yEUykQVUwDysW/xUJNP5o+KSTAvNSJatr3FbuCFuCjBSvageOLHePTeUwu6qjqe+Xs4piF1ByO/6cOJ8bt5Vcx0bAtI8/MPApplUU/JWevsPNApvnA/ntffI+u8DCwgP'
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ fn main() {
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_network, mut logger)!
|
||||
|
||||
zdb := models.Zdb{
|
||||
size: u64(2) * 1024 * 1024
|
||||
mode: 'user'
|
||||
size: u64(2) * 1024 * 1024
|
||||
mode: 'user'
|
||||
password: 'pass'
|
||||
}
|
||||
|
||||
@@ -25,17 +25,17 @@ fn main() {
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [wl]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ fn main() {
|
||||
|
||||
chain_net_enum := get_chain_network(chain_network)!
|
||||
mut deployer := tfgrid.new_deployer(mnemonics, chain_net_enum, mut logger)!
|
||||
|
||||
|
||||
mut workloads := []models.Workload{}
|
||||
node_id := get_node_id(chain_net_enum, memory, disk, cpu, public_ip)!
|
||||
// node_id := u32(150)
|
||||
@@ -38,20 +38,19 @@ fn main() {
|
||||
network_name := 'net_${rand.string(5).to_lower()}' // autocreate a network
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE=' // autocreate
|
||||
wireguard_listen_port: wg_port
|
||||
mycelium: models.Mycelium{
|
||||
mycelium: models.Mycelium{
|
||||
hex_key: rand.string(32).bytes().hex()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
workloads << network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
mut public_ip_name := ''
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
public_ip_name = rand.string(5).to_lower()
|
||||
workloads << models.PublicIP{
|
||||
v4: true
|
||||
@@ -59,52 +58,52 @@ fn main() {
|
||||
}
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist' // from user or default to ubuntu
|
||||
network: models.ZmachineNetwork{
|
||||
flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist' // from user or default to ubuntu
|
||||
network: models.ZmachineNetwork{
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
mycelium: models.MyceliumIP{
|
||||
network: network_name
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
mycelium: models.MyceliumIP{
|
||||
network: network_name
|
||||
hex_seed: rand.string(6).bytes().hex()
|
||||
}
|
||||
}
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: u8(cpu)
|
||||
cpu: u8(cpu)
|
||||
memory: i64(memory) * 1024 * 1024 * 1024
|
||||
}
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
'CODE_SERVER_PASSWORD': code_server_pass
|
||||
}
|
||||
}
|
||||
|
||||
workloads << zmachine.to_workload(
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
description: 'zmachine_test'
|
||||
)
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'holochain deployment'
|
||||
workloads: workloads
|
||||
twin_id: deployer.twin_id
|
||||
description: 'holochain deployment'
|
||||
workloads: workloads
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
@@ -147,7 +146,7 @@ fn get_chain_network(network string) !tfgrid.ChainNetwork {
|
||||
return chain_net_enum
|
||||
}
|
||||
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool) !u32{
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool) !u32 {
|
||||
gp_net := match network {
|
||||
.dev { gridproxy.TFGridNet.dev }
|
||||
.qa { gridproxy.TFGridNet.qa }
|
||||
@@ -157,15 +156,15 @@ fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, publi
|
||||
|
||||
mut gridproxy_client := gridproxy.get(gp_net, false)!
|
||||
mut free_ips := u64(0)
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
free_ips = 1
|
||||
}
|
||||
|
||||
mut node_it := gridproxy_client.get_nodes_has_resources(
|
||||
free_mru_gb: u64(memory)
|
||||
free_sru_gb: u64(disk)
|
||||
free_cpu: u64(cpu)
|
||||
free_ips: free_ips
|
||||
free_cpu: u64(cpu)
|
||||
free_ips: free_ips
|
||||
)
|
||||
nodes := node_it.next()
|
||||
mut node_id := u32(0) // get from user or use gridproxy to get nodeid
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import freeflowuniverse.herolib.threefold.grid.models
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model {NodeFilter}
|
||||
import freeflowuniverse.herolib.threefold.gridproxy.model { NodeFilter }
|
||||
import rand
|
||||
import log
|
||||
import os
|
||||
@@ -44,7 +44,7 @@ fn get_chain_network(network string) !tfgrid.ChainNetwork {
|
||||
return chain_net_enum
|
||||
}
|
||||
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool, has_domain bool, available_for u64) !u32{
|
||||
fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, public_ip bool, has_domain bool, available_for u64) !u32 {
|
||||
gp_net := match network {
|
||||
.dev { gridproxy.TFGridNet.dev }
|
||||
.qa { gridproxy.TFGridNet.qa }
|
||||
@@ -54,24 +54,24 @@ fn get_node_id(network tfgrid.ChainNetwork, memory int, disk int, cpu int, publi
|
||||
|
||||
mut gridproxy_client := gridproxy.get(gp_net, false)!
|
||||
mut free_ips := u64(0)
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
free_ips = 1
|
||||
}
|
||||
|
||||
mut filter_ := NodeFilter{
|
||||
free_ips: free_ips
|
||||
free_mru: u64(memory) * (1204 * 1204 * 1204)
|
||||
free_sru: u64(disk) * (1204 * 1204 * 1204)
|
||||
total_cru: u64(cpu)
|
||||
domain: has_domain
|
||||
free_ips: free_ips
|
||||
free_mru: u64(memory) * (1204 * 1204 * 1204)
|
||||
free_sru: u64(disk) * (1204 * 1204 * 1204)
|
||||
total_cru: u64(cpu)
|
||||
domain: has_domain
|
||||
available_for: available_for
|
||||
status: 'up'
|
||||
randomize: true
|
||||
size: u64(1)
|
||||
status: 'up'
|
||||
randomize: true
|
||||
size: u64(1)
|
||||
}
|
||||
|
||||
nodes := gridproxy_client.get_nodes(filter_)!
|
||||
if nodes.len != 1{
|
||||
if nodes.len != 1 {
|
||||
return error('cannot find a suitable node matching your specs')
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ logger.info('deploying on node: ${node_id}')
|
||||
network_name := 'net_${rand.string(5).to_lower()}' // autocreate a network
|
||||
wg_port := deployer.assign_wg_port(node_id)!
|
||||
mut network := models.Znet{
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
ip_range: '10.1.0.0/16' // auto-assign
|
||||
subnet: '10.1.1.0/24' // auto-assign
|
||||
wireguard_private_key: 'GDU+cjKrHNJS9fodzjFDzNFl5su3kJXTZ3ipPgUjOUE=' // autocreate
|
||||
wireguard_listen_port: wg_port
|
||||
// mycelium: models.Mycelium{
|
||||
@@ -117,7 +117,7 @@ mut network := models.Znet{
|
||||
workloads << network.to_workload(name: network_name, description: 'test_network1')
|
||||
|
||||
mut public_ip_name := ''
|
||||
if public_ip{
|
||||
if public_ip {
|
||||
public_ip_name = rand.string(5).to_lower()
|
||||
workloads << models.PublicIP{
|
||||
v4: true
|
||||
@@ -125,51 +125,51 @@ if public_ip{
|
||||
}
|
||||
|
||||
zmachine := models.Zmachine{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
flist: 'https://hub.grid.tf/tf-official-apps/base:latest.flist'
|
||||
network: models.ZmachineNetwork{
|
||||
interfaces: [
|
||||
models.ZNetworkInterface{
|
||||
network: network_name
|
||||
ip: '10.1.1.3'
|
||||
ip: '10.1.1.3'
|
||||
},
|
||||
]
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
public_ip: public_ip_name
|
||||
planetary: true
|
||||
// mycelium: models.MyceliumIP{
|
||||
// network: network_name
|
||||
// hex_seed: rand.string(6).bytes().hex()
|
||||
// }
|
||||
}
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
entrypoint: '/sbin/zinit init' // from user or default
|
||||
compute_capacity: models.ComputeCapacity{
|
||||
cpu: u8(cpu)
|
||||
cpu: u8(cpu)
|
||||
memory: i64(memory) * 1024 * 1024 * 1024
|
||||
}
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
size: u64(disk) * 1024 * 1024 * 1024
|
||||
env: {
|
||||
'SSH_KEY': ssh_key
|
||||
}
|
||||
}
|
||||
|
||||
workloads << zmachine.to_workload(
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
name: 'vm_${rand.string(5).to_lower()}'
|
||||
description: 'zmachine_test'
|
||||
)
|
||||
|
||||
signature_requirement := models.SignatureRequirement{
|
||||
weight_required: 1
|
||||
requests: [
|
||||
requests: [
|
||||
models.SignatureRequest{
|
||||
twin_id: deployer.twin_id
|
||||
weight: 1
|
||||
weight: 1
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
mut deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
description: 'vm with gateway'
|
||||
workloads: workloads
|
||||
twin_id: deployer.twin_id
|
||||
description: 'vm with gateway'
|
||||
workloads: workloads
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
deployment.add_metadata('vm', 'SimpleVM')
|
||||
@@ -187,11 +187,11 @@ dl := deployer.get_deployment(contract_id, node_id) or {
|
||||
machine_res := get_machine_result(dl)!
|
||||
logger.info('zmachine result: ${machine_res}')
|
||||
|
||||
gw_name := rand.string(5).to_lower()
|
||||
gw_name := rand.string(5).to_lower()
|
||||
gw := models.GatewayNameProxy{
|
||||
tls_passthrough: false
|
||||
backends: ['http://[${machine_res.planetary_ip}]:9000']
|
||||
name: gw_name
|
||||
backends: ['http://[${machine_res.planetary_ip}]:9000']
|
||||
name: gw_name
|
||||
}
|
||||
|
||||
gw_workload := gw.to_workload(name: gw_name)
|
||||
@@ -200,8 +200,8 @@ name_contract_id := deployer.client.create_name_contract(gw_name)!
|
||||
logger.info('name contract ${gw_workload.name} created with id ${name_contract_id}')
|
||||
|
||||
mut gw_deployment := models.new_deployment(
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [gw_workload]
|
||||
twin_id: deployer.twin_id
|
||||
workloads: [gw_workload]
|
||||
signature_requirement: signature_requirement
|
||||
)
|
||||
|
||||
|
||||
@@ -5,22 +5,22 @@ import log
|
||||
// Mock implementation for testing
|
||||
struct MockDeployer {
|
||||
mut:
|
||||
logger &log.Log
|
||||
logger &log.Log
|
||||
}
|
||||
|
||||
fn (mut d MockDeployer) cancel_contract(contract_id u64) ! {
|
||||
d.logger.info('Mock: Canceling contract ${contract_id}')
|
||||
d.logger.info('Mock: Canceling contract ${contract_id}')
|
||||
}
|
||||
|
||||
fn test_cancel_contract(contract_id u64) ! {
|
||||
mut logger := &log.Log{}
|
||||
logger.set_level(.debug)
|
||||
mut deployer := MockDeployer{
|
||||
logger: logger
|
||||
}
|
||||
deployer.cancel_contract(contract_id)!
|
||||
mut logger := &log.Log{}
|
||||
logger.set_level(.debug)
|
||||
mut deployer := MockDeployer{
|
||||
logger: logger
|
||||
}
|
||||
deployer.cancel_contract(contract_id)!
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_cancel_contract(u64(119497)) or { println('error happened: ${err}') }
|
||||
test_cancel_contract(u64(119497)) or { println('error happened: ${err}') }
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
|
||||
mut cl := tfgrid.get("my_config")!
|
||||
mut cl := tfgrid.get('my_config')!
|
||||
mut cfg := cl.config()!
|
||||
|
||||
println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
if cfg.mnemonics == "" {
|
||||
if cfg.mnemonics == '' {
|
||||
// will ask questions if not filled in yet
|
||||
cl.config_interactive()!
|
||||
}
|
||||
@@ -27,11 +27,11 @@ println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
cl = tfgrid.get("empty_config")!
|
||||
cl = tfgrid.get('empty_config')!
|
||||
|
||||
println(cl.instance)
|
||||
cfg = cl.config()!
|
||||
println(cfg)
|
||||
|
||||
// TO CONFIGURE NEW
|
||||
// TO CONFIGURE NEW
|
||||
// cl.config_delete()!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.threefold.grid as tfgrid
|
||||
import freeflowuniverse.herolib.threefold.griddriver { Client }
|
||||
import freeflowuniverse.herolib.threefold.griddriver
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import log
|
||||
|
||||
|
||||
@@ -1,40 +1,33 @@
|
||||
|
||||
|
||||
struct VMSpecs{
|
||||
struct VMSpecs {
|
||||
deployment_name string
|
||||
name string
|
||||
nodeid string
|
||||
pub_sshkeys []string
|
||||
flist string //if any, if used then ostype not used
|
||||
ostype OSType
|
||||
name string
|
||||
nodeid string
|
||||
pub_sshkeys []string
|
||||
flist string // if any, if used then ostype not used
|
||||
ostype OSType
|
||||
}
|
||||
|
||||
enum OSType{
|
||||
enum OSType {
|
||||
ubuntu_22_04
|
||||
ubuntu_24_04
|
||||
arch
|
||||
alpine
|
||||
}
|
||||
|
||||
struct VMDeployed{
|
||||
name string
|
||||
struct VMDeployed {
|
||||
name string
|
||||
nodeid string
|
||||
//size ..
|
||||
guid string
|
||||
// size ..
|
||||
guid string
|
||||
yggdrasil_ip string
|
||||
mycelium_ip string
|
||||
|
||||
mycelium_ip string
|
||||
}
|
||||
|
||||
|
||||
pub fn (vm VMDeployed) builder_node() builder.Node {
|
||||
|
||||
}
|
||||
|
||||
//only connect to yggdrasil and mycelium
|
||||
// only connect to yggdrasil and mycelium
|
||||
//
|
||||
fn vm_deploy(args_ VMSpecs) VMDeployed{
|
||||
|
||||
deploymentstate_db.set(args.deployment_name,"vm_${args.name}",VMDeployed.json)
|
||||
|
||||
}
|
||||
fn vm_deploy(args_ VMSpecs) VMDeployed {
|
||||
deploymentstate_db.set(args.deployment_name, 'vm_${args.name}', VMDeployed.json)
|
||||
}
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct WebGWArgs{
|
||||
struct WebGWArgs {
|
||||
deployment_name string
|
||||
//...
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//connect domain name, or exising to it
|
||||
fn webgateway_rule_deploy(args_ WebGWArgs) []VMDeployed{
|
||||
|
||||
}
|
||||
// connect domain name, or exising to it
|
||||
fn webgateway_rule_deploy(args_ WebGWArgs) []VMDeployed {
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
contract_id := u64(119450)
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: false)!
|
||||
bills := gp_client.get_contract_hourly_bill(contract_id)!
|
||||
|
||||
console.print_debug("${bills}")
|
||||
console.print_debug('${bills}')
|
||||
|
||||
@@ -11,10 +11,10 @@ fn get_contracts_example() ! {
|
||||
myfilter.contract_type = 'node'
|
||||
myfilter.twin_id = u64(5191)
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug("${mycontracts}")
|
||||
console.print_debug('${mycontracts}')
|
||||
}
|
||||
|
||||
fn get_contract_by_id_example(contract_id u64) ! {
|
||||
@@ -22,10 +22,10 @@ fn get_contract_by_id_example(contract_id u64) ! {
|
||||
|
||||
myfilter.contract_id = contract_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug("${mycontracts}")
|
||||
console.print_debug('${mycontracts}')
|
||||
}
|
||||
|
||||
fn get_my_contracts_example() ! {
|
||||
@@ -37,7 +37,7 @@ fn get_my_contracts_example() ! {
|
||||
myfilter.twin_id = u64(deployer.twin_id)
|
||||
myfilter.state = 'created'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: false)!
|
||||
mycontracts := gp_client.get_contracts(myfilter)!
|
||||
|
||||
console.print_debug('${mycontracts}')
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_farms_example() ! {
|
||||
myfilter.country = 'Egypt'
|
||||
myfilter.total_ips = u64(10)
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
myfarms := gp_client.get_farms(myfilter)!
|
||||
|
||||
console.print_debug("${myfarms}")
|
||||
console.print_debug('${myfarms}')
|
||||
}
|
||||
|
||||
fn get_farm_by_name_example(farm_name string) ! {
|
||||
@@ -20,11 +20,11 @@ fn get_farm_by_name_example(farm_name string) ! {
|
||||
|
||||
myfilter.name = farm_name
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
myfarms := gp_client.get_farms(myfilter)!
|
||||
|
||||
console.print_debug("${myfarms}")
|
||||
console.print_debug('${myfarms}')
|
||||
}
|
||||
|
||||
get_farms_example()!
|
||||
get_farm_by_name_example("freefarm")!
|
||||
get_farm_by_name_example('freefarm')!
|
||||
|
||||
@@ -8,11 +8,11 @@ fn get_gateway_nodes_example() ! {
|
||||
|
||||
myfilter.status = 'up'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mygateways := gp_client.get_gateways(myfilter)!
|
||||
|
||||
console.print_debug("${mygateways}")
|
||||
console.print_debug("${mygateways.len}")
|
||||
|
||||
console.print_debug('${mygateways}')
|
||||
console.print_debug('${mygateways.len}')
|
||||
}
|
||||
|
||||
fn get_gateway_by_id_example(node_id u64) ! {
|
||||
@@ -20,10 +20,10 @@ fn get_gateway_by_id_example(node_id u64) ! {
|
||||
|
||||
myfilter.node_id = node_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mygateways := gp_client.get_gateways(myfilter)!
|
||||
|
||||
console.print_debug("${mygateways}")
|
||||
console.print_debug('${mygateways}')
|
||||
}
|
||||
|
||||
get_gateway_nodes_example()!
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
mut gp_client := gridproxy.new(net:.test, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .test, cache: true)!
|
||||
|
||||
// get twin list
|
||||
twins := gp_client.get_twins()!
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_nodes_example() ! {
|
||||
myfilter.status = 'up'
|
||||
myfilter.country = 'belgium'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_by_id_example(node_id u64) ! {
|
||||
@@ -20,22 +20,22 @@ fn get_node_by_id_example(node_id u64) ! {
|
||||
|
||||
myfilter.node_id = node_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
|
||||
// get node available resources
|
||||
node_available_resources := mynodes[0].calc_available_resources()
|
||||
console.print_debug("${node_available_resources}")
|
||||
console.print_debug('${node_available_resources}')
|
||||
}
|
||||
|
||||
fn get_node_stats_by_id_example(node_id u64) ! {
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
|
||||
node_stats := gp_client.get_node_stats_by_id(node_id)!
|
||||
|
||||
console.print_debug("${node_stats}")
|
||||
console.print_debug('${node_stats}')
|
||||
}
|
||||
|
||||
fn get_node_by_available_capacity_example() ! {
|
||||
@@ -43,15 +43,15 @@ fn get_node_by_available_capacity_example() ! {
|
||||
|
||||
// minimum free capacity
|
||||
myfilter.free_mru = u64(0)
|
||||
myfilter.free_sru = u64(1024) // 1 tb
|
||||
myfilter.free_sru = u64(1024) // 1 tb
|
||||
myfilter.free_hru = u64(0)
|
||||
myfilter.free_ips = u64(1)
|
||||
|
||||
// init gridproxy client on devnet with redis cash
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_by_city_country_example() ! {
|
||||
@@ -60,10 +60,10 @@ fn get_node_by_city_country_example() ! {
|
||||
myfilter.city = 'Rio de Janeiro'
|
||||
myfilter.country = 'Brazil'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:false)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: false)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
console.print_debug("${mynodes}")
|
||||
console.print_debug('${mynodes}')
|
||||
}
|
||||
|
||||
fn get_node_box_poc_example() ! {
|
||||
@@ -71,10 +71,10 @@ fn get_node_box_poc_example() ! {
|
||||
|
||||
myfilter.status = 'up'
|
||||
|
||||
mut gp_client := gridproxy.new(net:.main, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .main, cache: true)!
|
||||
mynodes := gp_client.get_nodes(myfilter)!
|
||||
|
||||
for node in mynodes{
|
||||
for node in mynodes {
|
||||
console.print_debug('${node}')
|
||||
console.print_debug('${node.capacity.total_resources.hru.to_gigabytes()}')
|
||||
|
||||
@@ -83,7 +83,6 @@ fn get_node_box_poc_example() ! {
|
||||
|
||||
node_stats := gp_client.get_node_stats_by_id(node.node_id)!
|
||||
console.print_debug('${node_stats}')
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ fn get_online_grid_stats_example() ! {
|
||||
|
||||
myfilter.status = NodeStatus.online
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mystats := gp_client.get_stats(myfilter)!
|
||||
|
||||
console.print_debug("${mystats}")
|
||||
console.print_debug('${mystats}')
|
||||
}
|
||||
|
||||
fn get_all_grid_stats_example() ! {
|
||||
@@ -20,10 +20,10 @@ fn get_all_grid_stats_example() ! {
|
||||
|
||||
myfilter.status = NodeStatus.all
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mystats := gp_client.get_stats(myfilter)!
|
||||
|
||||
console.print_debug("${mystats}")
|
||||
console.print_debug('${mystats}')
|
||||
}
|
||||
|
||||
get_online_grid_stats_example()!
|
||||
|
||||
@@ -4,10 +4,10 @@ import freeflowuniverse.herolib.threefold.gridproxy
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
fn get_all_twins_example() ! {
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mytwins := gp_client.get_twins()!
|
||||
|
||||
console.print_debug("${mytwins}")
|
||||
console.print_debug('${mytwins}')
|
||||
}
|
||||
|
||||
fn get_twin_by_id_example(twin_id u64) ! {
|
||||
@@ -15,10 +15,10 @@ fn get_twin_by_id_example(twin_id u64) ! {
|
||||
|
||||
myfilter.twin_id = twin_id
|
||||
|
||||
mut gp_client := gridproxy.new(net:.dev, cache:true)!
|
||||
mut gp_client := gridproxy.new(net: .dev, cache: true)!
|
||||
mytwins := gp_client.get_twins(myfilter)!
|
||||
|
||||
console.print_debug("${mytwins}")
|
||||
console.print_debug('${mytwins}')
|
||||
}
|
||||
|
||||
get_all_twins_example()!
|
||||
|
||||
@@ -4,60 +4,59 @@ import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.clients.dagu
|
||||
|
||||
console.print_header("Deploy test of vmachines on TFGrid using TFRobot.")
|
||||
console.print_header('Deploy test of vmachines on TFGrid using TFRobot.')
|
||||
|
||||
mut bot := tfrobot.new()!
|
||||
|
||||
mut deploy_config := tfrobot.DeployConfig{
|
||||
name: 'holotest2'
|
||||
network: .main
|
||||
debug: true
|
||||
name: 'holotest2'
|
||||
network: .main
|
||||
debug: true
|
||||
node_groups: [
|
||||
tfrobot.NodeGroup{
|
||||
name: 'hologroup2'
|
||||
name: 'hologroup2'
|
||||
nodes_count: 20
|
||||
free_cpu: 8
|
||||
free_mru: 8
|
||||
free_ssd: 100
|
||||
free_cpu: 8
|
||||
free_mru: 8
|
||||
free_ssd: 100
|
||||
// region:"europe"
|
||||
},
|
||||
]
|
||||
vms: [
|
||||
vms: [
|
||||
tfrobot.VMConfig{
|
||||
name: 'myvm'
|
||||
vms_count: 5
|
||||
cpu: 1
|
||||
mem: 1
|
||||
name: 'myvm'
|
||||
vms_count: 5
|
||||
cpu: 1
|
||||
mem: 1
|
||||
entry_point: '/sbin/zinit init'
|
||||
// flist: 'https://hub.grid.tf/mariobassem1.3bot/threefolddev-holochain-latest.flist'
|
||||
flist: 'https://hub.grid.tf/ashraf.3bot/threefolddev-holochain-latest.flist'
|
||||
env_vars: {
|
||||
'CODE_SERVER_PASSWORD': 'planetfirst'
|
||||
flist: 'https://hub.grid.tf/ashraf.3bot/threefolddev-holochain-latest.flist'
|
||||
env_vars: {
|
||||
'CODE_SERVER_PASSWORD': 'planetfirst'
|
||||
'DAGU_BASICAUTH_USERNAME': 'admin'
|
||||
'DAGU_BASICAUTH_PASSWORD': 'planetfirst'
|
||||
}
|
||||
public_ip4: false
|
||||
root_size: 50
|
||||
planetary: true
|
||||
root_size: 50
|
||||
planetary: true
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
//ssh-key is not specified, first key will be chosen
|
||||
// ssh-key is not specified, first key will be chosen
|
||||
|
||||
//DEAL WITH SSH KEYS
|
||||
// DEAL WITH SSH KEYS
|
||||
tfrobot.sshagent_keys_add(mut deploy_config)!
|
||||
|
||||
console.print_header("nr of ssh keys in ssh-agent:${deploy_config.ssh_keys.len}")
|
||||
console.print_header('nr of ssh keys in ssh-agent:${deploy_config.ssh_keys.len}')
|
||||
|
||||
res := bot.deploy(deploy_config)!
|
||||
|
||||
|
||||
console.print_header("Get VM's and ssh into it.")
|
||||
|
||||
for vm in tfrobot.vms_get('holotest')!{
|
||||
for vm in tfrobot.vms_get('holotest')! {
|
||||
console.print_debug(vm.str())
|
||||
mut node:=vm.node()!
|
||||
r:=node.exec(cmd:"ls /")!
|
||||
mut node := vm.node()!
|
||||
r := node.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Get VM's.")
|
||||
|
||||
for vm in tfrobot.vms_get('holotest2')!{
|
||||
for vm in tfrobot.vms_get('holotest2')! {
|
||||
console.print_debug(vm.str())
|
||||
mut node:=vm.node()!
|
||||
r:=node.exec(cmd:"ls /")!
|
||||
mut node := vm.node()!
|
||||
r := node.exec(cmd: 'ls /')!
|
||||
println(r)
|
||||
}
|
||||
|
||||
@@ -3,44 +3,43 @@
|
||||
import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Tasker Example.")
|
||||
console.print_header('Tasker Example.')
|
||||
|
||||
mut vm := tfrobot.vm_get('holotest','test2')!
|
||||
mut vm := tfrobot.vm_get('holotest', 'test2')!
|
||||
|
||||
//get a set of tasks as we want to execute on the vm
|
||||
mut tasks:=vm.tasks_new(name:'holochain_scaffold')
|
||||
// get a set of tasks as we want to execute on the vm
|
||||
mut tasks := vm.tasks_new(name: 'holochain_scaffold')
|
||||
|
||||
tasks.step_add(
|
||||
nr:1
|
||||
name: 'Verify installation'
|
||||
command: 'nix run --refresh -j0 -v github:holochain/holochain#hc-scaffold -- --version'
|
||||
)!
|
||||
nr: 1
|
||||
name: 'Verify installation'
|
||||
command: 'nix run --refresh -j0 -v github:holochain/holochain#hc-scaffold -- --version'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:2
|
||||
name: 'Create working directory'
|
||||
command: 'mkdir -p /root/Holochain'
|
||||
depends: "1"
|
||||
)!
|
||||
nr: 2
|
||||
name: 'Create working directory'
|
||||
command: 'mkdir -p /root/Holochain'
|
||||
depends: '1'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:3
|
||||
name: 'Scaffold application'
|
||||
description: 'Scaffold a simple "Hello, World!" Holochain application'
|
||||
dir: '/root/Holochain'
|
||||
script: 'nix run github:holochain/holochain#hc-scaffold -- example hello-world || true'
|
||||
depends: "2"
|
||||
continue_on_error: true
|
||||
)!
|
||||
nr: 3
|
||||
name: 'Scaffold application'
|
||||
description: 'Scaffold a simple "Hello, World!" Holochain application'
|
||||
dir: '/root/Holochain'
|
||||
script: 'nix run github:holochain/holochain#hc-scaffold -- example hello-world || true'
|
||||
depends: '2'
|
||||
continue_on_error: true
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:4
|
||||
name: 'Run Application'
|
||||
dir: '/root/Holochain/hello-world'
|
||||
command: 'nix develop --command bash -c "npm install && npm run start" && exit'
|
||||
depends: "3"
|
||||
)!
|
||||
|
||||
nr: 4
|
||||
name: 'Run Application'
|
||||
dir: '/root/Holochain/hello-world'
|
||||
command: 'nix develop --command bash -c "npm install && npm run start" && exit'
|
||||
depends: '3'
|
||||
)!
|
||||
|
||||
vm.tasks_run(tasks)!
|
||||
vm.tasks_see(tasks)!
|
||||
|
||||
@@ -3,26 +3,25 @@
|
||||
import freeflowuniverse.herolib.threefold.tfrobot
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
console.print_header("Tasker Example 2.")
|
||||
console.print_header('Tasker Example 2.')
|
||||
|
||||
mut vm := tfrobot.vm_get('holotest','test1')!
|
||||
mut vm := tfrobot.vm_get('holotest', 'test1')!
|
||||
|
||||
//get a set of tasks as we want to execute on the vm
|
||||
mut tasks:=vm.tasks_new(name:'sysadmin')
|
||||
// get a set of tasks as we want to execute on the vm
|
||||
mut tasks := vm.tasks_new(name: 'sysadmin')
|
||||
|
||||
tasks.step_add(
|
||||
nr:1
|
||||
name: 'ls'
|
||||
command: 'ls /'
|
||||
)!
|
||||
nr: 1
|
||||
name: 'ls'
|
||||
command: 'ls /'
|
||||
)!
|
||||
|
||||
tasks.step_add(
|
||||
nr:2
|
||||
name: 'install something'
|
||||
command: 'nix-env --install mc'
|
||||
depends: "1"
|
||||
)!
|
||||
|
||||
nr: 2
|
||||
name: 'install something'
|
||||
command: 'nix-env --install mc'
|
||||
depends: '1'
|
||||
)!
|
||||
|
||||
vm.tasks_run(tasks)!
|
||||
vm.tasks_see(tasks)!
|
||||
|
||||
@@ -5,9 +5,8 @@ import freeflowuniverse.herolib.threefold.tfgrid3deployer
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.installers.threefold.griddriver
|
||||
|
||||
|
||||
fn main(){
|
||||
mut installer:= griddriver.get()!
|
||||
fn main() {
|
||||
mut installer := griddriver.get()!
|
||||
installer.install()!
|
||||
|
||||
// v := tfgrid3deployer.get()!
|
||||
@@ -52,7 +51,7 @@ fn main(){
|
||||
// vm1 := deployment.vm_get("my_vm1")!
|
||||
// reachable := vm1.healthcheck()!
|
||||
// println("vm reachable: ${reachable}")
|
||||
|
||||
|
||||
// if !reachable {
|
||||
// deployment.vm_delete()!
|
||||
// deployment.vm_deploy()!
|
||||
@@ -63,7 +62,6 @@ fn main(){
|
||||
// vm1.deploy()!
|
||||
// }
|
||||
|
||||
|
||||
/*
|
||||
TODO: Agreed on
|
||||
|
||||
|
||||
Reference in New Issue
Block a user