func NewSystemdManager(machine *machine.Machine, unitPrefix string) *SystemdManager { systemd, err := dbus.New() if err != nil { panic(err) } name := "fleet-" + machine.State().BootId + ".target" target := NewSystemdTarget(name) mgr := &SystemdManager{systemd, target, machine, unitPrefix, defaultSystemdRuntimePath, systemd.NewSubscriptionSet(), nil} mgr.writeUnit(target.Name(), "") return mgr }
func (self *EventBus) RemoveListener(name string, m *machine.Machine) { key := fmt.Sprintf("%s-%s", name, m.String()) if _, ok := self.listeners[key]; ok { delete(self.listeners, key) } }
func (self *EventBus) AddListener(name string, m *machine.Machine, l interface{}) { listener := EventListener{m, l} key := fmt.Sprintf("%s-%s", name, m.String()) self.listeners[key] = listener }