blob: 64688bf23d8a8d636b87930f6fe18413710528eb [file] [log] [blame]
Andrew Geisslera80a3af2019-02-04 14:01:49 -06001#pragma once
2
Matt Spinler35396c12019-04-05 11:46:57 -05003#include "types.hpp"
Andrew Geisslera80a3af2019-02-04 14:01:49 -06004
Andrew Geissler4511b332019-02-21 15:40:40 -06005constexpr const char* XYZ_ASSOCIATION_INTERFACE =
6 "xyz.openbmc_project.Association";
7
Andrew Geisslera80a3af2019-02-04 14:01:49 -06008/** @brief Remove input association
9 *
10 * @param[in] sourcePath - Path of the object that contains the
11 * org.openbmc.Associations
12 * @param[in] owner - The Dbus service having its associations
13 * removed
14 * @param[in,out] server - sdbus system object
Matt Spinlere2359fb2019-04-05 14:11:33 -050015 * @param[in,out] assocMaps - The association maps
Andrew Geisslera80a3af2019-02-04 14:01:49 -060016 *
Matt Spinlere2359fb2019-04-05 14:11:33 -050017 * @return Void, server, assocMaps updated if needed
Andrew Geisslera80a3af2019-02-04 14:01:49 -060018 */
19void removeAssociation(const std::string& sourcePath, const std::string& owner,
20 sdbusplus::asio::object_server& server,
Matt Spinlere2359fb2019-04-05 14:11:33 -050021 AssociationMaps& assocMaps);
Andrew Geisslerff5ce922019-02-21 12:43:09 -060022
23/** @brief Remove input paths from endpoints of an association
24 *
25 * If the last endpoint was removed, then remove the whole
26 * association object, otherwise just set the property
27 *
28 * @param[in] objectServer - sdbus system object
29 * @param[in] assocPath - Path of the object that contains the
30 * org.openbmc.Associations
31 * @param[in] endpointsToRemove - Endpoints to remove
Matt Spinlere2359fb2019-04-05 14:11:33 -050032 * @param[in,out] assocMaps - The association maps
Andrew Geisslerff5ce922019-02-21 12:43:09 -060033 *
Matt Spinlere2359fb2019-04-05 14:11:33 -050034 * @return Void, objectServer and assocMaps updated if needed
Andrew Geisslerff5ce922019-02-21 12:43:09 -060035 */
36void removeAssociationEndpoints(
37 sdbusplus::asio::object_server& objectServer, const std::string& assocPath,
38 const boost::container::flat_set<std::string>& endpointsToRemove,
Matt Spinlere2359fb2019-04-05 14:11:33 -050039 AssociationMaps& assocMaps);
Andrew Geissler7f1c44d2019-02-21 13:44:16 -060040
41/** @brief Check and remove any changed associations
42 *
43 * Based on the latest values of the org.openbmc.Associations.associations
44 * property, passed in via the newAssociations param, check if any of the
45 * paths in the xyz.openbmc_project.Association.endpoints D-Bus property
46 * for that association need to be removed. If the last path is removed
47 * from the endpoints property, remove that whole association object from
48 * D-Bus.
49 *
50 * @param[in] sourcePath - Path of the object that contains the
51 * org.openbmc.Associations
52 * @param[in] owner - The Dbus service having it's associatons
53 * changed
54 * @param[in] newAssociations - New associations to look at for change
55 * @param[in,out] objectServer - sdbus system object
Matt Spinlere2359fb2019-04-05 14:11:33 -050056 * @param[in,out] assocMaps - The association maps
Andrew Geissler7f1c44d2019-02-21 13:44:16 -060057 *
Matt Spinlere2359fb2019-04-05 14:11:33 -050058 * @return Void, objectServer and assocMaps updated if needed
Andrew Geissler7f1c44d2019-02-21 13:44:16 -060059 */
60void checkAssociationEndpointRemoves(
61 const std::string& sourcePath, const std::string& owner,
62 const AssociationPaths& newAssociations,
Matt Spinlere2359fb2019-04-05 14:11:33 -050063 sdbusplus::asio::object_server& objectServer, AssociationMaps& assocMaps);
Andrew Geissler4511b332019-02-21 15:40:40 -060064
65/** @brief Handle new or changed association interfaces
66 *
67 * Called when either a new org.openbmc.Associations interface was
68 * created, or the associations property on that interface changed
69 *
70 * @param[in,out] objectServer - sdbus system object
71 * @param[in] associations - New associations to look at for change
72 * @param[in] path - Path of the object that contains the
73 * org.openbmc.Associations
74 * @param[in] owner - The Dbus service having it's associatons
75 * changed
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050076 * @param[in] interfaceMap - The full interface map
Matt Spinlere2359fb2019-04-05 14:11:33 -050077 * @param[in,out] assocMaps - The association maps
Andrew Geissler4511b332019-02-21 15:40:40 -060078 *
Matt Spinlere2359fb2019-04-05 14:11:33 -050079 * @return Void, objectServer and assocMaps updated if needed
Andrew Geissler4511b332019-02-21 15:40:40 -060080 */
81void associationChanged(sdbusplus::asio::object_server& objectServer,
82 const std::vector<Association>& associations,
83 const std::string& path, const std::string& owner,
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050084 const interface_map_type& interfaceMap,
Matt Spinlere2359fb2019-04-05 14:11:33 -050085 AssociationMaps& assocMaps);
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050086
87/** @brief Add a pending associations entry
88 *
89 * Used when a client wants to create an association between
90 * 2 D-Bus endpoint paths, but one of the paths doesn't exist.
91 * When the path does show up in D-Bus, if there is a pending
92 * association then the real association objects can be created.
93 *
94 * @param[in] objectPath - The D-Bus object path that should be an
95 * association endpoint but doesn't exist
96 * on D-Bus.
97 * @param[in] type - The association type. Gets used in the final
98 * association path of <objectPath>/<type>.
99 * @param[in] endpointPath - The D-Bus path on the other side
100 * of the association. This path exists.
101 * @param[in] endpointType - The endpoint association type. Gets used
102 * in the final association path of
103 * <endpointPath>/<endpointType>.
104 * @param[in] owner - The service name that owns the association.
105 * @param[in,out] assocMaps - The association maps
106 */
107void addPendingAssociation(const std::string& objectPath,
108 const std::string& type,
109 const std::string& endpointPath,
110 const std::string& endpointType,
111 const std::string& owner,
112 AssociationMaps& assocMaps);