Struct buildchain::Lxc
[−]
[src]
pub struct Lxc(_);
An LXC container
Methods
impl Lxc
[src]
fn new(location: Location, name: &str, base: &str) -> Result<Lxc>
Create a new LXC container
Arguments
name
- The name of the container. This will be prepended withbuildchain-
base
- The base distribution to use,ubuntu:16.04
for example
Return
The newly created LXC container
Errors
Errors that are encountered while creating will be returned
Example
use buildchain::{Location, Lxc}; let mut lxc = Lxc::new(Location::Local, "test-new", "ubuntu:16.04").unwrap();
fn exec(&mut self, command: &[&str]) -> Result<()>
Run a command in an LXC container
Arguments
command
- An array of command arguments
Return
And empty tuple on success
Errors
Errors that are encountered while executing will be returned
Example
use buildchain::{Location, Lxc}; let mut lxc = Lxc::new(Location::Local, "test-exec", "ubuntu:16.04").unwrap(); lxc.exec(&["echo", "hello"]).unwrap();
fn mount(&mut self, name: &str, source: &str, dest: &str) -> Result<()>
Mount a path in an LXC container
Arguments
name
- The name of the mountsource
- The source path to mountdest
- The destination of the mount
Return
And empty tuple on success
Errors
Errors that are encountered while mounting will be returned
Example
use buildchain::{Location, Lxc}; let mut lxc = Lxc::new(Location::Local, "test-mount", "ubuntu:16.04").unwrap(); lxc.mount("source", ".", "/root/source").unwrap();
fn pull(&mut self, source: &str, dest: &str) -> Result<()>
Pull a file from the LXC container
Arguments
source
- The source of the file in the containerdest
- The destination of the file in the host
Return
And empty tuple on success
Errors
Errors that are encountered while mounting will be returned
Example
use buildchain::{Location, Lxc}; let mut lxc = Lxc::new(Location::Local, "test-pull", "ubuntu:16.04").unwrap(); lxc.pull("/etc/hostname", "target/hostname").unwrap();