コード例 #1
0
ファイル: ifacemgr_test.go プロジェクト: pedronis/snappy
func (s *interfaceManagerSuite) manager(c *C) *ifacestate.InterfaceManager {
	if s.privateMgr == nil {
		mgr, err := ifacestate.Manager(s.state, s.extraIfaces)
		c.Assert(err, IsNil)
		s.privateMgr = mgr
	}
	return s.privateMgr
}
コード例 #2
0
ファイル: overlord.go プロジェクト: clobrano/snappy
// New creates a new Overlord with all its state managers.
func New() (*Overlord, error) {
	o := &Overlord{
		loopTomb: new(tomb.Tomb),
	}

	backend := &overlordStateBackend{
		path:           dirs.SnapStateFile,
		ensureBefore:   o.ensureBefore,
		requestRestart: o.requestRestart,
	}
	s, err := loadState(backend)
	if err != nil {
		return nil, err
	}

	o.stateEng = NewStateEngine(s)

	snapMgr, err := snapstate.Manager(s)
	if err != nil {
		return nil, err
	}
	o.snapMgr = snapMgr
	o.stateEng.AddManager(o.snapMgr)

	assertMgr, err := assertstate.Manager(s)
	if err != nil {
		return nil, err
	}
	o.assertMgr = assertMgr
	o.stateEng.AddManager(o.assertMgr)

	ifaceMgr, err := ifacestate.Manager(s, nil)
	if err != nil {
		return nil, err
	}
	o.ifaceMgr = ifaceMgr
	o.stateEng.AddManager(o.ifaceMgr)

	hookMgr, err := hookstate.Manager(s)
	if err != nil {
		return nil, err
	}
	o.hookMgr = hookMgr
	o.stateEng.AddManager(o.hookMgr)

	configMgr, err := configstate.Manager(s, hookMgr)
	if err != nil {
		return nil, err
	}
	o.configMgr = configMgr

	deviceMgr, err := devicestate.Manager(s)
	if err != nil {
		return nil, err
	}
	o.deviceMgr = deviceMgr
	o.stateEng.AddManager(o.deviceMgr)

	// setting up the store
	authContext := auth.NewAuthContext(s, o.deviceMgr)
	sto := storeNew(nil, authContext)
	s.Lock()
	snapstate.ReplaceStore(s, sto)
	s.Unlock()

	return o, nil
}