| index b05b02388..13408ec10 100644 |
| --- a/move.go |
| +++ b/move.go |
| @@ -618,7 +618,7 @@ func (m *mover) accepted(ctx context.Context, r moveReply, wait, request bool) i |
| return moveExitDone |
| } |
| w := newMoveWatch(m, view.ID) |
| - w.toRegion = view.Target |
| + w.toRegion = placeOr(view.TargetName, view.Target) |
| a, code := m.readDetail(ctx) |
| if code >= 0 { |
| return code |
| @@ -692,11 +692,13 @@ func (w *moveWatch) learn(a moveAnswer) { |
| if a.ID != w.id { |
| return |
| } |
| - if a.Detail.From != "" { |
| - w.fromRegion = a.Detail.From |
| + // Places for the sentences (region labels §5 row 25): the console's |
| + // labels, else the codes it sent. Nothing here is ever a command. |
| + if a.Detail != nil && (a.Detail.From != "" || a.Detail.FromName != "") { |
| + w.fromRegion = placeOr(a.Detail.FromName, a.Detail.From) |
| } |
| if a.Target != "" { |
| - w.toRegion = a.Target |
| + w.toRegion = placeOr(a.TargetName, a.Target) |
| } |
| } |
| |
| @@ -1004,6 +1006,12 @@ var offlineVerbs = []string{"stage", "start", "seal", "flip", "open", "finish", |
| |
| // offlineView is the offline status view (GET) and the 202 every mutating |
| // door answers with. |
| +// fromPlace and toPlace are the move's regions as a sentence names them |
| +// (region labels §5 row 26): the console's labels, else the codes. Every |
| +// command printed (--to) keeps v.To. |
| +func (v offlineView) fromPlace() string { return placeOr(v.FromName, v.From) } |
| +func (v offlineView) toPlace() string { return placeOr(v.ToName, v.To) } |
| + |
| type offlineView struct { |
| Host string `json:"host"` |
| State string `json:"state"` |
| @@ -1068,7 +1076,7 @@ func (w *offlineRun) sayStaged(v offlineView) { |
| return |
| } |
| at := time.Unix(c.RoundAt, 0).UTC().Format("2006-01-02 15:04 UTC") |
| - moveSay(w.m.out, fmt.Sprintf("Staged %d of %d objects for %s in %s (%s of %s MB) at %s.", c.Done, c.Total, host, v.To, megabytes(c.DoneBytes), megabytes(c.TotalBytes), at)) |
| + moveSay(w.m.out, fmt.Sprintf("Staged %d of %d objects for %s in %s (%s of %s MB) at %s.", c.Done, c.Total, host, v.toPlace(), megabytes(c.DoneBytes), megabytes(c.TotalBytes), at)) |
| } |
| |
| // sayStartWhenReady is MV-O184: what comes after a stage. |
| @@ -1244,7 +1252,7 @@ func (w *offlineRun) sayFailure(v offlineView) bool { |
| } |
| switch kind { |
| case failTarget: |
| - moveSay(w.m.out, fmt.Sprintf("%s could not take %s: %s. Run carlos move offline abort --host %s to move it back.", v.To, host, reason, host)) |
| + moveSay(w.m.out, fmt.Sprintf("%s could not take %s: %s. Run carlos move offline abort --host %s to move it back.", v.toPlace(), host, reason, host)) |
| case failSource: |
| for _, r := range v.Reports { |
| if r.Role == moves.OfflineRoleSource && r.Phase == moves.OfflinePhaseFailed { |
| @@ -1269,7 +1277,7 @@ type offlineRun struct { |
| |
| func (w *offlineRun) learn(v offlineView) { |
| if v.ID != "" && (w.id == "" || w.id == v.ID) { |
| - w.id, w.from, w.to = v.ID, v.From, v.To |
| + w.id, w.from, w.to = v.ID, v.fromPlace(), v.toPlace() |
| } |
| } |
| |
| @@ -1421,7 +1429,7 @@ func (w *offlineRun) served(v offlineView) bool { |
| func (w *offlineRun) sayServed(v offlineView) { |
| if w.once("served") { |
| host := w.m.host |
| - moveSay(w.m.out, fmt.Sprintf("%s is served from %s. Run carlos move offline finish --host %s once %s has cleaned up.", host, v.To, host, v.From)) |
| + moveSay(w.m.out, fmt.Sprintf("%s is served from %s. Run carlos move offline finish --host %s once %s has cleaned up.", host, v.toPlace(), host, v.fromPlace())) |
| } |
| } |
| |
| @@ -1429,7 +1437,7 @@ func (w *offlineRun) sayServed(v offlineView) { |
| func (w *offlineRun) headline(r offlineReply) { |
| v, host := r.v, w.m.host |
| if v.State == provision.OfflineStaging { |
| - moveSay(w.m.out, fmt.Sprintf("Staging %s in %s. %s keeps serving while the data is copied.", host, v.To, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Staging %s in %s. %s keeps serving while the data is copied.", host, v.toPlace(), host)) |
| w.sayStaged(v) |
| if v.Next == "start" { |
| w.sayStartWhenReady(v) |
| @@ -1438,30 +1446,30 @@ func (w *offlineRun) headline(r offlineReply) { |
| w.sayWaiting(r) |
| return |
| } |
| - moveSay(w.m.out, moves.MoveStartingLine(host, v.From, v.To)) |
| + moveSay(w.m.out, moves.MoveStartingLine(host, v.fromPlace(), v.toPlace())) |
| if w.sayFailure(v) { |
| return |
| } |
| switch v.State { |
| case provision.OfflineStopping: |
| if v.Next == "seal" { |
| - moveSay(w.m.out, fmt.Sprintf("Every box in %s has stopped %s. Run carlos move offline seal --host %s to copy it.", v.From, host, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Every box in %s has stopped %s. Run carlos move offline seal --host %s to copy it.", v.fromPlace(), host, host)) |
| return |
| } |
| w.sayWaiting(r) |
| case provision.OfflineSealing: |
| - moveSay(w.m.out, fmt.Sprintf("Copying %s to %s.", host, v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("Copying %s to %s.", host, v.toPlace())) |
| case provision.OfflineSealed: |
| if v.Next == "flip" { |
| - moveSay(w.m.out, fmt.Sprintf("Copied and checked. Run carlos move offline flip --host %s to start it in %s.", host, v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("Copied and checked. Run carlos move offline flip --host %s to start it in %s.", host, v.toPlace())) |
| return |
| } |
| w.sayWaiting(r) |
| case provision.OfflineLanding: |
| - moveSay(w.m.out, moves.FlippedLine(v.From, v.To)) |
| + moveSay(w.m.out, moves.FlippedLine(v.fromPlace(), v.toPlace())) |
| case provision.OfflineLanded: |
| if v.Next == "open" { |
| - moveSay(w.m.out, fmt.Sprintf("%s holds everything %s needs. Nothing is served yet. Run carlos move offline open --host %s to serve it from %s.", v.To, host, host, v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("%s holds everything %s needs. Nothing is served yet. Run carlos move offline open --host %s to serve it from %s.", v.toPlace(), host, host, v.toPlace())) |
| return |
| } |
| w.sayWaiting(r) |
| @@ -1473,10 +1481,10 @@ func (w *offlineRun) headline(r offlineReply) { |
| } |
| w.sayCleaning(v) |
| case provision.OfflineReverting: |
| - moveSay(w.m.out, fmt.Sprintf("Moving %s back to %s.", host, v.From)) |
| + moveSay(w.m.out, fmt.Sprintf("Moving %s back to %s.", host, v.fromPlace())) |
| w.sayCleaning(v) |
| if v.Next == "finish" { |
| - moveSay(w.m.out, fmt.Sprintf("Every box has put %s back in %s. Run carlos move offline finish --host %s to end the move.", host, v.From, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Every box has put %s back in %s. Run carlos move offline finish --host %s to end the move.", host, v.fromPlace(), host)) |
| } |
| } |
| } |
| @@ -1575,7 +1583,7 @@ func (w *offlineRun) runStage(ctx context.Context, to string) int { |
| if r.v.State != provision.OfflineStaging { |
| return w.stray(r) |
| } |
| - moveSay(w.m.out, fmt.Sprintf("Staging %s in %s. %s keeps serving while the data is copied.", host, r.v.To, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Staging %s in %s. %s keeps serving while the data is copied.", host, r.v.toPlace(), host)) |
| asked := r.v.StagedAt |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| if r.v.State != provision.OfflineStaging { |
| @@ -1600,13 +1608,13 @@ func (w *offlineRun) runStart(ctx context.Context, to string) int { |
| return code |
| } |
| host := w.m.host |
| - moveSay(w.m.out, moves.MoveStartingLine(host, r.v.From, r.v.To)) |
| + moveSay(w.m.out, moves.MoveStartingLine(host, r.v.fromPlace(), r.v.toPlace())) |
| moveSay(w.m.out, fmt.Sprintf("%s is offline from now until the move opens or is aborted.", host)) |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| switch r.v.State { |
| case provision.OfflineStopping: |
| if r.v.Next == "seal" { |
| - moveSay(w.m.out, fmt.Sprintf("Every box in %s has stopped %s. Run carlos move offline seal --host %s to copy it.", r.v.From, host, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Every box in %s has stopped %s. Run carlos move offline seal --host %s to copy it.", r.v.fromPlace(), host, host)) |
| return moveExitDone, true |
| } |
| w.sayWaiting(r) |
| @@ -1622,7 +1630,7 @@ func (w *offlineRun) runSeal(ctx context.Context) int { |
| return code |
| } |
| host := w.m.host |
| - moveSay(w.m.out, fmt.Sprintf("Copying %s to %s.", host, r.v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("Copying %s to %s.", host, r.v.toPlace())) |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| switch r.v.State { |
| case provision.OfflineSealing, provision.OfflineSealed: |
| @@ -1631,7 +1639,7 @@ func (w *offlineRun) runSeal(ctx context.Context) int { |
| } |
| if r.v.State == provision.OfflineSealed { |
| if r.v.Next == "flip" { |
| - moveSay(w.m.out, fmt.Sprintf("Copied and checked. Run carlos move offline flip --host %s to start it in %s.", host, r.v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("Copied and checked. Run carlos move offline flip --host %s to start it in %s.", host, r.v.toPlace())) |
| return moveExitDone, true |
| } |
| w.sayWaiting(r) |
| @@ -1648,7 +1656,7 @@ func (w *offlineRun) runFlip(ctx context.Context) int { |
| return code |
| } |
| host := w.m.host |
| - moveSay(w.m.out, moves.FlippedLine(r.v.From, r.v.To)) |
| + moveSay(w.m.out, moves.FlippedLine(r.v.fromPlace(), r.v.toPlace())) |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| switch r.v.State { |
| case provision.OfflineLanding, provision.OfflineLanded: |
| @@ -1657,7 +1665,7 @@ func (w *offlineRun) runFlip(ctx context.Context) int { |
| } |
| if r.v.State == provision.OfflineLanded { |
| if r.v.Next == "open" { |
| - moveSay(w.m.out, fmt.Sprintf("%s holds everything %s needs. Nothing is served yet. Run carlos move offline open --host %s to serve it from %s.", r.v.To, host, host, r.v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("%s holds everything %s needs. Nothing is served yet. Run carlos move offline open --host %s to serve it from %s.", r.v.toPlace(), host, host, r.v.toPlace())) |
| return moveExitDone, true |
| } |
| w.sayWaiting(r) |
| @@ -1761,11 +1769,11 @@ func (w *offlineRun) runAbort(ctx context.Context) int { |
| return w.abortStaged(ctx, r) |
| } |
| host := w.m.host |
| - moveSay(w.m.out, fmt.Sprintf("Moving %s back to %s.", host, r.v.From)) |
| + moveSay(w.m.out, fmt.Sprintf("Moving %s back to %s.", host, r.v.fromPlace())) |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| if r.v.State == provision.OfflineReverting { |
| if r.v.Next == "finish" { |
| - moveSay(w.m.out, fmt.Sprintf("Every box has put %s back in %s. Run carlos move offline finish --host %s to end the move.", host, r.v.From, host)) |
| + moveSay(w.m.out, fmt.Sprintf("Every box has put %s back in %s. Run carlos move offline finish --host %s to end the move.", host, r.v.fromPlace(), host)) |
| return moveExitRolled, true |
| } |
| w.sayCleaning(r.v) |
| @@ -1779,7 +1787,7 @@ func (w *offlineRun) runAbort(ctx context.Context) int { |
| // copy, every source box reports, and the operator runs finish. |
| func (w *offlineRun) abortStaged(ctx context.Context, r offlineReply) int { |
| host := w.m.host |
| - moveSay(w.m.out, fmt.Sprintf("Removing the staged copy of %s from %s.", host, r.v.To)) |
| + moveSay(w.m.out, fmt.Sprintf("Removing the staged copy of %s from %s.", host, r.v.toPlace())) |
| return w.follow(ctx, r, func(r offlineReply) (int, bool) { |
| if r.v.State == provision.OfflineReverting { |
| if r.v.Next == "finish" { |