-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathzos3lite_gateway_domain.ts
More file actions
64 lines (53 loc) · 2.13 KB
/
Copy pathzos3lite_gateway_domain.ts
File metadata and controls
64 lines (53 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { Features, FilterOptions, GatewayNameModel, generateString } from "../src";
import { getClient } from "./client_loader";
import { log } from "./utils";
async function deploy(client, gw) {
const res = await client.gateway.deploy_name(gw);
log("================= Deploying name gateway =================");
log(res);
log("================= Deploying name gateway =================");
}
async function getDeployment(client, gw) {
const res = await client.gateway.getObj(gw);
log("================= Getting deployment information =================");
log(res);
log("================= Getting deployment information =================");
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function cancel(client, gw) {
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
async function main() {
const grid3 = await getClient();
const gatewayName = "gw" + generateString(6);
const gatewayQueryOptions: FilterOptions = {
gateway: true,
features: [Features.mycelium, Features.zmachinelight, Features.networklight],
farmName: "LiriaFarm",
};
const gatewayNodes = await grid3.capacity.filterNodes(gatewayQueryOptions);
if (gatewayNodes.length === 0) {
log("No nodes found for gateway. Skipping test.");
await grid3.disconnect();
return;
}
const gw: GatewayNameModel = {
name: gatewayName,
node_id: +gatewayNodes[0].nodeId,
tls_passthrough: false,
// the backends have to be in this format `http://ip:port` or `https://ip:port`, and the `ip` pingable from the node so using the ygg ip or public ip if available.
backends: ["http://185.206.122.35:8000"],
};
//Deploy gateway
await deploy(grid3, gw);
//Get the deployment
await getDeployment(grid3, gw.name);
//Uncomment the line below to cancel the deployment
// await cancel(grid3, { name: gw.name });
grid3.disconnect();
}
main();