juju: github.com/juju/juju/cloudconfig/instancecfg Index | Files

package instancecfg

import "github.com/juju/juju/cloudconfig/instancecfg"

Index

Package Files

instancecfg.go

Constants

const DefaultBridgeName = "br-eth0"

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

func FinishInstanceConfig Uses

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 Uses

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 Uses

func PopulateInstanceConfig(icfg *InstanceConfig,
    providerType, authorizedKeys string,
    sslHostnameVerification bool,
    proxyCfg ProxyConfiguration,
    enableOSRefreshUpdates bool,
    enableOSUpgrade bool,
    cloudInitUserData map[string]interface{},
    profiles []string,
) 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.

type BootstrapConfig Uses

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

    // InitialSSHHostKeys contains the initial SSH host keys to configure
    // on the bootstrap machine, indexed by algorithm. These will only be
    // valid for the initial SSH connection. The first thing we do upon
    // making the initial SSH connection is to replace each of these host
    // keys, to avoid the host keys being extracted from the metadata
    // service by a bad actor post-bootstrap.
    //
    // Any existing host keys on the machine with algorithms not specified
    // in the map will be left alone. This is important so that we do not
    // trample on the host keys of manually provisioned machines.
    InitialSSHHostKeys SSHHostKeys

    // 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

    // JujuDbSnapPath is the path to a .snap file that will be used as the juju-db
    // service.
    JujuDbSnapPath string

    // JujuDbSnapAssertions is a path to a .assert file that will be used
    // to verify the .snap at JujuDbSnapPath
    JujuDbSnapAssertionsPath string
}

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

func (*BootstrapConfig) VerifyConfig Uses

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

VerifyConfig verifies that the BootstrapConfig is valid.

type ControllerConfig Uses

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 Uses

func (cfg *ControllerConfig) VerifyConfig() error

VerifyConfig verifies that the ControllerConfig is valid.

type InstanceConfig Uses

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

    // CloudInitUserData defines key/value pairs from the model-config
    // specified by the user.
    CloudInitUserData map[string]interface{}

    // 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

    // LegacyProxySettings define normal http, https and ftp proxies.
    // These values are written to the /etc for the user profile and systemd settings.
    LegacyProxySettings proxy.Settings

    // JujuProxySettings define normal http, https and ftp proxies for accessing
    // the outside network. These values are not written to disk.
    JujuProxySettings 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

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

    // SnapStoreAssertions contains a list of assertions that must be
    // passed to snapd together with a store proxy ID parameter before it
    // can connect to a snap store proxy.
    SnapStoreAssertions string

    // SnapStoreProxyID references a store entry in the snap store
    // assertion list that must be passed to snapd before it can connect to
    // a snap store proxy.
    SnapStoreProxyID string

    // SnapStoreProxyURL specifies the address of the snap store proxy. If
    // specified instead of the assertions/storeID settings above, juju can
    // directly contact the proxy to retrieve the assertions and store ID.
    SnapStoreProxyURL 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

    // NetBondReconfigureDelay defines the duration in seconds that the
    // networking bridgescript should pause between ifdown, then
    // ifup when bridging bonded interfaces. See bugs #1594855 and
    // #1269921.
    NetBondReconfigureDelay int

    // Profiles is a slice of (lxd) profile names to be used by a container
    Profiles []string
    // contains filtered or unexported fields
}

InstanceConfig represents initialization information for a new juju instance.

func NewBootstrapInstanceConfig Uses

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 Uses

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 Uses

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

func (*InstanceConfig) APIHosts Uses

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

func (*InstanceConfig) AgentConfig Uses

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

func (*InstanceConfig) AgentVersion Uses

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 Uses

func (cfg *InstanceConfig) GUITools() string

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

func (*InstanceConfig) InitService Uses

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

func (*InstanceConfig) JujuTools Uses

func (cfg *InstanceConfig) JujuTools() string

JujuTools returns the directory where Juju tools are stored.

func (*InstanceConfig) SetSnapSource Uses

func (cfg *InstanceConfig) SetSnapSource(snapPath string, snapAssertionsPath string) error

SetSnapSource annotates the instance configuration with the location of a local .snap to upload during the instance's provisioning.

func (*InstanceConfig) SetTools Uses

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) SnapDir Uses

func (cfg *InstanceConfig) SnapDir() string

SnapDir returns the directory where snaps should be uploaded to.

func (*InstanceConfig) ToolsDir Uses

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

func (*InstanceConfig) ToolsList Uses

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

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

func (*InstanceConfig) VerifyConfig Uses

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

VerifyConfig verifies that the InstanceConfig is valid.

type ProxyConfiguration Uses

type ProxyConfiguration struct {
    // Legacy proxy settings.
    Legacy proxy.Settings

    // Juju-specific proxy settings.
    Juju proxy.Settings

    // Apt-specific proxy settings.
    Apt proxy.Settings

    // Snap-specific proxy settings.
    Snap proxy.Settings

    // Apt mirror.
    AptMirror string

    // SnapStoreAssertions contains a list of assertions that must be
    // passed to snapd together with a store proxy ID parameter before it
    // can connect to a snap store proxy.
    SnapStoreAssertions string

    // SnapStoreProxyID references a store entry in the snap store
    // assertion list that must be passed to snapd before it can connect to
    // a snap store proxy.
    SnapStoreProxyID string

    // SnapStoreProxyURL specifies the address of the snap store proxy. If
    // specified instead of the assertions/storeID settings above, juju can
    // directly contact the proxy to retrieve the assertions and store ID.
    SnapStoreProxyURL string
}

ProxyConfiguration encapsulates all proxy-related settings that can be used to populate an InstanceConfig.

type SSHHostKeys Uses

type SSHHostKeys struct {
    // RSA, if non-nil, contains the RSA key to configure as the initial
    // SSH host key.
    RSA *SSHKeyPair
}

SSHHostKeys contains the SSH host keys to configure for a bootstrap host.

type SSHKeyPair Uses

type SSHKeyPair struct {
    // Private contains the private key, PEM-encoded.
    Private string

    // Public contains the public key in authorized_keys format.
    Public string
}

SSHKeyPair is an SSH host key pair.

type StateInitializationParams Uses

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

    // ControllerModelEnvironVersion holds the initial controller model
    // environ version.
    ControllerModelEnvironVersion int

    // 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 hardware
    // 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 Uses

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

Marshal marshals StateInitializationParams to an opaque byte array.

func (*StateInitializationParams) Unmarshal Uses

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

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

Package instancecfg imports 33 packages (graph) and is imported by 949 packages. Updated 2019-09-23. Refresh now. Tools for package owners.