Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3515)

Delta Between Two Patch Sets: cmd/juju/status.go

Issue 8561046: cmd/juju: status displays machine errors (Closed)
Left Patch Set: cmd/juju: status displays machine errors Created 10 years, 11 months ago
Right Patch Set: cmd/juju: status displays machine errors Created 10 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | cmd/juju/status_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package main 1 package main
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/gnuflag" 5 "launchpad.net/gnuflag"
6 "launchpad.net/juju-core/cmd" 6 "launchpad.net/juju-core/cmd"
7 "launchpad.net/juju-core/environs" 7 "launchpad.net/juju-core/environs"
8 "launchpad.net/juju-core/juju" 8 "launchpad.net/juju-core/juju"
9 "launchpad.net/juju-core/state" 9 "launchpad.net/juju-core/state"
10 "launchpad.net/juju-core/state/api/params" 10 "launchpad.net/juju-core/state/api/params"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 func processMachine(machine *state.Machine, instance environs.Instance) (map[str ing]interface{}, error) { 131 func processMachine(machine *state.Machine, instance environs.Instance) (map[str ing]interface{}, error) {
132 r := m() 132 r := m()
133 r["instance-id"] = instance.Id() 133 r["instance-id"] = instance.Id()
134 134
135 if dnsname, err := instance.DNSName(); err == nil { 135 if dnsname, err := instance.DNSName(); err == nil {
136 r["dns-name"] = dnsname 136 r["dns-name"] = dnsname
137 } 137 }
138 138
139 processVersion(r, machine) 139 processVersion(r, machine)
140 140
141 // The following logic is ported from Python juju status command.
fwereade 2013/04/11 11:35:11 No longer accurate
dimitern 2013/04/11 12:00:27 Removed.
142 agentAlive, err := machine.AgentAlive() 141 agentAlive, err := machine.AgentAlive()
143 if err != nil { 142 if err != nil {
144 return nil, err 143 return nil, err
145 } 144 }
146 machineDead := machine.Life() == state.Dead 145 machineDead := machine.Life() == state.Dead
147 status, info, err := machine.Status() 146 status, info, err := machine.Status()
148 if err != nil { 147 if err != nil {
149 return nil, err 148 return nil, err
150 } 149 }
151 150
152 if status != params.MachinePending { 151 if status != params.MachinePending {
153 if !agentAlive && !machineDead { 152 if !agentAlive && !machineDead {
154 // Add the original status to the info, so it's not lost . 153 // Add the original status to the info, so it's not lost .
155 if info != "" { 154 if info != "" {
156 » » » » info = fmt.Sprintf("%s: %s", status, info) 155 » » » » info = fmt.Sprintf("(%s: %s)", status, info)
157 } else { 156 } else {
158 » » » » info = string(status) 157 » » » » info = fmt.Sprintf("(%s)", status)
fwereade 2013/04/11 11:35:11 Might be good to parenthesize these infos (because
159 } 158 }
160 // Agent should be running but it's not. 159 // Agent should be running but it's not.
161 status = params.MachineDown 160 status = params.MachineDown
fwereade 2013/04/11 11:35:11 This duplicated chunk makes me feel that maybe we
dimitern 2013/04/11 12:00:27 Let's not do this for now. We might find cases whe
162 } 161 }
163 } 162 }
164 r["agent-state"] = status 163 r["agent-state"] = status
165 if info != "" { 164 if info != "" {
166 r["agent-state-info"] = info 165 r["agent-state-info"] = info
167 } 166 }
168 return r, nil 167 return r, nil
169 } 168 }
170 169
171 // processServices gathers information about services. 170 // processServices gathers information about services.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 229 }
231 unitDead := unit.Life() == state.Dead 230 unitDead := unit.Life() == state.Dead
232 status, info, err := unit.Status() 231 status, info, err := unit.Status()
233 if err != nil { 232 if err != nil {
234 return nil, err 233 return nil, err
235 } 234 }
236 if status != params.UnitPending { 235 if status != params.UnitPending {
237 if !agentAlive && !unitDead { 236 if !agentAlive && !unitDead {
238 // Add the original status to the info, so it's not lost . 237 // Add the original status to the info, so it's not lost .
239 if info != "" { 238 if info != "" {
240 » » » » info = fmt.Sprintf("%s: %s", status, info) 239 » » » » info = fmt.Sprintf("(%s: %s)", status, info)
241 } else { 240 } else {
242 » » » » info = string(status) 241 » » » » info = fmt.Sprintf("(%s)", status)
fwereade 2013/04/11 11:35:11 parenthesize these too please
dimitern 2013/04/11 12:00:27 Done.
243 } 242 }
244 // Agent should be running but it's not. 243 // Agent should be running but it's not.
245 status = params.UnitDown 244 status = params.UnitDown
246 } 245 }
247 } 246 }
248 r["agent-state"] = status 247 r["agent-state"] = status
249 if info != "" { 248 if info != "" {
250 r["agent-state-info"] = info 249 r["agent-state-info"] = info
251 } 250 }
252 return r, nil 251 return r, nil
(...skipping 10 matching lines...) Expand all
263 } 262 }
264 263
265 func m() map[string]interface{} { return make(map[string]interface{}) } 264 func m() map[string]interface{} { return make(map[string]interface{}) }
266 265
267 func checkError(m map[string]interface{}, err error) map[string]interface{} { 266 func checkError(m map[string]interface{}, err error) map[string]interface{} {
268 if err != nil { 267 if err != nil {
269 return map[string]interface{}{"status-error": err.Error()} 268 return map[string]interface{}{"status-error": err.Error()}
270 } 269 }
271 return m 270 return m
272 } 271 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b