LXD PHP Client Documentation v0.0.1
Class Lxd Endpoints

Images

Methods
  • __construct(array $config, variable $curl)  :  void
    Class construct.
  • all(string $url)  :  array
    List of all images.
  • info(string $url, string $fingerprint, string $secret)  :  array
    Get image info.
  • create(array $options, array $headers, bool $wait)  :  array
    Create a new image.
  • createFromRemote(string $server, array $options, bool $autoUpdate, bool $wait)  :  array
    Create from remote.
  • createFromContainer(string $name, array $options, bool $wait)  :  array
    Create an image from a container.
  • createFromSnapshot(string $container, string $snapshot, array $options, bool $wait)  :  array
    Create an image from a snapshot.
  • replace(string $fingerprint, array $options, bool $wait)  :  array
    Replace the configuration of a image.
  • remove(string $fingerprint, bool $wait)  :  array
    Delete an image.
  • getSource(array $options)  :  Lxd\Endpoints\Exception | array
    Get image source attribute.
  • getOptions(array $options)  :  array
    Get the options for creating image.
Methods Details
  • public function __construct(array $config, variable $curl)
    Class construct.
  • public function all(string $url)
    List of all images.
    // images on connected server $lxd->images->all(); // images on public image server. (URL must include /1.0/images) $lxd->images->all("https://images.linuxcontainers.org:8443/1.0/images");
  • public function info(string $url, string $fingerprint, string $secret)
    Get image info.
    // image info on connected server $lxd->images->info(null, "images-fingerprint", "secret"); // images on public image server. (URL must include /1.0/images) $lxd->images->info("https://uk.images.linuxcontainers.org:8443/1.0/images", "images-fingerprint"));
  • public function create(array $options, array $headers, bool $wait)
    Create a new image.
    $lxd->images->create( [], // image options [], // API headers true // wait for operation );
  • public function createFromRemote(string $server, array $options, bool $autoUpdate, bool $wait)
    Create from remote.
    // Import an image by alias $lxd->images->createFromRemote( "https://images.linuxcontainers.org:8443", [ "alias" => "ubuntu/xenial/amd64", ] ); // Import an image by fingerprint $lxd->images->createFromRemote( "https://images.linuxcontainers.org:8443", [ "fingerprint" => "b0f4faff46c9cb02db10984e2cf71c62fd539a9ab680d6fd54955671f3186087", ] ); // Import an image by fingerprint, set auto update and wait for pull $lxd->images->createFromRemote( "https://images.linuxcontainers.org:8443", [ "fingerprint" => "b0f4faff46c9cb02db10984e2cf71c62fd539a9ab680d6fd54955671f3186087", ], true, true );
  • public function createFromContainer(string $name, array $options, bool $wait)
    Create an image from a container.
    // Create a private image from container. $lxd->images->createFromContainer('container-name'); // Create a public image from container $lxd->images->createFromContainer( 'container-name', [ 'public' => true ] ); // Create an image from container, store properties with the new image and override its filename. $lxd->images->createFromContainer( 'container-name', [ 'filename' => 'ubuntu-trusty.tar.gz', 'properties' => ['os' => 'Ubuntu'], ] );
  • public function createFromSnapshot(string $container, string $snapshot, array $options, bool $wait)
    Create an image from a snapshot.
    // Create a private image from snapshot $lxd->images->createFromSnapshot("container_name", "snapshot_name"); // Create a public image from snapshot $lxd->images->createFromSnapshot( "container_name", "snapshot_name", [ "public" => true ] ); // Store properties with the new image, and override its filename $lxd->images->createFromSnapshot( "container-name", "snapshot-name", [ "filename" => "ubuntu-trusty.tar.gz", "properties" => ["os" => "Ubuntu"] ] );
  • public function replace(string $fingerprint, array $options, bool $wait)
    Replace the configuration of a image.
    Configuration is overwritten, not merged. Clients should first call the info method to obtain the current configuration of a image. The resulting objects metadata should be modified and then passed to the update method. $image = $lxd->images->info(null, 'b0f4faff46c9cb02db10984e2cf71c62fd539a9ab680d6fd54955671f3186087'); $image['metadata']['public'] = true; $lxd->images->replace('container-name', $image['metadata']);
  • public function remove(string $fingerprint, bool $wait)
    Delete an image.
    $lxd->images->remove('b0f4faff46c9cb02db10984e2cf71c62fd539a9ab680d6fd54955671f3186087', true);
  • final private function getSource(array $options)
    Get image source attribute.
  • final private function getOptions(array $options)
    Get the options for creating image.