OLD | NEW |
1 // Copyright 2011, 2012, 2013 Canonical Ltd. | 1 // Copyright 2011, 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package environs | 4 package environs |
5 | 5 |
6 import ( | 6 import ( |
7 "io" | 7 "io" |
8 "os" | 8 "os" |
9 | 9 |
10 "launchpad.net/juju-core/constraints" | 10 "launchpad.net/juju-core/constraints" |
11 "launchpad.net/juju-core/environs/config" | 11 "launchpad.net/juju-core/environs/config" |
12 "launchpad.net/juju-core/environs/storage" | 12 "launchpad.net/juju-core/environs/storage" |
13 "launchpad.net/juju-core/instance" | 13 "launchpad.net/juju-core/instance" |
14 "launchpad.net/juju-core/state" | 14 "launchpad.net/juju-core/state" |
15 "launchpad.net/juju-core/state/api" | 15 "launchpad.net/juju-core/state/api" |
16 ) | 16 ) |
17 | 17 |
18 // EnvironCapability implements access to metadata about the capabilities | |
19 // of an environment. | |
20 type EnvironCapability interface { | |
21 // SupportedArchitectures returns the image architectures which can | |
22 // be hosted by this environment. | |
23 SupportedArchitectures() ([]string, error) | |
24 | |
25 // SupportNetworks returns whether the environment has support to | |
26 // specify networks for services and machines. | |
27 SupportNetworks() bool | |
28 } | |
29 | |
30 // A EnvironProvider represents a computing and storage provider. | 18 // A EnvironProvider represents a computing and storage provider. |
31 type EnvironProvider interface { | 19 type EnvironProvider interface { |
32 // Prepare prepares an environment for use. Any additional | 20 // Prepare prepares an environment for use. Any additional |
33 // configuration attributes in the returned environment should | 21 // configuration attributes in the returned environment should |
34 // be saved to be used later. If the environment is already | 22 // be saved to be used later. If the environment is already |
35 // prepared, this call is equivalent to Open. | 23 // prepared, this call is equivalent to Open. |
36 Prepare(ctx BootstrapContext, cfg *config.Config) (Environ, error) | 24 Prepare(ctx BootstrapContext, cfg *config.Config) (Environ, error) |
37 | 25 |
38 // Open opens the environment and returns it. | 26 // Open opens the environment and returns it. |
39 // The configuration must have come from a previously | 27 // The configuration must have come from a previously |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 StateInfo() (*state.Info, *api.Info, error) | 104 StateInfo() (*state.Info, *api.Info, error) |
117 | 105 |
118 // InstanceBroker defines methods for starting and stopping | 106 // InstanceBroker defines methods for starting and stopping |
119 // instances. | 107 // instances. |
120 InstanceBroker | 108 InstanceBroker |
121 | 109 |
122 // ConfigGetter allows the retrieval of the configuration data. | 110 // ConfigGetter allows the retrieval of the configuration data. |
123 ConfigGetter | 111 ConfigGetter |
124 | 112 |
125 // EnvironCapability allows access to this environment's capabilities. | 113 // EnvironCapability allows access to this environment's capabilities. |
126 » EnvironCapability | 114 » state.EnvironCapability |
127 | 115 |
128 // SetConfig updates the Environ's configuration. | 116 // SetConfig updates the Environ's configuration. |
129 // | 117 // |
130 // Calls to SetConfig do not affect the configuration of | 118 // Calls to SetConfig do not affect the configuration of |
131 // values previously obtained from Storage. | 119 // values previously obtained from Storage. |
132 SetConfig(cfg *config.Config) error | 120 SetConfig(cfg *config.Config) error |
133 | 121 |
134 // Instances returns a slice of instances corresponding to the | 122 // Instances returns a slice of instances corresponding to the |
135 // given instance ids. If no instances were found, but there | 123 // given instance ids. If no instances were found, but there |
136 // was no other error, it will return ErrNoInstances. If | 124 // was no other error, it will return ErrNoInstances. If |
(...skipping 24 matching lines...) Expand all Loading... |
161 ClosePorts(ports []instance.Port) error | 149 ClosePorts(ports []instance.Port) error |
162 | 150 |
163 // Ports returns the ports opened for the whole environment. | 151 // Ports returns the ports opened for the whole environment. |
164 // Must only be used if the environment was setup with the | 152 // Must only be used if the environment was setup with the |
165 // FwGlobal firewall mode. | 153 // FwGlobal firewall mode. |
166 Ports() ([]instance.Port, error) | 154 Ports() ([]instance.Port, error) |
167 | 155 |
168 // Provider returns the EnvironProvider that created this Environ. | 156 // Provider returns the EnvironProvider that created this Environ. |
169 Provider() EnvironProvider | 157 Provider() EnvironProvider |
170 | 158 |
171 » // TODO(axw) 2014-02-11 #pending-review | 159 » state.Prechecker |
172 » // Embed state.Prechecker, and introduce an EnvironBase | |
173 » // that embeds a no-op prechecker implementation. | |
174 } | 160 } |
175 | 161 |
176 // BootstrapContext is an interface that is passed to | 162 // BootstrapContext is an interface that is passed to |
177 // Environ.Bootstrap, providing a means of obtaining | 163 // Environ.Bootstrap, providing a means of obtaining |
178 // information about and manipulating the context in which | 164 // information about and manipulating the context in which |
179 // it is being invoked. | 165 // it is being invoked. |
180 type BootstrapContext interface { | 166 type BootstrapContext interface { |
181 GetStdin() io.Reader | 167 GetStdin() io.Reader |
182 GetStdout() io.Writer | 168 GetStdout() io.Writer |
183 GetStderr() io.Writer | 169 GetStderr() io.Writer |
184 Infof(format string, params ...interface{}) | 170 Infof(format string, params ...interface{}) |
185 Verbosef(format string, params ...interface{}) | 171 Verbosef(format string, params ...interface{}) |
186 | 172 |
187 // InterruptNotify starts watching for interrupt signals | 173 // InterruptNotify starts watching for interrupt signals |
188 // on behalf of the caller, sending them to the supplied | 174 // on behalf of the caller, sending them to the supplied |
189 // channel. | 175 // channel. |
190 InterruptNotify(sig chan<- os.Signal) | 176 InterruptNotify(sig chan<- os.Signal) |
191 | 177 |
192 // StopInterruptNotify undoes the effects of a previous | 178 // StopInterruptNotify undoes the effects of a previous |
193 // call to InterruptNotify with the same channel. After | 179 // call to InterruptNotify with the same channel. After |
194 // StopInterruptNotify returns, no more signals will be | 180 // StopInterruptNotify returns, no more signals will be |
195 // delivered to the channel. | 181 // delivered to the channel. |
196 StopInterruptNotify(chan<- os.Signal) | 182 StopInterruptNotify(chan<- os.Signal) |
197 } | 183 } |
OLD | NEW |