From 8b14947d960c3a321825bb528a66607d79f44ce0 Mon Sep 17 00:00:00 2001 From: Ranjib Dey Date: Mon, 16 Dec 2013 12:29:15 -0800 Subject: [PATCH] add docs --- README.md | 54 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3cf58e3..c9e5f65 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,58 @@ Ruby-LXC is a Ruby binding for liblxc. It allows the creation and management of Linux Containers from Ruby scripts. + ## Build and installation -Clone this repository and run the commands below. +Currently the binding is developed and tested against liblxc 1.0.0 build. To build ruby-lxc you need +- ubuntu 14.04 +- lxc ipackage +```sh +sudo apt-get install lxc liblxc0 lxc-dev +``` - $ rake native gem - # gem install pkg/ruby-lxc-0.1.0.gem +- Build essential for compiling the bindings +```sh +sudo apt-get install build-essential +``` + +- Clone this repository and run the commands below (assuming you have bundler). +```sh +bundle install +bundle exec rake compile +gem install pkg/ruby-lxc-0.1.0.gem +``` +or just add this to your ```Gemfile``` +```ruby +gem "ruby-lxc", github: "andrenth/ruby-lxc" +``` ## Usage -TODO :) For now see the tests in the `test` directory to see how the API -works. +- Container lifecycle management (create, start, stop and destroy containers) +```ruby +c = LXC::Container.new('foo') +c.create('ubuntu') # create a container named foo with ubuntu template +c.start +c.stop +c.destroy +``` + +- Additional state changing operations (freezing, unfreezing and cloning containers) +```ruby +c.freeze +c.unfreeze +c.reboot +c.shutdown +``` + +- Clone a container +```ruby +c.clone('bar') # clone foo into bar. parent container has to bee in freeze or stopped state. +``` + +- Wait for a state change +```ruby +c.wait('STOPPED', 10) # wait till container goes to STOPPED state, else timeout after 10 seconds +``` +