LXD PHP Client Documentation v0.0.1
Class Lxd Endpoints

Containers

Methods
  • __construct(array $config, variable $curl)  :  void
    Class construct
  • all()  :  array
    List all containers on the server.
  • info(string $name)  :  array
    List all containers on the server.
  • state(string $name)  :  array
    Get the current state of the container.
  • setState(string $name, string $action, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Main set state method for a container, methods below are shortcuts.
  • start(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Start a container.
  • stop(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Stop a container.
  • shutdown(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Shutdown a container - alias of stop.
  • restart(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Restart a container.
  • reboot(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Reboot a container - alias of restart.
  • freeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Freeze a container.
  • pause(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Pause a container - alias of freeze.
  • unfreeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Unfreeze a container.
  • thaw(string $name, int $timeout, bool $force, bool $stateful, bool $wait)  :  array
    Thaw a container - alias of unfreeze.
  • create(string $name, array $options, bool $wait)  :  array
    Create a container from an image (local or remote).
  • copy(string $name, string $copyName, array $options, bool $wait)  :  array
    Create a copy of an existing local container.
  • replace(string $name, array $opts, bool $wait)  :  array
    Replace the configuration of a container
  • getSource(array $options)  :  array
    Private method for getting container [source] options.
  • getOptions(string $name, array $options)  :  array
    Private method for getting container [default] options.
  • getEmptyOptions(string $name, array $options)  :  array
    Private method for getting default container [empty] options.
  • getRemoteImageOptions(string $name, array $source, array $options)  :  array
    Private method for getting default container [remote] options.
  • getLocalImageOptions(string $name, array $source, array $options)  :  array
    Private method for getting default container [local] options.
Methods Details
  • public function __construct(array $config, variable $curl)
    Class construct
  • public function all()
    List all containers on the server.
    $lxd->containers->all();
  • public function info(string $name)
    List all containers on the server.
    $lxd->containers->info('container-name');
  • public function state(string $name)
    Get the current state of the container.
    $lxd->containers->state('container-name');
  • public function setState(string $name, string $action, int $timeout, bool $force, bool $stateful, bool $wait)
    Main set state method for a container, methods below are shortcuts.
    $lxd->containers->setState('container-name', 'start', 30, true, true, true);
  • public function start(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Start a container.
    $lxd->containers->start('container-name', 30, true, true, true);
  • public function stop(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Stop a container.
    $lxd->containers->stop('container-name', 30, true, true, true);
  • public function shutdown(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Shutdown a container - alias of stop.
    $lxd->containers->shutdown('container-name', 30, true, true, true);
  • public function restart(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Restart a container.
    $lxd->containers->restart('container-name', 30, true, true, true);
  • public function reboot(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Reboot a container - alias of restart.
    $lxd->containers->reboot('container-name', 30, true, true, true);
  • public function freeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Freeze a container.
    $lxd->containers->freeze('container-name', 30, true, true, true);
  • public function pause(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Pause a container - alias of freeze.
    $lxd->containers->pause('container-name', 30, true, true, true);
  • public function unfreeze(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Unfreeze a container.
    $lxd->containers->unfreeze('container-name', 30, true, true, true);
  • public function thaw(string $name, int $timeout, bool $force, bool $stateful, bool $wait)
    Thaw a container - alias of unfreeze.
    $lxd->containers->thaw('container-name', 30, true, true, true);
  • public function create(string $name, array $options, bool $wait)
    Create a container from an image (local or remote).
    // Create container from image specified by alias $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", ] ); // Create container from image specified by fingerprint $lxd->containers->create( "test", [ "fingerprint" => "097e75d6f7419d3a5e204d8125582f2d7bdd4ee4c35bd324513321c645f0c415", ] ); // Create container based on most recent match of image properties $lxd->containers->create( "test", [ "properties" => [ "os" => "ubuntu", "release" => "14.04", "architecture" => "x86_64", ], ] ); // Create an empty container $lxd->containers->create( "test", [ "empty" => true, ] ); // Create container with custom configuration. // - Set the MAC address of the container's eth0 device $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", "config" => [ "volatile.eth0.hwaddr" => "aa:bb:cc:dd:ee:ff", ], ] ); // Create container and apply profiles to it $lxd->containers->create( "test", [ "alias" => "ubuntu/xenial/amd64", "profiles" => ["migratable", "unconfined"], ] ); // Create container from a publicly-accessible remote image $lxd->containers->create( "test", [ "server" => "https://images.linuxcontainers.org:8443", "alias" => "ubuntu/xenial/amd64", ] ); // Create container from a private remote image (authenticated by a secret) $lxd->containers->create( "test", [ "server" => "https://private.example.com:8443", "alias" => "ubuntu/xenial/amd64", "secret" => "my_secrect", ] );
  • public function copy(string $name, string $copyName, array $options, bool $wait)
    Create a copy of an existing local container.
    // Copy container $lxd->containers->copy('existing', 'new'); // Copy container and apply profiles to it $lxd->containers->copy( 'container-name', 'copy-container-name', 'profiles' => ['default', 'public'] );
  • public function replace(string $name, array $opts, bool $wait)
    Replace the configuration of a container
    Configuration is overwritten, not merged. Clients should first call the info method to obtain the current configuration of a container. The resulting objects metadata should be modified and then passed to the relace method. // Change container to be ephemeral $container = $lxd->containers->info('container-name'); $container['metadata']['ephemeral'] = true; $lxd->containers->replace('container-name', $$container['metadata']);
  • final private function getSource(array $options)
    Private method for getting container [source] options.
  • final private function getOptions(string $name, array $options)
    Private method for getting container [default] options.
  • final private function getEmptyOptions(string $name, array $options)
    Private method for getting default container [empty] options.
  • final private function getRemoteImageOptions(string $name, array $source, array $options)
    Private method for getting default container [remote] options.
  • final private function getLocalImageOptions(string $name, array $source, array $options)
    Private method for getting default container [local] options.