Documentation ¶
Overview ¶
DEPRECATED: This package is now deprecated in favor of github.com/lxc/lxd/client
This package will be entirely removed from the code tree with LXD 2.16
Index ¶
- Variables
- func GetLocalLXDErr(err error) error
- func HoistResponse(r *http.Response, rtype api.ResponseType) (*api.Response, error)
- func ParseResponse(r *http.Response) (*api.Response, error)
- func SaveConfig(c *Config, fname string) error
- func WebsocketDial(dialer websocket.Dialer, url string) (*websocket.Conn, error)
- type Client
- func (c *Client) Action(name string, action shared.ContainerAction, timeout int, force bool, ...) (*api.Response, error)
- func (c *Client) AddMyCertToServer(pwd string) error
- func (c *Client) Addresses() ([]string, error)
- func (c *Client) AmTrusted() bool
- func (c *Client) AssignProfile(container, profile string) (*api.Response, error)
- func (c *Client) AsyncWaitMeta(resp *api.Response) (map[string]interface{}, error)
- func (c *Client) CertificateAdd(cert *x509.Certificate, name string) error
- func (c *Client) CertificateList() ([]api.Certificate, error)
- func (c *Client) CertificateRemove(fingerprint string) error
- func (c *Client) ContainerDeviceAdd(container, devname, devtype string, props []string) (*api.Response, error)
- func (c *Client) ContainerDeviceDelete(container, devname string) (*api.Response, error)
- func (c *Client) ContainerInfo(name string) (*api.Container, error)
- func (c *Client) ContainerListDevices(container string) ([]string, error)
- func (c *Client) ContainerState(name string) (*api.ContainerState, error)
- func (c *Client) CopyImage(image string, dest *Client, copy_aliases bool, aliases []string, public bool, ...) error
- func (c *Client) Delete(name string) (*api.Response, error)
- func (c *Client) DeleteAlias(alias string) error
- func (c *Client) DeleteFile(container string, p string) error
- func (c *Client) DeleteImage(image string) error
- func (c *Client) Exec(name string, cmd []string, env map[string]string, stdin io.ReadCloser, ...) (int, error)
- func (c *Client) ExportImage(image string, target string) (string, error)
- func (c *Client) GetAlias(alias string) string
- func (c *Client) GetContainerConfig(container string) ([]string, error)
- func (c *Client) GetImageInfo(image string) (*api.Image, error)
- func (c *Client) GetLog(container string, log string) (io.Reader, error)
- func (c *Client) GetMigrationSourceWS(container string, stateful bool, containerOnly bool) (*api.Response, error)
- func (c *Client) GetOperation(url string) (*api.Operation, error)
- func (c *Client) GetProfileConfig(profile string) (map[string]string, error)
- func (c *Client) GetServerConfig() (*api.Response, error)
- func (c *Client) GetServerConfigString() ([]string, error)
- func (c *Client) ImageFromContainer(cname string, public bool, aliases []string, properties map[string]string, ...) (string, error)
- func (c *Client) Init(name string, imgremote string, image string, profiles *[]string, ...) (*api.Response, error)
- func (c *Client) IsAlias(alias string) (bool, error)
- func (c *Client) IsPublic() bool
- func (c *Client) ListAliases() ([]api.ImageAliasesEntry, error)
- func (c *Client) ListContainers() ([]api.Container, error)
- func (c *Client) ListImages() ([]api.Image, error)
- func (c *Client) ListNetworks() ([]api.Network, error)
- func (c *Client) ListProfiles() ([]api.Profile, error)
- func (c *Client) ListSnapshots(container string) ([]api.ContainerSnapshot, error)
- func (c *Client) ListStoragePools() ([]api.StoragePool, error)
- func (c *Client) LocalCopy(source string, name string, config map[string]string, profiles []string, ...) (*api.Response, error)
- func (c *Client) MigrateFrom(name string, operation string, certificate string, ...) (*api.Response, error)
- func (c *Client) Mkdir(container string, p string, mode os.FileMode, uid int, gid int) error
- func (c *Client) MkdirP(container string, p string, mode os.FileMode, uid int, gid int) error
- func (c *Client) Monitor(types []string, handler func(interface{}), done chan bool) error
- func (c *Client) NetworkCreate(name string, config map[string]string) error
- func (c *Client) NetworkDelete(name string) error
- func (c *Client) NetworkGet(name string) (api.Network, error)
- func (c *Client) NetworkPut(name string, network api.NetworkPut) error
- func (c *Client) PostAlias(alias string, desc string, target string) error
- func (c *Client) PostImage(imageFile string, rootfsFile string, properties []string, public bool, ...) (string, error)
- func (c *Client) PostImageURL(imageFile string, properties []string, public bool, aliases []string, ...) (string, error)
- func (c *Client) ProfileConfig(name string) (*api.Profile, error)
- func (c *Client) ProfileCopy(name, newname string, dest *Client) error
- func (c *Client) ProfileCreate(p string) error
- func (c *Client) ProfileDelete(p string) error
- func (c *Client) ProfileDeviceAdd(profile, devname, devtype string, props []string) (*api.Response, error)
- func (c *Client) ProfileDeviceDelete(profile, devname string) (*api.Response, error)
- func (c *Client) ProfileListDevices(profile string) ([]string, error)
- func (c *Client) PullFile(container string, p string) (int64, int64, int, string, io.ReadCloser, []string, error)
- func (c *Client) PushFile(container string, p string, gid int, uid int, mode string, buf io.ReadSeeker) error
- func (c *Client) PutImageInfo(name string, p api.ImagePut) error
- func (c *Client) PutProfile(name string, profile api.ProfilePut) error
- func (c *Client) RecursivePullFile(container string, p string, targetDir string) error
- func (c *Client) RecursivePushFile(container string, source string, target string) error
- func (c *Client) RefreshImage(image string, progressHandler func(progress string)) (bool, error)
- func (c *Client) Rename(name string, newName string) (*api.Response, error)
- func (c *Client) RestoreSnapshot(container string, snapshotName string, stateful bool) (*api.Response, error)
- func (c *Client) ServerStatus() (*api.Server, error)
- func (c *Client) SetContainerConfig(container, key, value string) error
- func (c *Client) SetProfileConfigItem(profile, key, value string) error
- func (c *Client) SetServerConfig(key string, value string) (*api.Response, error)
- func (c *Client) Snapshot(container string, snapshotName string, stateful bool) (*api.Response, error)
- func (c *Client) SnapshotInfo(snapName string) (*api.ContainerSnapshot, error)
- func (c *Client) StoragePoolCreate(name string, driver string, config map[string]string) error
- func (c *Client) StoragePoolDelete(name string) error
- func (c *Client) StoragePoolGet(name string) (api.StoragePool, error)
- func (c *Client) StoragePoolPut(name string, pool api.StoragePool) error
- func (c *Client) StoragePoolVolumeTypeCreate(pool string, volume string, volumeType string, config map[string]string) error
- func (c *Client) StoragePoolVolumeTypeDelete(pool string, volume string, volumeType string) error
- func (c *Client) StoragePoolVolumeTypeGet(pool string, volume string, volumeType string) (api.StorageVolume, error)
- func (c *Client) StoragePoolVolumeTypePut(pool string, volume string, volumeType string, volumeConfig api.StorageVolume) error
- func (c *Client) StoragePoolVolumesList(pool string) ([]api.StorageVolume, error)
- func (c *Client) UpdateContainerConfig(container string, st api.ContainerPut) error
- func (c *Client) UpdateServerConfig(ss api.ServerPut) (*api.Response, error)
- func (c *Client) WaitFor(waitURL string) (*api.Operation, error)
- func (c *Client) WaitForSuccess(waitURL string) error
- func (c *Client) WaitForSuccessOp(waitURL string) (*api.Operation, error)
- func (c *Client) Websocket(operation string, secret string) (*websocket.Conn, error)
- type Config
- type ConnectInfo
- type RemoteConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ Remotes: DefaultRemotes, DefaultRemote: "local"}
var DefaultRemotes = map[string]RemoteConfig{ "images": ImagesRemote, "local": LocalRemote, "ubuntu": UbuntuRemote, "ubuntu-daily": UbuntuDailyRemote}
var ImagesRemote = RemoteConfig{ Addr: "https://images.linuxcontainers.org", Public: true, Protocol: "simplestreams"}
var ( // LXDErrors are special errors; the client library hoists error codes // to these errors internally so that user code can compare against // them. We probably shouldn't hoist BadRequest or InternalError, since // LXD passes an error string along which is more informative than // whatever static error message we would put here. LXDErrors = map[int]error{ http.StatusNotFound: fmt.Errorf("not found"), } )
var LocalRemote = RemoteConfig{ Addr: "unix://", Static: true, Public: false}
var StaticRemotes = map[string]RemoteConfig{ "local": LocalRemote, "ubuntu": UbuntuRemote, "ubuntu-daily": UbuntuDailyRemote}
var UbuntuDailyRemote = RemoteConfig{ Addr: "https://cloud-images.ubuntu.com/daily", Static: true, Public: true, Protocol: "simplestreams"}
var UbuntuRemote = RemoteConfig{ Addr: "https://cloud-images.ubuntu.com/releases", Static: true, Public: true, Protocol: "simplestreams"}
Functions ¶
func GetLocalLXDErr ¶
GetLocalLXDErr determines whether or not an error is likely due to a local LXD configuration issue, and if so, returns the underlying error. GetLocalLXDErr can be used to provide customized error messages to help the user identify basic system issues, e.g. LXD daemon not running.
Returns syscall.ENOENT, syscall.ECONNREFUSED or syscall.EACCES when a local LXD configuration issue is detected, nil otherwise.
func HoistResponse ¶
HoistResponse hoists a regular http response into a response of type rtype or returns a golang error.
func ParseResponse ¶
ParseResponse parses a lxd style response out of an http.Response. Note that this does _not_ automatically convert error responses to golang errors. To do that, use ParseError. Internal client library uses should probably use HoistResponse, unless they are interested in accessing the underlying Error response (e.g. to inspect the error code).
func SaveConfig ¶
SaveConfig writes the provided configuration to the config file.
Types ¶
type Client ¶
type Client struct { BaseURL string BaseWSURL string Config Config Name string Remote *RemoteConfig Transport string Certificate string Http http.Client // contains filtered or unexported fields }
Client can talk to a LXD daemon.
func NewClientFromInfo ¶
func NewClientFromInfo(info ConnectInfo) (*Client, error)
NewClientFromInfo returns a new LXD client.
func (*Client) AddMyCertToServer ¶
func (*Client) AssignProfile ¶
func (*Client) AsyncWaitMeta ¶
func (*Client) CertificateAdd ¶
func (c *Client) CertificateAdd(cert *x509.Certificate, name string) error
func (*Client) CertificateList ¶
func (c *Client) CertificateList() ([]api.Certificate, error)
func (*Client) CertificateRemove ¶
func (*Client) ContainerDeviceAdd ¶
func (*Client) ContainerDeviceDelete ¶
func (*Client) ContainerListDevices ¶
func (*Client) ContainerState ¶
func (c *Client) ContainerState(name string) (*api.ContainerState, error)
func (*Client) DeleteAlias ¶
func (*Client) DeleteImage ¶
func (*Client) Exec ¶
func (c *Client) Exec(name string, cmd []string, env map[string]string, stdin io.ReadCloser, stdout io.WriteCloser, stderr io.WriteCloser, controlHandler func(*Client, *websocket.Conn), width int, height int) (int, error)
Exec runs a command inside the LXD container. For "interactive" use such as `lxc exec ...`, one should pass a controlHandler that talks over the control socket and handles things like SIGWINCH. If running non-interactive, passing a nil controlHandler will cause Exec to return when all of the command output is sent to the output buffers.
func (*Client) ExportImage ¶
func (*Client) GetContainerConfig ¶
* return string array representing a container's full configuration
func (*Client) GetMigrationSourceWS ¶
func (*Client) GetProfileConfig ¶
func (*Client) GetServerConfigString ¶
func (*Client) ImageFromContainer ¶
func (*Client) Init ¶
func (c *Client) Init(name string, imgremote string, image string, profiles *[]string, config map[string]string, devices map[string]map[string]string, ephem bool) (*api.Response, error)
Init creates a container from either a fingerprint or an alias; you must provide at least one.
func (*Client) ListAliases ¶
func (c *Client) ListAliases() ([]api.ImageAliasesEntry, error)
func (*Client) ListSnapshots ¶
func (c *Client) ListSnapshots(container string) ([]api.ContainerSnapshot, error)
func (*Client) ListStoragePools ¶
func (c *Client) ListStoragePools() ([]api.StoragePool, error)
Storage functions
func (*Client) MigrateFrom ¶
func (c *Client) MigrateFrom(name string, operation string, certificate string, sourceSecrets map[string]string, architecture string, config map[string]string, devices map[string]map[string]string, profiles []string, baseImage string, ephemeral bool, push bool, sourceClient *Client, sourceOperation string, containerOnly bool) (*api.Response, error)
func (*Client) NetworkCreate ¶
Network functions
func (*Client) NetworkDelete ¶
func (*Client) NetworkPut ¶
func (c *Client) NetworkPut(name string, network api.NetworkPut) error
func (*Client) PostImageURL ¶
func (*Client) ProfileCreate ¶
func (*Client) ProfileDelete ¶
func (*Client) ProfileDeviceAdd ¶
func (*Client) ProfileDeviceDelete ¶
func (*Client) ProfileListDevices ¶
func (*Client) PutProfile ¶
func (c *Client) PutProfile(name string, profile api.ProfilePut) error
func (*Client) RecursivePullFile ¶
func (*Client) RecursivePushFile ¶
func (*Client) RefreshImage ¶
Refresh an image. Return a bool indicating whether the image was actually refreshed.
func (*Client) RestoreSnapshot ¶
func (*Client) SetContainerConfig ¶
func (*Client) SetProfileConfigItem ¶
func (*Client) SetServerConfig ¶
func (*Client) SnapshotInfo ¶
func (c *Client) SnapshotInfo(snapName string) (*api.ContainerSnapshot, error)
func (*Client) StoragePoolCreate ¶
func (*Client) StoragePoolDelete ¶
func (*Client) StoragePoolGet ¶
func (c *Client) StoragePoolGet(name string) (api.StoragePool, error)
func (*Client) StoragePoolPut ¶
func (c *Client) StoragePoolPut(name string, pool api.StoragePool) error
func (*Client) StoragePoolVolumeTypeCreate ¶
func (c *Client) StoragePoolVolumeTypeCreate(pool string, volume string, volumeType string, config map[string]string) error
/1.0/storage-pools/{pool}/volumes/{volume_type}
func (*Client) StoragePoolVolumeTypeDelete ¶
/1.0/storage-pools/{pool}/volumes/{type}/{name}
func (*Client) StoragePoolVolumeTypeGet ¶
func (c *Client) StoragePoolVolumeTypeGet(pool string, volume string, volumeType string) (api.StorageVolume, error)
/1.0/storage-pools/{pool}/volumes/{type}/{name}
func (*Client) StoragePoolVolumeTypePut ¶
func (c *Client) StoragePoolVolumeTypePut(pool string, volume string, volumeType string, volumeConfig api.StorageVolume) error
/1.0/storage-pools/{pool}/volumes/{type}/{name}
func (*Client) StoragePoolVolumesList ¶
func (c *Client) StoragePoolVolumesList(pool string) ([]api.StorageVolume, error)
/1.0/storage-pools/{name}/volumes
func (*Client) UpdateContainerConfig ¶
func (c *Client) UpdateContainerConfig(container string, st api.ContainerPut) error
func (*Client) UpdateServerConfig ¶
func (*Client) WaitForSuccess ¶
func (*Client) WaitForSuccessOp ¶
type Config ¶
type Config struct { // DefaultRemote holds the remote daemon name from the Remotes map // that the client should communicate with by default. // If empty it defaults to "local". DefaultRemote string `yaml:"default-remote"` // Remotes defines a map of remote daemon names to the details for // communication with the named daemon. // The implicit "local" remote is always available and communicates // with the local daemon over a unix socket. Remotes map[string]RemoteConfig `yaml:"remotes"` // Command line aliases for `lxc` Aliases map[string]string `yaml:"aliases"` // This is the path to the config directory, so the client can find // previously stored server certs, give good error messages, and save // new server certs, etc. // // We don't need to store it, because of course once we've loaded this // structure we already know where it is :) ConfigDir string `yaml:"-"` }
Config holds settings to be used by a client or daemon.
func LoadConfig ¶
LoadConfig reads the configuration from the config path; if the path does not exist, it returns a default configuration.
func (*Config) ConfigPath ¶
func (*Config) ParseRemote ¶
func (*Config) ParseRemoteAndContainer ¶
func (*Config) ServerCertPath ¶
type ConnectInfo ¶
type ConnectInfo struct { // Name is a simple identifier for the remote server. In 'lxc' it is // the name used to lookup the address and other information in the // config.yml file. Name string // RemoteConfig is the information about the Remote that we are // connecting to. This includes information like if the remote is // Public and/or Static. RemoteConfig RemoteConfig // ClientPEMCert is the PEM encoded bytes of the client's certificate. // If Addr indicates a Unix socket, the certificate and key bytes will // not be used. ClientPEMCert string // ClientPEMKey is the PEM encoded private bytes of the client's key associated with its certificate ClientPEMKey string // ClientPEMCa is the PEM encoded client certificate authority (if any) ClientPEMCa string // ServerPEMCert is the PEM encoded server certificate that we are // connecting to. It can be the empty string if we do not know the // server's certificate yet. ServerPEMCert string }
ConnectInfo contains the information we need to connect to a specific LXD server
Directories ¶
Path | Synopsis |
---|---|
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.
|
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. |
* * This file is a bit funny.
|
* * This file is a bit funny. |
That this code needs to exist is kind of dumb, but I'm not sure how else to do it.
|
That this code needs to exist is kind of dumb, but I'm not sure how else to do it. |
api
Package api contains Go structs for all LXD API objects Overview This package has Go structs for every API object, all the various structs are named after the object they represent and some variations of those structs exist for initial object creation, object update and object retrieval.
|
Package api contains Go structs for all LXD API objects Overview This package has Go structs for every API object, all the various structs are named after the object they represent and some variations of those structs exist for initial object creation, object update and object retrieval. |
gnuflag
Package gnuflag implements command-line flag parsing in the GNU style.
|
Package gnuflag implements command-line flag parsing in the GNU style. |
test
|
|