Capacity Planning

Table of Contents


It's almost the same as in deploying a single VM the only difference is you can automate the choice of the node to deploy on using code. We now support FilterOptions to filter nodes based on specific criteria e.g the node resources (CRU, SRU, HRU, MRU) or being part of a specific farm or located in some country, or being a gateway or not


FilterOptions: { accessNodeV4?: boolean; accessNodeV6?: boolean; city?: string; country?: string; cru?: number; hru?: number; mru?: number; sru?: number; farmId?: number; farmName?: string; gateway?: boolean; publicIPs?: boolean; certified?: boolean; dedicated?: boolean; availableFor?: number; page?: number;}
import { DiskModel, FilterOptions, MachineModel, MachinesModel, NetworkModel } from "../src";
import { config, getClient } from "./client_loader";
import { log } from "./utils";

async function main() {
    const grid3 = await getClient();

    // create network Object
    const n = new NetworkModel(); = "dynamictest";
    n.ip_range = "";

    // create disk Object
    const disk = new DiskModel(); = "dynamicDisk";
    disk.size = 8;
    disk.mountpoint = "/testdisk";

    const vmQueryOptions: FilterOptions = {
        cru: 1,
        mru: 2, // GB
        sru: 9,
        country: "Belgium",
        availableFor: grid3.twinId,

    // create vm node Object
    const vm = new MachineModel(); = "testvm";
    vm.node_id = +(await grid3.capacity.filterNodes(vmQueryOptions))[0].nodeId; // TODO: allow random choise
    vm.disks = [disk];
    vm.public_ip = false;
    vm.planetary = true;
    vm.cpu = 1;
    vm.memory = 1024 * 2;
    vm.rootfs_size = 0;
    vm.flist = "";
    vm.entrypoint = "/sbin/zinit init";
    vm.env = {
        SSH_KEY: config.ssh_key,

    // create VMs Object
    const vms = new MachinesModel(); = "dynamicVMS"; = n;
    vms.machines = [vm];
    vms.metadata = "{'testVMs': true}";
    vms.description = "test deploying VMs via ts grid3 client";

    // deploy vms
    const res = await grid3.machines.deploy(vms);

    // get the deployment
    const l = await grid3.machines.getObj(;

    // // delete
    // const d = await grid3.machines.delete({ name: });
    // log(d);

    await grid3.disconnect();


In this example you can notice the criteria for server1

const server1_options: FilterOptions = {
    cru: 1,
    mru: 2, // GB
    sru: 9,
    country: "Belgium",
    availableFor: grid3.twinId,

Here we want all the nodes with CRU:1, MRU:2, SRU:9, located in Belgium and available for me (not rented for someone else).

Note some libraries allow reverse lookup of countries codes by name e.g i18n-iso-countries

and then in the MachineModel, we specified the node_id to be the first value of our filteration

vm.node_id = +(await nodes.filterNodes(server1_options))[0].nodeId;
Last change: 2024-02-27