[−][src]Struct lxd::Container
An LXD ephemeral container
Methods
impl Container
[src]
pub fn new(location: Location, name: &str, base: &str) -> Result<Self>
[src]
Create a new LXD container
Arguments
location
- The location of the hostname
- The name of the containerbase
- The base distribution to use,ubuntu:16.04
for example
Return
The newly created LXD container
Errors
Errors that are encountered while creating container will be returned
Example
use lxd::{Container, Location}; let mut container = Container::new(Location::Local, "test-new", "ubuntu:16.04").unwrap();
pub unsafe fn new_privileged(
location: Location,
name: &str,
base: &str
) -> Result<Self>
[src]
location: Location,
name: &str,
base: &str
) -> Result<Self>
Create a new privileged LXD container
Arguments
location
- The location of the hostname
- The name of the containerbase
- The base distribution to use,ubuntu:16.04
for example
Return
The newly created LXD container
Errors
Errors that are encountered while creating container will be returned
Example
use lxd::{Container, Location}; let mut container = unsafe { Container::new_privileged(Location::Local, "test-new-privileged", "ubuntu:16.04").unwrap() };
pub fn name(&self) -> &str
[src]
Get full name of container
pub fn snapshot<'a>(&'a self, name: &str) -> Result<Snapshot<'a>>
[src]
Create a snapshot of a container
Arguments
name
- name of the new snapshot
Return
A new snapshot on success
Errors
Errors that are encountered while creating snapshot will be returned
Example
use lxd::{Container, Location, Snapshot}; let container = Container::new(Location::Local, "test-snapshot", "ubuntu:16.04").unwrap(); container.snapshot("test-snapshot").unwrap();
pub fn exec(&mut self, command: &[&str]) -> Result<()>
[src]
Run a command in an LXD container
Arguments
command
- An array of command arguments
Return
An empty tuple on success
Errors
Errors that are encountered while executing will be returned
Example
use lxd::{Container, Location}; let mut container = Container::new(Location::Local, "test-exec", "ubuntu:16.04").unwrap(); container.exec(&["echo", "hello"]).unwrap();
pub fn mount<P: AsRef<Path>>(
&mut self,
name: &str,
source: P,
dest: &str
) -> Result<()>
[src]
&mut self,
name: &str,
source: P,
dest: &str
) -> Result<()>
Mount a path in an LXD container
Arguments
name
- The name of the mountsource
- The source path to mountdest
- The destination of the mount
Return
An empty tuple on success
Errors
Errors that are encountered while mounting will be returned
Example
use lxd::{Container, Location}; let mut container = Container::new(Location::Local, "test-mount", "ubuntu:16.04").unwrap(); container.mount("source", ".", "/root/source").unwrap();
pub fn push<P: AsRef<Path>>(
&mut self,
source: P,
dest: &str,
recursive: bool
) -> Result<()>
[src]
&mut self,
source: P,
dest: &str,
recursive: bool
) -> Result<()>
Push a file to the LXD container
Arguments
source
- The source of the file in the hostdest
- The destination of the file in the containerrecursive
- The source is a directory
Return
An empty tuple on success
Errors
Errors that are encountered while pushing will be returned
Example
extern crate lxd; extern crate tempdir; use lxd::{Container, Location}; use tempdir::TempDir; fn main() { let mut container = Container::new(Location::Local, "test-push", "ubuntu:16.04").unwrap(); let tmp = TempDir::new("").unwrap(); container.push(tmp.path(), "/root", true).unwrap(); }
pub fn pull<P: AsRef<Path>>(
&mut self,
source: &str,
dest: P,
recursive: bool
) -> Result<()>
[src]
&mut self,
source: &str,
dest: P,
recursive: bool
) -> Result<()>
Pull a file from the LXD container
Arguments
source
- The source of the file in the containerdest
- The destination of the file in the hostrecursive
- The source is a directory
Return
An empty tuple on success
Errors
Errors that are encountered while pulling will be returned
Example
extern crate lxd; extern crate tempdir; use lxd::{Container, Location}; use tempdir::TempDir; fn main() { let mut container = Container::new(Location::Local, "test-pull", "ubuntu:16.04").unwrap(); container.exec(&["mkdir", "artifacts"]).unwrap(); let tmp = TempDir::new("").unwrap(); container.pull("/root/artifacts", tmp.path(), true).unwrap(); }
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,