struct CrystaLXD::Container

Overview

https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containers

This object is instantiated through CrystaLXD::Client#container

Defined in:

client/container.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(client : Client, name : String) #

[View source]

Instance Method Detail

def create(source : Source::Image | Source::Copy | Source::Migration | Source::None, configuration : Configuration = Configuration.new) : Success(BackgroundOperation) | Error #

Creates a new container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-optional-targetmember).


[View source]

Removes this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#delete-1).


[View source]
def exec_direct(exec : Exec) : Success(BackgroundOperation) | Error #

Runs a remote command directly, without any wait for websocket connection (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersnameexec).


[View source]
def exec_websocket(exec : Exec, &) : Success(CrystaLXD::BackgroundOperation) | Error #

Runs a remote command and wait for a websocket connection before starting the process (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#10containersnameexec).

Yields the stdin and control websockets (in this order).

The control websocket can be used to send out-of-band messages during an exec session. This is currently used for window size changes and for forwarding of signals.

require "crystalxd"

exec = CrystaLXD::Container::Exec.new command: ["/bin/ls"], cwd: "/"
exec.on_stdout do |bytes|
  STDOUT.write bytes
end
mycontainer.exec_websocket exec do |stdin_ws, contol_ws|
end

[View source]
def freeze(timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error #

Freezes this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-1).


[View source]
def information : Success(Information) | Error #

Returns container configuration and current state (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-5).


[View source]
def name : String #

64 chars max, ASCII, no slash, no colon and no comma.


[View source]
def rename(new_name : String) : Success(BackgroundOperation) | Error #

Renames this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#post-optional-targetmember-1).


[View source]
def replace_config(configuration : Configuration) : Success(BackgroundOperation) | Error #

Replaces container configuration (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-etag-supported-2).


[View source]
def restart(force : Bool = true, timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error #

Restarts this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-1).


[View source]
def restore_snapshot(snapshot_name : String) : Success(BackgroundOperation) | Error #

Restores a snapshot (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-etag-supported-2).


[View source]
def start(stateful : Bool = false, timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error #

Starts this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-1).


[View source]
def state : Success(State) | Error #

Returns the current state (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#get-9).


[View source]
def stop(force : Bool = true, stateful : Bool = false, timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error #

Stops this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-1).


[View source]
def unfreeze(timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error #

Unfreezes this container (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#put-1).


[View source]
def update_config(configuration : Configuration) : Success(Empty) | Error #

Updates container configuration (https://github.com/lxc/lxd/blob/master/doc/rest-api.md#patch-etag-supported-2).


[View source]