LEFT | RIGHT |
1 package environs | 1 package environs |
2 | 2 |
3 import ( | 3 import ( |
4 "errors" | 4 "errors" |
5 "io" | 5 "io" |
6 "launchpad.net/juju-core/state" | 6 "launchpad.net/juju-core/state" |
7 "launchpad.net/juju-core/environs/config" | 7 "launchpad.net/juju-core/environs/config" |
8 ) | 8 ) |
9 | 9 |
10 // A EnvironProvider represents a computing and storage provider. | 10 // A EnvironProvider represents a computing and storage provider. |
11 type EnvironProvider interface { | 11 type EnvironProvider interface { |
12 // Open opens the environment and returns it. | 12 // Open opens the environment and returns it. |
13 Open(config *config.Config) (Environ, error) | 13 Open(config *config.Config) (Environ, error) |
14 | 14 |
15 » // TODO: add Validate | 15 » // Validate ensures that config is a valid configuration for this |
| 16 » // provider, applying changes to it if necessary, and returns the |
| 17 » // validated configuration. |
| 18 » // If old is not nil, it holds the previous environment configuration |
| 19 » // for consideration when validating changes. |
| 20 » // TODO: Validate(config, old *config.Config) (valid *config.Config, err
error) |
16 } | 21 } |
17 | 22 |
18 var ErrNoDNSName = errors.New("DNS name not allocated") | 23 var ErrNoDNSName = errors.New("DNS name not allocated") |
19 | 24 |
20 // Instance represents the provider-specific notion of a machine. | 25 // Instance represents the provider-specific notion of a machine. |
21 type Instance interface { | 26 type Instance interface { |
22 // Id returns a provider-generated identifier for the Instance. | 27 // Id returns a provider-generated identifier for the Instance. |
23 Id() string | 28 Id() string |
24 | 29 |
25 // DNSName returns the DNS name for the instance. | 30 // DNSName returns the DNS name for the instance. |
26 // If the name is not yet allocated, it will return | 31 // If the name is not yet allocated, it will return |
27 // an ErrNoDNSName error. | 32 // an ErrNoDNSName error. |
28 DNSName() (string, error) | 33 DNSName() (string, error) |
29 | 34 |
30 // WaitDNSName returns the DNS name for the instance, | 35 // WaitDNSName returns the DNS name for the instance, |
31 // waiting until it is allocated if necessary. | 36 // waiting until it is allocated if necessary. |
32 WaitDNSName() (string, error) | 37 WaitDNSName() (string, error) |
33 | 38 |
34 // OpenPorts opens the given ports on the instance, which | 39 // OpenPorts opens the given ports on the instance, which |
35 // should have been started with the given machine id. | 40 // should have been started with the given machine id. |
36 OpenPorts(machineId int, ports []state.Port) error | 41 OpenPorts(machineId int, ports []state.Port) error |
37 | 42 |
38 // ClosePorts closes the given ports on the instance, which | 43 // ClosePorts closes the given ports on the instance, which |
39 // should have been started with the given machine id. | 44 // should have been started with the given machine id. |
40 ClosePorts(machineId int, ports []state.Port) error | 45 ClosePorts(machineId int, ports []state.Port) error |
41 | 46 |
42 // Ports returns the set of ports open on the instance, which | 47 // Ports returns the set of ports open on the instance, which |
43 // should have been started with the given machine id. | 48 // should have been started with the given machine id. |
| 49 // The ports are returned as sorted by state.SortPorts. |
44 Ports(machineId int) ([]state.Port, error) | 50 Ports(machineId int) ([]state.Port, error) |
45 } | 51 } |
46 | 52 |
47 var ErrNoInstances = errors.New("no instances found") | 53 var ErrNoInstances = errors.New("no instances found") |
48 var ErrPartialInstances = errors.New("only some instances were found") | 54 var ErrPartialInstances = errors.New("only some instances were found") |
49 | 55 |
50 // NotFoundError records an error when something has not been found. | 56 // NotFoundError records an error when something has not been found. |
51 type NotFoundError struct { | 57 type NotFoundError struct { |
52 // error is the underlying error. | 58 // error is the underlying error. |
53 error | 59 error |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // yet be visible in the environment, so this method | 163 // yet be visible in the environment, so this method |
158 // can wait until they are. | 164 // can wait until they are. |
159 // | 165 // |
160 // When Destroy has been called, any Environ referring to the | 166 // When Destroy has been called, any Environ referring to the |
161 // same remote environment may become invalid | 167 // same remote environment may become invalid |
162 Destroy(insts []Instance) error | 168 Destroy(insts []Instance) error |
163 | 169 |
164 // AssignmentPolicy returns the environment's unit assignment policy. | 170 // AssignmentPolicy returns the environment's unit assignment policy. |
165 AssignmentPolicy() state.AssignmentPolicy | 171 AssignmentPolicy() state.AssignmentPolicy |
166 } | 172 } |
LEFT | RIGHT |