// WatchUnits starts a StringsWatcher to watch all units deployed to // any machine passed in args, in order to track which ones should be // deployed or recalled. func (d *DeployerAPI) WatchUnits(args params.Entities) (params.StringsWatchResults, error) { result := params.StringsWatchResults{ Results: make([]params.StringsWatchResult, len(args.Entities)), } for i, entity := range args.Entities { err := common.ErrPerm if d.authorizer.AuthOwner(entity.Tag) { var machine *state.Machine machine, err = d.st.Machine(state.MachineIdFromTag(entity.Tag)) if err == nil { watch := machine.WatchUnits() // Consume the initial event and forward it to the result. if changes, ok := <-watch.Changes(); ok { result.Results[i].StringsWatcherId = d.resources.Register(watch) result.Results[i].Changes = changes } else { err = watcher.MustErr(watch) } } } result.Results[i].Error = common.ServerError(err) } return result, nil }