// stateStepsFor25 returns upgrade steps for Juju 2.5.0 that manipulate state directly.
333452
func stateStepsFor25() []Step {
	return []Step{
		&upgradeStep{
			description: `migrate storage records to use "hostid" field`,
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().MigrateStorageMachineIdFields()
			},
		},
		&upgradeStep{
			description: "migrate legacy leases into raft",
			targets:     []Target{Controller},
			run:         MigrateLegacyLeases,
		},
		&upgradeStep{
			description: "migrate add-model permissions",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().MigrateAddModelPermissions()
			},
		},
		&upgradeStep{
			description: "set enable-disk-uuid (if on vsphere)",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().SetEnableDiskUUIDOnVsphere()
			},
		},
	}
}
220885
func (bt *BaseTask) AdjacentStates() []MachineState {
	adjacent := []MachineState{}
	if bt.next != nil {
		adjacent = append(adjacent, bt.next)
	}
	for _, eachCatcher := range bt.Catchers {
		adjacent = append(adjacent, eachCatcher.next)
	}
	return adjacent
}
904697
func (lifecycle *Lifecycle) Step() int {
	lifecycle.muStep.RLock()
	defer lifecycle.muStep.RUnlock()
	return lifecycle.step
}
321492
func StepmanRawStepLibStepInfo(collection, stepID, stepVersion string) (string, error) {
	logLevel := log.GetLevel().String()
	args := []string{"--loglevel", logLevel, "step-info", "--collection", collection,
		"--id", stepID, "--version", stepVersion, "--format", "raw"}
	return command.RunCommandAndReturnCombinedStdoutAndStderr("stepman", args...)
}
119451
func stateBeginColorESC(s *scanner, c byte) int {
	switch c {
	case '[':
		s.step = stateBeginColorRest
		return scanContinue
	}
	return s.error(c, "in string color escape code")
}
920496
func waitForState(errCh chan<- error, target string, refresh stateRefreshFunc) error {
	ctx := context.TODO()
	err := retry.Config{
		RetryDelay: (&retry.Backoff{InitialBackoff: 2 * time.Second, MaxBackoff: 2 * time.Second, Multiplier: 2}).Linear,
	}.Run(ctx, func(ctx context.Context) error {
		state, err := refresh()
		if err != nil {
			return err
		}
		if state == target {
			return nil
		}
		return fmt.Errorf("retrying for state %s, got %s", target, state)
	})
	errCh <- err
	return err
}
1136443
func runForAllModelStates(pool *StatePool, runner func(st *State) error) error {
	st := pool.SystemState()
	models, closer := st.db().GetCollection(modelsC)
	defer closer()

	var modelDocs []bson.M
	err := models.Find(nil).Select(bson.M{"_id": 1}).All(&modelDocs)
	if err != nil {
		return errors.Annotate(err, "failed to read models")
	}

	for _, modelDoc := range modelDocs {
		modelUUID := modelDoc["_id"].(string)
		model, err := pool.Get(modelUUID)
		if err != nil {
			return errors.Annotatef(err, "failed to open model %q", modelUUID)
		}
		defer func() {
			model.Release()
		}()
		if err := runner(model.State); err != nil {
			return errors.Annotatef(err, "model UUID %q", modelUUID)
		}
	}
	return nil
}
1086828
func GetStep(s Step) string {
	return fmt.Sprintf("{\"sequence\"=>\"%d\",\"state\"=>\"%s\",\"errors\"=>%s,\"warnings\"=>%s,\"operation\"=>\"%s\","+
		"\"startedTime\"=>\"%d\",\"queuedTime\"=>\"%d\",\"endTime\"=>\"%d\",\"options\"=>%s}",
		s.Sequence, s.State, s.Errors, s.Warnings, s.Operation, s.StartedTime, s.QueuedTime,
		s.EndTime, s.Options)

}
1186904
func stateStepsFor23() []Step {
	return []Step{
		&upgradeStep{
			description: "add a 'type' field to model documents",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().AddModelType()
			},
		},
		&upgradeStep{
			description: "migrate old leases",
			targets:     []Target{DatabaseMaster},
			run: func(context Context) error {
				return context.State().MigrateLeasesToGlobalTime()
			},
		},
	}
}
436926
func stateE0(s *Scanner, c int) int {
	if '0' <= c && c <= '9' {
		s.Step = stateE0
		return ScanContinue
	}
	return stateEndValue(s, c)
}
893117
func (st *State) GoalState() (application.GoalState, error) {
	var result params.GoalStateResults

	gs := application.GoalState{}

	args := params.Entities{
		Entities: []params.Entity{
			{Tag: st.unitTag.String()},
		},
	}

	err := st.facade.FacadeCall("GoalStates", args, &result)
	if err != nil {
		return gs, err
	}
	if len(result.Results) != 1 {
		return gs, errors.Errorf("expected 1 result, got %d", len(result.Results))
	}
	if err := result.Results[0].Error; err != nil {
		return gs, err
	}
	gs = goalStateFromParams(result.Results[0].Result)
	return gs, nil
}
1236089
func (o *Compute) SetSteps(v *Steps) *Compute {
	if o.Steps = v; o.Steps == nil {
		o.nullFields = append(o.nullFields, "Steps")
	}
	return o
}
268415
func liveStatesFromInitial(a *Automaton) *util.OpenBitSet {
	numStates := a.numStates()
	live := util.NewOpenBitSet()
	if numStates == 0 {
		return live
	}
	workList := list.New()
	live.Set(0)
	workList.PushBack(0)

	t := newTransition()
	for workList.Len() > 0 {
		s := workList.Remove(workList.Front()).(int)
		count := a.initTransition(s, t)
		for i := 0; i < count; i++ {
			a.nextTransition(t)
			if !live.Get(int64(t.dest)) {
				live.Set(int64(t.dest))
				workList.PushBack(t.dest)
			}
		}
	}

	return live
}
682707
func updateStateListForChar(states stateSlice, data []byte, index int) stateSlice {
	var result stateSlice = nil
	for _, s := range states {
		if r := updateStateForChar(s, data, index); len(r) > 0 {
			result = append(result, r...)
		}
	}
	return simplifyStates(result)
}
1011256
func ParseStepDefinition(pth string, validate bool) (models.StepModel, error) {
	bytes, err := fileutil.ReadBytesFromFile(pth)
	if err != nil {
		return models.StepModel{}, err
	}

	return parseStepModel(bytes, validate)
}
1071187
func (f *Flow) AddAllToOneStep(input *Dataset, output *Dataset) (step *Step) {
	step = f.NewStep()
	step.NetworkType = AllShardToOneShard
	fromStepToDataset(step, output)
	fromDatasetToStep(input, step)

	// setup the network
	task := step.NewTask()
	if output != nil {
		fromTaskToDatasetShard(task, output.GetShards()[0])
	}
	for _, shard := range input.GetShards() {
		fromDatasetShardToTask(shard, task)
	}
	return
}
712963
func stepsFor24() []Step {
	return []Step{
		&upgradeStep{
			description: "Install the service file in Standard location '/lib/systemd'",
			targets:     []Target{AllMachines},
			run:         installServiceFile,
		},
	}
}