Documentation ¶
Index ¶
- Constants
- Variables
- func AptProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}
- func ConcatAuthKeys(a, b string) string
- func LatestLtsSeries() string
- func PreferredSeries(cfg HasDefaultSeries) string
- func ProcessDeprecatedAttributes(attrs map[string]interface{}) map[string]interface{}
- func ProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}
- func ReadAuthorizedKeys(path string) (string, error)
- func Schema(extra environschema.Fields) (environschema.Fields, error)
- func SpecializeCharmRepo(repo charmrepo.Interface, cfg *Config) charmrepo.Interface
- func Validate(cfg, old *Config) error
- type Config
- func (c *Config) APIPort() int
- func (c *Config) AdminSecret() string
- func (c *Config) AgentMetadataURL() (string, bool)
- func (c *Config) AgentStream() string
- func (c *Config) AgentVersion() (version.Number, bool)
- func (c *Config) AllAttrs() map[string]interface{}
- func (c *Config) AllowLXCLoopMounts() (bool, bool)
- func (c *Config) Apply(attrs map[string]interface{}) (*Config, error)
- func (c *Config) AptFtpProxy() string
- func (c *Config) AptHttpProxy() string
- func (c *Config) AptHttpsProxy() string
- func (c *Config) AptMirror() string
- func (c *Config) AptProxySettings() proxy.Settings
- func (c *Config) AuthorizedKeys() string
- func (c *Config) BootstrapSSHOpts() SSHTimeoutOpts
- func (c *Config) CACert() (string, bool)
- func (c *Config) CAPrivateKey() (key string, ok bool)
- func (c *Config) DefaultSeries() (string, bool)
- func (c *Config) Development() bool
- func (c *Config) DisableNetworkManagement() (bool, bool)
- func (c *Config) EnableOSRefreshUpdate() bool
- func (c *Config) EnableOSUpgrade() bool
- func (c *Config) FirewallMode() string
- func (c *Config) FtpProxy() string
- func (cfg *Config) GenerateStateServerCertAndKey(hostAddresses []string) (string, string, error)
- func (c *Config) HttpProxy() string
- func (c *Config) HttpsProxy() string
- func (c *Config) ImageMetadataURL() (string, bool)
- func (c *Config) ImageStream() string
- func (c *Config) LXCDefaultMTU() (int, bool)
- func (c *Config) LXCUseClone() (bool, bool)
- func (c *Config) LXCUseCloneAUFS() (bool, bool)
- func (c *Config) LoggingConfig() string
- func (c *Config) Name() string
- func (c *Config) NoProxy() string
- func (c *Config) NumaCtlPreference() bool
- func (c *Config) PreferIPv6() bool
- func (c *Config) PreventAllChanges() bool
- func (c *Config) PreventDestroyEnvironment() bool
- func (c *Config) PreventRemoveObject() bool
- func (c *Config) ProvisionerHarvestMode() HarvestMode
- func (c *Config) ProxySSH() bool
- func (c *Config) ProxySettings() proxy.Settings
- func (c *Config) Remove(attrs []string) (*Config, error)
- func (c *Config) ResourceTags() (map[string]string, bool)
- func (c *Config) RsyslogCACert() string
- func (c *Config) RsyslogCAKey() string
- func (c *Config) SSLHostnameVerification() bool
- func (c *Config) StatePort() int
- func (c *Config) StorageDefaultBlockSource() (string, bool)
- func (c *Config) SyslogPort() int
- func (c *Config) TestMode() bool
- func (c *Config) Type() string
- func (c *Config) UUID() (string, bool)
- func (c *Config) UnknownAttrs() map[string]interface{}
- func (cfg *Config) ValidateUnknownAttrs(fields schema.Fields, defaults schema.Defaults) (map[string]interface{}, error)
- type Defaulting
- type HarvestMode
- type HasDefaultSeries
- type InvalidConfigValueError
- type SSHTimeoutOpts
Constants ¶
const ( // AuthKeysConfig is the configuration key for authorised keys. AuthKeysConfig = "authorized-keys" // JujuSystemKey is the SSH key comment for Juju system keys. JujuSystemKey = "juju-system-key" )
const ( // FwInstance requests the use of an individual firewall per instance. FwInstance = "instance" // FwGlobal requests the use of a single firewall group for all machines. // When ports are opened for one machine, all machines will have the same // port opened. FwGlobal = "global" // FwNone requests that no firewalling should be performed inside // the environment. No firewaller worker will be started. It's // useful for clouds without support for either global or per // instance security groups. FwNone = "none" // DefaultStatePort is the default port the state server is listening on. DefaultStatePort int = 37017 // DefaultApiPort is the default port the API server is listening on. DefaultAPIPort int = 17070 // DefaultSyslogPort is the default port that the syslog UDP/TCP listener is // listening on. DefaultSyslogPort int = 6514 // DefaultBootstrapSSHTimeout is the amount of time to wait // contacting a state server, in seconds. DefaultBootstrapSSHTimeout int = 600 // DefaultBootstrapSSHRetryDelay is the amount of time between // attempts to connect to an address, in seconds. DefaultBootstrapSSHRetryDelay int = 5 // DefaultBootstrapSSHAddressesDelay is the amount of time between // refreshing the addresses, in seconds. Not too frequent, as we // refresh addresses from the provider each time. DefaultBootstrapSSHAddressesDelay int = 10 // DefaultNumaControlPolicy should not be used by default. // Only use numactl if user specifically requests it DefaultNumaControlPolicy = false // DefaultPreventDestroyEnvironment should not be used by default. // Only prevent destroy-environment from running // if user specifically requests it. Otherwise, let it run. DefaultPreventDestroyEnvironment = false // DefaultPreventRemoveObject should not be used by default. // Only prevent remove-object from running // if user specifically requests it. Otherwise, let it run. // Object here is a juju artifact - machine, service, unit or relation. DefaultPreventRemoveObject = false // DefaultPreventAllChanges should not be used by default. // Only prevent all-changes from running // if user specifically requests it. Otherwise, let them run. DefaultPreventAllChanges = false // DefaultLXCDefaultMTU is the default value for "lxc-default-mtu" // config setting. Only non-zero, positive integer values will // have effect. DefaultLXCDefaultMTU = 0 )
const ( // ProvisionerHarvestModeKey stores the key for this setting. ProvisionerHarvestModeKey = "provisioner-harvest-mode" // AgentStreamKey stores the key for this setting. AgentStreamKey = "agent-stream" // AgentMetadataURLKey stores the key for this setting. AgentMetadataURLKey = "agent-metadata-url" // HttpProxyKey stores the key for this setting. HttpProxyKey = "http-proxy" // HttpsProxyKey stores the key for this setting. HttpsProxyKey = "https-proxy" // FtpProxyKey stores the key for this setting. FtpProxyKey = "ftp-proxy" // AptHttpProxyKey stores the key for this setting. AptHttpProxyKey = "apt-http-proxy" // AptHttpsProxyKey stores the key for this setting. AptHttpsProxyKey = "apt-https-proxy" // AptFtpProxyKey stores the key for this setting. AptFtpProxyKey = "apt-ftp-proxy" // NoProxyKey stores the key for this setting. NoProxyKey = "no-proxy" // LxcClone stores the value for this setting. LxcClone = "lxc-clone" // NumaControlPolicyKey stores the value for this setting SetNumaControlPolicyKey = "set-numa-control-policy" // BlockKeyPrefix is the prefix used for environment variables that block commands // TODO(anastasiamac 2015-02-27) remove it and all related post 1.24 as obsolete BlockKeyPrefix = "block-" // PreventDestroyEnvironmentKey stores the value for this setting PreventDestroyEnvironmentKey = BlockKeyPrefix + "destroy-environment" // PreventRemoveObjectKey stores the value for this setting PreventRemoveObjectKey = BlockKeyPrefix + "remove-object" // PreventAllChangesKey stores the value for this setting PreventAllChangesKey = BlockKeyPrefix + "all-changes" // The default block storage source. StorageDefaultBlockSourceKey = "storage-default-block-source" // ResourceTagsKey is an optional list or space-separated string // of k=v pairs, defining the tags for ResourceTags. ResourceTagsKey = "resource-tags" // For LXC containers, is the container allowed to mount block // devices. A theoretical security issue, so must be explicitly // allowed by the user. AllowLXCLoopMounts = "allow-lxc-loop-mounts" // LXCDefaultMTU, when set to a positive integer, overrides the // Machine Transmission Unit (MTU) setting of all network // interfaces created for LXC containers. See also bug #1442257. LXCDefaultMTU = "lxc-default-mtu" // Deprecated by provisioner-harvest-mode // ProvisionerSafeModeKey stores the key for this setting. ProvisionerSafeModeKey = "provisioner-safe-mode" // Deprecated by agent-stream // ToolsStreamKey stores the key for this setting. ToolsStreamKey = "tools-stream" // Deprecated by agent-metadata-url // ToolsMetadataURLKey stores the key for this setting. ToolsMetadataURLKey = "tools-metadata-url" // Deprecated by use-clone // LxcUseClone stores the key for this setting. LxcUseClone = "lxc-use-clone" )
TODO(katco-): Please grow this over time. Centralized place to store values of config keys. This transitions mistakes in referencing key-values to a compile-time error.
Variables ¶
var ProxyAttributes = []string{ HttpProxyKey, HttpsProxyKey, FtpProxyKey, AptHttpProxyKey, AptHttpsProxyKey, AptFtpProxyKey, }
proxyAttrs contains attribute names that could contain loopback URLs, pointing to localhost
Functions ¶
func AptProxyConfigMap ¶
AptProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.
func ConcatAuthKeys ¶
ConcatAuthKeys concatenates the two sets of authorised keys, interposing a newline if necessary, because authorised keys are newline-separated.
func LatestLtsSeries ¶
func LatestLtsSeries() string
func PreferredSeries ¶
func PreferredSeries(cfg HasDefaultSeries) string
PreferredSeries returns the preferred series to use when a charm does not explicitly specify a series.
func ProcessDeprecatedAttributes ¶
ProcessDeprecatedAttributes gathers any deprecated attributes in attrs and adds or replaces them with new name value pairs for the replacement attrs. Ths ensures that older versions of Juju which require that deprecated attribute values still be used will work as expected.
func ProxyConfigMap ¶
ProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.
func ReadAuthorizedKeys ¶
ReadAuthorizedKeys implements the standard juju behaviour for finding authorized_keys. It returns a set of keys in in authorized_keys format (see sshd(8) for a description). If path is non-empty, it names the file to use; otherwise the user's .ssh directory will be searched. Home directory expansion will be performed on the path if it starts with a ~; if the expanded path is relative, it will be interpreted relative to $HOME/.ssh.
The result of utils/ssh.PublicKeyFiles will always be prepended to the result. In practice, this means ReadAuthorizedKeys never returns an error when the call originates in the CLI.
func Schema ¶
func Schema(extra environschema.Fields) (environschema.Fields, error)
Schema returns a configuration schema that includes both the given extra fields and all the fields defined in this package. It returns an error if extra defines any fields defined in this package.
func SpecializeCharmRepo ¶
SpecializeCharmRepo customizes a repository for a given configuration. It returns a charm repository with test mode enabled if applicable.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config holds an immutable environment configuration.
func New ¶
func New(withDefaults Defaulting, attrs map[string]interface{}) (*Config, error)
New returns a new configuration. Fields that are common to all environment providers are verified. If useDefaults is UseDefaults, default values will be taken from the environment.
Specifically, the "authorized-keys-path" key is translated into "authorized-keys" by loading the content from respective file. Similarly, "ca-cert-path" and "ca-private-key-path" are translated into the "ca-cert" and "ca-private-key" values. If not specified, authorized SSH keys and CA details will be read from:
~/.ssh/id_dsa.pub ~/.ssh/id_rsa.pub ~/.ssh/identity.pub ~/.juju/<name>-cert.pem ~/.juju/<name>-private-key.pem
The required keys (after any files have been read) are "name", "type" and "authorized-keys", all of type string. Additional keys recognised are "agent-version" (string) and "development" (bool).
func (*Config) AdminSecret ¶
AdminSecret returns the administrator password. It's empty if the password has not been set.
func (*Config) AgentMetadataURL ¶
AgentMetadataURL returns the URL that locates the agent tarballs and metadata, and whether it has been set.
func (*Config) AgentStream ¶
AgentStream returns the simplestreams stream used to identify which tools to use when when bootstrapping or upgrading an environment.
func (*Config) AgentVersion ¶
AgentVersion returns the proposed version number for the agent tools, and whether it has been set. Once an environment is bootstrapped, this must always be valid.
func (*Config) AllowLXCLoopMounts ¶
AllowLXCLoopMounts returns whether loop devices are allowed to be mounted inside lxc containers.
func (*Config) AptFtpProxy ¶
AptFtpProxy returns the apt ftp proxy for the environment. Falls back to the default ftp-proxy if not specified.
func (*Config) AptHttpProxy ¶
AptHttpProxy returns the apt http proxy for the environment. Falls back to the default http-proxy if not specified.
func (*Config) AptHttpsProxy ¶
AptHttpsProxy returns the apt https proxy for the environment. Falls back to the default https-proxy if not specified.
func (*Config) AptProxySettings ¶
AptProxySettings returns all three proxy settings; http, https and ftp.
func (*Config) AuthorizedKeys ¶
AuthorizedKeys returns the content for ssh's authorized_keys file.
func (*Config) BootstrapSSHOpts ¶
func (c *Config) BootstrapSSHOpts() SSHTimeoutOpts
BootstrapSSHOpts returns the SSH timeout and retry delays used during bootstrap.
func (*Config) CACert ¶
CACert returns the certificate of the CA that signed the state server certificate, in PEM format, and whether the setting is available.
func (*Config) CAPrivateKey ¶
CAPrivateKey returns the private key of the CA that signed the state server certificate, in PEM format, and whether the setting is available.
func (*Config) DefaultSeries ¶
DefaultSeries returns the configured default Ubuntu series for the environment, and whether the default series was explicitly configured on the environment.
func (*Config) Development ¶
Development returns whether the environment is in development mode.
func (*Config) DisableNetworkManagement ¶
DisableNetworkManagement reports whether Juju is allowed to configure and manage networking inside the environment.
func (*Config) EnableOSRefreshUpdate ¶
EnableOSRefreshUpdate returns whether or not newly provisioned instances should run their respective OS's update capability.
func (*Config) EnableOSUpgrade ¶
EnableOSUpgrade returns whether or not newly provisioned instances should run their respective OS's upgrade capability.
func (*Config) FirewallMode ¶
FirewallMode returns whether the firewall should manage ports per machine, globally, or not at all. (FwInstance, FwGlobal, or FwNone).
func (*Config) GenerateStateServerCertAndKey ¶
GenerateStateServerCertAndKey makes sure that the config has a CACert and CAPrivateKey, generates and returns new certificate and key.
func (*Config) HttpsProxy ¶
HttpsProxy returns the https proxy for the environment.
func (*Config) ImageMetadataURL ¶
ImageMetadataURL returns the URL at which the metadata used to locate image ids is located, and wether it has been set.
func (*Config) ImageStream ¶
ImageStream returns the simplestreams stream used to identify which image ids to search when starting an instance.
func (*Config) LXCDefaultMTU ¶
LXCDefaultMTU reports whether the LXC provisioner should create a containers with a specific MTU value for all network intefaces.
func (*Config) LXCUseClone ¶
LXCUseClone reports whether the LXC provisioner should create a template and use cloning to speed up container provisioning.
func (*Config) LXCUseCloneAUFS ¶
LXCUseCloneAUFS reports whether the LXC provisioner should create a lxc clone using aufs if available.
func (*Config) LoggingConfig ¶
LoggingConfig returns the configuration string for the loggers.
func (*Config) NumaCtlPreference ¶
NumaCtlPreference returns if numactl is preferred.
func (*Config) PreferIPv6 ¶
PreferIPv6 returns whether IPv6 addresses for API endpoints and machines will be preferred (when available) over IPv4.
func (*Config) PreventAllChanges ¶
PreventAllChanges returns if all-changes should be blocked from proceeding, thus preventing the operation. Changes in this context are any alterations to current environment.
func (*Config) PreventDestroyEnvironment ¶
PreventDestroyEnvironment returns if destroy-environment should be blocked from proceeding, thus preventing the operation.
func (*Config) PreventRemoveObject ¶
PreventRemoveObject returns if remove-object should be blocked from proceeding, thus preventing the operation. Object in this context is a juju artifact: either a machine, a service, a unit or a relation.
func (*Config) ProvisionerHarvestMode ¶
func (c *Config) ProvisionerHarvestMode() HarvestMode
ProvisionerHarvestMode reports the harvesting methodology the provisioner should take.
func (*Config) ProxySSH ¶
ProxySSH returns a flag indicating whether SSH commands should be proxied through the API server.
func (*Config) ProxySettings ¶
ProxySettings returns all four proxy settings; http, https, ftp, and no proxy.
func (*Config) Remove ¶
Remove returns a new configuration that has the attributes of c minus attrs.
func (*Config) ResourceTags ¶
ResourceTags returns a set of tags to set on environment resources that Juju creates and manages, if the provider supports them. These tags have no special meaning to Juju, but may be used for existing chargeback accounting schemes or other identification purposes.
func (*Config) RsyslogCACert ¶
RsyslogCACert returns the certificate of the CA that signed the rsyslog certificate, in PEM format, or nil if one hasn't been generated yet.
func (*Config) RsyslogCAKey ¶
RsyslogCAKey returns the key of the CA that signed the rsyslog certificate, in PEM format, or nil if one hasn't been generated yet.
func (*Config) SSLHostnameVerification ¶
SSLHostnameVerification returns weather the environment has requested SSL hostname verification to be enabled.
func (*Config) StorageDefaultBlockSource ¶
StorageDefaultBlockSource returns the default block storage source for the environment.
func (*Config) SyslogPort ¶
SyslogPort returns the syslog port for the environment.
func (*Config) TestMode ¶
TestMode indicates if the environment is intended for testing. In this case, accessing the charm store does not affect statistical data of the store.
func (*Config) UUID ¶
UUID returns the uuid for the environment. For backwards compatability with 1.20 and earlier the value may be blank if no uuid is present in this configuration. Once all enviroment configurations have been upgraded, this relaxation will be dropped. The absence of a uuid is indicated by a result of "", false.
func (*Config) UnknownAttrs ¶
UnknownAttrs returns a copy of the raw configuration attributes that are supposedly specific to the environment type. They could also be wrong attributes, though. Only the specific environment implementation can tell.
func (*Config) ValidateUnknownAttrs ¶
func (cfg *Config) ValidateUnknownAttrs(fields schema.Fields, defaults schema.Defaults) (map[string]interface{}, error)
ValidateUnknownAttrs checks the unknown attributes of the config against the supplied fields and defaults, and returns an error if any fails to validate. Unknown fields are warned about, but preserved, on the basis that they are reasonably likely to have been written by or for a version of juju that does recognise the fields, but that their presence is still anomalous to some degree and should be flagged (and that there is thereby a mechanism for observing fields that really are typos etc).
type Defaulting ¶
type Defaulting bool
Defaulting is a value that specifies whether a configuration creator should use defaults from the environment.
const ( UseDefaults Defaulting = true NoDefaults Defaulting = false )
type HarvestMode ¶
type HarvestMode uint32
HarvestMode is a bit field which is used to store the harvesting behavior for Juju.
const ( // HarvestNone signifies that Juju should not harvest any // machines. HarvestNone HarvestMode = 1 << iota // HarvestUnknown signifies that Juju should only harvest machines // which exist, but we don't know about. HarvestUnknown // HarvestDestroyed signifies that Juju should only harvest // machines which have been explicitly released by the user // through a destroy of a service/environment/unit. HarvestDestroyed // HarvestAll signifies that Juju should harvest both unknown and // destroyed instances. ♫ Don't fear the reaper. ♫ HarvestAll HarvestMode = HarvestUnknown | HarvestDestroyed )
func ParseHarvestMode ¶
func ParseHarvestMode(description string) (HarvestMode, error)
ParseHarvestMode parses description of harvesting method and returns the representation.
func (HarvestMode) HarvestDestroyed ¶
func (method HarvestMode) HarvestDestroyed() bool
Destroyed returns whether or not the Destroyed harvesting flag is set.
func (HarvestMode) HarvestNone ¶
func (method HarvestMode) HarvestNone() bool
None returns whether or not the None harvesting flag is set.
func (HarvestMode) HarvestUnknown ¶
func (method HarvestMode) HarvestUnknown() bool
Unknown returns whether or not the Unknown harvesting flag is set.
func (HarvestMode) String ¶
func (method HarvestMode) String() string
String returns the description of the harvesting mode.
type HasDefaultSeries ¶
type InvalidConfigValueError ¶
type InvalidConfigValueError struct { // Key is the config key used to access the value. Key string // Value is the value that failed validation. Value string // Reason indicates why the value failed validation. Reason error }
InvalidConfigValue is an error type for a config value that failed validation.
func (*InvalidConfigValueError) Error ¶
func (e *InvalidConfigValueError) Error() string
Error returns the error string.
type SSHTimeoutOpts ¶
type SSHTimeoutOpts struct { // Timeout is the amount of time to wait contacting a state // server. Timeout time.Duration // RetryDelay is the amount of time between attempts to connect to // an address. RetryDelay time.Duration // AddressesDelay is the amount of time between refreshing the // addresses. AddressesDelay time.Duration }
SSHTimeoutOpts lists the amount of time we will wait for various parts of the SSH connection to complete. This is similar to DialOpts, see http://pad.lv/1258889 about possibly deduplicating them.