LEFT | RIGHT |
(no file at all) | |
1 // launchpad.net/juju/state | 1 // launchpad.net/juju/state |
2 // | 2 // |
3 // Copyright (c) 2011-2012 Canonical Ltd. | 3 // Copyright (c) 2011-2012 Canonical Ltd. |
4 | 4 |
5 package state | 5 package state |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "launchpad.net/juju-core/juju/state/presence" | 9 "launchpad.net/juju-core/juju/state/presence" |
10 "path" | 10 "path" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 func (m *Machine) Units() ([]*Unit, error) { | 69 func (m *Machine) Units() ([]*Unit, error) { |
70 topology, err := readTopology(m.st.zk) | 70 topology, err := readTopology(m.st.zk) |
71 if err != nil { | 71 if err != nil { |
72 return nil, err | 72 return nil, err |
73 } | 73 } |
74 keys := topology.UnitsForMachine(m.key) | 74 keys := topology.UnitsForMachine(m.key) |
75 units := make([]*Unit, len(keys)) | 75 units := make([]*Unit, len(keys)) |
76 for i, key := range keys { | 76 for i, key := range keys { |
77 units[i], err = m.st.unitFromKey(topology, key) | 77 units[i], err = m.st.unitFromKey(topology, key) |
78 if err != nil { | 78 if err != nil { |
79 » » » // If UnitsForMachine is returning keys that don't | 79 » » » return nil, fmt.Errorf("inconsistent topology: %v", err) |
80 » » » // exist, then something is badly wrong. | |
81 » » » panic(err) | |
82 } | 80 } |
83 } | 81 } |
84 return units, nil | 82 return units, nil |
85 } | 83 } |
86 | 84 |
87 // SetInstanceId sets the provider specific machine id for this machine. | 85 // SetInstanceId sets the provider specific machine id for this machine. |
88 func (m *Machine) SetInstanceId(id string) error { | 86 func (m *Machine) SetInstanceId(id string) error { |
89 config, err := readConfigNode(m.st.zk, m.zkPath()) | 87 config, err := readConfigNode(m.st.zk, m.zkPath()) |
90 if err != nil { | 88 if err != nil { |
91 return err | 89 return err |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 if i < 0 || err != nil { | 123 if i < 0 || err != nil { |
126 panic("keySeq: invalid key: " + key) | 124 panic("keySeq: invalid key: " + key) |
127 } | 125 } |
128 return int(id64) | 126 return int(id64) |
129 } | 127 } |
130 | 128 |
131 // machineKey returns the machine key corresponding to machineId. | 129 // machineKey returns the machine key corresponding to machineId. |
132 func machineKey(machineId int) string { | 130 func machineKey(machineId int) string { |
133 return fmt.Sprintf("machine-%010d", machineId) | 131 return fmt.Sprintf("machine-%010d", machineId) |
134 } | 132 } |
LEFT | RIGHT |