2014-03-04 16:40:35 -08:00
|
|
|
package introspect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
2014-03-12 19:36:31 -07:00
|
|
|
"github.com/coreos/coreos-cloudinit/third_party/github.com/guelfey/go.dbus"
|
2014-03-04 16:40:35 -08:00
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Call calls org.freedesktop.Introspectable.Introspect on a remote object
|
|
|
|
// and returns the introspection data.
|
|
|
|
func Call(o *dbus.Object) (*Node, error) {
|
|
|
|
var xmldata string
|
|
|
|
var node Node
|
|
|
|
|
|
|
|
err := o.Call("org.freedesktop.DBus.Introspectable.Introspect", 0).Store(&xmldata)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
err = xml.NewDecoder(strings.NewReader(xmldata)).Decode(&node)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if node.Name == "" {
|
|
|
|
node.Name = string(o.Path())
|
|
|
|
}
|
|
|
|
return &node, nil
|
|
|
|
}
|