config

package
v0.0.0-...-be26699 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2015 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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
)
View Source
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

proxyAttrs contains attribute names that could contain loopback URLs, pointing to localhost

Functions

func AptProxyConfigMap

func AptProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}

AptProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.

func ConcatAuthKeys

func ConcatAuthKeys(a, b string) string

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

func ProcessDeprecatedAttributes(attrs map[string]interface{}) map[string]interface{}

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

func ProxyConfigMap(proxySettings proxy.Settings) map[string]interface{}

ProxyConfigMap returns a map suitable to be applied to a Config to update proxy settings.

func ReadAuthorizedKeys

func ReadAuthorizedKeys(path string) (string, error)

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

func SpecializeCharmRepo(repo charmrepo.Interface, cfg *Config) charmrepo.Interface

SpecializeCharmRepo customizes a repository for a given configuration. It returns a charm repository with test mode enabled if applicable.

func Validate

func Validate(cfg, old *Config) error

Validate ensures that config is a valid configuration. If old is not nil, it holds the previous environment configuration for consideration when validating changes.

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) APIPort

func (c *Config) APIPort() int

APIPort returns the API server port for the environment.

func (*Config) AdminSecret

func (c *Config) AdminSecret() string

AdminSecret returns the administrator password. It's empty if the password has not been set.

func (*Config) AgentMetadataURL

func (c *Config) AgentMetadataURL() (string, bool)

AgentMetadataURL returns the URL that locates the agent tarballs and metadata, and whether it has been set.

func (*Config) AgentStream

func (c *Config) AgentStream() string

AgentStream returns the simplestreams stream used to identify which tools to use when when bootstrapping or upgrading an environment.

func (*Config) AgentVersion

func (c *Config) AgentVersion() (version.Number, bool)

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) AllAttrs

func (c *Config) AllAttrs() map[string]interface{}

AllAttrs returns a copy of the raw configuration attributes.

func (*Config) AllowLXCLoopMounts

func (c *Config) AllowLXCLoopMounts() (bool, bool)

AllowLXCLoopMounts returns whether loop devices are allowed to be mounted inside lxc containers.

func (*Config) Apply

func (c *Config) Apply(attrs map[string]interface{}) (*Config, error)

Apply returns a new configuration that has the attributes of c plus attrs.

func (*Config) AptFtpProxy

func (c *Config) AptFtpProxy() string

AptFtpProxy returns the apt ftp proxy for the environment. Falls back to the default ftp-proxy if not specified.

func (*Config) AptHttpProxy

func (c *Config) AptHttpProxy() string

AptHttpProxy returns the apt http proxy for the environment. Falls back to the default http-proxy if not specified.

func (*Config) AptHttpsProxy

func (c *Config) AptHttpsProxy() string

AptHttpsProxy returns the apt https proxy for the environment. Falls back to the default https-proxy if not specified.

func (*Config) AptMirror

func (c *Config) AptMirror() string

AptMirror sets the apt mirror for the environment.

func (*Config) AptProxySettings

func (c *Config) AptProxySettings() proxy.Settings

AptProxySettings returns all three proxy settings; http, https and ftp.

func (*Config) AuthorizedKeys

func (c *Config) AuthorizedKeys() string

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

func (c *Config) CACert() (string, bool)

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

func (c *Config) CAPrivateKey() (key string, ok bool)

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

func (c *Config) DefaultSeries() (string, bool)

DefaultSeries returns the configured default Ubuntu series for the environment, and whether the default series was explicitly configured on the environment.

func (*Config) Development

func (c *Config) Development() bool

Development returns whether the environment is in development mode.

func (*Config) DisableNetworkManagement

func (c *Config) DisableNetworkManagement() (bool, bool)

DisableNetworkManagement reports whether Juju is allowed to configure and manage networking inside the environment.

func (*Config) EnableOSRefreshUpdate

func (c *Config) EnableOSRefreshUpdate() bool

EnableOSRefreshUpdate returns whether or not newly provisioned instances should run their respective OS's update capability.

func (*Config) EnableOSUpgrade

func (c *Config) EnableOSUpgrade() bool

EnableOSUpgrade returns whether or not newly provisioned instances should run their respective OS's upgrade capability.

func (*Config) FirewallMode

func (c *Config) FirewallMode() string

FirewallMode returns whether the firewall should manage ports per machine, globally, or not at all. (FwInstance, FwGlobal, or FwNone).

func (*Config) FtpProxy

func (c *Config) FtpProxy() string

FtpProxy returns the ftp proxy for the environment.

func (*Config) GenerateStateServerCertAndKey

func (cfg *Config) GenerateStateServerCertAndKey(hostAddresses []string) (string, string, error)

GenerateStateServerCertAndKey makes sure that the config has a CACert and CAPrivateKey, generates and returns new certificate and key.

func (*Config) HttpProxy

func (c *Config) HttpProxy() string

HttpProxy returns the http proxy for the environment.

func (*Config) HttpsProxy

func (c *Config) HttpsProxy() string

HttpsProxy returns the https proxy for the environment.

func (*Config) ImageMetadataURL

func (c *Config) ImageMetadataURL() (string, bool)

ImageMetadataURL returns the URL at which the metadata used to locate image ids is located, and wether it has been set.

func (*Config) ImageStream

func (c *Config) ImageStream() string

ImageStream returns the simplestreams stream used to identify which image ids to search when starting an instance.

func (*Config) LXCDefaultMTU

func (c *Config) LXCDefaultMTU() (int, bool)

LXCDefaultMTU reports whether the LXC provisioner should create a containers with a specific MTU value for all network intefaces.

func (*Config) LXCUseClone

func (c *Config) LXCUseClone() (bool, bool)

LXCUseClone reports whether the LXC provisioner should create a template and use cloning to speed up container provisioning.

func (*Config) LXCUseCloneAUFS

func (c *Config) LXCUseCloneAUFS() (bool, bool)

LXCUseCloneAUFS reports whether the LXC provisioner should create a lxc clone using aufs if available.

func (*Config) LoggingConfig

func (c *Config) LoggingConfig() string

LoggingConfig returns the configuration string for the loggers.

func (*Config) Name

func (c *Config) Name() string

Name returns the environment name.

func (*Config) NoProxy

func (c *Config) NoProxy() string

NoProxy returns the 'no proxy' for the environment.

func (*Config) NumaCtlPreference

func (c *Config) NumaCtlPreference() bool

NumaCtlPreference returns if numactl is preferred.

func (*Config) PreferIPv6

func (c *Config) PreferIPv6() bool

PreferIPv6 returns whether IPv6 addresses for API endpoints and machines will be preferred (when available) over IPv4.

func (*Config) PreventAllChanges

func (c *Config) PreventAllChanges() bool

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

func (c *Config) PreventDestroyEnvironment() bool

PreventDestroyEnvironment returns if destroy-environment should be blocked from proceeding, thus preventing the operation.

func (*Config) PreventRemoveObject

func (c *Config) PreventRemoveObject() bool

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

func (c *Config) ProxySSH() bool

ProxySSH returns a flag indicating whether SSH commands should be proxied through the API server.

func (*Config) ProxySettings

func (c *Config) ProxySettings() proxy.Settings

ProxySettings returns all four proxy settings; http, https, ftp, and no proxy.

func (*Config) Remove

func (c *Config) Remove(attrs []string) (*Config, error)

Remove returns a new configuration that has the attributes of c minus attrs.

func (*Config) ResourceTags

func (c *Config) ResourceTags() (map[string]string, bool)

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

func (c *Config) RsyslogCACert() string

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

func (c *Config) RsyslogCAKey() string

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

func (c *Config) SSLHostnameVerification() bool

SSLHostnameVerification returns weather the environment has requested SSL hostname verification to be enabled.

func (*Config) StatePort

func (c *Config) StatePort() int

StatePort returns the state server port for the environment.

func (*Config) StorageDefaultBlockSource

func (c *Config) StorageDefaultBlockSource() (string, bool)

StorageDefaultBlockSource returns the default block storage source for the environment.

func (*Config) SyslogPort

func (c *Config) SyslogPort() int

SyslogPort returns the syslog port for the environment.

func (*Config) TestMode

func (c *Config) TestMode() bool

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) Type

func (c *Config) Type() string

Type returns the environment type.

func (*Config) UUID

func (c *Config) UUID() (string, bool)

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

func (c *Config) UnknownAttrs() map[string]interface{}

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 HasDefaultSeries interface {
	DefaultSeries() (string, bool)
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL