summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
Commit message (Collapse)AuthorAgeFilesLines
* unit-test: Move processing of interfaces addedAndrew Geissler2019-04-051-83/+4
| | | | | | | Make it easier to unit test and continue reduction of main.cpp Change-Id: Id360255e1546eda026e5e6ef9f15d29dcc82caaa Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Move associationChanged()Andrew Geissler2019-04-051-97/+6
| | | | | | | Make it easier to unit test and continue reduction of main.cpp Change-Id: Ic549e096343e7a2fb11985f1c48879ed4486e40b Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Move checkAssociationEndpointRemovesAndrew Geissler2019-04-051-66/+2
| | | | | | | Make it easier to unit test and continue reduction of main.cpp Change-Id: Id4f4c4fc1e3928f1b600555c6dbe05f651fffce5 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Move removeAssociationEndpoints()Andrew Geissler2019-04-051-43/+4
| | | | | | | Make it easier to unit test and continue reduction of main.cpp Change-Id: I2c0eac5c301687acab14add627586170020e4fe4 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Test deleting entry on name changeAndrew Geissler2019-04-051-53/+6
| | | | | | | | | | Breaking off into a separate function enables easier unit testing of the specific function Testing: 97% coverage of processing.cpp Change-Id: I08f229657a8f44230b711fabbae20fb403792637 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Create initial associations fileAndrew Geissler2019-04-051-108/+1
| | | | | | | | Make interface more unit testable by moving to separate file and documenting it. Change-Id: Ia27f33d706c62a0011790ec94185dd6be3922f21 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Add all required parameters to removeAssociationAndrew Geissler2019-04-051-10/+16
| | | | | | | | Testing is easier when all required parameters are input (vs. global references) Change-Id: I0c6c45c79a6095eaa6d702150cc346ac4f8e0e0d Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Test need_to_introspect functionAndrew Geissler2019-04-051-22/+9
| | | | | | | Testing: Verified 100% code coverage of processing.cpp Change-Id: I5ebdebe3fdcecbf250a23754f8b5c7db81bfaaa3 Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* unit-test: Introduce unit tests to phosphor-objmgrAndrew Geissler2019-04-051-24/+5
| | | | | | | | | Move a function to make more testable and add a test case for it Testing: Verified 100% test coverage in processing.cpp Change-Id: I0a888009cfeb57bbc8ad295681bea00b79f2a23d Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
* mapper: Support association property removesMatt Spinler2019-02-011-8/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the org.openbmc.Associations.association property changes, the change may entail removing entries from that property, in which case association objects may need to be removed. The existing code did not support this at all, it only supported adding new associations. This is done with the help of the associationOwners map, to know which previous associations an object path and service had so that it can tell when ones go away. As a reminder, if an org.openbmc.Associations.associations property under /path/A looks like: ['forward', 'reverse', '/path/B'], then the mapper will create 2 new objects - /path/A/forward and /path/B/reverse, with xyz.openbmc_project.Association.endpoints property values on them of ['/path/B'], and ['/path/A'], respectively. If that associations property is then cleared, the mapper needs to remove the objects it created, assuming there is no other service that also has an association that requires them. Resolves openbmc/phosphor-objmgr#16 Change-Id: I28defa831e5aefe8dd09b96c1b104fc1610471d6 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* mapper: Keep track of association ownersMatt Spinler2019-02-011-52/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | It is possible that an association object can be sourced from multiple D-Bus services and paths, and the existing code did not take that into account when removing assocations on interfacesRemoved signals, which caused it to overzealously remove association objects. For example, both objects /path/A and /path/B can have an org.openbmc.Associations property value such that the mapper creates a /path/C association object. Then, when /path/A is removed from D-Bus, the /path/C association object should still be kept until /path/B is also gone. The code accomplishes this be creating a new map of association metadata called associationOwners that keeps track of associations based on the service and path of the object that owns the org.openbmc.Associations object. Now, when the interfacesRemoved signal comes in for that org.openbmc.Associations object, the code knows if there are other owners of an association which determine if the mapper owned association object can be removed from D-Bus or not. Change-Id: If483e2ecd1d832b6287c2cbd67c5d23143f9ce32 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Fix looking for objects on root pathJames Feist2019-01-281-30/+21
| | | | | | | | | | | | | The current code would not remove the "/" for the root path causing a subtree or other call with path being "/" to miss any object exposed on "/". Fix this so that "/" is removed when it is the only character. Tested-by: Phosphor-pid-control stopped throwing when looking for object managers. Change-Id: I8ff49617d661910f22cc95409cd2df2489862b5f Signed-off-by: James Feist <james.feist@linux.intel.com>
* mapper: Delete unecessary parent paths on removesMatt Spinler2019-01-111-0/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When any application creates a path on D-Bus, D-Bus will automatically create all of the parent paths if they don't already exist with 3 interfaces - org.freedesktop.DBus.Peer, Introspectable, and Properties. The mapper knows about those from either an introspection or from explictly adding them during an interfacesAdded signal, so now it also has to delete them out of the mapper on an interfacesRemoved signal for the path being removed. To do this, when a path is removed, it will traverse all of its parents and check for the case of where a parent path only has 3 interfaces on it with the same owner, and there are no other children remaining with that owner. For example, if /A/B/C/D/E on owner X.Y is received in the interfacesRemoved handler, then after /A/B/C/D/E is removed from the interfaces map it will now check to see if /A/B/C/D is such that: * /A/B/C/D on owner X.Y has exactly 3 interfaces * There is no remaining path on X.Y that starts with /A/B/C/D/. If those are met, then /A/B/C/D on path X.Y will be removed from the interfaces map, and then the next parent /A/B/C will be checked. As soon as a parent doesn't need to be removed, the searching will stop. Tested: Check that these 3 interface paths that had been created are properly deleted, such as /xyz/openbmc_project/logging/entry when the last error log is removed. Change-Id: Ia9b79e6905108a76ddd6b425c22104bd77aedb24 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* mapper: Add missing parent paths in ifaces-addedMatt Spinler2019-01-111-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On an InterfacesAdded signal, a new path may have just been created with 2 or more new path segments. For example /A/B/C/D was just created and only /A/B exists so far. In this case, the current code never adds /A/B/C to the mapper, so trying to call GetObject or GetSubTree on that path would fail. To fix that, in the signal handler, check if all of the parent paths are already in the interface map, and add them if they aren't. It will take a shortcut and just add the three org.freedesktop.DBus interfaces Introspectable, Peer, and Properties, instead of calling the D-Bus introspect method since that is all it would find anyway. A big usecase of this is the REST server, where people try to do things like GET /xyz/openbmc_project/logging/entry/enumerate, which will fail if no logs existed when the mapper started since nothing explicitly created that exact path. Resolves openbmc/openbmc#3450 Tested: Created /xyz/openbmc_project/logging/entry/1, when previously only /xyz/openbmc_project/logging existed. Verify calling GetObject and GetSubTree now work on the /xyz/openbmc_project/logging/entry path. Change-Id: Id24f78beef9a34245d88de25a65006745fbda992 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* mapper: Don't stop after first GetAncestors resultMatt Spinler2019-01-041-1/+0
| | | | | | | | | | | | | | | | After the first result was found, the code was breaking out instead of continuing to look for other services that also satisified the operation. This made it so a path would never contain results for more than 1 service. To fix, simply remove the break statement. Tested: Call GetAncestors on a path with an ancestor that has multiple services and ensure they all are now returned. Change-Id: I6a29b7087d4e5e9763510797e0914c2f8e160495 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Filter results of GetAncestorsMatt Spinler2018-11-291-8/+10
| | | | | | | | | | | | | | | | | | As with GetSubTree, GetAncestors should only return the object paths with their services and interfaces for just the services that implement the interfaces passed into the function. The previous code was returning all services/interfaces for an object path that was an ancestor instead of just the services that actually provided that interface. Tested: Calling GetAncestors on /xyz/openbmc_project/ with the ObjectManager interface filter would now only return ancestors that actually had the ObjectManager interface. Change-Id: Ie80e78ac76a6fe9d474e6b34bc4555dca490ac51 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* mapper: Don't fail on some empty resultsMatt Spinler2018-11-261-17/+36
| | | | | | | | | | | | | | To preserve the behavior of the original mapper, don't fail the GetSubTree, GetSubTreePaths, and GetAncestors calls if the results are empty, instead only fail if the passed in object path isn't valid. This is particularly important to preserve the REST API that requires this different behavior between empty results and bad paths. Change-Id: I7e808a5613ed66cba4ea1a179a880e5c3f597f2a Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Remove interface filterEd Tanous2018-11-261-17/+7
| | | | | | | | | | | | | | | | | | | There are a number of cases where the interface filter causes some confusion. Not exposing org.freedesktop.DBus.ObjectManager interfaces caused some confusion around collections of objects, and the ability to search for sensors. Also, objects where the "parent" object has no useful interfaces leads to some question about how things like GetSubTree should behave in this condition. This patchset removes the interface filter alltogether. The only negatives should be a slightly increased memory usage, and extra interface support in mapperx. On a positive, it makes it a lot less likely to see bugs where the blacklists are concerned. Change-Id: I1ffd17106d0c659dd2f438fe25c2d6832a248987 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* Mapper: Remove unused ObjectManager usageEd Tanous2018-11-261-73/+11
| | | | | | | | | See comment for why the code was kept around. It looks like I misunderstood associations, so that code wasn't required after all. Clean up the ununsed code.. Change-Id: I5e19c6d633bd5c8e2ef105d147344352b2843753 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* mapper: Don't return the input path in GetSubTreeMatt Spinler2018-11-261-4/+26
| | | | | | | | | In both GetSubTree and GetSubTreePaths, don't return the input path as a result. This matches the behavior of the original mapper. Change-Id: Ib4bab71a6001e9a18ab2565b0e2d708b034f8c44 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* mapper: Fix GetSubTree bug in the c++ mapperEd Tanous2018-10-301-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | In cases where multiple daemons expose the same interface, there was a bug where, if an interface filter was applied, only the first found daemon would be returned. This resulted in sub-optimal behavior when searching for things like ObjectManager, that might exist in a lot of daemons. Tested By: Before Patch: root@wolfpass:/# dbus-send --system --print-reply --dest=xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper.GetSubTree string:"/" int32:1 array:string:org.freedesktop.DBus.ObjectManager Returns 1 entry After Patch: root@wolfpass:/# dbus-send --system --print-reply --dest=xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper.GetSubTree string:"/" int32:1 array:string:org.freedesktop.DBus.ObjectManager returns 12 entries Change-Id: I0b4e982649f03b0bacf35e26e4d7f310e644d6b8 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
* Don't return the input path in GetAncestorsMatt Spinler2018-10-021-1/+2
| | | | | | | | If '/A/B/C' is passed in as the path argument into GetAncestors, don't return /A/B/C, but only its actual ancestors /A and /A/B. Change-Id: I8dde80fa2ae5fad26c93be5fda5cfda9ff1b77d8 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Remove good path trace statementsMatt Spinler2018-10-021-14/+36
| | | | | | | These were good for debug, but shouldn't be necessary anymore. Change-Id: I0a2947dbd95da2532b2689329020519c39a21f6e Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Add full Associations supportMatt Spinler2018-09-281-15/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Associations are D-Bus objects that this application creates when another application creates an instance of an org.openbmc.Associations interface. For example, if an application with D-Bus path 'pathA' creates an instance of org.openbmc.Associations with an 'associations' property of: ['forward', 'reverse', 'pathB'] the mapper will create 2 new D-Bus objects: 1) 'pathA/forward' 2) 'pathB/reverse' 1) will have an xyz.openbmc_project.Association interface with an 'endpoints' property that contains ['pathB'] 2) will have an xyz.openbmc_project.Association interface with an 'endpoints' property that contains ['pathA'] If pathA is removed from the bus, 1) should be completely removed, and 2) should have 'pathA' removed from the endpoints property. If the endpoints property in 2) is now empty, that whole object should be removed as well. If, when adding the xyz.openbmc_project.Association interface, it already exists, then the endpoints property should just be added to. This commit finishes adding support for all of this. Change-Id: Ib1b3d39407a4b75992664552a766e49fdb27123f Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Use auto for a complicated typeMatt Spinler2018-09-281-6/+1
| | | | | | | A perfect example for how much typing it can save. Change-Id: I1826f5f7fe7c21aa39edd3759e748a567cf03a92 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Filter results of GetObjectMatt Spinler2018-09-281-4/+12
| | | | | | | | GetObject should only return the services (with their interfaces) that provide the interface passed in. Change-Id: I76ca7be85c7f2da4cc66d865a671c27504cb8061 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Filter results of GetSubTreeMatt Spinler2018-09-281-9/+37
| | | | | | | | | | | GetSubTree should only return service names and their interfaces for services that implement the interfaces passed into the function. The previous code would return every service/interface list if any service implemented the specified interfaces. Change-Id: I351af0aedd553e45125bffe2dd72aa352ec8d403 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Add service and interface whitelist/blacklistsMatt Spinler2018-09-281-5/+50
| | | | | | | | | | | | | This allows service whitelists and blacklists, and interface whitelists to be passed into the application. The whitelists can be prefixes, like xyz.openbmc_project. The blacklist is the full service name. A future commit can add support for interface blacklists. Change-Id: I91f6ef2f7be63e4d13ac03d570bba18ef8277fae Signed-off-by: Matt Spinler <spinler@us.ibm.com>
* Implement Mapper in C++/sdbusplus/asioEd Tanous2018-09-281-0/+837
This commit attempts to reimplement the mapper using C++/sdbusplus in the hopes of improving performance both at startup (lower priority) and runtime (higher priority). After this patch, performance seems to be greatly improved. On an unloaded system, full introspection of all daemons clocks in at 2.23 seconds for the worst case. Prelimiary tests show this to be 7X faster than the existing client. Expect this to come down slightly once associations are implemented, as that will introduce some overhead. It should not yet be considered complete although it does function. The things that still need doing are: 1. Implement the configurable whitelist/blacklist that the existing manage implements. Today they are compiled in. Tested By: time busctl call xyz.openbmc_project.ObjectMapper /xyz/openbmc_project/object_mapper xyz.openbmc_project.ObjectMapper GetSubTree sias "/" 0 1 xyz.openbmc_project.State.Chassis a{sa{sas}} 1 "/xyz/openbmc_project/state/chassis0" 1 "xyz.openbmc_project.State.Chassis" 2 "org.freedesktop.DBus.ObjectManager" "xyz.openbmc_project.State.Chassis" C++ implementation real 0m0.092s user 0m0.040s sys 0m0.010s Python implementation real 0m0.416s user 0m0.010s sys 0m0.030s Also has been tested using reboots, daemon dropouts and reconnects. Change-Id: I46ca8c273df09261cb2a2448a3570a601ea8e9f4 Signed-off-by: Ed Tanous <ed.tanous@intel.com> Signed-off-by: James Feist <james.feist@linux.intel.com> Signed-off-by: Matt Spinler <spinler@us.ibm.com>
OpenPOWER on IntegriCloud