diff --git a/web3gw/client/tfgrid/tfgrid.v b/web3gw/client/tfgrid/tfgrid.v index 0489c1f52..39add58e3 100644 --- a/web3gw/client/tfgrid/tfgrid.v +++ b/web3gw/client/tfgrid/tfgrid.v @@ -136,7 +136,7 @@ pub fn (mut t TFGridClient) cancel_zdb_deployment(name string) ! { // Deploys a gateway name given the name, the id of the node and the backends where the gateway should point to pub fn (mut t TFGridClient) deploy_gateway_name(args GatewayName) !GatewayName { - return t.client.send_json_rpc[[]GatewayName, GatewayName]('tfgrid.DeployGatewayName', + return t.client.send_json_rpc[[]GatewayName, GatewayName]('tfgrid.GatewayNameDeploy', [ args, ], t.timeout)! @@ -144,21 +144,21 @@ pub fn (mut t TFGridClient) deploy_gateway_name(args GatewayName) !GatewayName { // Retrieves information about the gateway name (backends, node, etc) pub fn (mut t TFGridClient) get_gateway_name(name string) !GatewayName { - return t.client.send_json_rpc[[]string, GatewayName]('tfgrid.GetGatewayName', [ + return t.client.send_json_rpc[[]string, GatewayName]('tfgrid.GatewayNameGet', [ name, ], t.timeout)! } // Cancels the gateway name pub fn (mut t TFGridClient) cancel_gateway_name(name string) ! { - _ := t.client.send_json_rpc[[]string, string]('tfgrid.CancelGatewayName', [ + _ := t.client.send_json_rpc[[]string, string]('tfgrid.GatewayNameDelete', [ name, ], t.timeout)! } // Adds a fully qualified domain name to the specified node and returns some computed information pub fn (mut t TFGridClient) deploy_gateway_fqdn(args GatewayFQDN) !GatewayFQDN { - return t.client.send_json_rpc[[]GatewayFQDN, GatewayFQDN]('tfgrid.DeployGatewayFQDN', + return t.client.send_json_rpc[[]GatewayFQDN, GatewayFQDN]('tfgrid.GatewayFQDNDeploy', [ args, ], t.timeout)! @@ -166,14 +166,14 @@ pub fn (mut t TFGridClient) deploy_gateway_fqdn(args GatewayFQDN) !GatewayFQDN { // Retrieves information about the fully qualified domain name pub fn (mut t TFGridClient) get_gateway_fqdn(name string) !GatewayFQDN { - return t.client.send_json_rpc[[]string, GatewayFQDN]('tfgrid.GetGatewayFQDN', [ + return t.client.send_json_rpc[[]string, GatewayFQDN]('tfgrid.GatewayFQDNGet', [ name, ], t.timeout)! } // Cancels the fully qualified domain name specified in the arguments pub fn (mut t TFGridClient) cancel_gateway_fqdn(name string) ! { - _ := t.client.send_json_rpc[[]string, string]('tfgrid.CancelGatewayFQDN', [ + _ := t.client.send_json_rpc[[]string, string]('tfgrid.GatewayFQDNDelete', [ name, ], t.timeout)! } diff --git a/web3gw/examples/tfgrid/gateway_fqdn.v b/web3gw/examples/tfgrid/gateway_fqdn.v index ad8f33ebc..ab70c77f7 100644 --- a/web3gw/examples/tfgrid/gateway_fqdn.v +++ b/web3gw/examples/tfgrid/gateway_fqdn.v @@ -1,6 +1,6 @@ module main -import threefoldtech.web3gw.tfgrid { GatewayFQDN, GatewayFQDNResult, TFGridClient } +import threefoldtech.web3gw.tfgrid { GatewayFQDN, TFGridClient } import log { Logger } import flag { FlagParser } import os @@ -10,7 +10,7 @@ const ( default_server_address = 'ws://127.0.0.1:8080' ) -fn deploy_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDNResult { +fn deploy_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDN { fp.usage_example('deploy [options]') name := fp.string_opt('name', `n`, 'Name of the gateway instance')! @@ -20,7 +20,7 @@ fn deploy_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDNResult fqdn := fp.string_opt('fqdn', `f`, 'FQDN of the gateway')! _ := fp.finalize()! - return t.gateways_deploy_fqdn(GatewayFQDN{ + return t.deploy_gateway_fqdn(GatewayFQDN{ name: name node_id: u32(node_id) tls_passthrough: tls_passthrough @@ -29,13 +29,13 @@ fn deploy_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDNResult })! } -fn get_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDNResult { +fn get_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) !GatewayFQDN { fp.usage_example('get [options]') name := fp.string_opt('name', `n`, 'Name of the gateway instance')! _ := fp.finalize()! - return t.gateways_get_fqdn(name)! + return t.get_gateway_fqdn(name)! } fn delete_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) ! { @@ -44,7 +44,7 @@ fn delete_gateway_fqdn(mut fp FlagParser, mut t TFGridClient) ! { name := fp.string_opt('name', `n`, 'Name of the gateway instance')! _ := fp.finalize()! - return t.gateways_delete_fqdn(name) + return t.cancel_gateway_fqdn(name) } fn main() { @@ -83,7 +83,7 @@ fn main() { mut tfgrid_client := tfgrid.new(mut myclient) - tfgrid_client.load(tfgrid.Credentials{ + tfgrid_client.load(tfgrid.Load{ mnemonic: mnemonic network: network })! diff --git a/web3gw/examples/tfgrid/gateway_name.v b/web3gw/examples/tfgrid/gateway_name.v index fb12622b2..f6703dc35 100644 --- a/web3gw/examples/tfgrid/gateway_name.v +++ b/web3gw/examples/tfgrid/gateway_name.v @@ -1,6 +1,6 @@ module main -import threefoldtech.web3gw.tfgrid { GatewayName, GatewayNameResult, TFGridClient } +import threefoldtech.web3gw.tfgrid { GatewayName, TFGridClient } import log { Logger } import flag { FlagParser } import os @@ -10,7 +10,7 @@ const ( default_server_address = 'ws://127.0.0.1:8080' ) -fn deploy_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayNameResult { +fn deploy_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayName { fp.usage_example('deploy [options]') name := fp.string_opt('name', `n`, 'Name of the gateway instance')! @@ -19,7 +19,7 @@ fn deploy_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayNameResult backend := fp.string_opt('backend', `b`, 'Backend of the gateway')! _ := fp.finalize()! - return t.gateways_deploy_name(GatewayName{ + return t.deploy_gateway_name(GatewayName{ name: name node_id: u32(node_id) tls_passthrough: tls_passthrough @@ -27,13 +27,13 @@ fn deploy_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayNameResult })! } -fn get_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayNameResult { +fn get_gateway_name(mut fp FlagParser, mut t TFGridClient) !GatewayName { fp.usage_example('get [options]') name := fp.string_opt('name', `n`, 'Name of the gateway instance')! _ := fp.finalize()! - return t.gateways_get_name(name)! + return t.get_gateway_name(name)! } fn delete_gateway_name(mut fp FlagParser, mut t TFGridClient) ! { @@ -42,7 +42,7 @@ fn delete_gateway_name(mut fp FlagParser, mut t TFGridClient) ! { name := fp.string_opt('name', `n`, 'Name of the gateway instance')! _ := fp.finalize()! - return t.gateways_delete_name(name) + return t.cancel_gateway_name(name) } fn main() { @@ -78,7 +78,7 @@ fn main() { mut tfgrid_client := tfgrid.new(mut myclient) - tfgrid_client.load(tfgrid.Credentials{ + tfgrid_client.load(tfgrid.Load{ mnemonic: mnemonic network: network })! diff --git a/web3gw/examples/tfgrid/vm.v b/web3gw/examples/tfgrid/vm.v index 5c84d6f3b..52fe63347 100644 --- a/web3gw/examples/tfgrid/vm.v +++ b/web3gw/examples/tfgrid/vm.v @@ -1,6 +1,6 @@ module main -import threefoldtech.web3gw.tfgrid { RemoveVM, TFGridClient, VM, VMResult } +import threefoldtech.web3gw.tfgrid { NetworkDeployment, TFGridClient, DeployVM, VMDeployment } import log { Logger } import flag { FlagParser } import os @@ -11,68 +11,58 @@ const ( default_server_address = 'ws://127.0.0.1:8080' ) -fn deploy_vm(mut fp FlagParser, mut t TFGridClient) !VMResult { +fn deploy_vm(mut fp FlagParser, mut t TFGridClient) !VMDeployment { fp.usage_example('deploy [options]') name := fp.string('vm_name', `m`, rand.string(6), 'VM name') - network := fp.string_opt('vm_network', `v`, 'Name of the VM network')! farm_id := fp.int('farm_id', `f`, 0, 'Farm ID to deploy on') - capacity := fp.string('capacity', `c`, 'medium', 'Capacity of the instance') - times := fp.int('times', `t`, 1, 'The number of vms to deploy') disk_size := fp.int('disk_size', `d`, 0, 'Size of disk the will be mounted on each vm') gateway := fp.bool('gateway', `g`, false, 'True to add a gateway for each vm') wg := fp.bool('wg', `w`, false, 'True to add a wireguard access point to the network') - add_public_ipv4 := fp.bool('add_public_ipv4', `4`, false, 'True to add a public ipv4 to each vm') - add_public_ipv6 := fp.bool('add_public_ipv6', `6`, false, 'True to add a public ipv6 to each vm') - ssh_key := fp.string('ssh', `s`, '', 'Public SSH Key to access the instance') _ := fp.finalize()! - vm := VM{ + vm := DeployVM{ name: name - network: network farm_id: u32(farm_id) - capacity: capacity - ssh_key: ssh_key - times: u32(times) - disk_size: u32(disk_size) + rootfs_size: u64(disk_size) gateway: gateway add_wireguard_access: wg - add_public_ipv4: add_public_ipv4 - add_public_ipv6: add_public_ipv6 } return t.deploy_vm(vm)! } -fn get_vm(mut fp FlagParser, mut t TFGridClient) !VMResult { +fn get_vm(mut fp FlagParser, mut t TFGridClient) !VMDeployment { fp.usage_example('get [options]') - network := fp.string_opt('vm_network', `v`, 'Name of the VM network')! + vm := fp.string_opt('vm_name', `v`, 'Name of the VM')! _ := fp.finalize()! - return t.get_vm(network)! + return t.get_vm_deployment(vm)! } fn delete_vm(mut fp FlagParser, mut t TFGridClient) ! { fp.usage_example('delete [options]') - network := fp.string_opt('vm_network', `v`, 'Name of the VM network')! + vm_name := fp.string_opt('vm_name', `v`, 'Name of the VM to be deleted')! + _ := fp.finalize()! - return t.delete_vm(network) + t.cancel_vm_deployment(vm_name)! } -fn remove_vm(mut fp FlagParser, mut t TFGridClient) !VMResult { +fn remove_vm(mut fp FlagParser, mut t TFGridClient)!NetworkDeployment { fp.usage_example('remove [options]') + vm_name := fp.string_opt('vm_name', `v`, 'Name of the VM to be removed')! network := fp.string_opt('vm_network', `v`, 'Name of the VM network')! - vm_name := fp.string_opt('vm', `v`, 'Name of the VM to be removed')! + _ := fp.finalize()! - return t.remove_vm(RemoveVM{ + return t.remove_vm_from_network_deployment( network: network - vm_name: vm_name - })! + vm: vm_name + )! } fn main() { @@ -108,7 +98,7 @@ fn main() { mut tfgrid_client := tfgrid.new(mut myclient) - tfgrid_client.load(tfgrid.Credentials{ + tfgrid_client.load(tfgrid.Load{ mnemonic: mnemonic network: network })!