Documentation ¶
Overview ¶
Package lxdprofile defines a set of functions and constants that can interact with LXD Profiles. LXD Profiles are key/value YAML configuration files that the LXD provider and LXD container broker can consume and apply to a container.
More information about a type of LXD configuration profile can found https://github.com/lxc/lxd/blob/master/doc/containers.md
LXDProfile package defines core concepts that can be utilised from different packages of the codebase, that want to work with a LXD profile. Not all key/value configurations from the underlying LXD can be applied and some key/values need to be applied using `--force`. To validate the LXD Profile before attempting to apply it to a ubuntu LXD container, there are some validation functions.
Each LXDProfile is given a unique name when applied to the container. This is for three reasons:
- readability - when an operator is attempting to debug if a LXD Profile has been applied for a given charm revision, it should be straightforward for the operator to read the output of `lxd profile list` to marry them.
- Collisions - to ensure that no other charm profile can't collide with in the LXC namespace for an existing LXD Profile, each profile namespaces in the following way `juju-<model>-<application>-<charm-revision>`
- Removability - juju needs to clean up LXD profiles that where applied to the LXD container, but are subsequently not required any more, either by an upgrade of the charm or the complete removal of the charm. Either way, the removal of the charms from the LXC profile list is to prevent orphan profiles from being left dangling.
Index ¶
- Constants
- Variables
- func AnnotateErrorStatus(err error) string
- func IsValidName(name string) bool
- func LXDProfileNames(names []string) []string
- func MatchProfileNameByAppName(names []string, appName string) (string, error)
- func Name(modelName, appName string, revision int) string
- func ProfileReplaceRevision(profile string, rev int) (string, error)
- func ProfileRevision(profile string) (int, error)
- func UpgradeStatusErrorred(status string) bool
- func UpgradeStatusFinished(status string) bool
- func UpgradeStatusTerminal(status string) bool
- func ValidateCharmInfoLXDProfile(info *apicharms.CharmInfo) error
- func ValidateCharmLXDProfile(ch charm.Charm) error
- func ValidateLXDProfile(profiler charm.LXDProfiler) error
Constants ¶
const ( // EmptyStatus represents the initial status EmptyStatus = "" // SuccessStatus defines if the lxd profile upgrade was a success SuccessStatus = "Success" // NotRequiredStatus defines when the lxd profile upgrade was not required NotRequiredStatus = "Not Required" // NotKnownStatus defines a state where the document for the lxd profile // is removed, or never existed, but we don't know what the status should be. NotKnownStatus = "Not known" // ErrorStatus defines when the lxd profile is in an error state ErrorStatus = "Error" // NotSupportedStatus defines when a machine does not support lxd profiles. NotSupportedStatus = "Not Supported" )
const AppName = "juju"
AppName here is used as the application prefix name. We can't use names.Juju as that changes depending on platform.
Variables ¶
var Prefix = fmt.Sprintf("%s-", AppName)
Prefix is used to prefix all the lxd profile programmable profiles. If a profile doesn't have the prefix, then it will be removed when ensuring the the validity of the names (see LXDProfileNames)
Functions ¶
func AnnotateErrorStatus ¶
AnnotateErrorStatus annotates an existing error with the correct status
func IsValidName ¶
IsValidName returns if the name of the lxd profile looks valid.
func LXDProfileNames ¶
LXDProfileNames ensures that the LXD profile names are unique yet preserve the same order as the input. It removes certain profile names from the list, for example "default" profile name will be removed.
func MatchProfileNameByAppName ¶
MatchProfileNameByApp returns the first profile which matches the provided appName. No match returns an empty string. Assumes there is not more than one profile for the same application.
func Name ¶
Name returns a serialisable name that we can use to identify profiles juju-<model>-<application>-<charm-revision>
func ProfileReplaceRevision ¶
ProfileReplaceRevision replaces the old revision with a new revision in the profile.
func ProfileRevision ¶
ProfileRevision returns an int which is the charm revision of the given profile name.
func UpgradeStatusErrorred ¶
UpgradeStatusErrorred defines if the status is in a error state.
func UpgradeStatusFinished ¶
UpgradeStatusFinished defines if the upgrade has completed
func UpgradeStatusTerminal ¶
UpgradeStatusTerminal defines if the status is in a terminal state. Success or not required is also considered terminal.
func ValidateCharmInfoLXDProfile ¶
ValidateCharmInfoLXDProfile will validate the charm info to determin if the information provided is valid or not.
func ValidateCharmLXDProfile ¶
ValidateCharmLXDProfile will attempt to validate a charm.Charm lxd profile. The LXDProfile is an optional method on the charm.Charm, so testing to check that it conforms to a LXDProfiler first is required. Failure to conform to the LXDProfiler will return no error.
func ValidateLXDProfile ¶
func ValidateLXDProfile(profiler charm.LXDProfiler) error
ValidateLXDProfile will validate the profile to determin if the configuration is valid or not before passing continuing on.
Types ¶
This section is empty.