From 6bbaa0d1f7a63d36650ccdf9a819d8c5465b0aee Mon Sep 17 00:00:00 2001 From: despiegk Date: Fri, 28 Feb 2025 07:50:13 -0700 Subject: [PATCH] cleanup client for grid --- .../deploy_tosort}/deployment.v | 0 .../deployer}/.heroscript | 2 +- .../deployer}/contracts.v | 2 +- .../deployer}/deployment.v | 2 +- .../deployer}/deployment_setup.v | 2 +- .../deployer}/filter.v | 2 +- .../deployer}/kvstore.v | 2 +- .../deployer}/network.v | 2 +- .../deployer}/readme.md | 8 +- .../deployer}/tfgrid3deployer_factory_.v | 16 +- .../deployer}/tfgrid3deployer_model.v | 2 +- .../deployer}/utils.v | 2 +- .../deployer}/vmachine.v | 2 +- .../deployer}/webnames.v | 2 +- .../deployer}/zdbs.v | 2 +- .../{grid => grid3/deployer2_sort}/README.md | 2 + .../{grid => grid3/deployer2_sort}/deployer.v | 2 +- .../deployer2_sort}/deployment_state.v | 2 +- .../{grid => grid3/deployer2_sort}/factory.v | 2 +- .../{grid => grid3/deployer2_sort}/graphql.v | 2 +- .../{grid => grid3/deployer2_sort}/rmb.v | 2 +- .../{grid => grid3/deployer2_sort}/vm.v | 2 +- .../{grid => grid3/deployer2_sort}/vm_test.v | 2 +- .../{grid => grid3/deployer2_sort}/zdb.v | 2 +- lib/threefold/{ => grid3}/griddriver/client.v | 0 lib/threefold/{ => grid3}/griddriver/rmb.v | 0 .../{ => grid3}/griddriver/substrate.v | 0 lib/threefold/{ => grid3}/griddriver/utils.v | 0 lib/threefold/{ => grid3}/gridproxy/README.md | 0 .../{ => grid3}/gridproxy/gridproxy_core.v | 0 .../{ => grid3}/gridproxy/gridproxy_factory.v | 0 .../gridproxy/gridproxy_highlevel.v | 0 .../{ => grid3}/gridproxy/gridproxy_test.v | 0 .../{ => grid3}/gridproxy/model/contract.v | 0 .../{ => grid3}/gridproxy/model/farm.v | 0 .../{ => grid3}/gridproxy/model/filter.v | 0 .../{ => grid3}/gridproxy/model/iterators.v | 0 .../{ => grid3}/gridproxy/model/model.v | 0 .../{ => grid3}/gridproxy/model/node.v | 0 .../{ => grid3}/gridproxy/model/stats.v | 0 .../{ => grid3}/gridproxy/model/twin.v | 0 .../{grid => grid3}/models/computecapacity.v | 0 .../{grid => grid3}/models/deployment.v | 0 .../{grid => grid3}/models/gw_fqdn.v | 0 .../{grid => grid3}/models/gw_name.v | 0 lib/threefold/{grid => grid3}/models/ip.v | 0 lib/threefold/{grid => grid3}/models/qsfs.v | 0 .../{grid => grid3}/models/workload.v | 0 lib/threefold/{grid => grid3}/models/zdb.v | 0 lib/threefold/{grid => grid3}/models/zlogs.v | 0 .../{grid => grid3}/models/zmachine.v | 0 lib/threefold/{grid => grid3}/models/zmount.v | 0 lib/threefold/{grid => grid3}/models/znet.v | 0 lib/threefold/{ => grid3}/rmb/model_rmb.v | 0 lib/threefold/{ => grid3}/rmb/readme.md | 0 lib/threefold/{ => grid3}/rmb/rmb_calls_zos.v | 0 .../rmb/rmb_calls_zos_statistics.v | 0 .../rmb/rmb_calls_zos_storagepools.v | 0 lib/threefold/{ => grid3}/rmb/rmb_client.v | 0 lib/threefold/{ => grid3}/rmb/rmb_request.v | 0 lib/threefold/{ => grid3}/rmb/rmb_test.v | 0 lib/threefold/{ => grid3}/tfrobot/README.md | 0 lib/threefold/{ => grid3}/tfrobot/cancel.v | 0 .../{ => grid3}/tfrobot/cancel_test.v | 0 lib/threefold/{ => grid3}/tfrobot/deploy.v | 0 .../{ => grid3}/tfrobot/deploy_test.v | 0 lib/threefold/{ => grid3}/tfrobot/factory.v | 0 .../{ => grid3}/tfrobot/factory_test.v | 0 lib/threefold/{ => grid3}/tfrobot/job.v | 0 lib/threefold/{ => grid3}/tfrobot/job_test.v | 0 .../{ => grid3}/tfrobot/templates/config.json | 0 .../{ => grid3}/tfrobot/templates/config.yaml | 0 .../{ => grid3}/tfrobot/tfrobot_redis.v | 0 lib/threefold/{ => grid3}/tfrobot/vm.v | 0 lib/threefold/{ => grid3}/tfrobot/vm_deploy.v | 0 .../{ => grid3}/tfrobot/vm_deploy_test.v | 0 lib/threefold/{ => grid3}/tokens/readme.md | 0 .../{ => grid3}/tokens/tokens_fetch.v | 0 lib/threefold/{ => grid3}/zerohub/flist.v | 0 lib/threefold/{ => grid3}/zerohub/readme.md | 0 lib/threefold/{ => grid3}/zerohub/zerohub.v | 0 .../{ => grid3}/zerohub/zerohub_test.v | 0 lib/threefold/main.v | 6 - lib/threefold/nodepilot/nodepilot.v | 108 ------------- lib/threefold/nodepilot/readme.md | 6 - lib/threefold/tfgrid_actions/README.md | 22 --- .../tfgrid_actions/blockchain/blockchain.v | 15 -- .../tfgrid_actions/blockchain/factory.v | 11 -- .../tfgrid_actions/clients/clients.v | 16 -- lib/threefold/tfgrid_actions/factory.v | 94 ----------- lib/threefold/tfgrid_actions/nostr/channel.v | 59 ------- lib/threefold/tfgrid_actions/nostr/direct.v | 34 ---- lib/threefold/tfgrid_actions/nostr/handler.v | 35 ---- .../tfgrid_actions/stellar/account.v | 47 ------ .../tfgrid_actions/stellar/handler.v | 30 ---- .../tfgrid_actions/tfgrid/contracts.v | 64 -------- lib/threefold/tfgrid_actions/tfgrid/core.v | 17 -- .../tfgrid_actions/tfgrid/discourse.v | 54 ------- lib/threefold/tfgrid_actions/tfgrid/farms.v | 61 ------- .../tfgrid_actions/tfgrid/funkwhale.v | 48 ------ .../tfgrid_actions/tfgrid/gateway_fqdn.v | 40 ----- .../tfgrid_actions/tfgrid/gateway_name.v | 38 ----- lib/threefold/tfgrid_actions/tfgrid/handler.v | 49 ------ lib/threefold/tfgrid_actions/tfgrid/helpers.v | 31 ---- lib/threefold/tfgrid_actions/tfgrid/k8s.v | 130 --------------- lib/threefold/tfgrid_actions/tfgrid/network.v | 88 ---------- lib/threefold/tfgrid_actions/tfgrid/nodes.v | 112 ------------- .../tfgrid_actions/tfgrid/peertube.v | 48 ------ .../tfgrid_actions/tfgrid/presearch.v | 50 ------ lib/threefold/tfgrid_actions/tfgrid/stats.v | 24 --- lib/threefold/tfgrid_actions/tfgrid/taiga.v | 50 ------ lib/threefold/tfgrid_actions/tfgrid/twins.v | 43 ----- lib/threefold/tfgrid_actions/tfgrid/vm.v | 75 --------- lib/threefold/tfgrid_actions/tfgrid/zdb.v | 42 ----- lib/threefold/tfgrid_actions/web3gw/handler.v | 38 ----- lib/threefold/tfgrid_actions/web3gw/keys.v | 47 ------ lib/threefold/tfgrid_actions/web3gw/money.v | 152 ------------------ 117 files changed, 34 insertions(+), 1816 deletions(-) rename lib/threefold/{deploy => grid3/deploy_tosort}/deployment.v (100%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/.heroscript (73%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/contracts.v (97%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/deployment.v (99%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/deployment_setup.v (99%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/filter.v (97%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/kvstore.v (97%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/network.v (99%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/readme.md (50%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/tfgrid3deployer_factory_.v (82%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/tfgrid3deployer_model.v (98%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/utils.v (98%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/vmachine.v (99%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/webnames.v (96%) rename lib/threefold/{tfgrid3deployer => grid3/deployer}/zdbs.v (96%) rename lib/threefold/{grid => grid3/deployer2_sort}/README.md (80%) rename lib/threefold/{grid => grid3/deployer2_sort}/deployer.v (99%) rename lib/threefold/{grid => grid3/deployer2_sort}/deployment_state.v (97%) rename lib/threefold/{grid => grid3/deployer2_sort}/factory.v (99%) rename lib/threefold/{grid => grid3/deployer2_sort}/graphql.v (99%) rename lib/threefold/{grid => grid3/deployer2_sort}/rmb.v (98%) rename lib/threefold/{grid => grid3/deployer2_sort}/vm.v (99%) rename lib/threefold/{grid => grid3/deployer2_sort}/vm_test.v (96%) rename lib/threefold/{grid => grid3/deployer2_sort}/zdb.v (99%) rename lib/threefold/{ => grid3}/griddriver/client.v (100%) rename lib/threefold/{ => grid3}/griddriver/rmb.v (100%) rename lib/threefold/{ => grid3}/griddriver/substrate.v (100%) rename lib/threefold/{ => grid3}/griddriver/utils.v (100%) rename lib/threefold/{ => grid3}/gridproxy/README.md (100%) rename lib/threefold/{ => grid3}/gridproxy/gridproxy_core.v (100%) rename lib/threefold/{ => grid3}/gridproxy/gridproxy_factory.v (100%) rename lib/threefold/{ => grid3}/gridproxy/gridproxy_highlevel.v (100%) rename lib/threefold/{ => grid3}/gridproxy/gridproxy_test.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/contract.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/farm.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/filter.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/iterators.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/model.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/node.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/stats.v (100%) rename lib/threefold/{ => grid3}/gridproxy/model/twin.v (100%) rename lib/threefold/{grid => grid3}/models/computecapacity.v (100%) rename lib/threefold/{grid => grid3}/models/deployment.v (100%) rename lib/threefold/{grid => grid3}/models/gw_fqdn.v (100%) rename lib/threefold/{grid => grid3}/models/gw_name.v (100%) rename lib/threefold/{grid => grid3}/models/ip.v (100%) rename lib/threefold/{grid => grid3}/models/qsfs.v (100%) rename lib/threefold/{grid => grid3}/models/workload.v (100%) rename lib/threefold/{grid => grid3}/models/zdb.v (100%) rename lib/threefold/{grid => grid3}/models/zlogs.v (100%) rename lib/threefold/{grid => grid3}/models/zmachine.v (100%) rename lib/threefold/{grid => grid3}/models/zmount.v (100%) rename lib/threefold/{grid => grid3}/models/znet.v (100%) rename lib/threefold/{ => grid3}/rmb/model_rmb.v (100%) rename lib/threefold/{ => grid3}/rmb/readme.md (100%) rename lib/threefold/{ => grid3}/rmb/rmb_calls_zos.v (100%) rename lib/threefold/{ => grid3}/rmb/rmb_calls_zos_statistics.v (100%) rename lib/threefold/{ => grid3}/rmb/rmb_calls_zos_storagepools.v (100%) rename lib/threefold/{ => grid3}/rmb/rmb_client.v (100%) rename lib/threefold/{ => grid3}/rmb/rmb_request.v (100%) rename lib/threefold/{ => grid3}/rmb/rmb_test.v (100%) rename lib/threefold/{ => grid3}/tfrobot/README.md (100%) rename lib/threefold/{ => grid3}/tfrobot/cancel.v (100%) rename lib/threefold/{ => grid3}/tfrobot/cancel_test.v (100%) rename lib/threefold/{ => grid3}/tfrobot/deploy.v (100%) rename lib/threefold/{ => grid3}/tfrobot/deploy_test.v (100%) rename lib/threefold/{ => grid3}/tfrobot/factory.v (100%) rename lib/threefold/{ => grid3}/tfrobot/factory_test.v (100%) rename lib/threefold/{ => grid3}/tfrobot/job.v (100%) rename lib/threefold/{ => grid3}/tfrobot/job_test.v (100%) rename lib/threefold/{ => grid3}/tfrobot/templates/config.json (100%) rename lib/threefold/{ => grid3}/tfrobot/templates/config.yaml (100%) rename lib/threefold/{ => grid3}/tfrobot/tfrobot_redis.v (100%) rename lib/threefold/{ => grid3}/tfrobot/vm.v (100%) rename lib/threefold/{ => grid3}/tfrobot/vm_deploy.v (100%) rename lib/threefold/{ => grid3}/tfrobot/vm_deploy_test.v (100%) rename lib/threefold/{ => grid3}/tokens/readme.md (100%) rename lib/threefold/{ => grid3}/tokens/tokens_fetch.v (100%) rename lib/threefold/{ => grid3}/zerohub/flist.v (100%) rename lib/threefold/{ => grid3}/zerohub/readme.md (100%) rename lib/threefold/{ => grid3}/zerohub/zerohub.v (100%) rename lib/threefold/{ => grid3}/zerohub/zerohub_test.v (100%) delete mode 100644 lib/threefold/main.v delete mode 100644 lib/threefold/nodepilot/nodepilot.v delete mode 100644 lib/threefold/nodepilot/readme.md delete mode 100644 lib/threefold/tfgrid_actions/README.md delete mode 100644 lib/threefold/tfgrid_actions/blockchain/blockchain.v delete mode 100644 lib/threefold/tfgrid_actions/blockchain/factory.v delete mode 100644 lib/threefold/tfgrid_actions/clients/clients.v delete mode 100644 lib/threefold/tfgrid_actions/factory.v delete mode 100644 lib/threefold/tfgrid_actions/nostr/channel.v delete mode 100644 lib/threefold/tfgrid_actions/nostr/direct.v delete mode 100644 lib/threefold/tfgrid_actions/nostr/handler.v delete mode 100644 lib/threefold/tfgrid_actions/stellar/account.v delete mode 100644 lib/threefold/tfgrid_actions/stellar/handler.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/contracts.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/core.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/discourse.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/farms.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/funkwhale.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/gateway_fqdn.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/gateway_name.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/handler.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/helpers.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/k8s.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/network.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/nodes.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/peertube.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/presearch.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/stats.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/taiga.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/twins.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/vm.v delete mode 100644 lib/threefold/tfgrid_actions/tfgrid/zdb.v delete mode 100644 lib/threefold/tfgrid_actions/web3gw/handler.v delete mode 100644 lib/threefold/tfgrid_actions/web3gw/keys.v delete mode 100644 lib/threefold/tfgrid_actions/web3gw/money.v diff --git a/lib/threefold/deploy/deployment.v b/lib/threefold/grid3/deploy_tosort/deployment.v similarity index 100% rename from lib/threefold/deploy/deployment.v rename to lib/threefold/grid3/deploy_tosort/deployment.v diff --git a/lib/threefold/tfgrid3deployer/.heroscript b/lib/threefold/grid3/deployer/.heroscript similarity index 73% rename from lib/threefold/tfgrid3deployer/.heroscript rename to lib/threefold/grid3/deployer/.heroscript index c413c05f..32fc8a0c 100644 --- a/lib/threefold/tfgrid3deployer/.heroscript +++ b/lib/threefold/grid3/deployer/.heroscript @@ -1,6 +1,6 @@ !!hero_code.generate_client - name:'tfgrid3deployer' + name:'deployer' classname:'TFGridDeployer' singleton:0 default:1 diff --git a/lib/threefold/tfgrid3deployer/contracts.v b/lib/threefold/grid3/deployer/contracts.v similarity index 97% rename from lib/threefold/tfgrid3deployer/contracts.v rename to lib/threefold/grid3/deployer/contracts.v index ecd5b8de..89b47b36 100644 --- a/lib/threefold/tfgrid3deployer/contracts.v +++ b/lib/threefold/grid3/deployer/contracts.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.gridproxy import freeflowuniverse.herolib.threefold.gridproxy.model as proxy_models diff --git a/lib/threefold/tfgrid3deployer/deployment.v b/lib/threefold/grid3/deployer/deployment.v similarity index 99% rename from lib/threefold/tfgrid3deployer/deployment.v rename to lib/threefold/grid3/deployer/deployment.v index ec39f895..4f85bfb6 100644 --- a/lib/threefold/tfgrid3deployer/deployment.v +++ b/lib/threefold/grid3/deployer/deployment.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.grid.models as grid_models import freeflowuniverse.herolib.threefold.grid diff --git a/lib/threefold/tfgrid3deployer/deployment_setup.v b/lib/threefold/grid3/deployer/deployment_setup.v similarity index 99% rename from lib/threefold/tfgrid3deployer/deployment_setup.v rename to lib/threefold/grid3/deployer/deployment_setup.v index fa2f6581..59e94462 100644 --- a/lib/threefold/tfgrid3deployer/deployment_setup.v +++ b/lib/threefold/grid3/deployer/deployment_setup.v @@ -1,5 +1,5 @@ // This file should only contains any functions, helpers that related to the deployment setup. -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.grid.models as grid_models import freeflowuniverse.herolib.threefold.grid diff --git a/lib/threefold/tfgrid3deployer/filter.v b/lib/threefold/grid3/deployer/filter.v similarity index 97% rename from lib/threefold/tfgrid3deployer/filter.v rename to lib/threefold/grid3/deployer/filter.v index 9098e6f3..bd1f2fbb 100644 --- a/lib/threefold/tfgrid3deployer/filter.v +++ b/lib/threefold/grid3/deployer/filter.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.gridproxy import freeflowuniverse.herolib.threefold.gridproxy.model as gridproxy_models diff --git a/lib/threefold/tfgrid3deployer/kvstore.v b/lib/threefold/grid3/deployer/kvstore.v similarity index 97% rename from lib/threefold/tfgrid3deployer/kvstore.v rename to lib/threefold/grid3/deployer/kvstore.v index 37871112..a38c9612 100644 --- a/lib/threefold/tfgrid3deployer/kvstore.v +++ b/lib/threefold/grid3/deployer/kvstore.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.core.base as context diff --git a/lib/threefold/tfgrid3deployer/network.v b/lib/threefold/grid3/deployer/network.v similarity index 99% rename from lib/threefold/tfgrid3deployer/network.v rename to lib/threefold/grid3/deployer/network.v index 07ef3cc6..c7e315be 100644 --- a/lib/threefold/tfgrid3deployer/network.v +++ b/lib/threefold/grid3/deployer/network.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.grid.models as grid_models import freeflowuniverse.herolib.threefold.grid diff --git a/lib/threefold/tfgrid3deployer/readme.md b/lib/threefold/grid3/deployer/readme.md similarity index 50% rename from lib/threefold/tfgrid3deployer/readme.md rename to lib/threefold/grid3/deployer/readme.md index adf4c325..1934c719 100644 --- a/lib/threefold/tfgrid3deployer/readme.md +++ b/lib/threefold/grid3/deployer/readme.md @@ -1,4 +1,4 @@ -# tfgrid3deployer +# deployer To get started @@ -6,9 +6,9 @@ To get started -import freeflowuniverse.herolib.clients. tfgrid3deployer +import freeflowuniverse.herolib.clients. deployer -mut client:= tfgrid3deployer.get()! +mut client:= deployer.get()! client... @@ -20,7 +20,7 @@ client... ## example heroscript ```hero -!!tfgrid3deployer.configure +!!deployer.configure secret: '...' host: 'localhost' port: 8888 diff --git a/lib/threefold/tfgrid3deployer/tfgrid3deployer_factory_.v b/lib/threefold/grid3/deployer/tfgrid3deployer_factory_.v similarity index 82% rename from lib/threefold/tfgrid3deployer/tfgrid3deployer_factory_.v rename to lib/threefold/grid3/deployer/tfgrid3deployer_factory_.v index 962e2ebb..2f80e6f6 100644 --- a/lib/threefold/tfgrid3deployer/tfgrid3deployer_factory_.v +++ b/lib/threefold/grid3/deployer/tfgrid3deployer_factory_.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.core.base import freeflowuniverse.herolib.core.playbook @@ -39,7 +39,7 @@ pub fn get(args_ ArgsGet) !&TFGridDeployer { if !exists(args)! { set(obj)! } else { - heroscript := context.hero_config_get('tfgrid3deployer', args.name)! + heroscript := context.hero_config_get('deployer', args.name)! mut obj_ := heroscript_loads(heroscript)! set_in_mem(obj_)! } @@ -47,7 +47,7 @@ pub fn get(args_ ArgsGet) !&TFGridDeployer { return tfgrid3deployer_global[args.name] or { println(tfgrid3deployer_global) // bug if we get here because should be in globals - panic('could not get config for tfgrid3deployer with name, is bug:${args.name}') + panic('could not get config for deployer with name, is bug:${args.name}') } } @@ -56,20 +56,20 @@ pub fn set(o TFGridDeployer) ! { set_in_mem(o)! mut context := base.context()! heroscript := heroscript_dumps(o)! - context.hero_config_set('tfgrid3deployer', o.name, heroscript)! + context.hero_config_set('deployer', o.name, heroscript)! } // does the config exists? pub fn exists(args_ ArgsGet) !bool { mut context := base.context()! mut args := args_get(args_) - return context.hero_config_exists('tfgrid3deployer', args.name) + return context.hero_config_exists('deployer', args.name) } pub fn delete(args_ ArgsGet) ! { mut args := args_get(args_) mut context := base.context()! - context.hero_config_delete('tfgrid3deployer', args.name)! + context.hero_config_delete('deployer', args.name)! if args.name in tfgrid3deployer_global { // del tfgrid3deployer_global[args.name] } @@ -95,7 +95,7 @@ pub fn play(args_ PlayArgs) ! { mut plbook := args.plbook or { playbook.new(text: args.heroscript)! } - mut install_actions := plbook.find(filter: 'tfgrid3deployer.configure')! + mut install_actions := plbook.find(filter: 'deployer.configure')! if install_actions.len > 0 { for install_action in install_actions { heroscript := install_action.heroscript() @@ -105,7 +105,7 @@ pub fn play(args_ PlayArgs) ! { } } -// switch instance to be used for tfgrid3deployer +// switch instance to be used for deployer pub fn switch(name string) { tfgrid3deployer_default = name } diff --git a/lib/threefold/tfgrid3deployer/tfgrid3deployer_model.v b/lib/threefold/grid3/deployer/tfgrid3deployer_model.v similarity index 98% rename from lib/threefold/tfgrid3deployer/tfgrid3deployer_model.v rename to lib/threefold/grid3/deployer/tfgrid3deployer_model.v index 8130beaf..82c200a7 100644 --- a/lib/threefold/tfgrid3deployer/tfgrid3deployer_model.v +++ b/lib/threefold/grid3/deployer/tfgrid3deployer_model.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.data.paramsparser import freeflowuniverse.herolib.data.encoderhero diff --git a/lib/threefold/tfgrid3deployer/utils.v b/lib/threefold/grid3/deployer/utils.v similarity index 98% rename from lib/threefold/tfgrid3deployer/utils.v rename to lib/threefold/grid3/deployer/utils.v index 158c544d..ee82e45c 100644 --- a/lib/threefold/tfgrid3deployer/utils.v +++ b/lib/threefold/grid3/deployer/utils.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.gridproxy import freeflowuniverse.herolib.threefold.grid diff --git a/lib/threefold/tfgrid3deployer/vmachine.v b/lib/threefold/grid3/deployer/vmachine.v similarity index 99% rename from lib/threefold/tfgrid3deployer/vmachine.v rename to lib/threefold/grid3/deployer/vmachine.v index 8e3c8618..208e111d 100644 --- a/lib/threefold/tfgrid3deployer/vmachine.v +++ b/lib/threefold/grid3/deployer/vmachine.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.ui.console import json diff --git a/lib/threefold/tfgrid3deployer/webnames.v b/lib/threefold/grid3/deployer/webnames.v similarity index 96% rename from lib/threefold/tfgrid3deployer/webnames.v rename to lib/threefold/grid3/deployer/webnames.v index ca096294..15afa620 100644 --- a/lib/threefold/tfgrid3deployer/webnames.v +++ b/lib/threefold/grid3/deployer/webnames.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import json diff --git a/lib/threefold/tfgrid3deployer/zdbs.v b/lib/threefold/grid3/deployer/zdbs.v similarity index 96% rename from lib/threefold/tfgrid3deployer/zdbs.v rename to lib/threefold/grid3/deployer/zdbs.v index a80d3629..5ca672a7 100644 --- a/lib/threefold/tfgrid3deployer/zdbs.v +++ b/lib/threefold/grid3/deployer/zdbs.v @@ -1,4 +1,4 @@ -module tfgrid3deployer +module deployer import freeflowuniverse.herolib.threefold.grid.models as grid_models // import freeflowuniverse.herolib.ui.console diff --git a/lib/threefold/grid/README.md b/lib/threefold/grid3/deployer2_sort/README.md similarity index 80% rename from lib/threefold/grid/README.md rename to lib/threefold/grid3/deployer2_sort/README.md index aad3f25d..b7398c97 100644 --- a/lib/threefold/grid/README.md +++ b/lib/threefold/grid3/deployer2_sort/README.md @@ -3,3 +3,5 @@ Create workloads in native low level format, and then use a gridriver go binary to post it to TFChain as well as send it to ZOS. + +//TODO: not sure how to use this one diff --git a/lib/threefold/grid/deployer.v b/lib/threefold/grid3/deployer2_sort/deployer.v similarity index 99% rename from lib/threefold/grid/deployer.v rename to lib/threefold/grid3/deployer2_sort/deployer.v index f6b57e7e..b1218e36 100644 --- a/lib/threefold/grid/deployer.v +++ b/lib/threefold/grid3/deployer2_sort/deployer.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import os import json diff --git a/lib/threefold/grid/deployment_state.v b/lib/threefold/grid3/deployer2_sort/deployment_state.v similarity index 97% rename from lib/threefold/grid/deployment_state.v rename to lib/threefold/grid3/deployer2_sort/deployment_state.v index b26b5056..2965dbd0 100644 --- a/lib/threefold/grid/deployment_state.v +++ b/lib/threefold/grid3/deployer2_sort/deployment_state.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import freeflowuniverse.herolib.core.redisclient diff --git a/lib/threefold/grid/factory.v b/lib/threefold/grid3/deployer2_sort/factory.v similarity index 99% rename from lib/threefold/grid/factory.v rename to lib/threefold/grid3/deployer2_sort/factory.v index 66d911af..04c4008b 100644 --- a/lib/threefold/grid/factory.v +++ b/lib/threefold/grid3/deployer2_sort/factory.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import freeflowuniverse.herolib.core.base import freeflowuniverse.herolib.core.playbook diff --git a/lib/threefold/grid/graphql.v b/lib/threefold/grid3/deployer2_sort/graphql.v similarity index 99% rename from lib/threefold/grid/graphql.v rename to lib/threefold/grid3/deployer2_sort/graphql.v index fa36b97a..72a3b1d2 100644 --- a/lib/threefold/grid/graphql.v +++ b/lib/threefold/grid3/deployer2_sort/graphql.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import net.http import json diff --git a/lib/threefold/grid/rmb.v b/lib/threefold/grid3/deployer2_sort/rmb.v similarity index 98% rename from lib/threefold/grid/rmb.v rename to lib/threefold/grid3/deployer2_sort/rmb.v index 81084d44..72e8b97a 100644 --- a/lib/threefold/grid/rmb.v +++ b/lib/threefold/grid3/deployer2_sort/rmb.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import json import freeflowuniverse.herolib.threefold.grid.models diff --git a/lib/threefold/grid/vm.v b/lib/threefold/grid3/deployer2_sort/vm.v similarity index 99% rename from lib/threefold/grid/vm.v rename to lib/threefold/grid3/deployer2_sort/vm.v index bf1a199c..0526cc43 100644 --- a/lib/threefold/grid/vm.v +++ b/lib/threefold/grid3/deployer2_sort/vm.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import json import log diff --git a/lib/threefold/grid/vm_test.v b/lib/threefold/grid3/deployer2_sort/vm_test.v similarity index 96% rename from lib/threefold/grid/vm_test.v rename to lib/threefold/grid3/deployer2_sort/vm_test.v index b9ddf4ed..1d165046 100644 --- a/lib/threefold/grid/vm_test.v +++ b/lib/threefold/grid3/deployer2_sort/vm_test.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import freeflowuniverse.herolib.installers.threefold.griddriver import os diff --git a/lib/threefold/grid/zdb.v b/lib/threefold/grid3/deployer2_sort/zdb.v similarity index 99% rename from lib/threefold/grid/zdb.v rename to lib/threefold/grid3/deployer2_sort/zdb.v index ed1fc9fb..cc0797cd 100644 --- a/lib/threefold/grid/zdb.v +++ b/lib/threefold/grid3/deployer2_sort/zdb.v @@ -1,4 +1,4 @@ -module grid +module deployer2 import freeflowuniverse.herolib.core.redisclient diff --git a/lib/threefold/griddriver/client.v b/lib/threefold/grid3/griddriver/client.v similarity index 100% rename from lib/threefold/griddriver/client.v rename to lib/threefold/grid3/griddriver/client.v diff --git a/lib/threefold/griddriver/rmb.v b/lib/threefold/grid3/griddriver/rmb.v similarity index 100% rename from lib/threefold/griddriver/rmb.v rename to lib/threefold/grid3/griddriver/rmb.v diff --git a/lib/threefold/griddriver/substrate.v b/lib/threefold/grid3/griddriver/substrate.v similarity index 100% rename from lib/threefold/griddriver/substrate.v rename to lib/threefold/grid3/griddriver/substrate.v diff --git a/lib/threefold/griddriver/utils.v b/lib/threefold/grid3/griddriver/utils.v similarity index 100% rename from lib/threefold/griddriver/utils.v rename to lib/threefold/grid3/griddriver/utils.v diff --git a/lib/threefold/gridproxy/README.md b/lib/threefold/grid3/gridproxy/README.md similarity index 100% rename from lib/threefold/gridproxy/README.md rename to lib/threefold/grid3/gridproxy/README.md diff --git a/lib/threefold/gridproxy/gridproxy_core.v b/lib/threefold/grid3/gridproxy/gridproxy_core.v similarity index 100% rename from lib/threefold/gridproxy/gridproxy_core.v rename to lib/threefold/grid3/gridproxy/gridproxy_core.v diff --git a/lib/threefold/gridproxy/gridproxy_factory.v b/lib/threefold/grid3/gridproxy/gridproxy_factory.v similarity index 100% rename from lib/threefold/gridproxy/gridproxy_factory.v rename to lib/threefold/grid3/gridproxy/gridproxy_factory.v diff --git a/lib/threefold/gridproxy/gridproxy_highlevel.v b/lib/threefold/grid3/gridproxy/gridproxy_highlevel.v similarity index 100% rename from lib/threefold/gridproxy/gridproxy_highlevel.v rename to lib/threefold/grid3/gridproxy/gridproxy_highlevel.v diff --git a/lib/threefold/gridproxy/gridproxy_test.v b/lib/threefold/grid3/gridproxy/gridproxy_test.v similarity index 100% rename from lib/threefold/gridproxy/gridproxy_test.v rename to lib/threefold/grid3/gridproxy/gridproxy_test.v diff --git a/lib/threefold/gridproxy/model/contract.v b/lib/threefold/grid3/gridproxy/model/contract.v similarity index 100% rename from lib/threefold/gridproxy/model/contract.v rename to lib/threefold/grid3/gridproxy/model/contract.v diff --git a/lib/threefold/gridproxy/model/farm.v b/lib/threefold/grid3/gridproxy/model/farm.v similarity index 100% rename from lib/threefold/gridproxy/model/farm.v rename to lib/threefold/grid3/gridproxy/model/farm.v diff --git a/lib/threefold/gridproxy/model/filter.v b/lib/threefold/grid3/gridproxy/model/filter.v similarity index 100% rename from lib/threefold/gridproxy/model/filter.v rename to lib/threefold/grid3/gridproxy/model/filter.v diff --git a/lib/threefold/gridproxy/model/iterators.v b/lib/threefold/grid3/gridproxy/model/iterators.v similarity index 100% rename from lib/threefold/gridproxy/model/iterators.v rename to lib/threefold/grid3/gridproxy/model/iterators.v diff --git a/lib/threefold/gridproxy/model/model.v b/lib/threefold/grid3/gridproxy/model/model.v similarity index 100% rename from lib/threefold/gridproxy/model/model.v rename to lib/threefold/grid3/gridproxy/model/model.v diff --git a/lib/threefold/gridproxy/model/node.v b/lib/threefold/grid3/gridproxy/model/node.v similarity index 100% rename from lib/threefold/gridproxy/model/node.v rename to lib/threefold/grid3/gridproxy/model/node.v diff --git a/lib/threefold/gridproxy/model/stats.v b/lib/threefold/grid3/gridproxy/model/stats.v similarity index 100% rename from lib/threefold/gridproxy/model/stats.v rename to lib/threefold/grid3/gridproxy/model/stats.v diff --git a/lib/threefold/gridproxy/model/twin.v b/lib/threefold/grid3/gridproxy/model/twin.v similarity index 100% rename from lib/threefold/gridproxy/model/twin.v rename to lib/threefold/grid3/gridproxy/model/twin.v diff --git a/lib/threefold/grid/models/computecapacity.v b/lib/threefold/grid3/models/computecapacity.v similarity index 100% rename from lib/threefold/grid/models/computecapacity.v rename to lib/threefold/grid3/models/computecapacity.v diff --git a/lib/threefold/grid/models/deployment.v b/lib/threefold/grid3/models/deployment.v similarity index 100% rename from lib/threefold/grid/models/deployment.v rename to lib/threefold/grid3/models/deployment.v diff --git a/lib/threefold/grid/models/gw_fqdn.v b/lib/threefold/grid3/models/gw_fqdn.v similarity index 100% rename from lib/threefold/grid/models/gw_fqdn.v rename to lib/threefold/grid3/models/gw_fqdn.v diff --git a/lib/threefold/grid/models/gw_name.v b/lib/threefold/grid3/models/gw_name.v similarity index 100% rename from lib/threefold/grid/models/gw_name.v rename to lib/threefold/grid3/models/gw_name.v diff --git a/lib/threefold/grid/models/ip.v b/lib/threefold/grid3/models/ip.v similarity index 100% rename from lib/threefold/grid/models/ip.v rename to lib/threefold/grid3/models/ip.v diff --git a/lib/threefold/grid/models/qsfs.v b/lib/threefold/grid3/models/qsfs.v similarity index 100% rename from lib/threefold/grid/models/qsfs.v rename to lib/threefold/grid3/models/qsfs.v diff --git a/lib/threefold/grid/models/workload.v b/lib/threefold/grid3/models/workload.v similarity index 100% rename from lib/threefold/grid/models/workload.v rename to lib/threefold/grid3/models/workload.v diff --git a/lib/threefold/grid/models/zdb.v b/lib/threefold/grid3/models/zdb.v similarity index 100% rename from lib/threefold/grid/models/zdb.v rename to lib/threefold/grid3/models/zdb.v diff --git a/lib/threefold/grid/models/zlogs.v b/lib/threefold/grid3/models/zlogs.v similarity index 100% rename from lib/threefold/grid/models/zlogs.v rename to lib/threefold/grid3/models/zlogs.v diff --git a/lib/threefold/grid/models/zmachine.v b/lib/threefold/grid3/models/zmachine.v similarity index 100% rename from lib/threefold/grid/models/zmachine.v rename to lib/threefold/grid3/models/zmachine.v diff --git a/lib/threefold/grid/models/zmount.v b/lib/threefold/grid3/models/zmount.v similarity index 100% rename from lib/threefold/grid/models/zmount.v rename to lib/threefold/grid3/models/zmount.v diff --git a/lib/threefold/grid/models/znet.v b/lib/threefold/grid3/models/znet.v similarity index 100% rename from lib/threefold/grid/models/znet.v rename to lib/threefold/grid3/models/znet.v diff --git a/lib/threefold/rmb/model_rmb.v b/lib/threefold/grid3/rmb/model_rmb.v similarity index 100% rename from lib/threefold/rmb/model_rmb.v rename to lib/threefold/grid3/rmb/model_rmb.v diff --git a/lib/threefold/rmb/readme.md b/lib/threefold/grid3/rmb/readme.md similarity index 100% rename from lib/threefold/rmb/readme.md rename to lib/threefold/grid3/rmb/readme.md diff --git a/lib/threefold/rmb/rmb_calls_zos.v b/lib/threefold/grid3/rmb/rmb_calls_zos.v similarity index 100% rename from lib/threefold/rmb/rmb_calls_zos.v rename to lib/threefold/grid3/rmb/rmb_calls_zos.v diff --git a/lib/threefold/rmb/rmb_calls_zos_statistics.v b/lib/threefold/grid3/rmb/rmb_calls_zos_statistics.v similarity index 100% rename from lib/threefold/rmb/rmb_calls_zos_statistics.v rename to lib/threefold/grid3/rmb/rmb_calls_zos_statistics.v diff --git a/lib/threefold/rmb/rmb_calls_zos_storagepools.v b/lib/threefold/grid3/rmb/rmb_calls_zos_storagepools.v similarity index 100% rename from lib/threefold/rmb/rmb_calls_zos_storagepools.v rename to lib/threefold/grid3/rmb/rmb_calls_zos_storagepools.v diff --git a/lib/threefold/rmb/rmb_client.v b/lib/threefold/grid3/rmb/rmb_client.v similarity index 100% rename from lib/threefold/rmb/rmb_client.v rename to lib/threefold/grid3/rmb/rmb_client.v diff --git a/lib/threefold/rmb/rmb_request.v b/lib/threefold/grid3/rmb/rmb_request.v similarity index 100% rename from lib/threefold/rmb/rmb_request.v rename to lib/threefold/grid3/rmb/rmb_request.v diff --git a/lib/threefold/rmb/rmb_test.v b/lib/threefold/grid3/rmb/rmb_test.v similarity index 100% rename from lib/threefold/rmb/rmb_test.v rename to lib/threefold/grid3/rmb/rmb_test.v diff --git a/lib/threefold/tfrobot/README.md b/lib/threefold/grid3/tfrobot/README.md similarity index 100% rename from lib/threefold/tfrobot/README.md rename to lib/threefold/grid3/tfrobot/README.md diff --git a/lib/threefold/tfrobot/cancel.v b/lib/threefold/grid3/tfrobot/cancel.v similarity index 100% rename from lib/threefold/tfrobot/cancel.v rename to lib/threefold/grid3/tfrobot/cancel.v diff --git a/lib/threefold/tfrobot/cancel_test.v b/lib/threefold/grid3/tfrobot/cancel_test.v similarity index 100% rename from lib/threefold/tfrobot/cancel_test.v rename to lib/threefold/grid3/tfrobot/cancel_test.v diff --git a/lib/threefold/tfrobot/deploy.v b/lib/threefold/grid3/tfrobot/deploy.v similarity index 100% rename from lib/threefold/tfrobot/deploy.v rename to lib/threefold/grid3/tfrobot/deploy.v diff --git a/lib/threefold/tfrobot/deploy_test.v b/lib/threefold/grid3/tfrobot/deploy_test.v similarity index 100% rename from lib/threefold/tfrobot/deploy_test.v rename to lib/threefold/grid3/tfrobot/deploy_test.v diff --git a/lib/threefold/tfrobot/factory.v b/lib/threefold/grid3/tfrobot/factory.v similarity index 100% rename from lib/threefold/tfrobot/factory.v rename to lib/threefold/grid3/tfrobot/factory.v diff --git a/lib/threefold/tfrobot/factory_test.v b/lib/threefold/grid3/tfrobot/factory_test.v similarity index 100% rename from lib/threefold/tfrobot/factory_test.v rename to lib/threefold/grid3/tfrobot/factory_test.v diff --git a/lib/threefold/tfrobot/job.v b/lib/threefold/grid3/tfrobot/job.v similarity index 100% rename from lib/threefold/tfrobot/job.v rename to lib/threefold/grid3/tfrobot/job.v diff --git a/lib/threefold/tfrobot/job_test.v b/lib/threefold/grid3/tfrobot/job_test.v similarity index 100% rename from lib/threefold/tfrobot/job_test.v rename to lib/threefold/grid3/tfrobot/job_test.v diff --git a/lib/threefold/tfrobot/templates/config.json b/lib/threefold/grid3/tfrobot/templates/config.json similarity index 100% rename from lib/threefold/tfrobot/templates/config.json rename to lib/threefold/grid3/tfrobot/templates/config.json diff --git a/lib/threefold/tfrobot/templates/config.yaml b/lib/threefold/grid3/tfrobot/templates/config.yaml similarity index 100% rename from lib/threefold/tfrobot/templates/config.yaml rename to lib/threefold/grid3/tfrobot/templates/config.yaml diff --git a/lib/threefold/tfrobot/tfrobot_redis.v b/lib/threefold/grid3/tfrobot/tfrobot_redis.v similarity index 100% rename from lib/threefold/tfrobot/tfrobot_redis.v rename to lib/threefold/grid3/tfrobot/tfrobot_redis.v diff --git a/lib/threefold/tfrobot/vm.v b/lib/threefold/grid3/tfrobot/vm.v similarity index 100% rename from lib/threefold/tfrobot/vm.v rename to lib/threefold/grid3/tfrobot/vm.v diff --git a/lib/threefold/tfrobot/vm_deploy.v b/lib/threefold/grid3/tfrobot/vm_deploy.v similarity index 100% rename from lib/threefold/tfrobot/vm_deploy.v rename to lib/threefold/grid3/tfrobot/vm_deploy.v diff --git a/lib/threefold/tfrobot/vm_deploy_test.v b/lib/threefold/grid3/tfrobot/vm_deploy_test.v similarity index 100% rename from lib/threefold/tfrobot/vm_deploy_test.v rename to lib/threefold/grid3/tfrobot/vm_deploy_test.v diff --git a/lib/threefold/tokens/readme.md b/lib/threefold/grid3/tokens/readme.md similarity index 100% rename from lib/threefold/tokens/readme.md rename to lib/threefold/grid3/tokens/readme.md diff --git a/lib/threefold/tokens/tokens_fetch.v b/lib/threefold/grid3/tokens/tokens_fetch.v similarity index 100% rename from lib/threefold/tokens/tokens_fetch.v rename to lib/threefold/grid3/tokens/tokens_fetch.v diff --git a/lib/threefold/zerohub/flist.v b/lib/threefold/grid3/zerohub/flist.v similarity index 100% rename from lib/threefold/zerohub/flist.v rename to lib/threefold/grid3/zerohub/flist.v diff --git a/lib/threefold/zerohub/readme.md b/lib/threefold/grid3/zerohub/readme.md similarity index 100% rename from lib/threefold/zerohub/readme.md rename to lib/threefold/grid3/zerohub/readme.md diff --git a/lib/threefold/zerohub/zerohub.v b/lib/threefold/grid3/zerohub/zerohub.v similarity index 100% rename from lib/threefold/zerohub/zerohub.v rename to lib/threefold/grid3/zerohub/zerohub.v diff --git a/lib/threefold/zerohub/zerohub_test.v b/lib/threefold/grid3/zerohub/zerohub_test.v similarity index 100% rename from lib/threefold/zerohub/zerohub_test.v rename to lib/threefold/grid3/zerohub/zerohub_test.v diff --git a/lib/threefold/main.v b/lib/threefold/main.v deleted file mode 100644 index 5cdf5711..00000000 --- a/lib/threefold/main.v +++ /dev/null @@ -1,6 +0,0 @@ -module main - -import freeflowuniverse.herolib.threefold.deploy - -fn main() { -} diff --git a/lib/threefold/nodepilot/nodepilot.v b/lib/threefold/nodepilot/nodepilot.v deleted file mode 100644 index 401a603a..00000000 --- a/lib/threefold/nodepilot/nodepilot.v +++ /dev/null @@ -1,108 +0,0 @@ -module nodepilot - -import freeflowuniverse.herolib.builder - -struct NodePilot { - noderoot string - repository string -mut: - node builder.Node -} - -pub fn nodepilot_new(name string, ipaddr string) ?NodePilot { - node := builder.node_new(name: name, ipaddr: ipaddr)? - return NodePilot{ - node: node - noderoot: '/root/node-pilot-light' - repository: 'https://github.com/threefoldtech/node-pilot-light' - } -} - -pub fn (mut n NodePilot) prepare() ? { - // not how its supposed to be used, todo is the right way - prepared := n.node.cache.get('nodepilot-prepare') or { '' } - if prepared != '' { - return - } - - if !n.node.cmd_exists('git') { - n.node.package_install(name: 'git')? - } - - if !n.node.cmd_exists('docker') { - n.node.package_install(name: 'ca-certificates curl gnupg lsb-release')? - n.node.executor.exec('curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --batch --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg')? - - arch := n.node.executor.exec('dpkg --print-architecture')?.trim_space() - release := n.node.executor.exec('lsb_release -cs')?.trim_space() - - n.node.executor.exec('echo "deb [arch=${arch} signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu ${release} stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null')? - - n.node.package_refresh()? - n.node.package_install(name: 'docker-ce docker-ce-cli containerd.io')? - n.node.executor.exec('service docker start')? - } - - n.node.executor.exec('docker ps -a')? - - if !n.node.executor.dir_exists(n.noderoot) { - // FIXME: repository is private - n.node.executor.exec('git clone ${n.repository} ${n.noderoot}')? - } - - n.node.cache.set('nodepilot-prepare', 'ready', 600)? -} - -fn (mut n NodePilot) is_running(s string) bool { - test := n.node.executor.exec('docker ps | grep ${s}') or { return false } - return true -} - -pub fn (mut n NodePilot) fuse_running() bool { - return n.is_running('fuse-000') -} - -pub fn (mut n NodePilot) fuse() ? { - rootdir := '/mnt/bc-fuse' - n.node.executor.exec('root=${rootdir} bash -x ${n.noderoot}/fuse/fuse.sh')? -} - -pub fn (mut n NodePilot) harmony_running() bool { - return n.is_running('harmony') -} - -pub fn (mut n NodePilot) harmony() ? { - rootdir := '/mnt/bc-harmony' - n.node.executor.exec('root=${rootdir} bash -x ${n.noderoot}/harmony/harmony.sh')? -} - -pub fn (mut n NodePilot) pokt_running() bool { - return n.is_running('pokt-000') -} - -pub fn (mut n NodePilot) pokt() ? { - test := n.node.executor.exec('docker ps | grep pokt-000') or { '' } - if test != '' { - return error('Pokt instance already running') - } - - rootdir := '/mnt/bc-pokt' - n.node.executor.exec('root=${rootdir} bash -x ${n.noderoot}/pokt/pokt.sh')? -} - -fn (mut n NodePilot) overlayfs(ropath string, rwpath string, tmp string, target string) ? { - n.node.executor.exec('mount -t overlay overlay -o lowerdir=${ropath},upperdir=${rwpath},workdir=${tmp} ${target}')? -} - -// make it easy by using the same password everywhere and the same host -// only namespace names needs to be different -fn (mut n NodePilot) zdbfs(host string, meta string, data string, temp string, password string, mountpoint string) ? { - mut zdbcmd := 'zdbfs ${mountpoint} -o ro ' - zdbcmd += '-o mh=${host} -o mn=${meta} -o ms=${password} ' - zdbcmd += '-o dh=${host} -o dn=${data} -o ds=${password} ' - zdbcmd += '-o th=${host} -o tn=${temp} -o ts=${password}' - - n.node.executor.exec(zdbcmd)? -} - -// TODO: pokt chains diff --git a/lib/threefold/nodepilot/readme.md b/lib/threefold/nodepilot/readme.md deleted file mode 100644 index f301bf8b..00000000 --- a/lib/threefold/nodepilot/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# Pokt.Network installer - -A set of tools to install your own pokt.network node in an easy way. - -> TODO: not sure if finished - diff --git a/lib/threefold/tfgrid_actions/README.md b/lib/threefold/tfgrid_actions/README.md deleted file mode 100644 index 6993cd49..00000000 --- a/lib/threefold/tfgrid_actions/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# heroscript actions handlers - -takes input in heroscript language and can then call v clients to talk to e.g. web3gw, web3gw is proxy in golang to tfgrid functionality. - -## Usage - -- For documentation on how to use heroscript, refer to this document [here](../../manual/src/threelang/parser.md) - -> todo: update doc - -## Development - -- To add new books to the parser, follow these instructions: - - - Create a new module inside the threelang folder - - Inside the new module, create a new handler for this book. - - While creating a new Runner, the new handler should be initialized, then saved to the Runner's state. - - The new handler should have its actions exposed in the Runner.run() method - - The new handler must implement a handle_action method. - - The handle_action method receives an playbook.Action, and executes the action however it sees fit. - - Handlers are responsible for logging their output, if any. - - To add documentation on how to use the new book, create a new folder [here](../../manual/src/threelang/) with the book's name, and add all needed documentation files in this folder. diff --git a/lib/threefold/tfgrid_actions/blockchain/blockchain.v b/lib/threefold/tfgrid_actions/blockchain/blockchain.v deleted file mode 100644 index 575f8ffa..00000000 --- a/lib/threefold/tfgrid_actions/blockchain/blockchain.v +++ /dev/null @@ -1,15 +0,0 @@ -module blockchain - -import freeflowuniverse.herolib.core.playbook { Actions } -import freeflowuniverse.herolib.core.texttools -import freeflowuniverse.herolib.data.paramsparser - -// TODO: not implemented, - -fn (mut c Controller) actions(actions_ Actions) ! { - mut actions2 := actions_.filtersort(actor: '???')! - for action in actions2 { - if action.name == '???' { - } - } -} diff --git a/lib/threefold/tfgrid_actions/blockchain/factory.v b/lib/threefold/tfgrid_actions/blockchain/factory.v deleted file mode 100644 index 6b78332a..00000000 --- a/lib/threefold/tfgrid_actions/blockchain/factory.v +++ /dev/null @@ -1,11 +0,0 @@ -module blockchain - -// import freeflowuniverse.herolib.core.playbook - -pub struct Controller { -} - -pub fn new() !Controller { - mut c := Controller{} - return c -} diff --git a/lib/threefold/tfgrid_actions/clients/clients.v b/lib/threefold/tfgrid_actions/clients/clients.v deleted file mode 100644 index 1cf279e1..00000000 --- a/lib/threefold/tfgrid_actions/clients/clients.v +++ /dev/null @@ -1,16 +0,0 @@ -module clients - -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { TFGridClient } -import freeflowuniverse.herolib.threefold.web3gw.tfchain { TfChainClient } -import freeflowuniverse.herolib.threefold.web3gw.stellar { StellarClient } -import freeflowuniverse.herolib.threefold.web3gw.eth { EthClient } -import freeflowuniverse.herolib.threefold.web3gw.btc { BtcClient } - -pub struct Clients { -pub mut: - tfg_client TFGridClient - tfc_client TfChainClient - str_client StellarClient - eth_client EthClient - btc_client BtcClient -} diff --git a/lib/threefold/tfgrid_actions/factory.v b/lib/threefold/tfgrid_actions/factory.v deleted file mode 100644 index 9ae0a09d..00000000 --- a/lib/threefold/tfgrid_actions/factory.v +++ /dev/null @@ -1,94 +0,0 @@ -module tfgrid_actions - -import log -import freeflowuniverse.herolib.core.playbook -import freeflowuniverse.herolib.data.rpcwebsocket { RpcWsClient } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client -import freeflowuniverse.herolib.threefold.web3gw.tfchain as tfchain_client -import freeflowuniverse.herolib.threefold.web3gw.stellar as stellar_client -import freeflowuniverse.herolib.threefold.web3gw.eth as eth_client -import freeflowuniverse.herolib.threefold.web3gw.btc as btc_client -import freeflowuniverse.herolib.threefold.tfgrid_actions.tfgrid { TFGridHandler } -import freeflowuniverse.herolib.threefold.tfgrid_actions.web3gw { Web3GWHandler } -import freeflowuniverse.herolib.threefold.tfgrid_actions.clients { Clients } -import freeflowuniverse.herolib.threefold.tfgrid_actions.stellar { StellarHandler } - -const tfgrid_book = 'tfgrid' -const web3gw_book = 'web3gw' -const stellar_book = 'stellar' - -pub struct Runner { -pub mut: - path string - clients Clients - tfgrid_handler TFGridHandler - web3gw_handler Web3GWHandler - stellar_handler StellarHandler -} - -@[params] -pub struct RunnerArgs { -pub mut: - name string - path string - address string -} - -pub fn new(args RunnerArgs, debug_log bool) !Runner { - mut ap := playbook.new(path: args.path)! - - mut logger := log.Logger(&log.Log{ - level: if debug_log { .debug } else { .info } - }) - - mut rpc_client := rpcwebsocket.new_rpcwsclient(args.address, &logger) or { - return error('Failed creating rpc websocket client: ${err}') - } - _ := spawn rpc_client.run() - - mut gw_clients := get_clients(mut rpc_client)! - - tfgrid_handler := tfgrid.new(mut rpc_client, logger, mut gw_clients.tfg_client) - web3gw_handler := web3gw.new(mut rpc_client, &logger, mut gw_clients) - stellar_handler := stellar.new(mut rpc_client, &logger, mut gw_clients.str_client) - - mut runner := Runner{ - path: args.path - tfgrid_handler: tfgrid_handler - web3gw_handler: web3gw_handler - clients: gw_clients - stellar_handler: stellar_handler - } - - runner.run(mut ap)! - return runner -} - -pub fn (mut r Runner) run(mut acs playbook.Actions) ! { - for action in acs.actions { - match action.book { - threelang.tfgrid_book { - r.tfgrid_handler.handle_action(action)! - } - threelang.web3gw_book { - r.web3gw_handler.handle_action(action)! - } - threelang.stellar_book { - r.stellar_handler.handle_action(action)! - } - else { - return error('module ${action.book} is invalid') - } - } - } -} - -pub fn get_clients(mut rpc_client RpcWsClient) !Clients { - return Clients{ - tfg_client: tfgrid_client.new(mut rpc_client) - tfc_client: tfchain_client.new(mut rpc_client) - btc_client: btc_client.new(mut rpc_client) - eth_client: eth_client.new(mut rpc_client) - str_client: stellar_client.new(mut rpc_client) - } -} diff --git a/lib/threefold/tfgrid_actions/nostr/channel.v b/lib/threefold/tfgrid_actions/nostr/channel.v deleted file mode 100644 index 35394905..00000000 --- a/lib/threefold/tfgrid_actions/nostr/channel.v +++ /dev/null @@ -1,59 +0,0 @@ -module nostr - -import freeflowuniverse.herolib.core.playbook { Action } - -fn (mut n NostrHandler) channel(action Action) ! { - match action.name { - 'create' { - // create a new channel - name := action.params.get('name')! - about := action.params.get_default('description', '')! - pic_url := action.params.get_default('picture', '')! - - channel_id := n.client.create_channel(name: name, about: about, picture: pic_url)! - n.logger.info('Channel ID ${channel_id}') - } - 'send' { - // send message to channel - channel_id := action.params.get('channel')! - content := action.params.get('content')! - message_id := action.params.get_default('reply_to', '')! - public_key := action.params.get_default('public_key_author', '')! - - n.client.create_channel_message( - channel_id: channel_id - content: content - message_id: message_id - public_key: public_key - )! - } - 'read_sub' { - // read subscription messages - channel_id := action.params.get('channel')! - mut id := action.params.get_default('id', '')! - if id == '' { - id = n.client.subscribe_channel_message(id: channel_id)! - n.logger.info('Subscription ID: ${id}') - } - count := action.params.get_u32_default('count', 10)! - - messages := n.client.get_subscription_events(id: id, count: count)! - n.logger.info('Channel Messages: ${messages}') - } - 'read' { - // read all channel messages - channel_id := action.params.get('channel')! - - messages := n.client.get_channel_message(channel_id: channel_id)! - n.logger.info('Channel Messages: ${messages}') - } - 'list' { - // list all channels on relay - channels := n.client.list_channels()! - n.logger.info('Channels: ${channels}') - } - else { - return error('operation ${action.name} is not supported on nostr groups') - } - } -} diff --git a/lib/threefold/tfgrid_actions/nostr/direct.v b/lib/threefold/tfgrid_actions/nostr/direct.v deleted file mode 100644 index 796429a7..00000000 --- a/lib/threefold/tfgrid_actions/nostr/direct.v +++ /dev/null @@ -1,34 +0,0 @@ -module nostr - -import freeflowuniverse.herolib.core.playbook { Action } - -fn (mut n NostrHandler) direct(action Action) ! { - match action.name { - 'send' { - // send direct message - receiver := action.params.get('receiver')! - content := action.params.get('content')! - - n.client.publish_direct_message( - receiver: receiver - content: content - )! - } - 'read' { - // reads and subscribes to direct messages - mut id := action.params.get_default('subscription_id', '')! - if id == '' { - id = n.client.subscribe_to_direct_messages()! - n.logger.info('subscription id: ${id}') - } - - count := action.params.get_u32_default('count', 10)! - - events := n.client.get_subscription_events(id: id, count: count)! - n.logger.info('Direct Message Events: ${events}') - } - else { - return error('operation ${action.name} is not supported on nostr direct messages') - } - } -} diff --git a/lib/threefold/tfgrid_actions/nostr/handler.v b/lib/threefold/tfgrid_actions/nostr/handler.v deleted file mode 100644 index 3304c7aa..00000000 --- a/lib/threefold/tfgrid_actions/nostr/handler.v +++ /dev/null @@ -1,35 +0,0 @@ -module nostr - -import threefoldtech.threebot.nostr as nostr_client { NostrClient } -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.data.rpcwebsocket { RpcWsClient } -import log { Logger } - -pub struct NostrHandler { -pub mut: - client NostrClient - logger Logger -} - -pub fn new(mut rpc_client RpcWsClient, logger Logger) NostrHandler { - mut cl := nostr_client.new(mut rpc_client) - - return NostrHandler{ - client: cl - logger: logger - } -} - -pub fn (mut n NostrHandler) handle_action(action Action) ! { - match action.actor { - 'channel' { - n.channel(action)! - } - 'direct' { - n.direct(action)! - } - else { - return error('actor ${action.actor} is not supported') - } - } -} diff --git a/lib/threefold/tfgrid_actions/stellar/account.v b/lib/threefold/tfgrid_actions/stellar/account.v deleted file mode 100644 index c0771a44..00000000 --- a/lib/threefold/tfgrid_actions/stellar/account.v +++ /dev/null @@ -1,47 +0,0 @@ -module stellar - -import freeflowuniverse.herolib.core.playbook { Action } - -fn (mut h StellarHandler) account(action Action) ! { - match action.name { - 'address' { - res := h.client.address()! - - h.logger.info(res) - } - 'create' { - network := action.params.get_default('network', 'public')! - - res := h.client.create_account(network)! - - h.logger.info(res) - } - 'transactions' { - account := action.params.get_default('account', '')! - limit := action.params.get_u32_default('limit', 10)! - include_failed := action.params.get_default_false('include_failed') - cursor := action.params.get_default('cursor', '')! - ascending := action.params.get_default_false('ascending') - - res := h.client.transactions( - account: account - limit: limit - include_failed: include_failed - cursor: cursor - ascending: ascending - )! - - h.logger.info('Transactions: ${res}') - } - 'data' { - account := action.params.get('account')! - - res := h.client.account_data(account)! - - h.logger.info('${res}') - } - else { - return error('account action ${action.name} is invalid') - } - } -} diff --git a/lib/threefold/tfgrid_actions/stellar/handler.v b/lib/threefold/tfgrid_actions/stellar/handler.v deleted file mode 100644 index 99a5315d..00000000 --- a/lib/threefold/tfgrid_actions/stellar/handler.v +++ /dev/null @@ -1,30 +0,0 @@ -module stellar - -import freeflowuniverse.herolib.threefold.web3gw.stellar as stellar_client { StellarClient } -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.data.rpcwebsocket { RpcWsClient } -import log { Logger } - -pub struct StellarHandler { -pub mut: - client StellarClient - logger Logger -} - -pub fn new(mut rpc_client RpcWsClient, logger Logger, mut client StellarClient) StellarHandler { - return StellarHandler{ - client: client - logger: logger - } -} - -pub fn (mut h StellarHandler) handle_action(action Action) ! { - match action.actor { - 'account' { - h.account(action)! - } - else { - return error('action actor ${action.actor} is invalid') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/contracts.v b/lib/threefold/tfgrid_actions/tfgrid/contracts.v deleted file mode 100644 index bcc86173..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/contracts.v +++ /dev/null @@ -1,64 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { ContractFilter, FindContracts, Limit } - -pub fn (mut h TFGridHandler) contracts(action Action) ! { - match action.name { - 'get' { - mnemonics := action.params.get_default('mnemonics', '')! - network := action.params.get_default('network', 'main')! - h.tfgrid.load( - mnemonic: mnemonics - network: network - )! - mut filter := ContractFilter{} - if action.params.exists('contract_id') { - filter.contract_id = action.params.get_u64('contract_id')! - } - if action.params.exists('twin_id') { - filter.twin_id = action.params.get_u64('twin_id')! - } - if action.params.exists('node_id') { - filter.node_id = action.params.get_u64('node_id')! - } - if action.params.exists('type') { - filter.type_ = action.params.get('type')! - } - if action.params.exists('state') { - filter.state = action.params.get('state')! - } - if action.params.exists('name') { - filter.name = action.params.get('name')! - } - if action.params.exists('number_of_public_ips') { - filter.number_of_public_ips = action.params.get_u64('number_of_public_ips')! - } - if action.params.exists('deployment_data') { - filter.deployment_data = action.params.get('deployment_data')! - } - if action.params.exists('deployment_hash') { - filter.deployment_hash = action.params.get('deployment_hash')! - } - - page := action.params.get_u64_default('page', 1)! - size := action.params.get_u64_default('size', 50)! - randomize := action.params.get_default_false('randomize') - - req := FindContracts{ - filters: filter - pagination: Limit{ - page: page - size: size - randomize: randomize - } - } - - res := h.tfgrid.find_contracts(req)! - h.logger.info('contracts: ${res}') - } - else { - return error('explorer does not support operation: ${action.name}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/core.v b/lib/threefold/tfgrid_actions/tfgrid/core.v deleted file mode 100644 index e27dcbdb..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/core.v +++ /dev/null @@ -1,17 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } - -fn (mut t TFGridHandler) core(action Action) ! { - match action.name { - 'login' { - mnemonic := action.params.get_default('mnemonic', '')! - netstring := action.params.get_default('network', 'main')! - - t.tfgrid.load(mnemonic: mnemonic, network: netstring)! - } - else { - return error('core action ${action.name} is invalid') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/discourse.v b/lib/threefold/tfgrid_actions/tfgrid/discourse.v deleted file mode 100644 index 565aa1e7..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/discourse.v +++ /dev/null @@ -1,54 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import rand - -fn (mut t TFGridHandler) discourse(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(10).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'medium')! - ssh_key_name := action.params.get_default('ssh_key', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - developer_email := action.params.get_default('developer_email', '')! - smtp_address := action.params.get_default('smtp_address', 'smtp.gmail.com')! - smtp_port := action.params.get_int_default('smtp_port', 587)! - smtp_username := action.params.get_default('smtp_username', '')! - smtp_password := action.params.get_default('smtp_password', '')! - smtp_tls := action.params.get_default_false('smtp_tls') - - deploy_res := t.tfgrid.deploy_discourse( - name: name - farm_id: u64(farm_id) - capacity: capacity - ssh_key: ssh_key - developer_email: developer_email - smtp_address: smtp_address - smtp_port: u32(smtp_port) - smtp_username: smtp_username - smtp_password: smtp_password - smtp_enable_tls: smtp_tls - )! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_discourse_deployment(name)! - - t.logger.info('${get_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_discourse_deployment(name) or { - return error('failed to delete discourse instance: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on discourse') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/farms.v b/lib/threefold/tfgrid_actions/tfgrid/farms.v deleted file mode 100644 index c153feeb..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/farms.v +++ /dev/null @@ -1,61 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { FarmFilter, FindFarms, Limit } - -pub fn (mut h TFGridHandler) farms(action Action) ! { - match action.name { - 'get' { - mut filter := FarmFilter{} - if action.params.exists('free_ips') { - filter.free_ips = action.params.get_u64('free_ips')! - } - if action.params.exists('total_ips') { - filter.total_ips = action.params.get_u64('total_ips')! - } - if action.params.exists('stellar_address') { - filter.stellar_address = action.params.get('stellar_address')! - } - if action.params.exists('pricing_policy_id') { - filter.pricing_policy_id = action.params.get_u64('pricing_policy_id')! - } - if action.params.exists('farm_id') { - filter.farm_id = action.params.get_u64('farm_id')! - } - if action.params.exists('twin_id') { - filter.twin_id = action.params.get_u64('twin_id')! - } - if action.params.exists('name') { - filter.name = action.params.get('name')! - } - if action.params.exists('name_contains') { - filter.name_contains = action.params.get('name_contains')! - } - if action.params.exists('certification_type') { - filter.certification_type = action.params.get('certification_type')! - } - if action.params.exists('dedicated') { - filter.dedicated = action.params.get_default_false('dedicated') - } - - page := action.params.get_u64_default('page', 1)! - size := action.params.get_u64_default('size', 50)! - randomize := action.params.get_default_false('randomize') - - req := FindFarms{ - filters: filter - pagination: Limit{ - page: page - size: size - randomize: randomize - } - } - - res := h.tfgrid.find_farms(req)! - h.logger.info('farms: ${res}') - } - else { - return error('explorer does not support operation: ${action.name}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/funkwhale.v b/lib/threefold/tfgrid_actions/tfgrid/funkwhale.v deleted file mode 100644 index 79339e3e..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/funkwhale.v +++ /dev/null @@ -1,48 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import rand - -fn (mut t TFGridHandler) funkwhale(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(10).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'meduim')! - ssh_key_name := action.params.get_default('ssh_key', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - admin_email := action.params.get('admin_email')! - admin_username := action.params.get_default('admin_username', '')! - admin_password := action.params.get_default('admin_password', '')! - - deploy_res := t.tfgrid.deploy_funkwhale( - name: name - farm_id: u64(farm_id) - capacity: capacity - ssh_key: ssh_key - admin_email: admin_email - admin_username: admin_username - admin_password: admin_password - )! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_funkwhale_deployment(name)! - - t.logger.info('${get_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_funkwhale_deployment(name) or { - return error('failed to delete funkwhale instance: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on funkwhale') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/gateway_fqdn.v b/lib/threefold/tfgrid_actions/tfgrid/gateway_fqdn.v deleted file mode 100644 index 8e638dae..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/gateway_fqdn.v +++ /dev/null @@ -1,40 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { GatewayFQDN } -import rand - -fn (mut t TFGridHandler) gateway_fqdn(action Action) ! { - match action.name { - 'create' { - node_id := action.params.get_int('node_id')! - name := action.params.get_default('name', rand.string(10).to_lower())! - tls_passthrough := action.params.get_default_false('tls_passthrough') - backend := action.params.get('backend')! - fqdn := action.params.get('fqdn')! - - gw_deploy := t.tfgrid.deploy_gateway_fqdn(GatewayFQDN{ - name: name - node_id: u32(node_id) - tls_passthrough: tls_passthrough - backends: [backend] - fqdn: fqdn - })! - - t.logger.info('${gw_deploy}') - } - 'delete' { - name := action.params.get('name')! - t.tfgrid.cancel_gateway_fqdn(name)! - } - 'get' { - name := action.params.get('name')! - gw_get := t.tfgrid.get_gateway_fqdn(name)! - - t.logger.info('${gw_get}') - } - else { - return error('action ${action.name} is not supported on gateways') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/gateway_name.v b/lib/threefold/tfgrid_actions/tfgrid/gateway_name.v deleted file mode 100644 index 05df8221..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/gateway_name.v +++ /dev/null @@ -1,38 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { GatewayName } -import rand - -fn (mut t TFGridHandler) gateway_name(action Action) ! { - match action.name { - 'create' { - node_id := action.params.get_int_default('node_id', 0)! - name := action.params.get_default('name', rand.string(10).to_lower())! - tls_passthrough := action.params.get_default_false('tls_passthrough') - backend := action.params.get('backend')! - - gw_deploy := t.tfgrid.deploy_gateway_name(GatewayName{ - name: name - node_id: u32(node_id) - tls_passthrough: tls_passthrough - backends: [backend] - })! - - t.logger.info('${gw_deploy}') - } - 'delete' { - name := action.params.get('name')! - t.tfgrid.cancel_gateway_name(name)! - } - 'get' { - name := action.params.get('name')! - gw_get := t.tfgrid.get_gateway_name(name)! - - t.logger.info('${gw_get}') - } - else { - return error('action ${action.name} is not supported on gateways') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/handler.v b/lib/threefold/tfgrid_actions/tfgrid/handler.v deleted file mode 100644 index 1a5169b3..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/handler.v +++ /dev/null @@ -1,49 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { TFGridClient } -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.data.rpcwebsocket { RpcWsClient } -import log { Logger } - -@[heap] -pub struct TFGridHandler { -pub mut: - tfgrid TFGridClient - ssh_keys map[string]string - logger Logger - handlers map[string]fn (action Action) ! -} - -pub fn new(mut rpc_client RpcWsClient, logger Logger, mut grid_client TFGridClient) TFGridHandler { - mut t := TFGridHandler{ - tfgrid: grid_client - logger: logger - } - - t.handlers = { - 'core': t.core - 'gateway_fqdn': t.gateway_fqdn - 'gateway_name': t.gateway_name - 'kubernetes': t.k8s - 'machine': t.vm - 'zdbs': t.zdb - 'discourse': t.discourse - 'funkwhale': t.funkwhale - 'peertube': t.peertube - 'taiga': t.taiga - 'presearch': t.presearch - 'nodes': t.nodes - 'farms': t.farms - 'twins': t.twins - 'contracts': t.contracts - 'stats': t.stats - } - - return t -} - -pub fn (mut t TFGridHandler) handle_action(action Action) ! { - handler := t.handlers[action.actor] or { return t.helper(action) } - - return handler(action) -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/helpers.v b/lib/threefold/tfgrid_actions/tfgrid/helpers.v deleted file mode 100644 index 7d6220f5..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/helpers.v +++ /dev/null @@ -1,31 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } - -pub fn (mut t TFGridHandler) helper(action Action) ! { - match action.actor { - 'sshkeys' { - t.ssh_key_helper(action)! - } - else { - return error('helper action ${action.actor} is invalid') - } - } -} - -fn (mut t TFGridHandler) ssh_key_helper(action Action) ! { - match action.name { - 'new' { - name := action.params.get('name')! - key := action.params.get('ssh_key')! - t.ssh_keys[name] = key - } - else { - return error('helper action name ${action.name} is invalid') - } - } -} - -fn (mut t TFGridHandler) get_ssh_key(name string) !string { - return t.ssh_keys[name] or { return error('ssh key ${name} does not exist') } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/k8s.v b/lib/threefold/tfgrid_actions/tfgrid/k8s.v deleted file mode 100644 index bc8cc7dc..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/k8s.v +++ /dev/null @@ -1,130 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { AddWorkerToK8sCluster, K8sCluster, K8sNode, RemoveWorkerFromK8sCluster } -import rand - -fn (mut t TFGridHandler) k8s(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(8).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'small')! - number_of_workers := action.params.get_int_default('workers', 1)! - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - master_public_ip := action.params.get_default_false('add_public_ip_to_master') - worerks_public_ip := action.params.get_default_false('add_public_ips_to_workers') - add_wg_access := action.params.get_default_false('add_wireguard_access') - - cpu, memory, disk_size := get_k8s_capacity(capacity)! - - mut node := K8sNode{ - name: 'master' - farm_id: u32(farm_id) - cpu: cpu - memory: memory - disk_size: disk_size - public_ip: master_public_ip - } - - mut workers := []K8sNode{} - for _ in 0 .. number_of_workers { - mut worker := K8sNode{ - name: 'wr' + rand.string(6) - farm_id: u32(farm_id) - cpu: cpu - memory: memory - disk_size: disk_size - public_ip: worerks_public_ip - } - - workers << worker - } - - cluster := K8sCluster{ - name: name - token: rand.string(6) - ssh_key: ssh_key - master: node - workers: workers - add_wg_access: add_wg_access - } - - deploy_res := t.tfgrid.deploy_k8s_cluster(cluster)! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_k8s_cluster(name)! - - t.logger.info('${get_res}') - } - 'add' { - name := action.params.get('name')! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'medium')! - add_public_ip := action.params.get_default_false('add_public_ip') - - cpu, memory, disk_size := get_k8s_capacity(capacity)! - - mut worker := K8sNode{ - name: 'wr' + rand.string(6) - farm_id: u32(farm_id) - cpu: cpu - memory: memory - disk_size: disk_size - public_ip: add_public_ip - } - - add_res := t.tfgrid.add_worker_to_k8s_cluster(AddWorkerToK8sCluster{ - cluster_name: name - worker: worker - })! - - t.logger.info('${add_res}') - } - 'remove' { - name := action.params.get('name')! - worker_name := action.params.get('worker_name')! - - remove_res := t.tfgrid.remove_worker_from_k8s_cluster(RemoveWorkerFromK8sCluster{ - cluster_name: name - worker_name: worker_name - })! - t.logger.info('${remove_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_k8s_cluster(name) or { - return error('failed to delete k8s cluster: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on k8s') - } - } -} - -fn get_k8s_capacity(capacity string) !(u32, u32, u32) { - match capacity { - 'small' { - return 1, 2048, 10 - } - 'medium' { - return 2, 4096, 20 - } - 'large' { - return 8, 8192, 40 - } - 'extra-large' { - return 8, 16384, 100 - } - else { - return error('invalid capacity ${capacity}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/network.v b/lib/threefold/tfgrid_actions/tfgrid/network.v deleted file mode 100644 index 0464808c..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/network.v +++ /dev/null @@ -1,88 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { NetworkConfiguration, VMConfiguration } -import rand - -fn (mut t TFGridHandler) network(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(6).to_lower())! - description := action.params.get_default('description', '')! - farm_id := action.params.get_int_default('farm_id', 0)! - flist := action.params.get_default('flist', '')! - entrypoint := action.params.get_default('entrypoint', '')! - public_ip := action.params.get_default_false('public_ip') - public_ip6 := action.params.get_default_false('public_ip6') - planetary := action.params.get_default_false('planetary') - cpu := action.params.get_u32_default('cpu', 1)! - memory := action.params.get_u64_default('memory', 1024)! - disk_size := action.params.get_storagecapacity_in_gigabytes('disk_size') or { 0 } - times := action.params.get_int_default('times', 1)! - wg := action.params.get_default_false('add_wireguard_access') - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - - env_vars := { - ssh_key_name: ssh_key - } - // construct vms from the provided data - mut vm_configs := []VMConfiguration{} - for i := 0; i < times; i++ { - vm_config := VMConfiguration{ - name: name - farm_id: u32(farm_id) - flist: flist - entrypoint: entrypoint - public_ip: public_ip - public_ip6: public_ip6 - planetary: planetary - cpu: cpu - memory: memory - rootfs_size: u32(disk_size) - env_vars: env_vars - } - vm_configs << vm_config - } - mut net_config := NetworkConfiguration{ - name: name - add_wireguard_access: wg - } - deploy_res := t.tfgrid.deploy_network( - name: name - description: description - network: net_config - vms: vm_configs - )! - - t.logger.info('${deploy_res}') - } - 'get' { - network := action.params.get('network')! - - get_res := t.tfgrid.get_network_deployment(network)! - - t.logger.info('${get_res}') - } - 'remove' { - network := action.params.get('network')! - machine := action.params.get('machine')! - - remove_res := t.tfgrid.remove_vm_from_network_deployment( - network: network - vm: machine - )! - t.logger.info('${remove_res}') - } - 'delete' { - network := action.params.get('network')! - - t.tfgrid.cancel_network_deployment(network) or { - return error('failed to delete vm network: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on vms') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/nodes.v b/lib/threefold/tfgrid_actions/tfgrid/nodes.v deleted file mode 100644 index 51613901..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/nodes.v +++ /dev/null @@ -1,112 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { FindNodes, Limit, NodeFilter } - -pub fn (mut h TFGridHandler) nodes(action Action) ! { - match action.name { - 'get' { - // network := action.params.get_default('network', 'main')! - // h.tfgrid.load(network)! - - mut filter := NodeFilter{} - if action.params.exists('status') { - filter.status = action.params.get('status')! - } - if action.params.exists('free_mru') { - filter.free_mru = action.params.get_storagecapacity_in_bytes('free_mru')! - } - if action.params.exists('free_hru') { - filter.free_hru = action.params.get_storagecapacity_in_bytes('free_hru')! - } - if action.params.exists('free_sru') { - filter.free_sru = action.params.get_storagecapacity_in_bytes('free_sru')! - } - if action.params.exists('total_mru') { - filter.total_mru = action.params.get_storagecapacity_in_bytes('total_mru')! - } - if action.params.exists('total_hru') { - filter.total_hru = action.params.get_storagecapacity_in_bytes('total_hru')! - } - if action.params.exists('total_sru') { - filter.total_sru = action.params.get_storagecapacity_in_bytes('total_sru')! - } - if action.params.exists('total_cru') { - filter.total_cru = action.params.get_u64('total_cru')! - } - if action.params.exists('country') { - filter.country = action.params.get('country')! - } - if action.params.exists('country_contains') { - filter.country_contains = action.params.get('country_contains')! - } - if action.params.exists('city') { - filter.city = action.params.get('city')! - } - if action.params.exists('city_contains') { - filter.city_contains = action.params.get('city_contains')! - } - if action.params.exists('farm_name') { - filter.farm_name = action.params.get('farm_name')! - } - if action.params.exists('farm_name_contains') { - filter.farm_name_contains = action.params.get('farm_name_contains')! - } - if action.params.exists('farm_id') { - filter.farm_ids = action.params.get_list_u64('farm_id')! - } - if action.params.exists('free_ips') { - filter.free_ips = action.params.get_u64('free_ips')! - } - if action.params.exists('ipv4') { - filter.ipv4 = action.params.get_default_false('ipv4') - } - if action.params.exists('ipv6') { - filter.ipv6 = action.params.get_default_false('ipv6') - } - if action.params.exists('domain') { - filter.domain = action.params.get_default_false('domain') - } - if action.params.exists('dedicated') { - filter.dedicated = action.params.get_default_false('dedicated') - } - if action.params.exists('rentable') { - filter.rentable = action.params.get_default_false('rentable') - } - if action.params.exists('rented') { - filter.rented = action.params.get_default_false('rented') - } - if action.params.exists('rented_by') { - filter.rented_by = action.params.get_u64('rented_by')! - } - if action.params.exists('available_for') { - filter.available_for = action.params.get_u64('available_for')! - } - if action.params.exists('node_id') { - filter.node_id = action.params.get_u64('node_id')! - } - if action.params.exists('twin_id') { - filter.twin_id = action.params.get_u64('twin_id')! - } - - page := action.params.get_u64_default('page', 1)! - size := action.params.get_u64_default('size', 50)! - randomize := action.params.get_default_false('randomize') - - req := FindNodes{ - filters: filter - pagination: Limit{ - page: page - size: size - randomize: randomize - } - } - - res := h.tfgrid.find_nodes(req)! - h.logger.info('nodes: ${res}') - } - else { - return error('explorer does not support operation: ${action.name}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/peertube.v b/lib/threefold/tfgrid_actions/tfgrid/peertube.v deleted file mode 100644 index 697e6745..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/peertube.v +++ /dev/null @@ -1,48 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import rand - -fn (mut t TFGridHandler) peertube(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(8).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'meduim')! - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - admin_email := action.params.get('admin_email')! - db_username := action.params.get_default('db_username', rand.string(8).to_lower())! - db_password := action.params.get_default('db_password', rand.string(8).to_lower())! - - deploy_res := t.tfgrid.deploy_peertube( - name: name - farm_id: u64(farm_id) - capacity: capacity - ssh_key: ssh_key - admin_email: admin_email - db_username: db_username - db_password: db_password - )! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_peertube_deployment(name)! - - t.logger.info('${get_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_peertube_deployment(name) or { - return error('failed to delete peertube instance: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on peertube') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/presearch.v b/lib/threefold/tfgrid_actions/tfgrid/presearch.v deleted file mode 100644 index db69a003..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/presearch.v +++ /dev/null @@ -1,50 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import rand - -fn (mut t TFGridHandler) presearch(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(10).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - disk_size := action.params.get_storagecapacity_in_gigabytes('disk_size') or { 0 } - public_ipv4 := action.params.get_default_false('public_ip') - registration_code := action.params.get('registration_code')! - public_restore_key := action.params.get_default('public_restore_key', '')! - private_restore_key := action.params.get_default('private_restore_key', '')! - - deploy_res := t.tfgrid.deploy_presearch( - name: name - farm_id: u64(farm_id) - ssh_key: ssh_key - disk_size: u32(disk_size) - public_ipv4: public_ipv4 - registration_code: registration_code - public_restore_key: public_restore_key - private_restore_key: private_restore_key - )! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_presearch_deployment(name)! - - t.logger.info('${get_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_presearch_deployment(name) or { - return error('failed to delete presearch instance: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on presearch') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/stats.v b/lib/threefold/tfgrid_actions/tfgrid/stats.v deleted file mode 100644 index e622ceb4..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/stats.v +++ /dev/null @@ -1,24 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { GetStatistics } - -pub fn (mut h TFGridHandler) stats(action Action) ! { - match action.name { - 'get' { - // network := action.params.get_default('network', 'main')! - // h.explorer.load(network)! - - mut filter := GetStatistics{} - if action.params.exists('status') { - filter.status = action.params.get('status')! - } - - res := h.tfgrid.statistics(filter)! - h.logger.info('stats: ${res}') - } - else { - return error('explorer does not support operation: ${action.name}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/taiga.v b/lib/threefold/tfgrid_actions/tfgrid/taiga.v deleted file mode 100644 index a6b0b743..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/taiga.v +++ /dev/null @@ -1,50 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import rand - -fn (mut t TFGridHandler) taiga(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(8).to_lower())! - farm_id := action.params.get_int_default('farm_id', 0)! - capacity := action.params.get_default('capacity', 'meduim')! - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - admin_username := action.params.get('admin_username')! - admin_password := action.params.get('admin_password')! - admin_email := action.params.get('admin_email')! - disk_size := action.params.get_storagecapacity_in_gigabytes('disk_size') or { 50 } - - deploy_res := t.tfgrid.deploy_taiga( - name: name - farm_id: u64(farm_id) - capacity: capacity - ssh_key: ssh_key - admin_username: admin_username - admin_password: admin_password - admin_email: admin_email - disk_size: u32(disk_size) - )! - - t.logger.info('${deploy_res}') - } - 'get' { - name := action.params.get('name')! - - get_res := t.tfgrid.get_taiga_deployment(name)! - - t.logger.info('${get_res}') - } - 'delete' { - name := action.params.get('name')! - - t.tfgrid.cancel_taiga_deployment(name) or { - return error('failed to delete taiga instance: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on taiga') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/twins.v b/lib/threefold/tfgrid_actions/tfgrid/twins.v deleted file mode 100644 index 4f49a022..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/twins.v +++ /dev/null @@ -1,43 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid { FindTwins, Limit, TwinFilter } - -pub fn (mut h TFGridHandler) twins(action Action) ! { - match action.name { - 'get' { - mut filter := TwinFilter{} - if action.params.exists('twin_id') { - filter.twin_id = action.params.get_u64('twin_id')! - } - if action.params.exists('account_id') { - filter.account_id = action.params.get('account_id')! - } - if action.params.exists('relay') { - filter.relay = action.params.get('relay')! - } - if action.params.exists('public_key') { - filter.public_key = action.params.get('public_key')! - } - - page := action.params.get_u64_default('page', 1)! - size := action.params.get_u64_default('size', 50)! - randomize := action.params.get_default_false('randomize') - - req := FindTwins{ - filters: filter - pagination: Limit{ - page: page - size: size - randomize: randomize - } - } - - res := h.tfgrid.find_twins(req)! - h.logger.info('twins: ${res}') - } - else { - return error('explorer does not support operation: ${action.name}') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/vm.v b/lib/threefold/tfgrid_actions/tfgrid/vm.v deleted file mode 100644 index 9181f7c8..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/vm.v +++ /dev/null @@ -1,75 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { DeployVM, RemoveVMFromNetworkDeployment } -import rand - -fn (mut t TFGridHandler) vm(action Action) ! { - match action.name { - 'create' { - name := action.params.get_default('name', rand.string(6).to_lower())! - node_id := action.params.get_int_default('node_id', 0)! - farm_id := action.params.get_int_default('farm_id', 0)! - flist := action.params.get_default('flist', 'https://hub.grid.tf/tf-official-apps/base:latest.flist')! - entrypoint := action.params.get_default('entrypoint', '/sbin/zinit init')! - public_ip := action.params.get_default_false('add_public_ipv4') - public_ip6 := action.params.get_default_false('add_public_ipv6') - planetary := action.params.get_default_true('planetary') - cpu := action.params.get_int_default('cpu', 1)! - memory := action.params.get_int_default('memory', 1024)! - rootfs := action.params.get_int_default('rootfs', 2048)! - gateway := action.params.get_default_false('gateway') - add_wireguard_access := action.params.get_default_false('add_wireguard_access') - ssh_key_name := action.params.get_default('sshkey', 'default')! - ssh_key := t.get_ssh_key(ssh_key_name)! - env_vars := { - ssh_key_name: ssh_key - } - deploy_res := t.tfgrid.deploy_vm(DeployVM{ - name: name - node_id: u32(node_id) - farm_id: u32(farm_id) - flist: flist - entrypoint: entrypoint - public_ip: public_ip - public_ip6: public_ip6 - planetary: planetary - cpu: u32(cpu) - memory: u64(memory) - rootfs_size: u64(rootfs) - env_vars: env_vars - add_wireguard_access: add_wireguard_access - gateway: gateway - })! - - t.logger.info('${deploy_res}') - } - 'get' { - network := action.params.get('network')! - - get_res := t.tfgrid.get_vm_deployment(network)! - - t.logger.info('${get_res}') - } - 'remove' { - network := action.params.get('network')! - machine := action.params.get('machine')! - - remove_res := t.tfgrid.remove_vm_from_network_deployment(RemoveVMFromNetworkDeployment{ - network: network - vm: machine - })! - t.logger.info('${remove_res}') - } - 'delete' { - network := action.params.get('network')! - - t.tfgrid.cancel_network_deployment(network) or { - return error('failed to delete vm network: ${err}') - } - } - else { - return error('operation ${action.name} is not supported on vms') - } - } -} diff --git a/lib/threefold/tfgrid_actions/tfgrid/zdb.v b/lib/threefold/tfgrid_actions/tfgrid/zdb.v deleted file mode 100644 index 7328f721..00000000 --- a/lib/threefold/tfgrid_actions/tfgrid/zdb.v +++ /dev/null @@ -1,42 +0,0 @@ -module tfgrid - -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.threefold.web3gw.tfgrid as tfgrid_client { ZDBDeployment } -import rand - -fn (mut t TFGridHandler) zdb(action Action) ! { - match action.name { - 'create' { - node_id := action.params.get_int_default('node_id', 0)! - name := action.params.get_default('name', rand.string(10).to_lower())! - password := action.params.get_default('password', rand.string(10).to_lower())! - public := action.params.get_default_false('public') - size := action.params.get_storagecapacity_in_gigabytes('size') or { 10 } - mode := action.params.get_default('mode', 'user')! - - zdb_deploy := t.tfgrid.deploy_zdb(ZDBDeployment{ - node_id: u32(node_id) - name: name - password: password - public: public - size: u32(size) - mode: mode - })! - - t.logger.info('${zdb_deploy}') - } - 'delete' { - name := action.params.get('name')! - t.tfgrid.cancel_zdb_deployment(name)! - } - 'get' { - name := action.params.get('name')! - zdb_get := t.tfgrid.get_zdb_deployment(name)! - - t.logger.info('${zdb_get}') - } - else { - return error('action ${action.name} is not supported on zdbs') - } - } -} diff --git a/lib/threefold/tfgrid_actions/web3gw/handler.v b/lib/threefold/tfgrid_actions/web3gw/handler.v deleted file mode 100644 index 84106b2b..00000000 --- a/lib/threefold/tfgrid_actions/web3gw/handler.v +++ /dev/null @@ -1,38 +0,0 @@ -module web3gw - -import log { Logger } -import freeflowuniverse.herolib.core.playbook { Action } -import freeflowuniverse.herolib.data.rpcwebsocket { RpcWsClient } -import freeflowuniverse.herolib.threefold.tfgrid_actions.clients { Clients } - -@[heap] -pub struct Web3GWHandler { -pub mut: - logger Logger - clients Clients - handlers map[string]fn (Action) ! -} - -pub fn new(mut rpc RpcWsClient, logger &Logger, mut wg_clients Clients) Web3GWHandler { - mut h := Web3GWHandler{ - logger: logger - clients: wg_clients - } - h.handlers = { - 'keys.define': h.keys_define - 'money.send': h.money_send - 'money.swap': h.money_swap - 'money.balance': h.money_balance - } - return h -} - -pub fn (mut h Web3GWHandler) handle_action(action Action) ! { - key := '${action.actor}.${action.name}' - if key in h.handlers { - handler := h.handlers[key] - handler(action)! - } else { - h.logger.error('unknown actor: ${action.actor}') - } -} diff --git a/lib/threefold/tfgrid_actions/web3gw/keys.v b/lib/threefold/tfgrid_actions/web3gw/keys.v deleted file mode 100644 index 23b41fb0..00000000 --- a/lib/threefold/tfgrid_actions/web3gw/keys.v +++ /dev/null @@ -1,47 +0,0 @@ -module web3gw - -import freeflowuniverse.herolib.core.playbook { Action } - -pub fn (mut h Web3GWHandler) keys_define(action Action) ! { - tfc_mnemonic := action.params.get_default('mnemonic', '')! - tfc_network := action.params.get_default('network', 'main')! - if tfc_mnemonic != '' { - h.clients.tfc_client.load( - network: tfc_network - mnemonic: tfc_mnemonic - )! - h.clients.tfg_client.load( - network: tfc_network - mnemonic: tfc_mnemonic - )! - } - - btc_host := action.params.get_default('bitcoin_host', '')! - btc_user := action.params.get_default('bitcoin_user', '')! - btc_pass := action.params.get_default('bitcoin_pass', '')! - if btc_host != '' || btc_user != '' || btc_pass != '' { - h.clients.btc_client.load( - host: btc_host - user: btc_user - pass: btc_pass - )! - } - - eth_url := action.params.get_default('ethereum_url', '')! - eth_secret := action.params.get_default('ethereum_secret', '')! - if eth_url != '' || eth_secret != '' { - h.clients.eth_client.load( - url: eth_url - secret: eth_secret - )! - } - - str_network := action.params.get_default('stellar_network', 'public')! - str_secret := action.params.get_default('stellar_secret', '')! - if str_secret != '' { - h.clients.str_client.load( - network: str_network - secret: str_secret - )! - } -} diff --git a/lib/threefold/tfgrid_actions/web3gw/money.v b/lib/threefold/tfgrid_actions/web3gw/money.v deleted file mode 100644 index ca92b362..00000000 --- a/lib/threefold/tfgrid_actions/web3gw/money.v +++ /dev/null @@ -1,152 +0,0 @@ -module web3gw - -import freeflowuniverse.herolib.core.playbook { Action } -import strconv - -const default_currencies = { - 'bitcoin': 'btc' - 'ethereum': 'eth' - 'stellar': 'xlm' - 'tfchain': 'tft' -} - -pub fn (mut h Web3GWHandler) money_send(action Action) ! { - channel := action.params.get('channel')! - bridge_to := action.params.get_default('channel_to', '')! - to := action.params.get('to')! - amount := action.params.get('amount')! - - if bridge_to != '' { - if channel == 'ethereum' && bridge_to == 'stellar' { - hash_bridge_to_stellar := h.clients.eth_client.bridge_to_stellar( - amount: amount - destination: to - )! - h.clients.str_client.await_transaction_on_eth_bridge(hash_bridge_to_stellar)! - h.logger.info('bridge to stellar done') - } else if channel == 'stellar' && bridge_to == 'ethereum' { - res := h.clients.str_client.bridge_to_eth( - amount: amount - destination: to - )! - h.logger.info(res) - } else if channel == 'stellar' && bridge_to == 'tfchain' { - mut twin_id := strconv.atoi(to) or { 0 } - if twin_id == 0 { - // make call for tfchain to get tht twin_id from address - res := h.clients.tfc_client.get_twin_by_pubkey(to)! - twin_id = int(res) - } - - hash_bridge_to_tfchain := h.clients.str_client.bridge_to_tfchain( - amount: amount - twin_id: u32(twin_id) - )! - h.clients.tfc_client.await_transaction_on_tfchain_bridge(hash_bridge_to_tfchain)! - h.logger.info('bridge to tfchain done') - } else if channel == 'tfchain' && bridge_to == 'stellar' { - h.clients.tfc_client.swap_to_stellar( - amount: amount.u64() - target_stellar_address: to - )! - } else { - return error('unsupported bridge') - } - } else { - match channel { - 'bitcoin' { - res := h.clients.btc_client.send_to_address( - address: to - amount: amount.i64() - )! - h.logger.info(res) - } - 'stellar' { - res := h.clients.str_client.transfer( - destination: to - amount: amount - )! - h.logger.info(res) - } - 'ethereum' { - res := h.clients.eth_client.transfer( - destination: to - amount: amount - )! - h.logger.info(res) - } - 'tfchain' { - h.clients.tfc_client.transfer( - destination: to - amount: amount.u64() - )! - h.logger.info('transfered') - } - else { - return error('Unknown channel: ${channel}') - } - } - } -} - -pub fn (mut h Web3GWHandler) money_swap(action Action) ! { - from := action.params.get('from')! - to := action.params.get('to')! - amount := action.params.get('amount')! - - if from == 'eth' && to == 'tft' { - res := h.clients.eth_client.swap_eth_for_tft(amount)! - h.logger.info(res) - } else if from == 'tft' && to == 'eth' { - res := h.clients.eth_client.swap_tft_for_eth(amount)! - h.logger.info(res) - } else if from == 'tft' && to == 'xlm' { - res := h.clients.str_client.swap( - amount: amount - source_asset: from - destination_asset: to - )! - h.logger.info(res) - } else if from == 'xlm' && to == 'tft' { - res := h.clients.str_client.swap( - amount: amount - source_asset: from - destination_asset: to - )! - h.logger.info(res) - } else { - return error('unsupported swap') - } -} - -pub fn (mut h Web3GWHandler) money_balance(action Action) ! { - channel := action.params.get('channel')! - mut currency := action.params.get_default('currency', '')! - - if currency == '' { - currency = default_currencies[channel]! - } - - if channel == 'bitcoin' { - account := action.params.get('account')! - res := h.clients.btc_client.get_balance(account)! - h.logger.info('balance on ${channel} is ${res}') - } else if channel == 'ethereum' && currency == 'eth' { - address := h.clients.eth_client.address()! - res := h.clients.eth_client.balance(address)! - h.logger.info('balance on ${channel} is ${res}') - } else if channel == 'ethereum' && currency == 'tft' { - res := h.clients.eth_client.tft_balance()! - h.logger.info('balance on ${channel} is ${res}') - } else if channel == 'stellar' { - address := h.clients.str_client.address()! - res := h.clients.str_client.balance(address)! - h.logger.info('balance on ${channel} is ${res}') - } else if channel == 'tfchain' { - address := h.clients.tfc_client.address()! - res := h.clients.tfc_client.balance(address)! - h.logger.info('balance on ${channel} is ${res}') - } else { - return error('unsupported channel. should be one of: ${default_currencies.keys()}') - } -}