Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListUnitsByNames returns an error #223

Closed
rebeccaskinner opened this issue Feb 13, 2017 · 3 comments
Closed

ListUnitsByNames returns an error #223

rebeccaskinner opened this issue Feb 13, 2017 · 3 comments

Comments

@rebeccaskinner
Copy link

What Happens:

Calling the ListUnitsByNames function on *dbus.Conn results in an unexpected error: Unknown method 'ListUnitsByNames' or interface 'org.freedesktop.systemd1.Manager'

What I expected to happen:

A slice of UnitStatus and no error, or a more descriptive error message.

How to reproduce:

Sample Code:

package main
import (
	"fmt"
	"github.com/coreos/go-systemd/dbus"
)

func main() {
	conn, err := dbus.New()
	if err != nil {
		fmt.Println("error getting connection: ", err)
	}
	res, err := conn.ListUnitsByNames([]string{"acpid.service"})
	if err != nil {
		fmt.Println("error with ListUnitsByNames: ", err)
		return
	}
	fmt.Printf("got %d results\n", len(res))
}

Test system:

uname -a; lsb_release -a
Linux rebecca-vboxdev 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
@lucab
Copy link
Contributor

lucab commented Feb 13, 2017

Which systemd version is this on? ListUnitsByNames has been added only recently in systemd/systemd#3182, which should be v232+ v230+.

@dongsupark
Copy link

@lucab I think systemd needs to be v230 or higher for ListUnitsByNames, while systemd on Ubuntu xenial is v229.
So it's recommended to introduce fallback like this.

@rebeccaskinner
Copy link
Author

Okay yeah, I'm on 229. I've refactored to work around needing the call. I wonder if it's worthwhile to append a since: <version> line to the method comment descriptions? Happy to take some time to make a PR if that's something that you all think would be valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants