juju: github.com/juju/juju/provider/lxd Index | Files | Directories

package lxd

import "github.com/juju/juju/provider/lxd"

Index

Package Files

config.go credentials.go environ.go environ_broker.go environ_instance.go environ_policy.go errors.go init.go instance.go instance_information.go lxd.go provider.go server.go storage.go upgrades.go userdata.go

func IsAuthorisationFailure Uses

func IsAuthorisationFailure(err error) bool

IsAuthorisationFailure determines if the given error has an authorisation failure.

func NewProvider Uses

func NewProvider() environs.CloudEnvironProvider

NewProvider returns a new LXD EnvironProvider.

func ReadLegacyCloudCredentials Uses

func ReadLegacyCloudCredentials(readFile func(string) ([]byte, error)) (cloud.Credential, error)

ReadLegacyCloudCredentials reads cloud credentials off disk for an old LXD controller, and returns them as a cloud.Credential with the certificate auth-type.

If the credential files are missing from the filesystem, an error satisfying errors.IsNotFound will be returned.

type CertificateGenerator Uses

type CertificateGenerator interface {
    // Generate creates client or server certificate and key pair,
    // returning them as byte arrays in memory.
    Generate(client bool) (certPEM, keyPEM []byte, err error)
}

CertificateGenerator groups methods for generating a new certificate

type CertificateReadWriter Uses

type CertificateReadWriter interface {
    // Read takes a path and returns both a cert and key PEM.
    // Returns an error if there was an issue reading the certs.
    Read(path string) (certPEM, keyPEM []byte, err error)

    // Write takes a path and cert, key PEM and stores them.
    // Returns an error if there was an issue writing the certs.
    Write(path string, certPEM, keyPEM []byte) error
}

CertificateReadWriter groups methods that is required to read and write certificates at a given path. go:generate mockgen -package lxd -destination credentials_mock_test.go github.com/juju/juju/provider/lxd CertificateReadWriter,CertificateGenerator,NetLookup

type InterfaceAddress Uses

type InterfaceAddress interface {

    // InterfaceAddress looks for the network interface
    // and returns the IPv4 address from the possible addresses.
    // Returns an error if there is an issue locating the interface name or
    // the address associated with it.
    InterfaceAddress(string) (string, error)
}

InterfaceAddress groups methods that is required to find addresses for a given interface

type LXCConfig Uses

type LXCConfig struct {
    DefaultRemote string                     `yaml:"local"`
    Remotes       map[string]LXCRemoteConfig `yaml:"remotes"`
}

LXCConfig represents a configuration setup of a LXC configuration file. The LXCConfig expects the configuration file to be in a yaml representation.

type LXCConfigReader Uses

type LXCConfigReader interface {
    // ReadConfig takes a path and returns a LXCConfig.
    // Returns an error if there is an error with the location of the config
    // file, or there was an error parsing the file.
    ReadConfig(path string) (LXCConfig, error)

    // ReadCert takes a path and returns a raw certificate, there is no
    // validation of the certificate.
    // Returns an error if there is an error with the location of the
    // certificate.
    ReadCert(path string) ([]byte, error)
}

LXCConfigReader reads files required for the LXC configuration. go:generate mockgen -package lxd -destination provider_mock_test.go github.com/juju/juju/provider/lxd LXCConfigReader

type LXCRemoteConfig Uses

type LXCRemoteConfig struct {
    Addr     string `yaml:"addr"`
    Public   bool   `yaml:"public"`
    Protocol string `yaml:"protocol"`
    AuthType string `yaml:"auth_type"`
}

LXCRemoteConfig defines a the remote servers of a LXC configuration.

type NetLookup Uses

type NetLookup interface {
    // LookupHost looks up the given host using the local resolver.
    // It returns a slice of that host's addresses.
    LookupHost(string) ([]string, error)

    // InterfaceAddrs returns a list of the system's unicast interface
    // addresses.
    InterfaceAddrs() ([]net.Addr, error)
}

NetLookup groups methods for looking up hosts and interface addresses.

type Server Uses

type Server interface {
    FindImage(string, string, []lxd.ServerSpec, bool, environs.StatusCallbackFunc) (lxd.SourcedImage, error)
    GetServer() (server *lxdapi.Server, ETag string, err error)
    ServerVersion() string
    GetConnectionInfo() (info *lxdclient.ConnectionInfo, err error)
    UpdateServerConfig(map[string]string) error
    UpdateContainerConfig(string, map[string]string) error
    CreateCertificate(lxdapi.CertificatesPost) error
    GetCertificate(fingerprint string) (certificate *lxdapi.Certificate, ETag string, err error)
    DeleteCertificate(fingerprint string) (err error)
    CreateClientCertificate(certificate *lxd.Certificate) error
    LocalBridgeName() string
    AliveContainers(prefix string) ([]lxd.Container, error)
    ContainerAddresses(name string) ([]network.ProviderAddress, error)
    RemoveContainer(name string) error
    RemoveContainers(names []string) error
    FilterContainers(prefix string, statuses ...string) ([]lxd.Container, error)
    CreateContainerFromSpec(spec lxd.ContainerSpec) (*lxd.Container, error)
    WriteContainer(*lxd.Container) error
    CreateProfileWithConfig(string, map[string]string) error
    GetProfile(string) (*lxdapi.Profile, string, error)
    GetContainerProfiles(string) ([]string, error)
    HasProfile(string) (bool, error)
    CreateProfile(post lxdapi.ProfilesPost) (err error)
    DeleteProfile(string) (err error)
    ReplaceOrAddContainerProfile(string, string, string) error
    UpdateContainerProfiles(name string, profiles []string) error
    VerifyNetworkDevice(*lxdapi.Profile, string) error
    EnsureDefaultStorage(*lxdapi.Profile, string) error
    StorageSupported() bool
    GetStoragePool(name string) (pool *lxdapi.StoragePool, ETag string, err error)
    GetStoragePools() (pools []lxdapi.StoragePool, err error)
    CreatePool(name, driver string, attrs map[string]string) error
    GetStoragePoolVolume(pool string, volType string, name string) (*lxdapi.StorageVolume, string, error)
    GetStoragePoolVolumes(pool string) (volumes []lxdapi.StorageVolume, err error)
    CreateVolume(pool, name string, config map[string]string) error
    UpdateStoragePoolVolume(pool string, volType string, name string, volume lxdapi.StorageVolumePut, ETag string) error
    DeleteStoragePoolVolume(pool string, volType string, name string) (err error)
    ServerCertificate() string
    HostArch() string
    EnableHTTPSListener() error
    GetNICsFromProfile(profName string) (map[string]map[string]string, error)
    IsClustered() bool
    UseTargetServer(name string) (*lxd.Server, error)
    GetClusterMembers() (members []lxdapi.ClusterMember, err error)
    Name() string
}

Server defines an interface of all localized methods that the environment and provider utilizes. go:generate mockgen -package lxd -destination server_mock_test.go github.com/juju/juju/provider/lxd Server,ServerFactory,InterfaceAddress

type ServerFactory Uses

type ServerFactory interface {
    // LocalServer creates a new lxd server and augments and wraps the lxd
    // server, by ensuring sane defaults exist with network, storage.
    LocalServer() (Server, error)

    // LocalServerAddress returns the local servers address from the factory.
    LocalServerAddress() (string, error)

    // RemoteServer creates a new server that connects to a remote lxd server.
    // If the cloudSpec endpoint is nil or empty, it will assume that you want
    // to connection to a local server and will instead use that one.
    RemoteServer(environs.CloudSpec) (Server, error)

    // InsecureRemoteServer creates a new server that connect to a remote lxd
    // server in a insecure manner.
    // If the cloudSpec endpoint is nil or empty, it will assume that you want
    // to connection to a local server and will instead use that one.
    InsecureRemoteServer(environs.CloudSpec) (Server, error)
}

ServerFactory creates a new factory for creating servers that are required by the server.

func NewServerFactory Uses

func NewServerFactory() ServerFactory

NewServerFactory creates a new ServerFactory with sane defaults.

Directories

PathSynopsis
lxdnamesPackage lxdnames provides names for the lxd provider.

Package lxd imports 56 packages (graph) and is imported by 28 packages. Updated 2019-10-11. Refresh now. Tools for package owners.