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