Left: | ||
Right: |
OLD | NEW |
---|---|
1 package state | 1 package state |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "labix.org/v2/mgo" | 5 "labix.org/v2/mgo" |
6 "labix.org/v2/mgo/txn" | 6 "labix.org/v2/mgo/txn" |
7 "launchpad.net/juju-core/state/presence" | 7 "launchpad.net/juju-core/state/presence" |
8 "launchpad.net/juju-core/trivial" | 8 "launchpad.net/juju-core/trivial" |
9 "strconv" | 9 "strconv" |
10 "time" | 10 "time" |
(...skipping 23 matching lines...) Expand all Loading... | |
34 // Id returns the machine id. | 34 // Id returns the machine id. |
35 func (m *Machine) Id() int { | 35 func (m *Machine) Id() int { |
36 return m.doc.Id | 36 return m.doc.Id |
37 } | 37 } |
38 | 38 |
39 // globalKey returns the global database key for the machine. | 39 // globalKey returns the global database key for the machine. |
40 func (m *Machine) globalKey() string { | 40 func (m *Machine) globalKey() string { |
41 return "m#" + m.String() | 41 return "m#" + m.String() |
42 } | 42 } |
43 | 43 |
44 // PathKey returns a name identifying the machine that can be used as a | |
45 // file name. The returned key will be different from other | |
46 // PathKeys returned by any other entities from the same state. | |
niemeyer
2012/09/28 14:39:34
s/PathKeys/PathKey values/
As a good convention,
rog
2012/09/28 15:28:58
done. i changed the one it was copied from too.
| |
47 func (m *Machine) PathKey() string { | |
48 return fmt.Sprintf("machine-%d", m.doc.Id) | |
49 } | |
50 | |
44 // Life returns whether the machine is Alive, Dying or Dead. | 51 // Life returns whether the machine is Alive, Dying or Dead. |
45 func (m *Machine) Life() Life { | 52 func (m *Machine) Life() Life { |
46 return m.doc.Life | 53 return m.doc.Life |
47 } | 54 } |
48 | 55 |
49 // Workers returns the workers that the machine agent for m must run. | 56 // Workers returns the workers that the machine agent for m must run. |
50 func (m *Machine) Workers() []WorkerKind { | 57 func (m *Machine) Workers() []WorkerKind { |
51 return m.doc.Workers | 58 return m.doc.Workers |
52 } | 59 } |
53 | 60 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 return fmt.Errorf("cannot set instance id of machine %s: %v", m, onAbort(err, errNotAlive)) | 209 return fmt.Errorf("cannot set instance id of machine %s: %v", m, onAbort(err, errNotAlive)) |
203 } | 210 } |
204 m.doc.InstanceId = id | 211 m.doc.InstanceId = id |
205 return nil | 212 return nil |
206 } | 213 } |
207 | 214 |
208 // String returns a unique description of this machine. | 215 // String returns a unique description of this machine. |
209 func (m *Machine) String() string { | 216 func (m *Machine) String() string { |
210 return strconv.Itoa(m.doc.Id) | 217 return strconv.Itoa(m.doc.Id) |
211 } | 218 } |
OLD | NEW |