Documentation
¶
Index ¶
- func IsAuthorisationFailure(err error) bool
- func NewProvider() environs.CloudEnvironProvider
- func ReadLegacyCloudCredentials(readFile func(string) ([]byte, error)) (cloud.Credential, error)
- type CertificateGenerator
- type CertificateReadWriter
- type InterfaceAddress
- type LXCConfig
- type LXCConfigReader
- type LXCRemoteConfig
- type NetLookup
- type Server
- type ServerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAuthorisationFailure ¶
IsAuthorisationFailure determines if the given error has an authorisation failure.
func NewProvider ¶
func NewProvider() environs.CloudEnvironProvider
NewProvider returns a new LXD EnvironProvider.
func ReadLegacyCloudCredentials ¶
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.
Types ¶
type CertificateGenerator ¶
type CertificateGenerator interface {
// Generate creates client or server certificate and key pair,
// returning them as byte arrays in memory.
Generate(client bool, addHosts bool) (certPEM, keyPEM []byte, err error)
}
CertificateGenerator groups methods for generating a new certificate
type CertificateReadWriter ¶
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.
type InterfaceAddress ¶
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 ¶
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 ¶
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.
type LXCRemoteConfig ¶
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 ¶
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 ¶
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
SupportedArches() []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
HasExtension(extension string) (exists bool)
GetNetworks() ([]lxdapi.Network, error)
GetNetworkState(name string) (*lxdapi.NetworkState, error)
GetContainer(name string) (*lxdapi.Container, string, error)
GetContainerState(name string) (*lxdapi.ContainerState, string, error)
// UseProject ensures that this server will use the input project.
// See: https://linuxcontainers.org/lxd/docs/master/projects.
UseProject(string)
}
Server defines an interface of all localized methods that the environment and provider utilizes.
type ServerFactory ¶
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(environscloudspec.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(environscloudspec.CloudSpec) (Server, error)
}
ServerFactory creates a new factory for creating servers that are required by the server.
func NewServerFactory ¶
func NewServerFactory(httpClient *http.Client) ServerFactory
NewServerFactory creates a new ServerFactory with sane defaults.