github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/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  	"time"
    10  
    11  	"github.com/juju/juju/cloudconfig/instancecfg"
    12  	"github.com/juju/juju/constraints"
    13  	"github.com/juju/juju/controller"
    14  	"github.com/juju/juju/environs/imagemetadata"
    15  	"github.com/juju/juju/tools"
    16  )
    17  
    18  // BootstrapParams holds the parameters for bootstrapping an environment.
    19  type BootstrapParams struct {
    20  	// Cloud contains the name of the cloud that Juju will be
    21  	// bootstrapped in. Used for printing feedback during bootstrap.
    22  	CloudName string
    23  
    24  	// CloudRegion is the name of the cloud region that Juju will be
    25  	// bootstrapped in. Used for printing feedback during bootstrap.
    26  	CloudRegion string
    27  
    28  	// ControllerConfig contains the configuration attributes for the
    29  	// bootstrapped controller.
    30  	ControllerConfig controller.Config
    31  
    32  	// ModelConstraints are merged with the bootstrap constraints
    33  	// to choose the initial instance, and will be stored in the new
    34  	// environment's state.
    35  	ModelConstraints constraints.Value
    36  
    37  	// BootstrapConstraints, in conjunction with ModelConstraints,
    38  	// are used to choose the initial instance. BootstrapConstraints
    39  	// will not be stored in state for the environment.
    40  	BootstrapConstraints constraints.Value
    41  
    42  	// BootstrapSeries, if specified, is the series to use for the
    43  	// initial bootstrap machine.
    44  	BootstrapSeries string
    45  
    46  	// Placement, if non-empty, holds an environment-specific placement
    47  	// directive used to choose the initial instance.
    48  	Placement string
    49  
    50  	// AvailableTools is a collection of tools which the Bootstrap method
    51  	// may use to decide which architecture/series to instantiate.
    52  	AvailableTools tools.List
    53  
    54  	// ContainerBridgeName, if non-empty, overrides the default
    55  	// network bridge device to use for LXC and KVM containers. See
    56  	// also instancecfg.DefaultBridgeName.
    57  	ContainerBridgeName string
    58  
    59  	// ImageMetadata contains simplestreams image metadata for providers
    60  	// that rely on it for selecting images. This will be empty for
    61  	// providers that do not implements simplestreams.HasRegion.
    62  	ImageMetadata []*imagemetadata.ImageMetadata
    63  }
    64  
    65  // BootstrapFinalizer is a function returned from Environ.Bootstrap.
    66  // The caller must pass a InstanceConfig with the Tools field set.
    67  type BootstrapFinalizer func(BootstrapContext, *instancecfg.InstanceConfig, BootstrapDialOpts) error
    68  
    69  // BootstrapDialOpts contains the options for the synchronous part of the
    70  // bootstrap procedure, where the CLI connects to the bootstrap machine
    71  // to complete the process.
    72  type BootstrapDialOpts struct {
    73  	// Timeout is the amount of time to wait contacting a state
    74  	// server.
    75  	Timeout time.Duration
    76  
    77  	// RetryDelay is the amount of time between attempts to connect to
    78  	// an address.
    79  	RetryDelay time.Duration
    80  
    81  	// AddressesDelay is the amount of time between refreshing the
    82  	// addresses.
    83  	AddressesDelay time.Duration
    84  }
    85  
    86  // BootstrapResult holds the data returned by calls to Environ.Bootstrap.
    87  type BootstrapResult struct {
    88  	// Arch is the instance's architecture.
    89  	Arch string
    90  
    91  	// Series is the instance's series.
    92  	Series string
    93  
    94  	// Finalize is a function that must be called to finalize the
    95  	// bootstrap process by transferring the tools and installing the
    96  	// initial Juju controller.
    97  	Finalize BootstrapFinalizer
    98  }
    99  
   100  // BootstrapContext is an interface that is passed to
   101  // Environ.Bootstrap, providing a means of obtaining
   102  // information about and manipulating the context in which
   103  // it is being invoked.
   104  type BootstrapContext interface {
   105  	GetStdin() io.Reader
   106  	GetStdout() io.Writer
   107  	GetStderr() io.Writer
   108  	Infof(format string, params ...interface{})
   109  	Verbosef(format string, params ...interface{})
   110  
   111  	// InterruptNotify starts watching for interrupt signals
   112  	// on behalf of the caller, sending them to the supplied
   113  	// channel.
   114  	InterruptNotify(sig chan<- os.Signal)
   115  
   116  	// StopInterruptNotify undoes the effects of a previous
   117  	// call to InterruptNotify with the same channel. After
   118  	// StopInterruptNotify returns, no more signals will be
   119  	// delivered to the channel.
   120  	StopInterruptNotify(chan<- os.Signal)
   121  
   122  	// ShouldVerifyCredentials indicates whether the caller's cloud
   123  	// credentials should be verified.
   124  	ShouldVerifyCredentials() bool
   125  }