instancecfg

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBridgeName = DefaultBridgePrefix + "eth0"

DefaultBridgeName is the network bridge device name used for LXC and KVM containers

View Source
const DefaultBridgePrefix = "br-"

DefaultBridgePrefix is the prefix for all network bridge device name used for LXC and KVM containers.

Variables

This section is empty.

Functions

func FinishInstanceConfig

func FinishInstanceConfig(icfg *InstanceConfig, cfg *config.Config) (err error)

FinishInstanceConfig sets fields on a InstanceConfig that can be determined by inspecting a plain config.Config and the machine constraints at the last moment before creating the user-data. It assumes that the supplied Config comes from an environment that has passed through all the validation checks in the Bootstrap func, and that has set an agent-version (via finding the tools to, use for bootstrap, or otherwise). TODO(fwereade) This function is not meant to be "good" in any serious way: it is better that this functionality be collected in one place here than that it be spread out across 3 or 4 providers, but this is its only redeeming feature.

func InstanceTags

func InstanceTags(modelUUID, controllerUUID string, tagger tags.ResourceTagger, jobs []multiwatcher.MachineJob) map[string]string

InstanceTags returns the minimum set of tags that should be set on a machine instance, if the provider supports them.

func PopulateInstanceConfig

func PopulateInstanceConfig(icfg *InstanceConfig,
	providerType, authorizedKeys string,
	sslHostnameVerification bool,
	proxySettings, aptProxySettings proxy.Settings,
	aptMirror string,
	enableOSRefreshUpdates bool,
	enableOSUpgrade bool,
) error

PopulateInstanceConfig is called both from the FinishInstanceConfig below, which does have access to the environment config, and from the container provisioners, which don't have access to the environment config. Everything that is needed to provision a container needs to be returned to the provisioner in the ContainerConfig structure. Those values are then used to call this function.

Types

type BootstrapConfig

type BootstrapConfig struct {
	StateInitializationParams

	// GUI is the Juju GUI archive to be installed in the new instance.
	GUI *coretools.GUIArchive

	// Timeout is the amount of time to wait for bootstrap to complete.
	Timeout time.Duration

	// StateServingInfo holds the information for serving the state.
	// This is only specified for bootstrap; controllers started
	// subsequently will acquire their serving info from another
	// server.
	StateServingInfo params.StateServingInfo
}

BootstrapConfig represents bootstrap-specific initialization information for a new juju instance. This is only relevant for the bootstrap machine.

func (*BootstrapConfig) VerifyConfig

func (cfg *BootstrapConfig) VerifyConfig() (err error)

VerifyConfig verifies that the BootstrapConfig is valid.

type ControllerConfig

type ControllerConfig struct {
	// MongoInfo holds the means for the new instance to communicate with the
	// juju state database. Unless the new instance is running a controller
	// (Controller is set), there must be at least one controller address supplied.
	// The entity name must match that of the instance being started,
	// or be empty when starting a controller.
	MongoInfo *mongo.MongoInfo

	// Config contains controller config attributes.
	Config controller.Config

	// The public key used to sign Juju simplestreams image metadata.
	PublicImageSigningKey string
}

ControllerConfig represents controller-specific initialization information for a new juju instance. This is only relevant for controller machines.

func (*ControllerConfig) VerifyConfig

func (cfg *ControllerConfig) VerifyConfig() error

VerifyConfig verifies that the ControllerConfig is valid.

type InstanceConfig

type InstanceConfig struct {
	// Tags is a set of tags to set on the instance, if supported. This
	// should be populated using the InstanceTags method in this package.
	Tags map[string]string

	// Bootstrap contains bootstrap-specific configuration. If this is set,
	// Controller must also be set.
	Bootstrap *BootstrapConfig

	// Controller contains controller-specific configuration. If this is
	// set, then the instance will be configured as a controller machine.
	Controller *ControllerConfig

	// APIInfo holds the means for the new instance to communicate with the
	// juju state API. Unless the new instance is running a controller (Controller is
	// set), there must be at least one controller address supplied.
	// The entity name must match that of the instance being started,
	// or be empty when starting a controller.
	APIInfo *api.Info

	// ControllerTag identifies the controller.
	ControllerTag names.ControllerTag

	// MachineNonce is set at provisioning/bootstrap time and used to
	// ensure the agent is running on the correct instance.
	MachineNonce string

	// DataDir holds the directory that juju state will be put in the new
	// instance.
	DataDir string

	// LogDir holds the directory that juju logs will be written to.
	LogDir string

	// MetricsSpoolDir represents the spool directory path, where all
	// metrics are stored.
	MetricsSpoolDir string

	// Jobs holds what machine jobs to run.
	Jobs []multiwatcher.MachineJob

	// CloudInitOutputLog specifies the path to the output log for cloud-init.
	// The directory containing the log file must already exist.
	CloudInitOutputLog string

	// MachineId identifies the new machine.
	MachineId string

	// MachineContainerType specifies the type of container that the instance
	// is.  If the instance is not a container, then the type is "".
	MachineContainerType instance.ContainerType

	// MachineContainerHostname specifies the hostname to be used with the
	// cloud config for the instance. If this is not set, hostname uses the default.
	MachineContainerHostname string

	// AuthorizedKeys specifies the keys that are allowed to
	// connect to the instance (see cloudinit.SSHAddAuthorizedKeys)
	// If no keys are supplied, there can be no ssh access to the node.
	// On a bootstrap instance, that is fatal. On other
	// instances it will mean that the ssh, scp and debug-hooks
	// commands cannot work.
	AuthorizedKeys string

	// AgentEnvironment defines additional configuration variables to set in
	// the instance agent config.
	AgentEnvironment map[string]string

	// DisableSSLHostnameVerification can be set to true to tell cloud-init
	// that it shouldn't verify SSL certificates
	DisableSSLHostnameVerification bool

	// Series represents the instance series.
	Series string

	// MachineAgentServiceName is the init service name for the Juju machine agent.
	MachineAgentServiceName string

	// ProxySettings define normal http, https and ftp proxies.
	ProxySettings proxy.Settings

	// AptProxySettings define the http, https and ftp proxy settings to use
	// for apt, which may or may not be the same as the normal ProxySettings.
	AptProxySettings proxy.Settings

	// AptMirror defines an APT mirror location, which, if specified, will
	// override the default APT sources.
	AptMirror string

	// The type of Simple Stream to download and deploy on this instance.
	ImageStream string

	// EnableOSRefreshUpdate specifies whether Juju will refresh its
	// respective OS's updates list.
	EnableOSRefreshUpdate bool

	// EnableOSUpgrade defines Juju's behavior when provisioning
	// instances. If enabled, the OS will perform any upgrades
	// available as part of its provisioning.
	EnableOSUpgrade bool
	// contains filtered or unexported fields
}

InstanceConfig represents initialization information for a new juju instance.

func NewBootstrapInstanceConfig

func NewBootstrapInstanceConfig(
	config controller.Config,
	cons, modelCons constraints.Value,
	series, publicImageSigningKey string,
) (*InstanceConfig, error)

NewBootstrapInstanceConfig sets up a basic machine configuration for a bootstrap node. You'll still need to supply more information, but this takes care of the fixed entries and the ones that are always needed.

func NewInstanceConfig

func NewInstanceConfig(
	controllerTag names.ControllerTag,
	machineID,
	machineNonce,
	imageStream,
	series string,
	apiInfo *api.Info,
) (*InstanceConfig, error)

NewInstanceConfig sets up a basic machine configuration, for a non-bootstrap node. You'll still need to supply more information, but this takes care of the fixed entries and the ones that are always needed.

func (*InstanceConfig) APIHostAddrs

func (cfg *InstanceConfig) APIHostAddrs() []string

func (*InstanceConfig) AgentConfig

func (cfg *InstanceConfig) AgentConfig(
	tag names.Tag,
	toolsVersion version.Number,
) (agent.ConfigSetter, error)

func (*InstanceConfig) AgentVersion

func (cfg *InstanceConfig) AgentVersion() version.Binary

AgentVersion returns the version of the Juju agent that will be configured on the instance. The zero value will be returned if there are no tools set.

func (*InstanceConfig) GUITools

func (cfg *InstanceConfig) GUITools() string

GUITools returns the directory where the Juju GUI release is stored.

func (*InstanceConfig) InitService

func (cfg *InstanceConfig) InitService(renderer shell.Renderer) (service.Service, error)

func (*InstanceConfig) JujuTools

func (cfg *InstanceConfig) JujuTools() string

JujuTools returns the directory where Juju tools are stored.

func (*InstanceConfig) SetTools

func (cfg *InstanceConfig) SetTools(toolsList coretools.List) error

SetTools sets the tools that should be tried when provisioning this instance. There must be at least one. Other than the URL, each item must be the same.

TODO(axw) 2016-04-19 lp:1572116 SetTools should verify that the tools have URLs, since they will be needed for downloading on the instance. We can't do that until all usage-sites are updated to pass through non-empty URLs.

func (*InstanceConfig) ToolsDir

func (cfg *InstanceConfig) ToolsDir(renderer shell.Renderer) string

func (*InstanceConfig) ToolsList

func (cfg *InstanceConfig) ToolsList() coretools.List

ToolsList returns the list of tools in the order in which they will be tried.

func (*InstanceConfig) VerifyConfig

func (cfg *InstanceConfig) VerifyConfig() (err error)

VerifyConfig verifies that the InstanceConfig is valid.

type StateInitializationParams

type StateInitializationParams struct {
	// ControllerModelConfig holds the initial controller model configuration.
	ControllerModelConfig *config.Config

	// ControllerCloudName is the name of the cloud that Juju will be
	// bootstrapped in.
	ControllerCloudName string

	// ControllerCloud contains the properties of the cloud that Juju will
	// be bootstrapped in.
	ControllerCloud cloud.Cloud

	// ControllerCloudRegion is the name of the cloud region that Juju will be
	// bootstrapped in.
	ControllerCloudRegion string

	// ControllerCloudCredentialName is the name of the cloud credential that
	// Juju will be bootstrapped with.
	ControllerCloudCredentialName string

	// ControllerCloudCredential contains the cloud credential that Juju will
	// be bootstrapped with.
	ControllerCloudCredential *cloud.Credential

	// ControllerConfig is the set of config attributes relevant
	// to a controller.
	ControllerConfig controller.Config

	// ControllerInheritedConfig is a set of config attributes to be shared by all
	// models managed by this controller.
	ControllerInheritedConfig map[string]interface{}

	// RegionInheritedConfig holds region specific configuration attributes to
	// be shared across all models in the same controller on a particular
	// cloud.
	RegionInheritedConfig cloud.RegionConfig

	// HostedModelConfig is a set of config attributes to be overlaid
	// on the controller model config (Config, above) to construct the
	// initial hosted model config.
	HostedModelConfig map[string]interface{}

	// BootstrapMachineInstanceId is the instance ID of the bootstrap
	// machine instance being initialized.
	BootstrapMachineInstanceId instance.Id

	// BootstrapMachineConstraints holds the constraints for the bootstrap
	// machine.
	BootstrapMachineConstraints constraints.Value

	// BootstrapMachineHardwareCharacteristics contains the harrdware
	// characteristics of the bootstrap machine instance being initialized.
	BootstrapMachineHardwareCharacteristics *instance.HardwareCharacteristics

	// ModelConstraints holds the initial model constraints.
	ModelConstraints constraints.Value

	// CustomImageMetadata is optional custom simplestreams image metadata
	// to store in environment storage at bootstrap time. This is ignored
	// in non-bootstrap instances.
	CustomImageMetadata []*imagemetadata.ImageMetadata
}

StateInitializationParams contains parameters for initializing the state database.

This structure will be passed to the bootstrap agent. To do so, the Marshal and Unmarshal methods must be used.

func (*StateInitializationParams) Marshal

func (p *StateInitializationParams) Marshal() ([]byte, error)

Marshal marshals StateInitializationParams to an opaque byte array.

func (*StateInitializationParams) Unmarshal

func (p *StateInitializationParams) Unmarshal(data []byte) error

Unmarshal unmarshals StateInitializationParams from a byte array that was generated with StateInitializationParams.Marshal.

Jump to

Keyboard shortcuts

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