diff --git a/.github/workflows/grid_client_nightly.yml b/.github/workflows/grid_client_nightly.yml index b32b7ec77f..26e1ec9bf7 100644 --- a/.github/workflows/grid_client_nightly.yml +++ b/.github/workflows/grid_client_nightly.yml @@ -4,7 +4,7 @@ name: Grid Client Nightly on: schedule: - - cron: "0 6 * * *" + - cron: "0 4 * * *" workflow_dispatch: jobs: deployment-scripts: @@ -46,6 +46,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y git libtool tmux redis net-tools + - name: Install run: | yarn @@ -86,11 +87,30 @@ jobs: continue-on-error: true run: | yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/zdb.ts + - name: Cleanup - Delete all contracts id: deleteall run: | yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/delete_all_contracts.ts + - name: Run check up - List all contracts + id: command_step + run: | + sleep 15 + yarn run ts-node --project packages/grid_client/tsconfig-node.json packages/grid_client/scripts/list_all_contracts.ts > output.txt + + - name: Check if contracts are Empty + run: | + # print the file content + cat output.txt + + # Check if Node contracts are empty + if grep -q "nodeContracts: \[\]" output.txt && ! grep -q "nodeContracts: \[[[:space:]]*\]" output.txt; then + echo "Deletion failed; The Node Contract is not empty." + # Print the contract that couldn't be deleted + exit 1 + fi + - name: Test Results run: | echo Dynamic Single Vm: ${{ steps.dynamicsinglevm.outcome }} @@ -110,5 +130,6 @@ jobs: steps.vmqsfs.outcome != 'success' || steps.kubernetesqsfs.outcome != 'success' || steps.kvstore.outcome != 'success' || - steps.zdb.outcome != 'success' + steps.zdb.outcome != 'success' || + steps.deleteall.outcome != 'success' run: exit 1 diff --git a/.github/workflows/grid_client_tests.yml b/.github/workflows/grid_client_tests.yml index 87f7e7ecaf..b78e288492 100644 --- a/.github/workflows/grid_client_tests.yml +++ b/.github/workflows/grid_client_tests.yml @@ -41,11 +41,11 @@ jobs: gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add - echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list sudo apt-get update - wget https://github.com/yggdrasil-network/yggdrasil-go/releases/download/v0.4.7/yggdrasil-0.4.7-amd64.deb - sudo dpkg -i yggdrasil-0.4.7-amd64.deb + wget https://github.com/yggdrasil-network/yggdrasil-go/releases/download/v0.5.4/yggdrasil-0.5.4-amd64.deb + sudo dpkg -i yggdrasil-0.5.4-amd64.deb sudo systemctl enable yggdrasil PEERS=$(curl https://raw.githubusercontent.com/threefoldtech/zos-config/main/development.json | jq '.yggdrasil.peers[]' -r | sed 's/\//\\\//g' | sed -z 's/\n/\\n/g') - sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil.conf + sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil/yggdrasil.conf sudo systemctl start yggdrasil - name: Generate SSH Key run: | diff --git a/packages/grid_client/scripts/add_node_to_network.ts b/packages/grid_client/scripts/add_node_to_network.ts index b5a0ce346c..b876f6f8ed 100644 --- a/packages/grid_client/scripts/add_node_to_network.ts +++ b/packages/grid_client/scripts/add_node_to_network.ts @@ -3,14 +3,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function addNode(client, node) { - try { - const res = await client.networks.addNode(node); - log("================= Adding node ================="); - log(res); - log("================= Adding node ================="); - } catch (error) { - log("Error while adding node " + error); - } + const res = await client.networks.addNode(node); + log("================= Adding node ================="); + log(res); + log("================= Adding node ================="); } async function main() { diff --git a/packages/grid_client/scripts/add_worker.ts b/packages/grid_client/scripts/add_worker.ts index 24ab747677..4a9ba176d0 100644 --- a/packages/grid_client/scripts/add_worker.ts +++ b/packages/grid_client/scripts/add_worker.ts @@ -5,36 +5,24 @@ import { log } from "./utils"; // Please run kubernetes script first before running this one to create the cluster. async function addWorker(client, worker) { - try { - const res = await client.k8s.add_worker(worker); - log("================= Adding worker ================="); - log(res); - log("================= Adding worker ================="); - } catch (error) { - log("Error while adding the worker" + error); - } + const res = await client.k8s.add_worker(worker); + log("================= Adding worker ================="); + log(res); + log("================= Adding worker ================="); } async function getWorker(client, worker) { - try { - const res = await client.k8s.getObj(worker); - log("================= Getting worker information ================="); - log(res); - log("================= Getting worker information ================="); - } catch (error) { - log("Error while getting the worker" + error); - } + const res = await client.k8s.getObj(worker); + log("================= Getting worker information ================="); + log(res); + log("================= Getting worker information ================="); } async function deleteWorker(client, worker) { - try { - const res = await client.k8s.delete_worker(worker); - log("================= Deleting the worker ================="); - log(res); - log("================= Deleting the worker ================="); - } catch (error) { - log("Error while deleting the worker" + error); - } + const res = await client.k8s.delete_worker(worker); + log("================= Deleting the worker ================="); + log(res); + log("================= Deleting the worker ================="); } async function main() { diff --git a/packages/grid_client/scripts/calculator.ts b/packages/grid_client/scripts/calculator.ts index 218834d3b9..f696482d97 100644 --- a/packages/grid_client/scripts/calculator.ts +++ b/packages/grid_client/scripts/calculator.ts @@ -3,69 +3,45 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function calculateCU(client, CUModel) { - try { - const res = await client.calculator.calCU(CUModel); - log("================= Calculating CU ================="); - log(res); - log("================= Calculating CU ================="); - } catch (error) { - log("Error while calculating CU " + error); - } + const res = await client.calculator.calCU(CUModel); + log("================= Calculating CU ================="); + log(res); + log("================= Calculating CU ================="); } async function calculateSU(client, SUModel) { - try { - const res = await client.calculator.calSU(SUModel); - log("================= Calculating SU ================="); - log(res); - log("================= Calculating SU ================="); - } catch (error) { - log("Error while calculating SU " + error); - } + const res = await client.calculator.calSU(SUModel); + log("================= Calculating SU ================="); + log(res); + log("================= Calculating SU ================="); } async function getTFTPrice(client) { - try { - const res = await client.calculator.tftPrice(); - log("================= TFT Price ================="); - log(res); - log("================= TFT Price ================="); - } catch (error) { - log("Error while getting TFT price " + error); - } + const res = await client.calculator.tftPrice(); + log("================= TFT Price ================="); + log(res); + log("================= TFT Price ================="); } async function getPricingPolicy(client) { - try { - const res = await client.calculator.getPrices(); - log("================= Pricing Policy ================="); - log(res); - log("================= Pricing Policy ================="); - } catch (error) { - log("Error while getting pricing policy " + error); - } + const res = await client.calculator.getPrices(); + log("================= Pricing Policy ================="); + log(res); + log("================= Pricing Policy ================="); } async function calculateDeployment(client, CalculatorModel) { - try { - const res = await client.calculator.calculate(CalculatorModel); - log("================= Deployment Cost ================="); - log(res); - log("================= Deployment Cost ================="); - } catch (error) { - log("Error while calculating deployment cost " + error); - } + const res = await client.calculator.calculate(CalculatorModel); + log("================= Deployment Cost ================="); + log(res); + log("================= Deployment Cost ================="); } async function calculateDeploymentWithCurrentBalance(client, CalculatorModel) { - try { - const res = await client.calculator.calculateWithMyBalance(CalculatorModel); - log("================= Deployment Cost with current balance ================="); - log(res); - log("================= Deployment Cost with current balance ================="); - } catch (error) { - log("Error while calculating deployment cost " + error); - } + const res = await client.calculator.calculateWithMyBalance(CalculatorModel); + log("================= Deployment Cost with current balance ================="); + log(res); + log("================= Deployment Cost with current balance ================="); } async function main() { diff --git a/packages/grid_client/scripts/caprover_leader.ts b/packages/grid_client/scripts/caprover_leader.ts index df001a7b12..a0237e19a7 100644 --- a/packages/grid_client/scripts/caprover_leader.ts +++ b/packages/grid_client/scripts/caprover_leader.ts @@ -3,37 +3,25 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying Caprover cluster ================="); - log(res); - log("================= Deploying Caprover cluster ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying Caprover cluster ================="); + log(res); + log("================= Deploying Caprover cluster ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log(`You can access Caprover via the browser using: http://captain.${res[0].env.CAPROVER_ROOT_DOMAIN}`); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log(`You can access Caprover via the browser using: http://captain.${res[0].env.CAPROVER_ROOT_DOMAIN}`); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/caprover_worker.ts b/packages/grid_client/scripts/caprover_worker.ts index acd609e0a4..9d6f4c1572 100644 --- a/packages/grid_client/scripts/caprover_worker.ts +++ b/packages/grid_client/scripts/caprover_worker.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying Worker ================="); - log(res); - log("================= Deploying Worker ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying Worker ================="); + log(res); + log("================= Deploying Worker ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/checkNodeAlive.ts b/packages/grid_client/scripts/checkNodeAlive.ts index 6bb232f27e..83829b5640 100644 --- a/packages/grid_client/scripts/checkNodeAlive.ts +++ b/packages/grid_client/scripts/checkNodeAlive.ts @@ -3,14 +3,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function pingNode(client, nodeId) { - try { - const res = await client.zos.pingNode(nodeId); - log("================= Ping result ================="); - log(res); - log("================= Ping result ================="); - } catch (error) { - log(`Node ${nodeId.nodeId} is offline`); - } + const res = await client.zos.pingNode(nodeId); + log("================= Ping result ================="); + log(res); + log("================= Ping result ================="); } async function main() { diff --git a/packages/grid_client/scripts/create_account.ts b/packages/grid_client/scripts/create_account.ts index d35dfe9ec8..0b49fb7c28 100644 --- a/packages/grid_client/scripts/create_account.ts +++ b/packages/grid_client/scripts/create_account.ts @@ -7,14 +7,10 @@ import config from "./config.json"; import { log } from "./utils"; async function createAccount(client, relay) { - try { - const res = await client.tfchain.createAccount(relay, true); - log("================= Creating account ================="); - log(res); - log("================= Creating account ================="); - } catch (error) { - log("Error while creating account " + error); - } + const res = await client.tfchain.createAccount(relay, true); + log("================= Creating account ================="); + log(res); + log("================= Creating account ================="); } async function main() { diff --git a/packages/grid_client/scripts/delete_all_contracts.ts b/packages/grid_client/scripts/delete_all_contracts.ts index da03c89326..c7601110dc 100644 --- a/packages/grid_client/scripts/delete_all_contracts.ts +++ b/packages/grid_client/scripts/delete_all_contracts.ts @@ -2,14 +2,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function deleteAllContracts(client) { - try { - const res = await client.contracts.cancelMyContracts(); - log("================= Deleting all contracts ================="); - log(res); - log("================= Deleting all contracts ================="); - } catch (error) { - log("Error while deleting contracts " + error); - } + const res = await client.contracts.cancelMyContracts(); + log("================= Deleting all contracts ================="); + log(res); + log("================= Deleting all contracts ================="); } async function main() { diff --git a/packages/grid_client/scripts/dynamic_single_vm.ts b/packages/grid_client/scripts/dynamic_single_vm.ts index 89d17306fd..4774faded9 100644 --- a/packages/grid_client/scripts/dynamic_single_vm.ts +++ b/packages/grid_client/scripts/dynamic_single_vm.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/extraFees.ts b/packages/grid_client/scripts/extraFees.ts index 761b717fc7..74bd7739e5 100644 --- a/packages/grid_client/scripts/extraFees.ts +++ b/packages/grid_client/scripts/extraFees.ts @@ -3,25 +3,17 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function setExtraFee(client, extraFee) { - try { - const res = await client.contracts.setDedicatedNodeExtraFee(extraFee); - log("================= Setting extra fee ================="); - log(res); - log("================= Setting extra fee ================="); - } catch (error) { - log("Error while setting extra fee " + error); - } + const res = await client.contracts.setDedicatedNodeExtraFee(extraFee); + log("================= Setting extra fee ================="); + log(res); + log("================= Setting extra fee ================="); } async function getExtraFee(client, node) { - try { - const res = await client.contracts.getDedicatedNodeExtraFee(node); - log("================= Getting extra fee ================="); - log(res); - log("================= Getting extra fee ================="); - } catch (error) { - log("Error while getting extra fee " + error); - } + const res = await client.contracts.getDedicatedNodeExtraFee(node); + log("================= Getting extra fee ================="); + log(res); + log("================= Getting extra fee ================="); } async function main() { diff --git a/packages/grid_client/scripts/farmerbot.ts b/packages/grid_client/scripts/farmerbot.ts index 5f00b21e3b..2f86830fdf 100644 --- a/packages/grid_client/scripts/farmerbot.ts +++ b/packages/grid_client/scripts/farmerbot.ts @@ -4,25 +4,17 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function pingFarm(client, farm) { - try { - const res = await client.farmerbot.pingFarm(farm); - log("================= Pinging farm ================="); - log(res); - log("================= Pinging farm ================="); - } catch (error) { - log("Error while pinging farm " + error); - } + const res = await client.farmerbot.pingFarm(farm); + log("================= Pinging farm ================="); + log(res); + log("================= Pinging farm ================="); } async function findNode(client, FarmerBotFindNode) { - try { - const res = await client.farmerbot.findNode(FarmerBotFindNode); - log("================= Finding node ================="); - log(res); - log("================= Finding node ================="); - } catch (error) { - log("Error while finding node " + error); - } + const res = await client.farmerbot.findNode(FarmerBotFindNode); + log("================= Finding node ================="); + log(res); + log("================= Finding node ================="); } async function main() { diff --git a/packages/grid_client/scripts/fqdn_gateway.ts b/packages/grid_client/scripts/fqdn_gateway.ts index dab4277151..5328fa103e 100644 --- a/packages/grid_client/scripts/fqdn_gateway.ts +++ b/packages/grid_client/scripts/fqdn_gateway.ts @@ -3,36 +3,24 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, gw) { - try { - const res = await client.gateway.deploy_fqdn(gw); - log("================= Deploying FQDN gateway ================="); - log(res); - log("================= Deploying FQDN gateway ================="); - } catch (error) { - log("Error while Deploying the gateway " + error); - } + const res = await client.gateway.deploy_fqdn(gw); + log("================= Deploying FQDN gateway ================="); + log(res); + log("================= Deploying FQDN gateway ================="); } async function getDeployment(client, gw) { - try { - const res = await client.gateway.getObj(gw); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.gateway.getObj(gw); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, gw) { - try { - const res = await client.gateway.delete_fqdn(gw); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.gateway.delete_fqdn(gw); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } // read more about the gateway types in this doc: https://github.com/threefoldtech/zos/tree/main/docs/internals/gateway diff --git a/packages/grid_client/scripts/get_dao_proposals.ts b/packages/grid_client/scripts/get_dao_proposals.ts index c41712552a..71ac4ee783 100644 --- a/packages/grid_client/scripts/get_dao_proposals.ts +++ b/packages/grid_client/scripts/get_dao_proposals.ts @@ -2,14 +2,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function getProposals(client) { - try { - const res = await client.dao.get(); - log("================= Getting proposals ================="); - log(res); - log("================= Getting proposals ================="); - } catch (error) { - log("Error while getting the proposals " + error); - } + const res = await client.dao.get(); + log("================= Getting proposals ================="); + log(res); + log("================= Getting proposals ================="); } async function main() { diff --git a/packages/grid_client/scripts/get_deletion_time.ts b/packages/grid_client/scripts/get_deletion_time.ts index 3d57c0f4fd..00d07255d4 100644 --- a/packages/grid_client/scripts/get_deletion_time.ts +++ b/packages/grid_client/scripts/get_deletion_time.ts @@ -2,14 +2,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function getDeletionTime(client, contractId) { - try { - const res = await client.contracts.getDeletionTime({ id: contractId }); - log("================= Getting deletion time ================="); - log(res); - log("================= Getting deletion time ================="); - } catch (error) { - log("Error while getting deletion time " + error); - } + const res = await client.contracts.getDeletionTime({ id: contractId }); + log("================= Getting deletion time ================="); + log(res); + log("================= Getting deletion time ================="); } async function main() { diff --git a/packages/grid_client/scripts/get_network_config.ts b/packages/grid_client/scripts/get_network_config.ts index c1cf35e607..6ea96e57db 100644 --- a/packages/grid_client/scripts/get_network_config.ts +++ b/packages/grid_client/scripts/get_network_config.ts @@ -2,25 +2,17 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function listNetworks(client) { - try { - const res = await client.networks.list(); - log("================= Listing Networks ================="); - log(res); - log("================= Listing Networks ================="); - } catch (error) { - log("Error while listing networks " + error); - } + const res = await client.networks.list(); + log("================= Listing Networks ================="); + log(res); + log("================= Listing Networks ================="); } async function getNetworkConfig(client, networkName) { - try { - const res = await client.networks.getWireGuardConfigs({ name: networkName }); - log("================= Getting network config ================="); - log(res); - log("================= Getting network config ================="); - } catch (error) { - log("Error while getting network config " + error); - } + const res = await client.networks.getWireGuardConfigs({ name: networkName }); + log("================= Getting network config ================="); + log(res); + log("================= Getting network config ================="); } async function main() { diff --git a/packages/grid_client/scripts/kubernetes.ts b/packages/grid_client/scripts/kubernetes.ts index 97f7a0673f..c01fd058fa 100644 --- a/packages/grid_client/scripts/kubernetes.ts +++ b/packages/grid_client/scripts/kubernetes.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, k8s) { - try { - const res = await client.k8s.deploy(k8s); - log("================= Deploying K8s ================="); - log(res); - log("================= Deploying K8s ================="); - } catch (error) { - log("Error while Deploying the cluster " + error); - } + const res = await client.k8s.deploy(k8s); + log("================= Deploying K8s ================="); + log(res); + log("================= Deploying K8s ================="); } async function getDeployment(client, k8s) { - try { - const res = await client.k8s.getObj(k8s); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.k8s.getObj(k8s); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, k8s) { - try { - const res = await client.k8s.delete(k8s); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.k8s.delete(k8s); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/kubernetes_with_qsfs.ts b/packages/grid_client/scripts/kubernetes_with_qsfs.ts index 0f5b62e6db..139a79c6e2 100644 --- a/packages/grid_client/scripts/kubernetes_with_qsfs.ts +++ b/packages/grid_client/scripts/kubernetes_with_qsfs.ts @@ -3,58 +3,38 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deployQsfs(client, qsfs) { - try { - const res = await client.qsfs_zdbs.deploy(qsfs); - log("================= Deploying QSFS ================="); - log(res); - log("================= Deploying QSFS ================="); - } catch (error) { - log("Error while Deploying QSFS " + error); - } + const res = await client.qsfs_zdbs.deploy(qsfs); + log("================= Deploying QSFS ================="); + log(res); + log("================= Deploying QSFS ================="); } async function deploy(client, k8s) { - try { - const res = await client.k8s.deploy(k8s); - log("================= Deploying K8s ================="); - log(res); - log("================= Deploying K8s ================="); - } catch (error) { - log("Error while Deploying the cluster " + error); - } + const res = await client.k8s.deploy(k8s); + log("================= Deploying K8s ================="); + log(res); + log("================= Deploying K8s ================="); } async function getDeployment(client, k8s) { - try { - const res = await client.k8s.getObj(k8s); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.k8s.getObj(k8s); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, k8s) { - try { - const res = await client.k8s.delete(k8s); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.k8s.delete(k8s); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function deleteQsfs(client, qsfs) { - try { - const res = await client.qsfs_zdbs.delete(qsfs); - log("================= Deleting QSFS ================="); - log(res); - log("================= Deleting QSFS ================="); - } catch (error) { - log("Error while deleting qsfs " + error); - } + const res = await client.qsfs_zdbs.delete(qsfs); + log("================= Deleting QSFS ================="); + log(res); + log("================= Deleting QSFS ================="); } async function main() { diff --git a/packages/grid_client/scripts/kvstore_example.ts b/packages/grid_client/scripts/kvstore_example.ts index 8916c879cd..bc0f2f300b 100644 --- a/packages/grid_client/scripts/kvstore_example.ts +++ b/packages/grid_client/scripts/kvstore_example.ts @@ -2,47 +2,31 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function setKey(client, key) { - try { - const res = await client.kvstore.set(key); - log("================= Setting the key ================="); - log(res); - log("================= Setting the key ================="); - } catch (error) { - log("Error while setting the key " + error); - } + const res = await client.kvstore.set(key); + log("================= Setting the key ================="); + log(res); + log("================= Setting the key ================="); } async function listAllKeys(client) { - try { - const res = await client.kvstore.list(); - log("================= Listing all keys ================="); - log(res); - log("================= Listing all keys ================="); - } catch (error) { - log("Error while listing keys " + error); - } + const res = await client.kvstore.list(); + log("================= Listing all keys ================="); + log(res); + log("================= Listing all keys ================="); } async function getKey(client, key) { - try { - const res = await client.kvstore.get(key); - log("================= Getting key ================="); - log(res); - log("================= Getting key ================="); - } catch (error) { - log("Error while getting key " + error); - } + const res = await client.kvstore.get(key); + log("================= Getting key ================="); + log(res); + log("================= Getting key ================="); } async function removeKey(client, key) { - try { - const res = await client.kvstore.remove(key); - log("================= Removing key ================="); - log(res); - log("================= Removing key ================="); - } catch (error) { - log("Error while removing key " + error); - } + const res = await client.kvstore.remove(key); + log("================= Removing key ================="); + log(res); + log("================= Removing key ================="); } /* diff --git a/packages/grid_client/scripts/list_all_contracts.ts b/packages/grid_client/scripts/list_all_contracts.ts index 53666d1660..cff7cbd531 100644 --- a/packages/grid_client/scripts/list_all_contracts.ts +++ b/packages/grid_client/scripts/list_all_contracts.ts @@ -2,14 +2,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function listAllContracts(client) { - try { - const res = await client.contracts.listMyContracts(); - log("================= Listing all contracts ================="); - log(res); - log("================= Listing all contracts ================="); - } catch (error) { - log("Error while listing contracts " + error); - } + const res = await client.contracts.listMyContracts(); + log("================= Listing all contracts ================="); + log(res); + log("================= Listing all contracts ================="); } async function main() { diff --git a/packages/grid_client/scripts/multiple_vms.ts b/packages/grid_client/scripts/multiple_vms.ts index 235e4b8ef1..6624917125 100644 --- a/packages/grid_client/scripts/multiple_vms.ts +++ b/packages/grid_client/scripts/multiple_vms.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/name_gateway.ts b/packages/grid_client/scripts/name_gateway.ts index 683636df57..e3e2747de0 100644 --- a/packages/grid_client/scripts/name_gateway.ts +++ b/packages/grid_client/scripts/name_gateway.ts @@ -3,36 +3,24 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, gw) { - try { - const res = await client.gateway.deploy_name(gw); - log("================= Deploying name gateway ================="); - log(res); - log("================= Deploying name gateway ================="); - } catch (error) { - log("Error while Deploying the gateway " + error); - } + const res = await client.gateway.deploy_name(gw); + log("================= Deploying name gateway ================="); + log(res); + log("================= Deploying name gateway ================="); } async function getDeployment(client, gw) { - try { - const res = await client.gateway.getObj(gw); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.gateway.getObj(gw); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, gw) { - try { - const res = await client.gateway.delete_name(gw); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.gateway.delete_name(gw); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } // read more about the gateway types in this doc: https://github.com/threefoldtech/zos/tree/main/docs/internals/gateway diff --git a/packages/grid_client/scripts/renting.ts b/packages/grid_client/scripts/renting.ts index e5ecdf0419..a395eba433 100644 --- a/packages/grid_client/scripts/renting.ts +++ b/packages/grid_client/scripts/renting.ts @@ -18,59 +18,42 @@ import { log } from "./utils"; // Get rent contract ID for a node async function getRentContract(client: GridClient, nodeId: number) { - try { - const rentContractId = await client.nodes.getRentContractId({ nodeId }); - log("================= Rent Contract ID ================="); - log(rentContractId); - log("================= Rent Contract ID ================="); - return rentContractId; - } catch (error) { - console.error("Error fetching rent contract ID:", error); - } + const rentContractId = await client.nodes.getRentContractId({ nodeId }); + log("================= Rent Contract ID ================="); + log(rentContractId); + log("================= Rent Contract ID ================="); + return rentContractId; } // Reserve a node async function reserveNode(client: GridClient, nodeId: number) { - try { - const reserved = await client.nodes.reserve({ nodeId }); - log("================= Reserve Nodes ================="); - log(reserved); - log("================= Reserve Nodes ================="); - return reserved; - } catch (error) { - console.error("Error reserving node:", error); - } + const reserved = await client.nodes.reserve({ nodeId }); + log("================= Reserve Nodes ================="); + log(reserved); + log("================= Reserve Nodes ================="); + return reserved; } // Get a list of rentable nodes async function getRentableNodes(client: GridClient) { - try { - const rentable = await client.capacity.filterNodes({ rentable: true }); - if (rentable.length > 0) { - log("================= Rentable Nodes ================="); - log(rentable); - log("================= Rentable Nodes ================="); - return rentable; - } else { - console.error("No rentable nodes available."); - return []; - } - } catch (error) { - console.error("Error fetching rentable nodes:", error); + const rentable = await client.capacity.filterNodes({ rentable: true }); + if (rentable.length > 0) { + log("================= Rentable Nodes ================="); + log(rentable); + log("================= Rentable Nodes ================="); + return rentable; + } else { + console.error("No rentable nodes available."); return []; } } // Unreserve a node async function unreserve(client: GridClient, nodeId: number) { - try { - const unreserved = await client.nodes.unreserve({ nodeId }); - log("================= Unreserved Node ================="); - log(unreserved); - log("================= Unreserved Node ================="); - } catch (error) { - console.error("Error unreserving node:", error); - } + const unreserved = await client.nodes.unreserve({ nodeId }); + log("================= Unreserved Node ================="); + log(unreserved); + log("================= Unreserved Node ================="); } // Main function diff --git a/packages/grid_client/scripts/set_node_power.ts b/packages/grid_client/scripts/set_node_power.ts index 81328959e0..84f741d5f3 100644 --- a/packages/grid_client/scripts/set_node_power.ts +++ b/packages/grid_client/scripts/set_node_power.ts @@ -3,14 +3,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function setNodePower(client, nodePower) { - try { - const res = await client.nodes.setNodePower(nodePower); - log("================= Setting node power ================="); - log(res); - log("================= Setting node power ================="); - } catch (error) { - log("Error while setting node power " + error); - } + const res = await client.nodes.setNodePower(nodePower); + log("================= Setting node power ================="); + log(res); + log("================= Setting node power ================="); } async function main() { diff --git a/packages/grid_client/scripts/single_vm.ts b/packages/grid_client/scripts/single_vm.ts index 79f19d26ea..aff7d55606 100644 --- a/packages/grid_client/scripts/single_vm.ts +++ b/packages/grid_client/scripts/single_vm.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/stellar.ts b/packages/grid_client/scripts/stellar.ts index f155e2c321..2a45cb3229 100644 --- a/packages/grid_client/scripts/stellar.ts +++ b/packages/grid_client/scripts/stellar.ts @@ -11,115 +11,75 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function create(client, account) { - try { - const res = await client.stellar.create(account); - log("================= Creating account ================="); - log(res); - log("================= Creating account ================="); - return res; - } catch (error) { - log("Error while creating account " + error); - } + const res = await client.stellar.create(account); + log("================= Creating account ================="); + log(res); + log("================= Creating account ================="); + return res; } async function init(client, account) { - try { - const res = await client.stellar.init(account); - log("================= Initializing account ================="); - log(res); - log("================= Initializing account ================="); - } catch (error) { - log("Error while initializing account " + error); - } + const res = await client.stellar.init(account); + log("================= Initializing account ================="); + log(res); + log("================= Initializing account ================="); } async function list(client) { - try { - const res = await client.stellar.list(); - log("================= Listing account ================="); - log(res); - log("================= Listing account ================="); - } catch (error) { - log("Error while listing account " + error); - } + const res = await client.stellar.list(); + log("================= Listing account ================="); + log(res); + log("================= Listing account ================="); } async function exist(client, account) { - try { - const res = await client.stellar.exist(account); - log("================= Checking account ================="); - log(res); - log("================= Checking account ================="); - } catch (error) { - log("Error while checking account " + error); - } + const res = await client.stellar.exist(account); + log("================= Checking account ================="); + log(res); + log("================= Checking account ================="); } async function get(client, account) { - try { - const res = await client.stellar.get(account); - log("================= Getting account ================="); - log(res); - log("================= Getting account ================="); - return res; - } catch (error) { - log("Error while getting account " + error); - } + const res = await client.stellar.get(account); + log("================= Getting account ================="); + log(res); + log("================= Getting account ================="); + return res; } async function balanceByAddress(client, address) { - try { - const res = await client.stellar.balance_by_address(address); - log("================= Getting balance ================="); - log(res); - log("================= Getting balance ================="); - } catch (error) { - log("Error while getting balance " + error); - } + const res = await client.stellar.balance_by_address(address); + log("================= Getting balance ================="); + log(res); + log("================= Getting balance ================="); } async function assets(client, account) { - try { - const res = await client.stellar.assets(account); - log("================= Getting assets ================="); - log(res); - log("================= Getting assets ================="); - } catch (error) { - log("Error while getting assets " + error); - } + const res = await client.stellar.assets(account); + log("================= Getting assets ================="); + log(res); + log("================= Getting assets ================="); } async function sign(client, message) { - try { - const res = await client.stellar.sign(message); - log("================= Signing message ================="); - log(res); - log("================= Signing message ================="); - } catch (error) { - log("Error while signing message " + error); - } + const res = await client.stellar.sign(message); + log("================= Signing message ================="); + log(res); + log("================= Signing message ================="); } async function pay(client, payment) { - try { - const res = await client.stellar.pay(payment); - log("================= Paying ================="); - log(res); - log("================= Paying ================="); - } catch (error) { - log("Error while paying " + error); - } + const res = await client.stellar.pay(payment); + log("================= Paying ================="); + log(res); + log("================= Paying ================="); } async function deleteAccount(client, account) { - try { - const res = await client.stellar.delete(account); - log("================= Deleting account ================="); - log(res); - log("================= Deleting account ================="); - } catch (error) { - log("Error while deleting account " + error); - } + const res = await client.stellar.delete(account); + log("================= Deleting account ================="); + log(res); + log("================= Deleting account ================="); } async function main() { diff --git a/packages/grid_client/scripts/test_node_filters.ts b/packages/grid_client/scripts/test_node_filters.ts index b2f187ef0d..40af8b00e7 100644 --- a/packages/grid_client/scripts/test_node_filters.ts +++ b/packages/grid_client/scripts/test_node_filters.ts @@ -3,58 +3,38 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function getFarms(client) { - try { - const res = await client.capacity.getFarms(); - log("================= Getting farms ================="); - log(res); - log("================= Getting farms ================="); - } catch (error) { - log("Error while getting farms " + error); - } + const res = await client.capacity.getFarms(); + log("================= Getting farms ================="); + log(res); + log("================= Getting farms ================="); } async function getNodes(client) { - try { - const res = await client.capacity.getNodes(); - log("================= Getting nodes ================="); - log(res); - log("================= Getting nodes ================="); - } catch (error) { - log("Error while getting nodes " + error); - } + const res = await client.capacity.getNodes(); + log("================= Getting nodes ================="); + log(res); + log("================= Getting nodes ================="); } async function getNodesByFarmId(client, farmId) { - try { - const res = await client.capacity.getNodesByFarmId(farmId); - log("================= Getting nodes ================="); - log(res); - log("================= Getting nodes ================="); - } catch (error) { - log("Error while getting nodes " + error); - } + const res = await client.capacity.getNodesByFarmId(farmId); + log("================= Getting nodes ================="); + log(res); + log("================= Getting nodes ================="); } async function getNodeFreeResources(client, nodeId) { - try { - const res = await client.capacity.getNodeFreeResources(nodeId); - log("================= Getting resources ================="); - log(res); - log("================= Getting resources ================="); - } catch (error) { - log("Error while getting resources " + error); - } + const res = await client.capacity.getNodeFreeResources(nodeId); + log("================= Getting resources ================="); + log(res); + log("================= Getting resources ================="); } async function filterNodes(client, filterOptions) { - try { - const res = await client.capacity.filterNodes(filterOptions); - log("================= Filtering nodes ================="); - log(res); - log("================= Filtering nodes ================="); - } catch (error) { - log("Error while filtering nodes " + error); - } + const res = await client.capacity.filterNodes(filterOptions); + log("================= Filtering nodes ================="); + log(res); + log("================= Filtering nodes ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/create_account.ts b/packages/grid_client/scripts/tfchain/create_account.ts index 0665ba5b3f..5357e28c52 100644 --- a/packages/grid_client/scripts/tfchain/create_account.ts +++ b/packages/grid_client/scripts/tfchain/create_account.ts @@ -5,14 +5,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function createAccount(client, account) { - try { - const res = await client.tfchain.create(account); - log("================= Creating account ================="); - log(res); - log("================= Creating account ================="); - } catch (error) { - log("Error while creating account" + error); - } + const res = await client.tfchain.create(account); + log("================= Creating account ================="); + log(res); + log("================= Creating account ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/get_account.ts b/packages/grid_client/scripts/tfchain/get_account.ts index 1d4df69f4a..453dcbd218 100644 --- a/packages/grid_client/scripts/tfchain/get_account.ts +++ b/packages/grid_client/scripts/tfchain/get_account.ts @@ -3,14 +3,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function getAccount(client, account) { - try { - const res = await client.tfchain.get(account); - log("================= Getting account ================="); - log(res); - log("================= Getting account ================="); - } catch (error) { - log("Error while getting account" + error); - } + const res = await client.tfchain.get(account); + log("================= Getting account ================="); + log(res); + log("================= Getting account ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/get_balance_by_address.ts b/packages/grid_client/scripts/tfchain/get_balance_by_address.ts index bf24300c34..2cba182eb5 100644 --- a/packages/grid_client/scripts/tfchain/get_balance_by_address.ts +++ b/packages/grid_client/scripts/tfchain/get_balance_by_address.ts @@ -3,14 +3,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function getBalanceByAddress(client, address) { - try { - const res = await client.tfchain.balanceByAddress(address); - log("================= Getting balance ================="); - log(res); - log("================= Getting balance ================="); - } catch (error) { - log("Error while getting balance" + error); - } + const res = await client.tfchain.balanceByAddress(address); + log("================= Getting balance ================="); + log(res); + log("================= Getting balance ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/get_balance_by_name.ts b/packages/grid_client/scripts/tfchain/get_balance_by_name.ts index 7438173c4c..7e257a02fd 100644 --- a/packages/grid_client/scripts/tfchain/get_balance_by_name.ts +++ b/packages/grid_client/scripts/tfchain/get_balance_by_name.ts @@ -3,14 +3,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function getBalanceByName(client, account) { - try { - const res = await client.tfchain.assets(account); - log("================= Getting balance ================="); - log(res); - log("================= Getting balance ================="); - } catch (error) { - log("Error while getting balance" + error); - } + const res = await client.tfchain.assets(account); + log("================= Getting balance ================="); + log(res); + log("================= Getting balance ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/import.ts b/packages/grid_client/scripts/tfchain/import.ts index b02829abca..89612747e2 100644 --- a/packages/grid_client/scripts/tfchain/import.ts +++ b/packages/grid_client/scripts/tfchain/import.ts @@ -3,14 +3,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function importAccount(client, account) { - try { - const res = await client.tfchain.init(account); - log("================= Importing account ================="); - log(res); - log("================= Importing account ================="); - } catch (error) { - log("Error while importing account" + error); - } + const res = await client.tfchain.init(account); + log("================= Importing account ================="); + log(res); + log("================= Importing account ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/transfer.ts b/packages/grid_client/scripts/tfchain/transfer.ts index ed8ec26506..53f760256b 100644 --- a/packages/grid_client/scripts/tfchain/transfer.ts +++ b/packages/grid_client/scripts/tfchain/transfer.ts @@ -3,14 +3,10 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function transfer(client, transfer) { - try { - const res = await client.tfchain.pay(transfer); - log("================= Transferring funds ================="); - log(res); - log("================= Transferring funds ================="); - } catch (error) { - log("Error while transferring funds " + error); - } + const res = await client.tfchain.pay(transfer); + log("================= Transferring funds ================="); + log(res); + log("================= Transferring funds ================="); } async function main() { diff --git a/packages/grid_client/scripts/tfchain/vote_dao_proposal.ts b/packages/grid_client/scripts/tfchain/vote_dao_proposal.ts index c865770575..c94fa327d1 100644 --- a/packages/grid_client/scripts/tfchain/vote_dao_proposal.ts +++ b/packages/grid_client/scripts/tfchain/vote_dao_proposal.ts @@ -3,25 +3,17 @@ import { getClient } from "../client_loader"; import { log } from "../utils"; async function importAccount(client, account) { - try { - const res = await client.tfchain.init(account); - log("================= Importing account ================="); - log(res); - log("================= Importing account ================="); - } catch (error) { - log("Error while importing account" + error); - } + const res = await client.tfchain.init(account); + log("================= Importing account ================="); + log(res); + log("================= Importing account ================="); } async function vote(client, vote) { - try { - const res = await client.tfchain.vote(vote); - log("================= Voting ================="); - log(res); - log("================= Voting ================="); - } catch (error) { - log("Error while voting " + error); - } + const res = await client.tfchain.vote(vote); + log("================= Voting ================="); + log(res); + log("================= Voting ================="); } async function main() { diff --git a/packages/grid_client/scripts/update_twin.ts b/packages/grid_client/scripts/update_twin.ts index 02d8cc278c..cd94befce6 100644 --- a/packages/grid_client/scripts/update_twin.ts +++ b/packages/grid_client/scripts/update_twin.ts @@ -3,14 +3,10 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function updateTwin(client, relay) { - try { - const res = await client.twins.update(relay); - log("================= Updating twin ================="); - log(res); - log("================= Updating twin ================="); - } catch (error) { - log("Error while updating twin " + error); - } + const res = await client.twins.update(relay); + log("================= Updating twin ================="); + log(res); + log("================= Updating twin ================="); } async function main() { diff --git a/packages/grid_client/scripts/vm_with_gpu.ts b/packages/grid_client/scripts/vm_with_gpu.ts index bd01c34086..92aeeb41d4 100644 --- a/packages/grid_client/scripts/vm_with_gpu.ts +++ b/packages/grid_client/scripts/vm_with_gpu.ts @@ -3,36 +3,24 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/vm_with_qsfs.ts b/packages/grid_client/scripts/vm_with_qsfs.ts index 139e447173..29b2517f2a 100644 --- a/packages/grid_client/scripts/vm_with_qsfs.ts +++ b/packages/grid_client/scripts/vm_with_qsfs.ts @@ -3,58 +3,38 @@ import { config, getClient } from "./client_loader"; import { log } from "./utils"; async function deployQsfs(client, qsfs) { - try { - const res = await client.qsfs_zdbs.deploy(qsfs); - log("================= Deploying QSFS ================="); - log(res); - log("================= Deploying QSFS ================="); - } catch (error) { - log("Error while Deploying QSFS " + error); - } + const res = await client.qsfs_zdbs.deploy(qsfs); + log("================= Deploying QSFS ================="); + log(res); + log("================= Deploying QSFS ================="); } async function deploy(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function deleteQsfs(client, qsfs) { - try { - const res = await client.qsfs_zdbs.delete(qsfs); - log("================= Deleting QSFS ================="); - log(res); - log("================= Deleting QSFS ================="); - } catch (error) { - log("Error while deleting qsfs " + error); - } + const res = await client.qsfs_zdbs.delete(qsfs); + log("================= Deleting QSFS ================="); + log(res); + log("================= Deleting QSFS ================="); } async function main() { diff --git a/packages/grid_client/scripts/wireguard_vm.ts b/packages/grid_client/scripts/wireguard_vm.ts index a32e44bafd..1a39b5c441 100644 --- a/packages/grid_client/scripts/wireguard_vm.ts +++ b/packages/grid_client/scripts/wireguard_vm.ts @@ -47,70 +47,46 @@ function createGwModel(node_id: number, ip: string, networkName: string, name: s } async function deployVM(client, vms) { - try { - const res = await client.machines.deploy(vms); - log("================= Deploying VM ================="); - log(res); - log("================= Deploying VM ================="); - } catch (error) { - log("Error while Deploying the VM " + error); - } + const res = await client.machines.deploy(vms); + log("================= Deploying VM ================="); + log(res); + log("================= Deploying VM ================="); } async function getVMDeployment(client, vms) { - try { - const res = await client.machines.getObj(vms); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - return res; - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.machines.getObj(vms); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); + return res; } async function deployGw(client, gw) { - try { - const res = await client.gateway.deploy_name(gw); - log("================= Deploying name gateway ================="); - log(res); - log("================= Deploying name gateway ================="); - } catch (error) { - log("Error while Deploying the gateway " + error); - } + const res = await client.gateway.deploy_name(gw); + log("================= Deploying name gateway ================="); + log(res); + log("================= Deploying name gateway ================="); } async function getGwDeployment(client, gw) { - try { - const res = await client.gateway.getObj(gw); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.gateway.getObj(gw); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function deleteVM(client, vms) { - try { - const res = await client.machines.delete(vms); - log("================= Canceling the VM deployment ================="); - log(res); - log("================= Canceling the VM deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.machines.delete(vms); + log("================= Canceling the VM deployment ================="); + log(res); + log("================= Canceling the VM deployment ================="); } async function deleteGw(client, gw) { - try { - const res = await client.gateway.delete_name(gw); - log("================= Canceling the GW deployment ================="); - log(res); - log("================= Canceling the GW deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.gateway.delete_name(gw); + log("================= Canceling the GW deployment ================="); + log(res); + log("================= Canceling the GW deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/zdb.ts b/packages/grid_client/scripts/zdb.ts index ddf137f6d0..0818b64fda 100644 --- a/packages/grid_client/scripts/zdb.ts +++ b/packages/grid_client/scripts/zdb.ts @@ -3,36 +3,24 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function deploy(client, zdb) { - try { - const res = await client.zdbs.deploy(zdb); - log("================= Deploying ZDBs ================="); - log(res); - log("================= Deploying ZDBs ================="); - } catch (error) { - log("Error while Deploying the ZDBs " + error); - } + const res = await client.zdbs.deploy(zdb); + log("================= Deploying ZDBs ================="); + log(res); + log("================= Deploying ZDBs ================="); } async function getDeployment(client, zdb) { - try { - const res = await client.zdbs.getObj(zdb); - log("================= Getting deployment information ================="); - log(res); - log("================= Getting deployment information ================="); - } catch (error) { - log("Error while getting the deployment " + error); - } + const res = await client.zdbs.getObj(zdb); + log("================= Getting deployment information ================="); + log(res); + log("================= Getting deployment information ================="); } async function cancel(client, zdb) { - try { - const res = await client.zdbs.delete(zdb); - log("================= Canceling the deployment ================="); - log(res); - log("================= Canceling the deployment ================="); - } catch (error) { - log("Error while canceling the deployment " + error); - } + const res = await client.zdbs.delete(zdb); + log("================= Canceling the deployment ================="); + log(res); + log("================= Canceling the deployment ================="); } async function main() { diff --git a/packages/grid_client/scripts/zos_rmb_requests.ts b/packages/grid_client/scripts/zos_rmb_requests.ts index 698c3786a9..75ce55dcc8 100644 --- a/packages/grid_client/scripts/zos_rmb_requests.ts +++ b/packages/grid_client/scripts/zos_rmb_requests.ts @@ -3,91 +3,59 @@ import { getClient } from "./client_loader"; import { log } from "./utils"; async function pingNode(client, nodeId) { - try { - const res = await client.zos.pingNode(nodeId); - log("================= Pinging node ================="); - log(res); - log("================= Pinging node ================="); - } catch (error) { - log("Error while pinging node " + error); - } + const res = await client.zos.pingNode(nodeId); + log("================= Pinging node ================="); + log(res); + log("================= Pinging node ================="); } async function getDeployment(client, contractId) { - try { - const res = await client.zos.getDeployment(contractId); - log("================= Getting deployment ================="); - log(res); - log("================= Getting deployment ================="); - } catch (error) { - log("Error while getting deployment " + error); - } + const res = await client.zos.getDeployment(contractId); + log("================= Getting deployment ================="); + log(res); + log("================= Getting deployment ================="); } async function hasPublicIPv6(client, nodeId) { - try { - const res = await client.zos.hasPublicIPv6(nodeId); - log("================= Checking public ipv6 ================="); - log(res); - log("================= Checking public ipv6 ================="); - } catch (error) { - log("Error while checking public ipv6 " + error); - } + const res = await client.zos.hasPublicIPv6(nodeId); + log("================= Checking public ipv6 ================="); + log(res); + log("================= Checking public ipv6 ================="); } async function listNetworkInterfaces(client, nodeId) { - try { - const res = await client.zos.listNetworkInterfaces(nodeId); - log("================= Listing network interfaces ================="); - log(res); - log("================= Listing network interfaces ================="); - } catch (error) { - log("Error while listing network interfaces " + error); - } + const res = await client.zos.listNetworkInterfaces(nodeId); + log("================= Listing network interfaces ================="); + log(res); + log("================= Listing network interfaces ================="); } async function listNetworkPublicIPs(client, nodeId) { - try { - const res = await client.zos.listNetworkPublicIPs(nodeId); - log("================= Listing public ips ================="); - log(res); - log("================= Listing public ips ================="); - } catch (error) { - log("Error while listing public ips " + error); - } + const res = await client.zos.listNetworkPublicIPs(nodeId); + log("================= Listing public ips ================="); + log(res); + log("================= Listing public ips ================="); } async function getNetworkPublicConfig(client, nodeId) { - try { - const res = await client.zos.getNetworkPublicConfig(nodeId); - log("================= Getting public config ================="); - log(res); - log("================= Getting public config ================="); - } catch (error) { - log("Error while getting public config " + error); - } + const res = await client.zos.getNetworkPublicConfig(nodeId); + log("================= Getting public config ================="); + log(res); + log("================= Getting public config ================="); } async function getStoragePools(client, nodeId) { - try { - const res = await client.zos.getStoragePools(nodeId); - log("================= Getting storage pools ================="); - log(res); - log("================= Getting storage pools ================="); - } catch (error) { - log("Error while getting storage pools " + error); - } + const res = await client.zos.getStoragePools(nodeId); + log("================= Getting storage pools ================="); + log(res); + log("================= Getting storage pools ================="); } async function getNodeGPUInfo(client, nodeId) { - try { - const res = await client.zos.getNodeGPUInfo(nodeId); - log("================= Getting GPU info ================="); - log(res); - log("================= Getting GPU info ================="); - } catch (error) { - log("Error while getting GPU info " + error); - } + const res = await client.zos.getNodeGPUInfo(nodeId); + log("================= Getting GPU info ================="); + log(res); + log("================= Getting GPU info ================="); } async function main() {