// UnitState returns a single UnitState stored in the registry for a given unit
// name.
12962
func (r *EtcdRegistry) UnitState(name string) (state *unit.UnitState, err error) {
	var us *unit.UnitState
	us, err = r.stateByMUSKey(name)
	if err != nil {
		return nil, err
	}

	return us, nil
}
976781
func SaveState(fd uintptr) (*State, error) {
	var oldState State
	if err := tcget(fd, &oldState.termios); err != 0 {
		return nil, err
	}

	return &oldState, nil
}
500027
func (s *InstanceStatus) SetState(v string) *InstanceStatus {
	s.State = &v
	return s
}
798689
func (r *UnitStateService) Get(unitName string) *UnitStateGetCall {
	c := &UnitStateGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
	c.unitName = unitName
	return c
}
64150
func (r *EtcdRegistry) RemoveUnitState(jobName string) error {
	// TODO(jonboulle): consider https://github.com/coreos/fleet/issues/465
	legacyKey := r.legacyUnitStatePath(jobName)
	_, err := r.kAPI.Delete(context.Background(), legacyKey, nil)
	if err != nil && !isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
		return err
	}

	// TODO(jonboulle): deal properly with multiple states
	newKey := r.unitStatesNamespace(jobName)
	opts := &etcd.DeleteOptions{
		Recursive: true,
	}
	_, err = r.kAPI.Delete(context.Background(), newKey, opts)
	if err != nil && !isEtcdError(err, etcd.ErrorCodeKeyNotFound) {
		return err
	}
	return nil
}
335111
func (m *ModelStatus) UnitAgent(unitName string) (status.StatusInfo, error) {
	// We do horrible things with unit status.
	// See notes in unitagent.go.
	info, err := m.getStatus(unitAgentGlobalKey(unitName), "agent")
	if err != nil {
		return info, err
	}
	if info.Status == status.Error {
		return status.StatusInfo{
			Status:  status.Idle,
			Message: "",
			Data:    map[string]interface{}{},
			Since:   info.Since,
		}, nil
	}
	return info, nil
}
313459
func (f *FSM) AddState(state *FSMState) {
	if f.states == nil {
		f.states = make(map[string]*FSMState)
	}
	f.states[state.Name] = state
}
49657
func (r *EtcdRegistry) unitStatesNamespace(jobName string) string {
	return r.prefixed(statesPrefix, jobName)
}
1142329
func (m *systemdUnitManager) GetUnitState(name string) (*unit.UnitState, error) {
	m.mutex.Lock()
	defer m.mutex.Unlock()
	us, err := m.getUnitState(name)
	if err != nil {
		return nil, err
	}
	if h, ok := m.hashes[name]; ok {
		us.UnitHash = h.String()
	}
	return us, nil
}
1205258
func (s *InstanceFleetStatus) SetState(v string) *InstanceFleetStatus {
	s.State = &v
	return s
}
451722
func (s *UnclaimDeviceOutput) SetState(v string) *UnclaimDeviceOutput {
	s.State = &v
	return s
}
348912
func Convert_v1_ContainerState_To_core_ContainerState(in *v1.ContainerState, out *core.ContainerState, s conversion.Scope) error {
	return autoConvert_v1_ContainerState_To_core_ContainerState(in, out, s)
}
1083474
func (d *Dispatcher) getState(name string) (State, error) {
	if s, ok := d.States[name]; ok {
		return CloneState(s), nil
	}
	return State{}, ErrUnknownState
}
762117
func (c *Conn) SystemState() (*Property, error) {
	var err error
	var prop dbus.Variant

	obj := c.sysconn.Object("org.freedesktop.systemd1", "/org/freedesktop/systemd1")
	err = obj.Call("org.freedesktop.DBus.Properties.Get", 0, "org.freedesktop.systemd1.Manager", "SystemState").Store(&prop)
	if err != nil {
		return nil, err
	}

	return &Property{Name: "SystemState", Value: prop}, nil
}
246330
func (s *ReservedCacheNode) SetState(v string) *ReservedCacheNode {
	s.State = &v
	return s
}
961405
func BuildState(cb func(*SyncState)) *State {
	s := NewState()
	cb(s.SyncWrapper())
	return s
}
804379
func (c *FSM) State() *state.Store {
	c.stateLock.RLock()
	defer c.stateLock.RUnlock()
	return c.state
}