lxcjs

    1.2.0 • Public • Published

    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"
    }
    

    Keywords

    Install

    npm i lxcjs

    DownloadsWeekly Downloads

    6

    Version

    1.2.0

    License

    MIT

    Last publish

    Collaborators

    • avatar