-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsingle_vm_zos3_lite.ts
More file actions
119 lines (108 loc) · 4.42 KB
/
Copy pathsingle_vm_zos3_lite.ts
File metadata and controls
119 lines (108 loc) · 4.42 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import { Features, FilterOptions, generateRandomHexSeed, generateString, MachinesModel } from "../src";
import { FLISTS } from "../src/helpers/flists";
import { config, getClient } from "./client_loader";
import { log, pingNodes } from "./utils";
async function deploy(client, vms) {
const resultVM = await client.machines.deploy(vms);
log("================= Deploying VM =================");
log(resultVM);
log("================= Deploying VM =================");
}
async function getDeployment(client, vms) {
const resultVM = await client.machines.getObj(vms.name);
log("================= Getting deployment information =================");
log(resultVM);
log("================= Getting deployment information =================");
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async function cancel(client, vms) {
const resultVM = await client.machines.delete(vms);
log("================= Canceling the deployment =================");
log(resultVM);
log("================= Canceling the deployment =================");
}
async function main() {
const name = "vm" + generateString(6);
const networkName = "nw" + generateString(6);
const grid3 = await getClient(`vm/${name}`);
const instanceCapacity = { cru: 2, mru: 4, sru: 100 }; // Update the instance capacity values according to your requirements.
//VMNode Selection
const vmQueryOptions: FilterOptions = {
cru: instanceCapacity.cru,
mru: instanceCapacity.mru,
sru: instanceCapacity.sru,
availableFor: grid3.twinId,
features: [Features.zmachinelight, Features.networklight, Features.mycelium],
nodeExclude: [259],
farmName: "LiriaFarm",
};
const nodes = await grid3.capacity.filterNodes(vmQueryOptions);
const vmNode = await pingNodes(grid3, nodes);
const vms: MachinesModel = {
name,
network: {
name: networkName,
ip_range: "10.249.0.0/16",
myceliumSeeds: [
{
nodeId: vmNode,
/**
* ### Mycelium Network Seed:
* - The `seed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, set the `seed` field to the old seed value.
*/
seed: generateRandomHexSeed(32),
},
],
},
machines: [
{
name: "testvmMY",
node_id: vmNode,
disks: [
{
name: "wedDisk",
size: instanceCapacity.sru,
mountpoint: "/testdisk",
},
],
planetary: false,
public_ip: false,
public_ip6: false,
/**
* ### Mycelium Flag Behavior:
* - When the `mycelium` flag is enabled, there’s no need to manually provide the `myceliumSeed` flag.
* - The `GridClient` will automatically generate the necessary seed for you.
* - **However**, if you have **an existing seed** from a previously deleted machine and wish to deploy a new machine that retains the same IP address,
* - **you can simply pass in the old seed during deployment instead of calling the `generateRandomHexSeed()` function**.
*/
mycelium: true,
/**
* ### Mycelium Seed:
* - The `myceliumSeed` is an optional field used to provide a specific seed for the Mycelium network.
* - If not provided, the `GridClient` will generate a seed automatically when the `mycelium` flag is enabled.
* - **Use Case:** If you need the new machine to have the same IP address as a previously deleted machine, set the `seed` field to the old seed value. */
myceliumSeed: generateRandomHexSeed(6), // (HexSeed of length 6)
cpu: instanceCapacity.cru,
memory: 1024 * instanceCapacity.mru,
rootfs_size: 0,
flist: FLISTS.MICROVMS_UBUNTU_24.flist,
entrypoint: FLISTS.MICROVMS_UBUNTU_24.entryPoint,
env: {
SSH_KEY: config.ssh_key,
},
},
],
metadata: "",
description: "test deploying single ZOS4 VM with mycelium via ts grid3 client",
};
//Deploy VMs
await deploy(grid3, vms);
//Get the deployment
await getDeployment(grid3, vms);
//Uncomment the line below to cancel the deployment
// await cancel(grid3, { name });
await grid3.disconnect();
}
main();