struct

CrystaLXD::Container

Inherits Struct < Value < Object

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

This object is instantiated through CrystaLXD::Client#container

Constructors

new(client : Client, name : String)

Instance methods

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).

delete

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

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).

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
freeze(timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error

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

information

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

name

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

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).

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).

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).

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).

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).

state

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

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).

unfreeze(timeout : Int32 | Nil = nil) : Success(BackgroundOperation) | Error

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

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).

Nested types