1.2.0 • Published 8 years ago

lxcjs v1.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
8 years ago

lxcjs

npm dependencies

A Node JS wrapper around lxc commands.

Install

npm i --save lxcjs

Test

./test.js

Usage

const config = require('./config.json');
const lxc    = require('lxcjs')(config);

// Containers status
lxc
    .status
    .then(out => process.stdout.write(out));

// Container start
lxc
    .start(containerName)
    .then(out => process.stdout.write(out))
    .catch(err => process.stderr.write(err));

// Container stop
lxc
    .stop(containerName)
    .then(out => process.stdout.write(out))
    .catch(err => process.stderr.write(err));

// Get all containers
lxc
    .util
    .getContainers()
    .then(out => process.stdout.write(out))
    .catch(err => process.stderr.write(err));

// Get running containers
lxc
    .util
    .getRunningContainers()
    .then(out => process.stdout.write(out))
    .catch(err => process.stderr.write(err));

// Get stopped containers
lxc
    .util
    .getStoppedContainers()
    .then(out => process.stdout.write(out))
    .catch(err => process.stderr.write(err));

// Get informations on a container
lxc
    .info(container)
    .then(info => {
        process.stdout.write(`Name : ${info.name}\n`);
        process.stdout.write(`State : ${info.state}\n`);
        process.stdout.write(`Host : ${info.host}\n`);
        process.stdout.write(`Ip : ${info.ip}\n`);
    })
    .catch(err => process.stderr.write(err));

With config.json providing following informations :

{
    "lxc_path" : "/path/to/containers/directory",
    "lxc_commands_path" : "/path/to/lxc/commands/directory"
}
1.2.0

8 years ago

1.1.1

8 years ago

1.0.0

8 years ago

0.1.0

8 years ago