Deploying ZDB
Table of Contents
Introduction
We show how to deploy ZDB on the TFGrid with the Javascript client.
Prerequisites
- Make sure you have your client prepared
Example code
import { FilterOptions, ZDBModel, ZdbModes, ZDBSModel } from "../src";
import { getClient } from "./client_loader";
import { log } from "./utils";
async function main() {
const grid3 = await getClient();
const zdbQueryOptions: FilterOptions = {
sru: 1,
hru: 1,
availableFor: grid3.twinId,
farmId: 1,
};
// create zdb object
const zdb = new ZDBModel();
zdb.name = "hamada";
zdb.node_id = +(await grid3.capacity.filterNodes(zdbQueryOptions))[0].nodeId;
zdb.mode = ZdbModes.user;
zdb.disk_size = 1;
zdb.publicNamespace = false;
zdb.password = "testzdb";
// create zdbs object
const zdbs = new ZDBSModel();
zdbs.name = "tttzdbs";
zdbs.zdbs = [zdb];
zdbs.metadata = '{"test": "test"}';
// deploy zdb
const res = await grid3.zdbs.deploy(zdbs);
log(res);
// get the deployment
const l = await grid3.zdbs.getObj(zdbs.name);
log(l);
// // delete
// const d = await grid3.zdbs.delete({ name: zdbs.name });
// log(d);
await grid3.disconnect();
}
main();
Detailed explanation
Getting the client
const grid3 = getClient();
Building the model
// create zdb object
const zdb = new ZDBModel();
zdb.name = "hamada";
zdb.node_id = +(await grid3.capacity.filterNodes(zdbQueryOptions))[0].nodeId;
zdb.mode = ZdbModes.user;
zdb.disk_size = 1;
zdb.publicNamespace = false;
zdb.password = "testzdb";
Here we define a ZDB model
and setting the relevant properties e.g
- name
- node_id : where to deploy on
- mode:
user
orseq
- disk_size: disk size in GB
- publicNamespace: a public namespace can be read-only if a password is set
- password: namespace password
preparing ZDBs collection
// create zdbs object
const zdbs = new ZDBSModel();
zdbs.name = "tttzdbs";
zdbs.zdbs = [zdb];
zdbs.metadata = '{"test": "test"}';
you can attach multiple ZDBs into the collection and send it for deployment
Deployment
const res = await grid3.zdbs.deploy(zdbs);
log(res);
Getting Deployment information
getObj
gives detailed information about the workload.
// get the deployment
const l = await grid3.zdbs.getObj(zdbs.name);
log(l);
Deleting a deployment
.delete
method helps cancelling the relevant contracts related to that ZDBs deployment
// delete
const d = await grid3.zdbs.delete({ name: zdbs.name });
log(d);