node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org ยป


OpenVZ Wrapper NodeJS

NodeJS Wrapper for the OpenVZ CLI. This does not do a lot of error checking, so be careful.

To Install:

  npm install openvz

Default Configs:

  nameserver        : '',
  userpasswd        : 'root:root',
  ostemplate        : 'centos-6-x86_64',
  layout            : 'ploop',
  diskspace         : '10G:10G',
  hostname          : 'vm{$VMID}.localhost',
  root              : '/vz/root/${VMID}',
  private           : '/vz/private/${VMID}',
  ipadd             : '192.168.1.${VMID}'

to change a default attribute, pass it into the constructor:

  var vz = new VZ({ layout:'simfs' });

Example Usage:

  var VZ = require('openvz');
  var onReady = function(){
    console.log( 'All VMs', host.containers );
    host.createContainer({ ctid:115, nameserver:'' },function(e,vm){
        console.log('VM Created');
              console.log('VM Started');
  var containerDefaults = {
    hostname  : 'container-${VMID}.localhost',
    ipadd     : '192.168.1.${VMID}',
    layout    : 'ploop',
    onReady   : onReady
  var host = new VZ(containerDefaults);

Running Container Specific Commands:

  var vm = host.getContainerByCTID( 115 );
  // To Stop:
  // To Start:
  // To Restart:
  // Run a custom command:'set',{ cpuunits:1000, diskspace:'10G:10G', save:true });
        // would run: vzctl set 115 --cpuunits 1000 --diskspace '10G:10G' --save