All of lore.kernel.org
 help / color / mirror / Atom feed
* Parsing dbus introspect
@ 2019-10-18  2:34 Patrick Venture
  2019-10-18  2:46 ` William Kennington
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Venture @ 2019-10-18  2:34 UTC (permalink / raw)
  To: James Feist; +Cc: Peter Lundgren, OpenBMC Maillist

With dbus-sensors, if I follow the Association property, i can find
the board that owns the sensor.  However, we have a use-case where we
want sensors to be able to have their own EntityId and EntityInstance
values configured via the json --

This lead to three situations:
1) sensor's board doesn't implement the Ipmi decoration
2) sensor's board implements the Ipmi decoration
3) sensor's board implements the Ipmi decoration, but the sensor has
override values in the sensor dbus object owned by EntityManager.

The way I see to do it is to introspect on the dbus path and service,
and then search the list of interfaces to find one that starts
"xyz.openbmc_project.Configuration" and then search that interface for
an "EntityId" and "EntityInstance" property, and if present, read
them.

So this leads me to this email:
1) Has anyone already got an XML parser they like and has used it in
this way?  Just to save me from figuring out the exact way to wire it
up.

busctl call xyz.openbmc_project.EntityManager
/xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
org.freedesktop.DBus.Introspectable Introspect

s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
<interface name=\"org.freedesktop.DBus.Peer\">\n  <method
name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
</interface>\n <interface
name=\"org.freedesktop.DBus.Introspectable\">\n  <method
name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
direction=\"out\"/>\n  </method>\n </interface>\n <interface
name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
<arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
  <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
</interface>\n <interface
name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
<property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
<property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
<property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
</interface>\n</node>\n"

It's pretty easy -- it takes no parameters and returns a string that I
feed into an XML parser, and then walk the nodes --> but has anyone
already done this? Maybe I can use their code as a snippet or if it's
in a common OpenBMC library?

If nobody else has done this yet, I'll reply to this email with the
patch that does it :)  I'm definitely interested in suggestions on a
favored c++ XML parser.

Thanks
Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing dbus introspect
  2019-10-18  2:34 Parsing dbus introspect Patrick Venture
@ 2019-10-18  2:46 ` William Kennington
  2019-10-18  3:29   ` Patrick Venture
  0 siblings, 1 reply; 6+ messages in thread
From: William Kennington @ 2019-10-18  2:46 UTC (permalink / raw)
  To: Patrick Venture; +Cc: James Feist, Peter Lundgren, OpenBMC Maillist

Looks like systemd doesn't even use an xml parser
https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c

On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture@google.com> wrote:
>
> With dbus-sensors, if I follow the Association property, i can find
> the board that owns the sensor.  However, we have a use-case where we
> want sensors to be able to have their own EntityId and EntityInstance
> values configured via the json --
>
> This lead to three situations:
> 1) sensor's board doesn't implement the Ipmi decoration
> 2) sensor's board implements the Ipmi decoration
> 3) sensor's board implements the Ipmi decoration, but the sensor has
> override values in the sensor dbus object owned by EntityManager.
>
> The way I see to do it is to introspect on the dbus path and service,
> and then search the list of interfaces to find one that starts
> "xyz.openbmc_project.Configuration" and then search that interface for
> an "EntityId" and "EntityInstance" property, and if present, read
> them.
>
> So this leads me to this email:
> 1) Has anyone already got an XML parser they like and has used it in
> this way?  Just to save me from figuring out the exact way to wire it
> up.
>
> busctl call xyz.openbmc_project.EntityManager
> /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> org.freedesktop.DBus.Introspectable Introspect
>
> s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> </interface>\n <interface
> name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> direction=\"out\"/>\n  </method>\n </interface>\n <interface
> name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
>   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> </interface>\n <interface
> name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> </interface>\n</node>\n"
>
> It's pretty easy -- it takes no parameters and returns a string that I
> feed into an XML parser, and then walk the nodes --> but has anyone
> already done this? Maybe I can use their code as a snippet or if it's
> in a common OpenBMC library?
>
> If nobody else has done this yet, I'll reply to this email with the
> patch that does it :)  I'm definitely interested in suggestions on a
> favored c++ XML parser.
>
> Thanks
> Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing dbus introspect
  2019-10-18  2:46 ` William Kennington
@ 2019-10-18  3:29   ` Patrick Venture
  2019-10-18  3:30     ` Patrick Venture
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Venture @ 2019-10-18  3:29 UTC (permalink / raw)
  To: William Kennington; +Cc: James Feist, Peter Lundgren, OpenBMC Maillist

On Thu, Oct 17, 2019 at 7:46 PM William Kennington <wak@google.com> wrote:
>
> Looks like systemd doesn't even use an xml parser
> https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c

I'm thinking I'll just regex for what I seek in this case.  Since I
know the lead of the string, and how the surrounding bits should
appear.  I just need the interface name, a good regex use-case. :)

>
> On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture@google.com> wrote:
> >
> > With dbus-sensors, if I follow the Association property, i can find
> > the board that owns the sensor.  However, we have a use-case where we
> > want sensors to be able to have their own EntityId and EntityInstance
> > values configured via the json --
> >
> > This lead to three situations:
> > 1) sensor's board doesn't implement the Ipmi decoration
> > 2) sensor's board implements the Ipmi decoration
> > 3) sensor's board implements the Ipmi decoration, but the sensor has
> > override values in the sensor dbus object owned by EntityManager.
> >
> > The way I see to do it is to introspect on the dbus path and service,
> > and then search the list of interfaces to find one that starts
> > "xyz.openbmc_project.Configuration" and then search that interface for
> > an "EntityId" and "EntityInstance" property, and if present, read
> > them.
> >
> > So this leads me to this email:
> > 1) Has anyone already got an XML parser they like and has used it in
> > this way?  Just to save me from figuring out the exact way to wire it
> > up.
> >
> > busctl call xyz.openbmc_project.EntityManager
> > /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> > org.freedesktop.DBus.Introspectable Introspect
> >
> > s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> > Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> > <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> > name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> > name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> > </interface>\n <interface
> > name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> > name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> > direction=\"out\"/>\n  </method>\n </interface>\n <interface
> > name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> > <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> > name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> > type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> > type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> > name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> > name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
> >   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> > type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> > </interface>\n <interface
> > name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> > name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> > <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> > <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> > <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> > </interface>\n</node>\n"
> >
> > It's pretty easy -- it takes no parameters and returns a string that I
> > feed into an XML parser, and then walk the nodes --> but has anyone
> > already done this? Maybe I can use their code as a snippet or if it's
> > in a common OpenBMC library?
> >
> > If nobody else has done this yet, I'll reply to this email with the
> > patch that does it :)  I'm definitely interested in suggestions on a
> > favored c++ XML parser.
> >
> > Thanks
> > Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing dbus introspect
  2019-10-18  3:29   ` Patrick Venture
@ 2019-10-18  3:30     ` Patrick Venture
  2019-10-18  5:55       ` Lei YU
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick Venture @ 2019-10-18  3:30 UTC (permalink / raw)
  To: William Kennington; +Cc: James Feist, Peter Lundgren, OpenBMC Maillist

On Thu, Oct 17, 2019 at 8:29 PM Patrick Venture <venture@google.com> wrote:
>
> On Thu, Oct 17, 2019 at 7:46 PM William Kennington <wak@google.com> wrote:
> >
> > Looks like systemd doesn't even use an xml parser
> > https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c
>
> I'm thinking I'll just regex for what I seek in this case.  Since I
> know the lead of the string, and how the surrounding bits should
> appear.  I just need the interface name, a good regex use-case. :)

<interface name=\"xyz.openbmc_project.Configuration.TMP421\">

>
> >
> > On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture@google.com> wrote:
> > >
> > > With dbus-sensors, if I follow the Association property, i can find
> > > the board that owns the sensor.  However, we have a use-case where we
> > > want sensors to be able to have their own EntityId and EntityInstance
> > > values configured via the json --
> > >
> > > This lead to three situations:
> > > 1) sensor's board doesn't implement the Ipmi decoration
> > > 2) sensor's board implements the Ipmi decoration
> > > 3) sensor's board implements the Ipmi decoration, but the sensor has
> > > override values in the sensor dbus object owned by EntityManager.
> > >
> > > The way I see to do it is to introspect on the dbus path and service,
> > > and then search the list of interfaces to find one that starts
> > > "xyz.openbmc_project.Configuration" and then search that interface for
> > > an "EntityId" and "EntityInstance" property, and if present, read
> > > them.
> > >
> > > So this leads me to this email:
> > > 1) Has anyone already got an XML parser they like and has used it in
> > > this way?  Just to save me from figuring out the exact way to wire it
> > > up.
> > >
> > > busctl call xyz.openbmc_project.EntityManager
> > > /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> > > org.freedesktop.DBus.Introspectable Introspect
> > >
> > > s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> > > Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> > > <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> > > name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> > > name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> > > </interface>\n <interface
> > > name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> > > name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> > > direction=\"out\"/>\n  </method>\n </interface>\n <interface
> > > name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> > > <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> > > name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> > > type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> > > type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> > > name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> > > name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
> > >   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> > > type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> > > </interface>\n <interface
> > > name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> > > name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> > > <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> > > <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> > > <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> > > </interface>\n</node>\n"
> > >
> > > It's pretty easy -- it takes no parameters and returns a string that I
> > > feed into an XML parser, and then walk the nodes --> but has anyone
> > > already done this? Maybe I can use their code as a snippet or if it's
> > > in a common OpenBMC library?
> > >
> > > If nobody else has done this yet, I'll reply to this email with the
> > > patch that does it :)  I'm definitely interested in suggestions on a
> > > favored c++ XML parser.
> > >
> > > Thanks
> > > Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing dbus introspect
  2019-10-18  3:30     ` Patrick Venture
@ 2019-10-18  5:55       ` Lei YU
  2019-10-18 15:41         ` Patrick Venture
  0 siblings, 1 reply; 6+ messages in thread
From: Lei YU @ 2019-10-18  5:55 UTC (permalink / raw)
  To: Patrick Venture
  Cc: William Kennington, Peter Lundgren, OpenBMC Maillist, James Feist

I think object mapper already does this for you.
Just call GetSubtree and you get a list of objects and the interfaces
they implement.

E.g.
 busctl call "xyz.openbmc_project.ObjectMapper"
"/xyz/openbmc_project/object_mapper"
"xyz.openbmc_project.ObjectMapper" GetSubTree sias
/xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
0 0

On Fri, Oct 18, 2019 at 11:33 AM Patrick Venture <venture@google.com> wrote:
>
> On Thu, Oct 17, 2019 at 8:29 PM Patrick Venture <venture@google.com> wrote:
> >
> > On Thu, Oct 17, 2019 at 7:46 PM William Kennington <wak@google.com> wrote:
> > >
> > > Looks like systemd doesn't even use an xml parser
> > > https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c
> >
> > I'm thinking I'll just regex for what I seek in this case.  Since I
> > know the lead of the string, and how the surrounding bits should
> > appear.  I just need the interface name, a good regex use-case. :)
>
> <interface name=\"xyz.openbmc_project.Configuration.TMP421\">
>
> >
> > >
> > > On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture@google.com> wrote:
> > > >
> > > > With dbus-sensors, if I follow the Association property, i can find
> > > > the board that owns the sensor.  However, we have a use-case where we
> > > > want sensors to be able to have their own EntityId and EntityInstance
> > > > values configured via the json --
> > > >
> > > > This lead to three situations:
> > > > 1) sensor's board doesn't implement the Ipmi decoration
> > > > 2) sensor's board implements the Ipmi decoration
> > > > 3) sensor's board implements the Ipmi decoration, but the sensor has
> > > > override values in the sensor dbus object owned by EntityManager.
> > > >
> > > > The way I see to do it is to introspect on the dbus path and service,
> > > > and then search the list of interfaces to find one that starts
> > > > "xyz.openbmc_project.Configuration" and then search that interface for
> > > > an "EntityId" and "EntityInstance" property, and if present, read
> > > > them.
> > > >
> > > > So this leads me to this email:
> > > > 1) Has anyone already got an XML parser they like and has used it in
> > > > this way?  Just to save me from figuring out the exact way to wire it
> > > > up.
> > > >
> > > > busctl call xyz.openbmc_project.EntityManager
> > > > /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> > > > org.freedesktop.DBus.Introspectable Introspect
> > > >
> > > > s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> > > > Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> > > > <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> > > > name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> > > > name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> > > > </interface>\n <interface
> > > > name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> > > > name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> > > > direction=\"out\"/>\n  </method>\n </interface>\n <interface
> > > > name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> > > > <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> > > > name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> > > > type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> > > > type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> > > > name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> > > > name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
> > > >   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> > > > type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> > > > </interface>\n <interface
> > > > name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> > > > name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> > > > <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> > > > <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> > > > <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> > > > </interface>\n</node>\n"
> > > >
> > > > It's pretty easy -- it takes no parameters and returns a string that I
> > > > feed into an XML parser, and then walk the nodes --> but has anyone
> > > > already done this? Maybe I can use their code as a snippet or if it's
> > > > in a common OpenBMC library?
> > > >
> > > > If nobody else has done this yet, I'll reply to this email with the
> > > > patch that does it :)  I'm definitely interested in suggestions on a
> > > > favored c++ XML parser.
> > > >
> > > > Thanks
> > > > Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Parsing dbus introspect
  2019-10-18  5:55       ` Lei YU
@ 2019-10-18 15:41         ` Patrick Venture
  0 siblings, 0 replies; 6+ messages in thread
From: Patrick Venture @ 2019-10-18 15:41 UTC (permalink / raw)
  To: Lei YU; +Cc: William Kennington, Peter Lundgren, OpenBMC Maillist, James Feist

On Thu, Oct 17, 2019 at 10:55 PM Lei YU <mine260309@gmail.com> wrote:
>
> I think object mapper already does this for you.
> Just call GetSubtree and you get a list of objects and the interfaces
> they implement.
>
> E.g.
>  busctl call "xyz.openbmc_project.ObjectMapper"
> "/xyz/openbmc_project/object_mapper"
> "xyz.openbmc_project.ObjectMapper" GetSubTree sias
> /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> 0 0

Thanks!  Although GetSubTree returned nothing, I checked the other methods:

busctl call xyz.openbmc_project.ObjectMapper
/xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper
GetObject sas /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
0

a{sas} 1 "xyz.openbmc_project.EntityManager" 1
"xyz.openbmc_project.Configuration.TMP421"

I didn't know the last parameter was optional -- so I have always used
it for a slightly different purpose.  This is excellent, thanks!

>
> On Fri, Oct 18, 2019 at 11:33 AM Patrick Venture <venture@google.com> wrote:
> >
> > On Thu, Oct 17, 2019 at 8:29 PM Patrick Venture <venture@google.com> wrote:
> > >
> > > On Thu, Oct 17, 2019 at 7:46 PM William Kennington <wak@google.com> wrote:
> > > >
> > > > Looks like systemd doesn't even use an xml parser
> > > > https://github.com/systemd/systemd/blob/cee97d57687e93e07a8ee36edf0e0d0f3317fccc/src/busctl/busctl-introspect.c
> > >
> > > I'm thinking I'll just regex for what I seek in this case.  Since I
> > > know the lead of the string, and how the surrounding bits should
> > > appear.  I just need the interface name, a good regex use-case. :)
> >
> > <interface name=\"xyz.openbmc_project.Configuration.TMP421\">
> >
> > >
> > > >
> > > > On Thu, Oct 17, 2019 at 7:35 PM Patrick Venture <venture@google.com> wrote:
> > > > >
> > > > > With dbus-sensors, if I follow the Association property, i can find
> > > > > the board that owns the sensor.  However, we have a use-case where we
> > > > > want sensors to be able to have their own EntityId and EntityInstance
> > > > > values configured via the json --
> > > > >
> > > > > This lead to three situations:
> > > > > 1) sensor's board doesn't implement the Ipmi decoration
> > > > > 2) sensor's board implements the Ipmi decoration
> > > > > 3) sensor's board implements the Ipmi decoration, but the sensor has
> > > > > override values in the sensor dbus object owned by EntityManager.
> > > > >
> > > > > The way I see to do it is to introspect on the dbus path and service,
> > > > > and then search the list of interfaces to find one that starts
> > > > > "xyz.openbmc_project.Configuration" and then search that interface for
> > > > > an "EntityId" and "EntityInstance" property, and if present, read
> > > > > them.
> > > > >
> > > > > So this leads me to this email:
> > > > > 1) Has anyone already got an XML parser they like and has used it in
> > > > > this way?  Just to save me from figuring out the exact way to wire it
> > > > > up.
> > > > >
> > > > > busctl call xyz.openbmc_project.EntityManager
> > > > > /xyz/openbmc_project/inventory/system/board/18_razorback_card/18_rzbk_temp
> > > > > org.freedesktop.DBus.Introspectable Introspect
> > > > >
> > > > > s "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object
> > > > > Introspection 1.0//EN\"\n\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n<node>\n
> > > > > <interface name=\"org.freedesktop.DBus.Peer\">\n  <method
> > > > > name=\"Ping\"/>\n  <method name=\"GetMachineId\">\n   <arg type=\"s\"
> > > > > name=\"machine_uuid\" direction=\"out\"/>\n  </method>\n
> > > > > </interface>\n <interface
> > > > > name=\"org.freedesktop.DBus.Introspectable\">\n  <method
> > > > > name=\"Introspect\">\n   <arg name=\"data\" type=\"s\"
> > > > > direction=\"out\"/>\n  </method>\n </interface>\n <interface
> > > > > name=\"org.freedesktop.DBus.Properties\">\n  <method name=\"Get\">\n
> > > > > <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > > name=\"value\" direction=\"out\" type=\"v\"/>\n  </method>\n  <method
> > > > > name=\"GetAll\">\n   <arg name=\"interface\" direction=\"in\"
> > > > > type=\"s\"/>\n   <arg name=\"properties\" direction=\"out\"
> > > > > type=\"a{sv}\"/>\n  </method>\n  <method name=\"Set\">\n   <arg
> > > > > name=\"interface\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > > name=\"property\" direction=\"in\" type=\"s\"/>\n   <arg
> > > > > name=\"value\" direction=\"in\" type=\"v\"/>\n  </method>\n  <signal
> > > > > name=\"PropertiesChanged\">\n   <arg type=\"s\" name=\"interface\"/>\n
> > > > >   <arg type=\"a{sv}\" name=\"changed_properties\"/>\n   <arg
> > > > > type=\"as\" name=\"invalidated_properties\"/>\n  </signal>\n
> > > > > </interface>\n <interface
> > > > > name=\"xyz.openbmc_project.Configuration.TMP421\">\n  <property
> > > > > name=\"Address\" type=\"t\" access=\"read\">\n  </property>\n
> > > > > <property name=\"Bus\" type=\"t\" access=\"read\">\n  </property>\n
> > > > > <property name=\"Name\" type=\"s\" access=\"read\">\n  </property>\n
> > > > > <property name=\"Type\" type=\"s\" access=\"read\">\n  </property>\n
> > > > > </interface>\n</node>\n"
> > > > >
> > > > > It's pretty easy -- it takes no parameters and returns a string that I
> > > > > feed into an XML parser, and then walk the nodes --> but has anyone
> > > > > already done this? Maybe I can use their code as a snippet or if it's
> > > > > in a common OpenBMC library?
> > > > >
> > > > > If nobody else has done this yet, I'll reply to this email with the
> > > > > patch that does it :)  I'm definitely interested in suggestions on a
> > > > > favored c++ XML parser.
> > > > >
> > > > > Thanks
> > > > > Patrick

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-10-18 15:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18  2:34 Parsing dbus introspect Patrick Venture
2019-10-18  2:46 ` William Kennington
2019-10-18  3:29   ` Patrick Venture
2019-10-18  3:30     ` Patrick Venture
2019-10-18  5:55       ` Lei YU
2019-10-18 15:41         ` Patrick Venture

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.