lxd

package
v0.0.0-...-9ff6e62 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2017 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package lxd implements a client for the LXD API

Overview

This package lets you connect to LXD daemons or SimpleStream image servers over a Unix socket or HTTPs. You can then interact with those remote servers, creating containers, images, moving them around, ...

Example - container creation

This creates a container on a local LXD daemon and then starts it.

// Connect to LXD over the Unix socket
c, err := lxd.ConnectLXDUnix("", nil)
if err != nil {
  return err
}

// Container creation request
req := api.ContainersPost{
  Name: "my-container",
  Source: api.ContainerSource{
    Type:  "image",
    Alias: "my-image",
  },
}

// Get LXD to create the container (background operation)
op, err := c.CreateContainer(req)
if err != nil {
  return err
}

// Wait for the operation to complete
err = op.Wait()
if err != nil {
  return err
}

// Get LXD to start the container (background operation)
reqState := api.ContainerStatePut{
  Action: "start",
  Timeout: -1,
}

op, err = c.UpdateContainerState(name, reqState, "")
if err != nil {
  return err
}

// Wait for the operation to complete
err = op.Wait()
if err != nil {
  return err
}

Example - command execution

This executes an interactive bash terminal

// Connect to LXD over the Unix socket
c, err := lxd.ConnectLXDUnix("", nil)
if err != nil {
  return err
}

// Setup the exec request
req := api.ContainerExecPost{
  Command: []string{"bash"},
  WaitForWS: true,
  Interactive: true,
  Width: 80,
  Height: 15,
}

// Setup the exec arguments (fds)
args := lxd.ContainerExecArgs{
  Stdin: os.Stdin,
  Stdout: os.Stdout,
  Stderr: os.Stderr,
}

// Setup the terminal (set to raw mode)
if req.Interactive {
  cfd := int(syscall.Stdin)
  oldttystate, err := termios.MakeRaw(cfd)
  if err != nil {
    return err
  }

  defer termios.Restore(cfd, oldttystate)
}

// Get the current state
op, err := c.ExecContainer("c1", req, &args)
if err != nil {
  return err
}

// Wait for it to complete
err = op.Wait()
if err != nil {
  return err
}

Example - image copy

This copies an image from a simplestreams server to a local LXD daemon

// Connect to LXD over the Unix socket
c, err := lxd.ConnectLXDUnix("", nil)
if err != nil {
  return err
}

// Connect to the remote SimpleStreams server
d, err = lxd.ConnectSimpleStreams("https://images.linuxcontainers.org", nil)
if err != nil {
  return err
}

// Resolve the alias
alias, _, err := d.GetImageAlias("centos/7")
if err != nil {
  return err
}

// Get the image information
image, _, err := d.GetImage(alias.Target)
if err != nil {
  return err
}

// Ask LXD to copy the image from the remote server
op, err := d.CopyImage(*image, c, nil)
if err != nil {
  return err
}

// And wait for it to finish
err = op.Wait()
if err != nil {
  return err
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionArgs

type ConnectionArgs struct {
	// TLS certificate of the remote server. If not specified, the system CA is used.
	TLSServerCert string

	// TLS certificate to use for client authentication.
	TLSClientCert string

	// TLS key to use for client authentication.
	TLSClientKey string

	// TLS CA to validate against when in PKI mode.
	TLSCA string

	// User agent string
	UserAgent string

	// Custom proxy
	Proxy func(*http.Request) (*url.URL, error)
}

ConnectionArgs represents a set of common connection properties

type ConnectionInfo

type ConnectionInfo struct {
	Addresses   []string
	Certificate string
	Protocol    string
}

The ConnectionInfo struct represents general information for a connection

type ContainerCopyArgs

type ContainerCopyArgs struct {
	// If set, the container will be renamed on copy
	Name string

	// If set, the container running state will be transferred (live migration)
	Live bool

	// If set, only the container will copied, its snapshots won't
	ContainerOnly bool
}

The ContainerCopyArgs struct is used to pass additional options during container copy

type ContainerExecArgs

type ContainerExecArgs struct {
	// Standard input
	Stdin io.ReadCloser

	// Standard output
	Stdout io.WriteCloser

	// Standard error
	Stderr io.WriteCloser

	// Control message handler (window resize, signals, ...)
	Control func(conn *websocket.Conn)

	// Channel that will be closed when all data operations are done
	DataDone chan bool
}

The ContainerExecArgs struct is used to pass additional options during container exec

type ContainerFileArgs

type ContainerFileArgs struct {
	// File content
	Content io.ReadSeeker

	// User id that owns the file
	UID int64

	// Group id that owns the file
	GID int64

	// File permissions
	Mode int

	// File type (file or directory)
	Type string

	// File write mode (overwrite or append)
	WriteMode string
}

The ContainerFileArgs struct is used to pass the various options for a container file upload

type ContainerFileResponse

type ContainerFileResponse struct {
	// User id that owns the file
	UID int64

	// Group id that owns the file
	GID int64

	// File permissions
	Mode int

	// File type (file or directory)
	Type string

	// If a directory, the list of files inside it
	Entries []string
}

The ContainerFileResponse struct is used as part of the response for a container file download

type ContainerServer

type ContainerServer interface {
	ImageServer

	// Server functions
	GetServer() (server *api.Server, ETag string, err error)
	UpdateServer(server api.ServerPut, ETag string) (err error)
	HasExtension(extension string) bool

	// Certificate functions
	GetCertificateFingerprints() (fingerprints []string, err error)
	GetCertificates() (certificates []api.Certificate, err error)
	GetCertificate(fingerprint string) (certificate *api.Certificate, ETag string, err error)
	CreateCertificate(certificate api.CertificatesPost) (err error)
	UpdateCertificate(fingerprint string, certificate api.CertificatePut, ETag string) (err error)
	DeleteCertificate(fingerprint string) (err error)

	// Container functions
	GetContainerNames() (names []string, err error)
	GetContainers() (containers []api.Container, err error)
	GetContainer(name string) (container *api.Container, ETag string, err error)
	CreateContainer(container api.ContainersPost) (op *Operation, err error)
	CreateContainerFromImage(source ImageServer, image api.Image, imgcontainer api.ContainersPost) (op *RemoteOperation, err error)
	CopyContainer(source ContainerServer, container api.Container, args *ContainerCopyArgs) (op *RemoteOperation, err error)
	UpdateContainer(name string, container api.ContainerPut, ETag string) (op *Operation, err error)
	RenameContainer(name string, container api.ContainerPost) (op *Operation, err error)
	MigrateContainer(name string, container api.ContainerPost) (op *Operation, err error)
	DeleteContainer(name string) (op *Operation, err error)

	ExecContainer(containerName string, exec api.ContainerExecPost, args *ContainerExecArgs) (*Operation, error)

	GetContainerFile(containerName string, path string) (content io.ReadCloser, resp *ContainerFileResponse, err error)
	CreateContainerFile(containerName string, path string, args ContainerFileArgs) (err error)
	DeleteContainerFile(containerName string, path string) (err error)

	GetContainerSnapshotNames(containerName string) (names []string, err error)
	GetContainerSnapshots(containerName string) (snapshots []api.ContainerSnapshot, err error)
	GetContainerSnapshot(containerName string, name string) (snapshot *api.ContainerSnapshot, ETag string, err error)
	CreateContainerSnapshot(containerName string, snapshot api.ContainerSnapshotsPost) (op *Operation, err error)
	CopyContainerSnapshot(source ContainerServer, snapshot api.ContainerSnapshot, args *ContainerSnapshotCopyArgs) (op *RemoteOperation, err error)
	RenameContainerSnapshot(containerName string, name string, container api.ContainerSnapshotPost) (op *Operation, err error)
	MigrateContainerSnapshot(containerName string, name string, container api.ContainerSnapshotPost) (op *Operation, err error)
	DeleteContainerSnapshot(containerName string, name string) (op *Operation, err error)

	GetContainerState(name string) (state *api.ContainerState, ETag string, err error)
	UpdateContainerState(name string, state api.ContainerStatePut, ETag string) (op *Operation, err error)

	GetContainerLogfiles(name string) (logfiles []string, err error)
	GetContainerLogfile(name string, filename string) (content io.ReadCloser, err error)
	DeleteContainerLogfile(name string, filename string) (err error)

	// Event handling functions
	GetEvents() (listener *EventListener, err error)

	// Image functions
	CreateImage(image api.ImagesPost, args *ImageCreateArgs) (op *Operation, err error)
	CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (op *RemoteOperation, err error)
	UpdateImage(fingerprint string, image api.ImagePut, ETag string) (err error)
	DeleteImage(fingerprint string) (op *Operation, err error)
	RefreshImage(fingerprint string) (op *Operation, err error)
	CreateImageSecret(fingerprint string) (op *Operation, err error)
	CreateImageAlias(alias api.ImageAliasesPost) (err error)
	UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) (err error)
	RenameImageAlias(name string, alias api.ImageAliasesEntryPost) (err error)
	DeleteImageAlias(name string) (err error)

	// Network functions ("network" API extension)
	GetNetworkNames() (names []string, err error)
	GetNetworks() (networks []api.Network, err error)
	GetNetwork(name string) (network *api.Network, ETag string, err error)
	CreateNetwork(network api.NetworksPost) (err error)
	UpdateNetwork(name string, network api.NetworkPut, ETag string) (err error)
	RenameNetwork(name string, network api.NetworkPost) (err error)
	DeleteNetwork(name string) (err error)

	// Operation functions
	GetOperation(uuid string) (op *api.Operation, ETag string, err error)
	DeleteOperation(uuid string) (err error)
	GetOperationWebsocket(uuid string, secret string) (conn *websocket.Conn, err error)

	// Profile functions
	GetProfileNames() (names []string, err error)
	GetProfiles() (profiles []api.Profile, err error)
	GetProfile(name string) (profile *api.Profile, ETag string, err error)
	CreateProfile(profile api.ProfilesPost) (err error)
	UpdateProfile(name string, profile api.ProfilePut, ETag string) (err error)
	RenameProfile(name string, profile api.ProfilePost) (err error)
	DeleteProfile(name string) (err error)

	// Storage pool functions ("storage" API extension)
	GetStoragePoolNames() (names []string, err error)
	GetStoragePools() (pools []api.StoragePool, err error)
	GetStoragePool(name string) (pool *api.StoragePool, ETag string, err error)
	CreateStoragePool(pool api.StoragePoolsPost) (err error)
	UpdateStoragePool(name string, pool api.StoragePoolPut, ETag string) (err error)
	DeleteStoragePool(name string) (err error)

	// Storage volume functions ("storage" API extension)
	GetStoragePoolVolumeNames(pool string) (names []string, err error)
	GetStoragePoolVolumes(pool string) (volumes []api.StorageVolume, err error)
	GetStoragePoolVolume(pool string, volType string, name string) (volume *api.StorageVolume, ETag string, err error)
	CreateStoragePoolVolume(pool string, volume api.StorageVolumesPost) (err error)
	UpdateStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePut, ETag string) (err error)
	DeleteStoragePoolVolume(pool string, volType string, name string) (err error)

	// Internal functions (for internal use)
	RawQuery(method string, path string, data interface{}, queryETag string) (resp *api.Response, ETag string, err error)
	RawWebsocket(path string) (conn *websocket.Conn, err error)
}

The ContainerServer type represents a full featured LXD server.

func ConnectLXD

func ConnectLXD(url string, args *ConnectionArgs) (ContainerServer, error)

ConnectLXD lets you connect to a remote LXD daemon over HTTPs.

A client certificate (TLSClientCert) and key (TLSClientKey) must be provided.

If connecting to a LXD daemon running in PKI mode, the PKI CA (TLSCA) must also be provided.

Unless the remote server is trusted by the system CA, the remote certificate must be provided (TLSServerCert).

func ConnectLXDUnix

func ConnectLXDUnix(path string, args *ConnectionArgs) (ContainerServer, error)

ConnectLXDUnix lets you connect to a remote LXD daemon over a local unix socket.

If the path argument is empty, then $LXD_DIR/unix.socket will be used. If that one isn't set either, then the path will default to /var/lib/lxd/unix.socket.

type ContainerSnapshotCopyArgs

type ContainerSnapshotCopyArgs struct {
	// If set, the container will be renamed on copy
	Name string
}

The ContainerSnapshotCopyArgs struct is used to pass additional options during container copy

type EventListener

type EventListener struct {
	// contains filtered or unexported fields
}

The EventListener struct is used to interact with a LXD event stream

func (*EventListener) AddHandler

func (e *EventListener) AddHandler(types []string, function func(interface{})) (*EventTarget, error)

AddHandler adds a function to be called whenever an event is received

func (*EventListener) Disconnect

func (e *EventListener) Disconnect()

Disconnect must be used once done listening for events

func (*EventListener) RemoveHandler

func (e *EventListener) RemoveHandler(target *EventTarget) error

RemoveHandler removes a function to be called whenever an event is received

func (*EventListener) Wait

func (e *EventListener) Wait() error

Wait hangs until the server disconnects the connection or Disconnect() is called

type EventTarget

type EventTarget struct {
	// contains filtered or unexported fields
}

The EventTarget struct is returned to the caller of AddHandler and used in RemoveHandler

type ImageCopyArgs

type ImageCopyArgs struct {
	// Aliases to add to the copied image.
	Aliases []api.ImageAlias

	// Whether to have LXD keep this image up to date
	AutoUpdate bool

	// Whether to copy the source image aliases to the target
	CopyAliases bool

	// Whether this image is to be made available to unauthenticated users
	Public bool
}

The ImageCopyArgs struct is used to pass additional options during image copy

type ImageCreateArgs

type ImageCreateArgs struct {
	// Reader for the meta file
	MetaFile io.Reader

	// Filename for the meta file
	MetaName string

	// Reader for the rootfs file
	RootfsFile io.Reader

	// Filename for the rootfs file
	RootfsName string

	// Progress handler (called with upload progress)
	ProgressHandler func(progress ProgressData)
}

The ImageCreateArgs struct is used for direct image upload

type ImageFileRequest

type ImageFileRequest struct {
	// Writer for the metadata file
	MetaFile io.WriteSeeker

	// Writer for the rootfs file
	RootfsFile io.WriteSeeker

	// Progress handler (called whenever some progress is made)
	ProgressHandler func(progress ProgressData)

	// A canceler that can be used to interrupt some part of the image download request
	Canceler *cancel.Canceler
}

The ImageFileRequest struct is used for an image download request

type ImageFileResponse

type ImageFileResponse struct {
	// Filename for the metadata file
	MetaName string

	// Size of the metadata file
	MetaSize int64

	// Filename for the rootfs file
	RootfsName string

	// Size of the rootfs file
	RootfsSize int64
}

The ImageFileResponse struct is used as the response for image downloads

type ImageServer

type ImageServer interface {
	Server

	// Image handling functions
	GetImages() (images []api.Image, err error)
	GetImageFingerprints() (fingerprints []string, err error)

	GetImage(fingerprint string) (image *api.Image, ETag string, err error)
	GetImageFile(fingerprint string, req ImageFileRequest) (resp *ImageFileResponse, err error)
	GetImageSecret(fingerprint string) (secret string, err error)

	GetPrivateImage(fingerprint string, secret string) (image *api.Image, ETag string, err error)
	GetPrivateImageFile(fingerprint string, secret string, req ImageFileRequest) (resp *ImageFileResponse, err error)

	GetImageAliases() (aliases []api.ImageAliasesEntry, err error)
	GetImageAliasNames() (names []string, err error)

	GetImageAlias(name string) (alias *api.ImageAliasesEntry, ETag string, err error)
}

The ImageServer type represents a read-only image server.

func ConnectPublicLXD

func ConnectPublicLXD(url string, args *ConnectionArgs) (ImageServer, error)

ConnectPublicLXD lets you connect to a remote public LXD daemon over HTTPs.

Unless the remote server is trusted by the system CA, the remote certificate must be provided (TLSServerCert).

func ConnectSimpleStreams

func ConnectSimpleStreams(url string, args *ConnectionArgs) (ImageServer, error)

ConnectSimpleStreams lets you connect to a remote SimpleStreams image server over HTTPs.

Unless the remote server is trusted by the system CA, the remote certificate must be provided (TLSServerCert).

type Operation

type Operation struct {
	api.Operation
	// contains filtered or unexported fields
}

The Operation type represents an ongoing LXD operation (asynchronous processing)

func (*Operation) AddHandler

func (op *Operation) AddHandler(function func(api.Operation)) (*EventTarget, error)

AddHandler adds a function to be called whenever an event is received

func (*Operation) Cancel

func (op *Operation) Cancel() error

Cancel will request that LXD cancels the operation (if supported)

func (*Operation) GetWebsocket

func (op *Operation) GetWebsocket(secret string) (*websocket.Conn, error)

GetWebsocket returns a raw websocket connection from the operation

func (*Operation) Refresh

func (op *Operation) Refresh() error

Refresh pulls the current version of the operation and updates the struct

func (*Operation) RemoveHandler

func (op *Operation) RemoveHandler(target *EventTarget) error

RemoveHandler removes a function to be called whenever an event is received

func (*Operation) Wait

func (op *Operation) Wait() error

Wait lets you wait until the operation reaches a final state

type ProgressData

type ProgressData struct {
	// Preferred string repreentation of progress (always set)
	Text string

	// Progress in percent
	Percentage int

	// Number of bytes transferred (for files)
	TransferredBytes int64

	// Total number of bytes (for files)
	TotalBytes int64
}

The ProgressData struct represents new progress information on an operation

type ProtocolLXD

type ProtocolLXD struct {
	// contains filtered or unexported fields
}

ProtocolLXD represents a LXD API server

func (*ProtocolLXD) CopyContainer

func (r *ProtocolLXD) CopyContainer(source ContainerServer, container api.Container, args *ContainerCopyArgs) (*RemoteOperation, error)

CopyContainer copies a container from a remote server. Additional options can be passed using ContainerCopyArgs

func (*ProtocolLXD) CopyContainerSnapshot

func (r *ProtocolLXD) CopyContainerSnapshot(source ContainerServer, snapshot api.ContainerSnapshot, args *ContainerSnapshotCopyArgs) (*RemoteOperation, error)

CopyContainerSnapshot copies a snapshot from a remote server into a new container. Additional options can be passed using ContainerCopyArgs

func (*ProtocolLXD) CopyImage

func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (*RemoteOperation, error)

CopyImage copies an image from a remote server. Additional options can be passed using ImageCopyArgs

func (*ProtocolLXD) CreateCertificate

func (r *ProtocolLXD) CreateCertificate(certificate api.CertificatesPost) error

CreateCertificate adds a new certificate to the LXD trust store

func (*ProtocolLXD) CreateContainer

func (r *ProtocolLXD) CreateContainer(container api.ContainersPost) (*Operation, error)

CreateContainer requests that LXD creates a new container

func (*ProtocolLXD) CreateContainerFile

func (r *ProtocolLXD) CreateContainerFile(containerName string, path string, args ContainerFileArgs) error

CreateContainerFile tells LXD to create a file in the container

func (*ProtocolLXD) CreateContainerFromImage

func (r *ProtocolLXD) CreateContainerFromImage(source ImageServer, image api.Image, req api.ContainersPost) (*RemoteOperation, error)

CreateContainerFromImage is a convenience function to make it easier to create a container from an existing image

func (*ProtocolLXD) CreateContainerSnapshot

func (r *ProtocolLXD) CreateContainerSnapshot(containerName string, snapshot api.ContainerSnapshotsPost) (*Operation, error)

CreateContainerSnapshot requests that LXD creates a new snapshot for the container

func (*ProtocolLXD) CreateImage

func (r *ProtocolLXD) CreateImage(image api.ImagesPost, args *ImageCreateArgs) (*Operation, error)

CreateImage requests that LXD creates, copies or import a new image

func (*ProtocolLXD) CreateImageAlias

func (r *ProtocolLXD) CreateImageAlias(alias api.ImageAliasesPost) error

CreateImageAlias sets up a new image alias

func (*ProtocolLXD) CreateImageSecret

func (r *ProtocolLXD) CreateImageSecret(fingerprint string) (*Operation, error)

CreateImageSecret requests that LXD issues a temporary image secret

func (*ProtocolLXD) CreateNetwork

func (r *ProtocolLXD) CreateNetwork(network api.NetworksPost) error

CreateNetwork defines a new network using the provided Network struct

func (*ProtocolLXD) CreateProfile

func (r *ProtocolLXD) CreateProfile(profile api.ProfilesPost) error

CreateProfile defines a new container profile

func (*ProtocolLXD) CreateStoragePool

func (r *ProtocolLXD) CreateStoragePool(pool api.StoragePoolsPost) error

CreateStoragePool defines a new storage pool using the provided StoragePool struct

func (*ProtocolLXD) CreateStoragePoolVolume

func (r *ProtocolLXD) CreateStoragePoolVolume(pool string, volume api.StorageVolumesPost) error

CreateStoragePoolVolume defines a new storage volume

func (*ProtocolLXD) DeleteCertificate

func (r *ProtocolLXD) DeleteCertificate(fingerprint string) error

DeleteCertificate removes a certificate from the LXD trust store

func (*ProtocolLXD) DeleteContainer

func (r *ProtocolLXD) DeleteContainer(name string) (*Operation, error)

DeleteContainer requests that LXD deletes the container

func (*ProtocolLXD) DeleteContainerFile

func (r *ProtocolLXD) DeleteContainerFile(containerName string, path string) error

DeleteContainerFile deletes a file in the container

func (*ProtocolLXD) DeleteContainerLogfile

func (r *ProtocolLXD) DeleteContainerLogfile(name string, filename string) error

DeleteContainerLogfile deletes the requested logfile

func (*ProtocolLXD) DeleteContainerSnapshot

func (r *ProtocolLXD) DeleteContainerSnapshot(containerName string, name string) (*Operation, error)

DeleteContainerSnapshot requests that LXD deletes the container snapshot

func (*ProtocolLXD) DeleteImage

func (r *ProtocolLXD) DeleteImage(fingerprint string) (*Operation, error)

DeleteImage requests that LXD removes an image from the store

func (*ProtocolLXD) DeleteImageAlias

func (r *ProtocolLXD) DeleteImageAlias(name string) error

DeleteImageAlias removes an alias from the LXD image store

func (*ProtocolLXD) DeleteNetwork

func (r *ProtocolLXD) DeleteNetwork(name string) error

DeleteNetwork deletes an existing network

func (*ProtocolLXD) DeleteOperation

func (r *ProtocolLXD) DeleteOperation(uuid string) error

DeleteOperation deletes (cancels) a running operation

func (*ProtocolLXD) DeleteProfile

func (r *ProtocolLXD) DeleteProfile(name string) error

DeleteProfile deletes a profile

func (*ProtocolLXD) DeleteStoragePool

func (r *ProtocolLXD) DeleteStoragePool(name string) error

DeleteStoragePool deletes a storage pool

func (*ProtocolLXD) DeleteStoragePoolVolume

func (r *ProtocolLXD) DeleteStoragePoolVolume(pool string, volType string, name string) error

DeleteStoragePoolVolume deletes a storage pool

func (*ProtocolLXD) ExecContainer

func (r *ProtocolLXD) ExecContainer(containerName string, exec api.ContainerExecPost, args *ContainerExecArgs) (*Operation, error)

ExecContainer requests that LXD spawns a command inside the container

func (*ProtocolLXD) GetCertificate

func (r *ProtocolLXD) GetCertificate(fingerprint string) (*api.Certificate, string, error)

GetCertificate returns the certificate entry for the provided fingerprint

func (*ProtocolLXD) GetCertificateFingerprints

func (r *ProtocolLXD) GetCertificateFingerprints() ([]string, error)

GetCertificateFingerprints returns a list of certificate fingerprints

func (*ProtocolLXD) GetCertificates

func (r *ProtocolLXD) GetCertificates() ([]api.Certificate, error)

GetCertificates returns a list of certificates

func (*ProtocolLXD) GetConnectionInfo

func (r *ProtocolLXD) GetConnectionInfo() (*ConnectionInfo, error)

GetConnectionInfo returns the basic connection information used to interact with the server

func (*ProtocolLXD) GetContainer

func (r *ProtocolLXD) GetContainer(name string) (*api.Container, string, error)

GetContainer returns the container entry for the provided name

func (*ProtocolLXD) GetContainerFile

func (r *ProtocolLXD) GetContainerFile(containerName string, path string) (io.ReadCloser, *ContainerFileResponse, error)

GetContainerFile retrieves the provided path from the container

func (*ProtocolLXD) GetContainerLogfile

func (r *ProtocolLXD) GetContainerLogfile(name string, filename string) (io.ReadCloser, error)

GetContainerLogfile returns the content of the requested logfile

Note that it's the caller's responsibility to close the returned ReadCloser

func (*ProtocolLXD) GetContainerLogfiles

func (r *ProtocolLXD) GetContainerLogfiles(name string) ([]string, error)

GetContainerLogfiles returns a list of logfiles for the container

func (*ProtocolLXD) GetContainerNames

func (r *ProtocolLXD) GetContainerNames() ([]string, error)

GetContainerNames returns a list of container names

func (*ProtocolLXD) GetContainerSnapshot

func (r *ProtocolLXD) GetContainerSnapshot(containerName string, name string) (*api.ContainerSnapshot, string, error)

GetContainerSnapshot returns a Snapshot struct for the provided container and snapshot names

func (*ProtocolLXD) GetContainerSnapshotNames

func (r *ProtocolLXD) GetContainerSnapshotNames(containerName string) ([]string, error)

GetContainerSnapshotNames returns a list of snapshot names for the container

func (*ProtocolLXD) GetContainerSnapshots

func (r *ProtocolLXD) GetContainerSnapshots(containerName string) ([]api.ContainerSnapshot, error)

GetContainerSnapshots returns a list of snapshots for the container

func (*ProtocolLXD) GetContainerState

func (r *ProtocolLXD) GetContainerState(name string) (*api.ContainerState, string, error)

GetContainerState returns a ContainerState entry for the provided container name

func (*ProtocolLXD) GetContainers

func (r *ProtocolLXD) GetContainers() ([]api.Container, error)

GetContainers returns a list of containers

func (*ProtocolLXD) GetEvents

func (r *ProtocolLXD) GetEvents() (*EventListener, error)

GetEvents connects to the LXD monitoring interface

func (*ProtocolLXD) GetImage

func (r *ProtocolLXD) GetImage(fingerprint string) (*api.Image, string, error)

GetImage returns an Image struct for the provided fingerprint

func (*ProtocolLXD) GetImageAlias

func (r *ProtocolLXD) GetImageAlias(name string) (*api.ImageAliasesEntry, string, error)

GetImageAlias returns an existing alias as an ImageAliasesEntry struct

func (*ProtocolLXD) GetImageAliasNames

func (r *ProtocolLXD) GetImageAliasNames() ([]string, error)

GetImageAliasNames returns the list of available alias names

func (*ProtocolLXD) GetImageAliases

func (r *ProtocolLXD) GetImageAliases() ([]api.ImageAliasesEntry, error)

GetImageAliases returns the list of available aliases as ImageAliasesEntry structs

func (*ProtocolLXD) GetImageFile

func (r *ProtocolLXD) GetImageFile(fingerprint string, req ImageFileRequest) (*ImageFileResponse, error)

GetImageFile downloads an image from the server, returning an ImageFileRequest struct

func (*ProtocolLXD) GetImageFingerprints

func (r *ProtocolLXD) GetImageFingerprints() ([]string, error)

GetImageFingerprints returns a list of available image fingerprints

func (*ProtocolLXD) GetImageSecret

func (r *ProtocolLXD) GetImageSecret(fingerprint string) (string, error)

GetImageSecret is a helper around CreateImageSecret that returns a secret for the image

func (*ProtocolLXD) GetImages

func (r *ProtocolLXD) GetImages() ([]api.Image, error)

GetImages returns a list of available images as Image structs

func (*ProtocolLXD) GetNetwork

func (r *ProtocolLXD) GetNetwork(name string) (*api.Network, string, error)

GetNetwork returns a Network entry for the provided name

func (*ProtocolLXD) GetNetworkNames

func (r *ProtocolLXD) GetNetworkNames() ([]string, error)

GetNetworkNames returns a list of network names

func (*ProtocolLXD) GetNetworks

func (r *ProtocolLXD) GetNetworks() ([]api.Network, error)

GetNetworks returns a list of Network struct

func (*ProtocolLXD) GetOperation

func (r *ProtocolLXD) GetOperation(uuid string) (*api.Operation, string, error)

GetOperation returns an Operation entry for the provided uuid

func (*ProtocolLXD) GetOperationWebsocket

func (r *ProtocolLXD) GetOperationWebsocket(uuid string, secret string) (*websocket.Conn, error)

GetOperationWebsocket returns a websocket connection for the provided operation

func (*ProtocolLXD) GetPrivateImage

func (r *ProtocolLXD) GetPrivateImage(fingerprint string, secret string) (*api.Image, string, error)

GetPrivateImage is similar to GetImage but allows passing a secret download token

func (*ProtocolLXD) GetPrivateImageFile

func (r *ProtocolLXD) GetPrivateImageFile(fingerprint string, secret string, req ImageFileRequest) (*ImageFileResponse, error)

GetPrivateImageFile is similar to GetImageFile but allows passing a secret download token

func (*ProtocolLXD) GetProfile

func (r *ProtocolLXD) GetProfile(name string) (*api.Profile, string, error)

GetProfile returns a Profile entry for the provided name

func (*ProtocolLXD) GetProfileNames

func (r *ProtocolLXD) GetProfileNames() ([]string, error)

GetProfileNames returns a list of available profile names

func (*ProtocolLXD) GetProfiles

func (r *ProtocolLXD) GetProfiles() ([]api.Profile, error)

GetProfiles returns a list of available Profile structs

func (*ProtocolLXD) GetServer

func (r *ProtocolLXD) GetServer() (*api.Server, string, error)

GetServer returns the server status as a Server struct

func (*ProtocolLXD) GetStoragePool

func (r *ProtocolLXD) GetStoragePool(name string) (*api.StoragePool, string, error)

GetStoragePool returns a StoragePool entry for the provided pool name

func (*ProtocolLXD) GetStoragePoolNames

func (r *ProtocolLXD) GetStoragePoolNames() ([]string, error)

GetStoragePoolNames returns the names of all storage pools

func (*ProtocolLXD) GetStoragePoolVolume

func (r *ProtocolLXD) GetStoragePoolVolume(pool string, volType string, name string) (*api.StorageVolume, string, error)

GetStoragePoolVolume returns a StorageVolume entry for the provided pool and volume name

func (*ProtocolLXD) GetStoragePoolVolumeNames

func (r *ProtocolLXD) GetStoragePoolVolumeNames(pool string) ([]string, error)

GetStoragePoolVolumeNames returns the names of all volumes in a pool

func (*ProtocolLXD) GetStoragePoolVolumes

func (r *ProtocolLXD) GetStoragePoolVolumes(pool string) ([]api.StorageVolume, error)

GetStoragePoolVolumes returns a list of StorageVolume entries for the provided pool

func (*ProtocolLXD) GetStoragePools

func (r *ProtocolLXD) GetStoragePools() ([]api.StoragePool, error)

GetStoragePools returns a list of StoragePool entries

func (*ProtocolLXD) HasExtension

func (r *ProtocolLXD) HasExtension(extension string) bool

HasExtension returns true if the server supports a given API extension

func (*ProtocolLXD) MigrateContainer

func (r *ProtocolLXD) MigrateContainer(name string, container api.ContainerPost) (*Operation, error)

MigrateContainer requests that LXD prepares for a container migration

func (*ProtocolLXD) MigrateContainerSnapshot

func (r *ProtocolLXD) MigrateContainerSnapshot(containerName string, name string, container api.ContainerSnapshotPost) (*Operation, error)

MigrateContainerSnapshot requests that LXD prepares for a snapshot migration

func (*ProtocolLXD) RawQuery

func (r *ProtocolLXD) RawQuery(method string, path string, data interface{}, ETag string) (*api.Response, string, error)

RawQuery allows directly querying the LXD API

This should only be used by internal LXD tools.

func (*ProtocolLXD) RawWebsocket

func (r *ProtocolLXD) RawWebsocket(path string) (*websocket.Conn, error)

RawWebsocket allows directly connection to LXD API websockets

This should only be used by internal LXD tools.

func (*ProtocolLXD) RefreshImage

func (r *ProtocolLXD) RefreshImage(fingerprint string) (*Operation, error)

RefreshImage requests that LXD issues an image refresh

func (*ProtocolLXD) RenameContainer

func (r *ProtocolLXD) RenameContainer(name string, container api.ContainerPost) (*Operation, error)

RenameContainer requests that LXD renames the container

func (*ProtocolLXD) RenameContainerSnapshot

func (r *ProtocolLXD) RenameContainerSnapshot(containerName string, name string, container api.ContainerSnapshotPost) (*Operation, error)

RenameContainerSnapshot requests that LXD renames the snapshot

func (*ProtocolLXD) RenameImageAlias

func (r *ProtocolLXD) RenameImageAlias(name string, alias api.ImageAliasesEntryPost) error

RenameImageAlias renames an existing image alias

func (*ProtocolLXD) RenameNetwork

func (r *ProtocolLXD) RenameNetwork(name string, network api.NetworkPost) error

RenameNetwork renames an existing network entry

func (*ProtocolLXD) RenameProfile

func (r *ProtocolLXD) RenameProfile(name string, profile api.ProfilePost) error

RenameProfile renames an existing profile entry

func (*ProtocolLXD) UpdateCertificate

func (r *ProtocolLXD) UpdateCertificate(fingerprint string, certificate api.CertificatePut, ETag string) error

UpdateCertificate updates the certificate definition

func (*ProtocolLXD) UpdateContainer

func (r *ProtocolLXD) UpdateContainer(name string, container api.ContainerPut, ETag string) (*Operation, error)

UpdateContainer updates the container definition

func (*ProtocolLXD) UpdateContainerState

func (r *ProtocolLXD) UpdateContainerState(name string, state api.ContainerStatePut, ETag string) (*Operation, error)

UpdateContainerState updates the container to match the requested state

func (*ProtocolLXD) UpdateImage

func (r *ProtocolLXD) UpdateImage(fingerprint string, image api.ImagePut, ETag string) error

UpdateImage updates the image definition

func (*ProtocolLXD) UpdateImageAlias

func (r *ProtocolLXD) UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) error

UpdateImageAlias updates the image alias definition

func (*ProtocolLXD) UpdateNetwork

func (r *ProtocolLXD) UpdateNetwork(name string, network api.NetworkPut, ETag string) error

UpdateNetwork updates the network to match the provided Network struct

func (*ProtocolLXD) UpdateProfile

func (r *ProtocolLXD) UpdateProfile(name string, profile api.ProfilePut, ETag string) error

UpdateProfile updates the profile to match the provided Profile struct

func (*ProtocolLXD) UpdateServer

func (r *ProtocolLXD) UpdateServer(server api.ServerPut, ETag string) error

UpdateServer updates the server status to match the provided Server struct

func (*ProtocolLXD) UpdateStoragePool

func (r *ProtocolLXD) UpdateStoragePool(name string, pool api.StoragePoolPut, ETag string) error

UpdateStoragePool updates the pool to match the provided StoragePool struct

func (*ProtocolLXD) UpdateStoragePoolVolume

func (r *ProtocolLXD) UpdateStoragePoolVolume(pool string, volType string, name string, volume api.StorageVolumePut, ETag string) error

UpdateStoragePoolVolume updates the volume to match the provided StoragePoolVolume struct

type ProtocolSimpleStreams

type ProtocolSimpleStreams struct {
	// contains filtered or unexported fields
}

ProtocolSimpleStreams implements a SimpleStreams API client

func (*ProtocolSimpleStreams) GetConnectionInfo

func (r *ProtocolSimpleStreams) GetConnectionInfo() (*ConnectionInfo, error)

GetConnectionInfo returns the basic connection information used to interact with the server

func (*ProtocolSimpleStreams) GetImage

func (r *ProtocolSimpleStreams) GetImage(fingerprint string) (*api.Image, string, error)

GetImage returns an Image struct for the provided fingerprint

func (*ProtocolSimpleStreams) GetImageAlias

func (r *ProtocolSimpleStreams) GetImageAlias(name string) (*api.ImageAliasesEntry, string, error)

GetImageAlias returns an existing alias as an ImageAliasesEntry struct

func (*ProtocolSimpleStreams) GetImageAliasNames

func (r *ProtocolSimpleStreams) GetImageAliasNames() ([]string, error)

GetImageAliasNames returns the list of available alias names

func (*ProtocolSimpleStreams) GetImageAliases

func (r *ProtocolSimpleStreams) GetImageAliases() ([]api.ImageAliasesEntry, error)

GetImageAliases returns the list of available aliases as ImageAliasesEntry structs

func (*ProtocolSimpleStreams) GetImageFile

func (r *ProtocolSimpleStreams) GetImageFile(fingerprint string, req ImageFileRequest) (*ImageFileResponse, error)

GetImageFile downloads an image from the server, returning an ImageFileResponse struct

func (*ProtocolSimpleStreams) GetImageFingerprints

func (r *ProtocolSimpleStreams) GetImageFingerprints() ([]string, error)

GetImageFingerprints returns a list of available image fingerprints

func (*ProtocolSimpleStreams) GetImageSecret

func (r *ProtocolSimpleStreams) GetImageSecret(fingerprint string) (string, error)

GetImageSecret isn't relevant for the simplestreams protocol

func (*ProtocolSimpleStreams) GetImages

func (r *ProtocolSimpleStreams) GetImages() ([]api.Image, error)

GetImages returns a list of available images as Image structs

func (*ProtocolSimpleStreams) GetPrivateImage

func (r *ProtocolSimpleStreams) GetPrivateImage(fingerprint string, secret string) (*api.Image, string, error)

GetPrivateImage isn't relevant for the simplestreams protocol

func (*ProtocolSimpleStreams) GetPrivateImageFile

func (r *ProtocolSimpleStreams) GetPrivateImageFile(fingerprint string, secret string, req ImageFileRequest) (*ImageFileResponse, error)

GetPrivateImageFile isn't relevant for the simplestreams protocol

type RemoteOperation

type RemoteOperation struct {
	// contains filtered or unexported fields
}

The RemoteOperation type represents an ongoing LXD operation between two servers

func (*RemoteOperation) AddHandler

func (op *RemoteOperation) AddHandler(function func(api.Operation)) (*EventTarget, error)

AddHandler adds a function to be called whenever an event is received

func (*RemoteOperation) GetTarget

func (op *RemoteOperation) GetTarget() (*api.Operation, error)

GetTarget returns the target operation

func (*RemoteOperation) Wait

func (op *RemoteOperation) Wait() error

Wait lets you wait until the operation reaches a final state

type Server

type Server interface {
	GetConnectionInfo() (info *ConnectionInfo, err error)
}

The Server type represents a generic read-only server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL