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