LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2013 Canonical Ltd. | 1 // Copyright 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 maas | 4 package maas |
5 | 5 |
6 import ( | 6 import ( |
7 "bytes" | 7 "bytes" |
8 "fmt" | 8 "fmt" |
9 "io/ioutil" | 9 "io/ioutil" |
10 "launchpad.net/goyaml" | 10 "launchpad.net/goyaml" |
11 "launchpad.net/juju-core/instance" | 11 "launchpad.net/juju-core/instance" |
12 ) | 12 ) |
| 13 |
| 14 // TODO: This entire file is duplicated between the EC2, OpenStack, MAAS, |
| 15 // and Azure providers (bug 1195721). |
13 | 16 |
14 const stateFile = "provider-state" | 17 const stateFile = "provider-state" |
15 | 18 |
16 // Persistent environment state. An environment needs to know what instances | 19 // Persistent environment state. An environment needs to know what instances |
17 // it manages. | 20 // it manages. |
18 type bootstrapState struct { | 21 type bootstrapState struct { |
19 StateInstances []instance.Id `yaml:"state-instances"` | 22 StateInstances []instance.Id `yaml:"state-instances"` |
20 } | 23 } |
21 | 24 |
22 // saveState writes the environment's state to the provider-state file stored | 25 // saveState writes the environment's state to the provider-state file stored |
(...skipping 18 matching lines...) Expand all Loading... |
41 if err != nil { | 44 if err != nil { |
42 return nil, fmt.Errorf("error reading %q: %v", stateFile, err) | 45 return nil, fmt.Errorf("error reading %q: %v", stateFile, err) |
43 } | 46 } |
44 var state bootstrapState | 47 var state bootstrapState |
45 err = goyaml.Unmarshal(data, &state) | 48 err = goyaml.Unmarshal(data, &state) |
46 if err != nil { | 49 if err != nil { |
47 return nil, fmt.Errorf("error unmarshalling %q: %v", stateFile,
err) | 50 return nil, fmt.Errorf("error unmarshalling %q: %v", stateFile,
err) |
48 } | 51 } |
49 return &state, nil | 52 return &state, nil |
50 } | 53 } |
LEFT | RIGHT |