LEFT | RIGHT |
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 "errors" | 7 "errors" |
8 "io" | 8 "io" |
9 "launchpad.net/juju-core/constraints" | 9 "launchpad.net/juju-core/constraints" |
10 "launchpad.net/juju-core/environs/config" | 10 "launchpad.net/juju-core/environs/config" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ClosePorts(machineId string, ports []params.Port) error | 74 ClosePorts(machineId string, ports []params.Port) error |
75 | 75 |
76 // Ports returns the set of ports open on the instance, which | 76 // Ports returns the set of ports open on the instance, which |
77 // should have been started with the given machine id. | 77 // should have been started with the given machine id. |
78 // The ports are returned as sorted by state.SortPorts. | 78 // The ports are returned as sorted by state.SortPorts. |
79 Ports(machineId string) ([]params.Port, error) | 79 Ports(machineId string) ([]params.Port, error) |
80 } | 80 } |
81 | 81 |
82 var ErrNoInstances = errors.New("no instances found") | 82 var ErrNoInstances = errors.New("no instances found") |
83 var ErrPartialInstances = errors.New("only some instances were found") | 83 var ErrPartialInstances = errors.New("only some instances were found") |
84 | |
85 // NotFoundError records an error when something has not been found. | |
86 type NotFoundError struct { | |
87 // error is the underlying error. | |
88 error | |
89 } | |
90 | |
91 // IsNotFoundError returns true if err is a NotFoundError. | |
92 func IsNotFoundError(err error) bool { | |
93 if _, ok := err.(*NotFoundError); ok { | |
94 return true | |
95 } | |
96 return false | |
97 } | |
98 | 84 |
99 // A StorageReader can retrieve and list files from a storage provider. | 85 // A StorageReader can retrieve and list files from a storage provider. |
100 type StorageReader interface { | 86 type StorageReader interface { |
101 // Get opens the given storage file and returns a ReadCloser | 87 // Get opens the given storage file and returns a ReadCloser |
102 // that can be used to read its contents. It is the caller's | 88 // that can be used to read its contents. It is the caller's |
103 // responsibility to close it after use. If the name does not | 89 // responsibility to close it after use. If the name does not |
104 // exist, it should return a *NotFoundError. | 90 // exist, it should return a *NotFoundError. |
105 Get(name string) (io.ReadCloser, error) | 91 Get(name string) (io.ReadCloser, error) |
106 | 92 |
107 // List lists all names in the storage with the given prefix, in | 93 // List lists all names in the storage with the given prefix, in |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 ClosePorts(ports []params.Port) error | 209 ClosePorts(ports []params.Port) error |
224 | 210 |
225 // Ports returns the ports opened for the whole environment. | 211 // Ports returns the ports opened for the whole environment. |
226 // Must only be used if the environment was setup with the | 212 // Must only be used if the environment was setup with the |
227 // FwGlobal firewall mode. | 213 // FwGlobal firewall mode. |
228 Ports() ([]params.Port, error) | 214 Ports() ([]params.Port, error) |
229 | 215 |
230 // Provider returns the EnvironProvider that created this Environ. | 216 // Provider returns the EnvironProvider that created this Environ. |
231 Provider() EnvironProvider | 217 Provider() EnvironProvider |
232 } | 218 } |
LEFT | RIGHT |