github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/environs/bootstrap.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package environs 5 6 import ( 7 "io" 8 "os" 9 10 "github.com/juju/juju/cloudconfig/instancecfg" 11 "github.com/juju/juju/constraints" 12 "github.com/juju/juju/environs/imagemetadata" 13 "github.com/juju/juju/tools" 14 ) 15 16 // BootstrapParams holds the parameters for bootstrapping an environment. 17 type BootstrapParams struct { 18 // ModelConstraints are merged with the bootstrap constraints 19 // to choose the initial instance, and will be stored in the new 20 // environment's state. 21 ModelConstraints constraints.Value 22 23 // BootstrapConstraints, in conjunction with ModelConstraints, 24 // are used to choose the initial instance. BootstrapConstraints 25 // will not be stored in state for the environment. 26 BootstrapConstraints constraints.Value 27 28 // BootstrapSeries, if specified, is the series to use for the 29 // initial bootstrap machine. 30 BootstrapSeries string 31 32 // Placement, if non-empty, holds an environment-specific placement 33 // directive used to choose the initial instance. 34 Placement string 35 36 // AvailableTools is a collection of tools which the Bootstrap method 37 // may use to decide which architecture/series to instantiate. 38 AvailableTools tools.List 39 40 // ContainerBridgeName, if non-empty, overrides the default 41 // network bridge device to use for LXC and KVM containers. See 42 // also instancecfg.DefaultBridgeName. 43 ContainerBridgeName string 44 45 // ImageMetadata contains simplestreams image metadata for providers 46 // that rely on it for selecting images. This will be empty for 47 // providers that do not implements simplestreams.HasRegion. 48 ImageMetadata []*imagemetadata.ImageMetadata 49 } 50 51 // BootstrapFinalizer is a function returned from Environ.Bootstrap. 52 // The caller must pass a InstanceConfig with the Tools field set. 53 type BootstrapFinalizer func(BootstrapContext, *instancecfg.InstanceConfig) error 54 55 // BootstrapResult holds the data returned by calls to Environ.Bootstrap. 56 type BootstrapResult struct { 57 // Arch is the instance's architecture. 58 Arch string 59 60 // Series is the instance's series. 61 Series string 62 63 // Finalize is a function that must be called to finalize the 64 // bootstrap process by transferring the tools and installing the 65 // initial Juju controller. 66 Finalize BootstrapFinalizer 67 } 68 69 // BootstrapContext is an interface that is passed to 70 // Environ.Bootstrap, providing a means of obtaining 71 // information about and manipulating the context in which 72 // it is being invoked. 73 type BootstrapContext interface { 74 GetStdin() io.Reader 75 GetStdout() io.Writer 76 GetStderr() io.Writer 77 Infof(format string, params ...interface{}) 78 Verbosef(format string, params ...interface{}) 79 80 // InterruptNotify starts watching for interrupt signals 81 // on behalf of the caller, sending them to the supplied 82 // channel. 83 InterruptNotify(sig chan<- os.Signal) 84 85 // StopInterruptNotify undoes the effects of a previous 86 // call to InterruptNotify with the same channel. After 87 // StopInterruptNotify returns, no more signals will be 88 // delivered to the channel. 89 StopInterruptNotify(chan<- os.Signal) 90 91 // ShouldVerifyCredentials indicates whether the caller's cloud 92 // credentials should be verified. 93 ShouldVerifyCredentials() bool 94 }