LEFT | RIGHT |
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // It does nothing otherwise. | 89 // It does nothing otherwise. |
90 func (m *Machine) EnsureDead() error { | 90 func (m *Machine) EnsureDead() error { |
91 err := ensureDead(m.st, m.st.machines, m.doc.Id, "machine", nil, "") | 91 err := ensureDead(m.st, m.st.machines, m.doc.Id, "machine", nil, "") |
92 if err != nil { | 92 if err != nil { |
93 return err | 93 return err |
94 } | 94 } |
95 m.doc.Life = Dead | 95 m.doc.Life = Dead |
96 return nil | 96 return nil |
97 } | 97 } |
98 | 98 |
99 // Refresh reads the contents of the Machine from the underlying | 99 // Refresh refreshes the contents of the machine from the underlying |
100 // state. It returns a NotFoundError if the machine has been removed. | 100 // state. It returns a NotFoundError if the machine has been removed. |
101 func (m *Machine) Refresh() error { | 101 func (m *Machine) Refresh() error { |
102 doc := machineDoc{} | 102 doc := machineDoc{} |
103 err := m.st.machines.FindId(m.doc.Id).One(&doc) | 103 err := m.st.machines.FindId(m.doc.Id).One(&doc) |
104 if err == mgo.ErrNotFound { | 104 if err == mgo.ErrNotFound { |
105 return notFound("machine %v", m) | 105 return notFound("machine %v", m) |
106 } | 106 } |
107 if err != nil { | 107 if err != nil { |
108 return fmt.Errorf("cannot refresh machine %v: %v", m, err) | 108 return fmt.Errorf("cannot refresh machine %v: %v", m, err) |
109 } | 109 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return fmt.Errorf("cannot set instance id of machine %s: %v", m,
onAbort(err, errNotAlive)) | 195 return fmt.Errorf("cannot set instance id of machine %s: %v", m,
onAbort(err, errNotAlive)) |
196 } | 196 } |
197 m.doc.InstanceId = id | 197 m.doc.InstanceId = id |
198 return nil | 198 return nil |
199 } | 199 } |
200 | 200 |
201 // String returns a unique description of this machine. | 201 // String returns a unique description of this machine. |
202 func (m *Machine) String() string { | 202 func (m *Machine) String() string { |
203 return strconv.Itoa(m.doc.Id) | 203 return strconv.Itoa(m.doc.Id) |
204 } | 204 } |
LEFT | RIGHT |