Documentation
¶
Overview ¶
Package lxdclient provides initialization code for connecting to an LXD server, using the same configuration as used by the "lxc" command.
If using the unix socket, connect via the path:
$LXD_SOCKET, if defined
Otherwise, the first of these that exists:
- $LXD_DIR/unix.socket
- /var/lib/unix.socket
- /var/snap/lxd/common/lxd/unix.socket
Otherwise, lxdclient looks for a config directory:
$LXD_CONF, if defined
Otherwise, the first of these that exists:
- os.UserConfigDir()/lxc
- $os.UserHomeDir()/snap/lxd/common/config
- the path returned by github.com/lxc/lxd lxc/config.Config.GlobalConfigPath():
GlobalConfigPath
- $LXD_GLOBAL_CONF
- /etc/lxd
Where $var is the var environment variable.
Index ¶
- Variables
- func ConfigDir() (string, error)
- func LoadConfig() (*config.Config, error)
- func UnixSocket() (string, error)
- type LxdClient
- func (t *LxdClient) Config() *config.Config
- func (t *LxdClient) Configured() error
- func (t *LxdClient) CurrentProject() string
- func (t *LxdClient) CurrentServer() (lxd.InstanceServer, error)
- func (t *LxdClient) Init() error
- func (t *LxdClient) ProjectServer(project string) (lxd.InstanceServer, error)
- func (t *LxdClient) RootServer() (lxd.InstanceServer, error)
Constants ¶
This section is empty.
Variables ¶
var Trace bool
Functions ¶
func ConfigDir ¶
ConfigDir returns the default LXD client configuration directory. See https://github.com/canonical/lxd/blob/master/client/main.go We use a similar strategy as main.go func (c *cmdGlobal) PreRun, except that we add $HOME/snap/lxd/common/config/ to the LXD config directories searched. If no LXD CONF directory is found, return "", nil.
func LoadConfig ¶
func UnixSocket ¶
UnixSocket returns the default LXD Unix Socket See https://github.com/canonical/lxd/blob/master/client/connection.go We use a similar strategy as connection.go ConnectLXDUnixWithContext(), except that we add /var/snap/lxd/common/lxd/ to the LXD directories searched. If no LXD directory is found, return "", nil.
Types ¶
type LxdClient ¶
type LxdClient struct { ForceLocal bool `name:"force-local" usage:"Force using the local unix socket"` Project string `name:"project" usage:"Override the default project"` // contains filtered or unexported fields }
LxdClient provides an lxd.InstanceServer Use it by calling these methods, in order: Configured(), CurrentServer().
func (*LxdClient) Configured ¶
func (*LxdClient) CurrentProject ¶
func (*LxdClient) CurrentServer ¶
func (t *LxdClient) CurrentServer() (lxd.InstanceServer, error)
RootServer - return the LXD instance server for the current project
func (*LxdClient) ProjectServer ¶
func (t *LxdClient) ProjectServer(project string) (lxd.InstanceServer, error)
RootServer - return the LXD instance server for the specified project If project is empty, use the default project
func (*LxdClient) RootServer ¶
func (t *LxdClient) RootServer() (lxd.InstanceServer, error)
RootServer - return the unqualified (no project) LXD instance server