Skip to content

Commit

Permalink
Merge pull request #48 from jonboulle/master
Browse files Browse the repository at this point in the history
feat(*): add ResetFailedUnit
  • Loading branch information
jonboulle committed May 28, 2014
2 parents f743bc1 + 424dea7 commit 75041d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dbus/dbus.go
Expand Up @@ -38,7 +38,7 @@ func ObjectPath(path string) dbus.ObjectPath {
return dbus.ObjectPath(path)
}

// Conn is a connection to systemds dbus endpoint.
// Conn is a connection to systemd's dbus endpoint.
type Conn struct {
sysconn *dbus.Conn
sysobj *dbus.Object
Expand Down
10 changes: 8 additions & 2 deletions dbus/methods.go
Expand Up @@ -18,6 +18,7 @@ package dbus

import (
"errors"

"github.com/godbus/dbus"
)

Expand Down Expand Up @@ -62,7 +63,7 @@ func (c *Conn) runJob(job string, args ...interface{}) (string, error) {
return <-respCh, nil
}

// StartUnit enqeues a start job and depending jobs, if any (unless otherwise
// StartUnit enqueues a start job and depending jobs, if any (unless otherwise
// specified by the mode string).
//
// Takes the unit to activate, plus a mode string. The mode needs to be one of
Expand Down Expand Up @@ -138,6 +139,11 @@ func (c *Conn) KillUnit(name string, signal int32) {
c.sysobj.Call("org.freedesktop.systemd1.Manager.KillUnit", 0, name, "all", signal).Store()
}

// ResetFailedUnit resets the "failed" state of a specific unit.
func (c *Conn) ResetFailedUnit(name string) (string, error) {
return c.runJob("org.freedesktop.systemd1.Manager.ResetFailedUnit", name)
}

// getProperties takes the unit name and returns all of its dbus object properties, for the given dbus interface
func (c *Conn) getProperties(unit string, dbusInterface string) (map[string]interface{}, error) {
var err error
Expand Down Expand Up @@ -208,7 +214,7 @@ func (c *Conn) SetUnitProperties(name string, runtime bool, properties ...Proper
}

func (c *Conn) GetUnitTypeProperty(unit string, unitType string, propertyName string) (*Property, error) {
return c.getProperty(unit, "org.freedesktop.systemd1." + unitType, propertyName)
return c.getProperty(unit, "org.freedesktop.systemd1."+unitType, propertyName)
}

// ListUnits returns an array with all currently loaded units. Note that
Expand Down

0 comments on commit 75041d0

Please sign in to comment.