Check for missing endpoints when adding assocs

An association links 2 D-Bus object paths together, one
which is the path that has the original associations
property, and another endpoint path.  It's possible that
that endpoint path doesn't exist on D-Bus when that
associations property is created.

This commit, along with upcoming ones, adds support to not
create the actual association object paths until that
endpoint path shows up on D-Bus.  In addition, if that
endpoint path were to get removed from D-Bus in the future,
then the association paths should be removed until that
path is back again.

This particular commit introduces the PendingAssociations map
to track these cases, and adds support in the associationChanged
path to add associations to this map if the endpoint path isn't
on D-Bus instead of just blindly creating the association objects.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I1f4bf0e02bf7a350d9e3f18c3591737289a51a39
diff --git a/src/associations.hpp b/src/associations.hpp
index 31e8b6a..64688bf 100644
--- a/src/associations.hpp
+++ b/src/associations.hpp
@@ -73,6 +73,7 @@
  *                                  org.openbmc.Associations
  * @param[in] owner               - The Dbus service having it's associatons
  *                                  changed
+ * @param[in] interfaceMap        - The full interface map
  * @param[in,out] assocMaps       - The association maps
  *
  * @return Void, objectServer and assocMaps updated if needed
@@ -80,4 +81,32 @@
 void associationChanged(sdbusplus::asio::object_server& objectServer,
                         const std::vector<Association>& associations,
                         const std::string& path, const std::string& owner,
+                        const interface_map_type& interfaceMap,
                         AssociationMaps& assocMaps);
+
+/** @brief Add a pending associations entry
+ *
+ *  Used when a client wants to create an association between
+ *  2 D-Bus endpoint paths, but one of the paths doesn't exist.
+ *  When the path does show up in D-Bus, if there is a pending
+ *  association then the real association objects can be created.
+ *
+ * @param[in] objectPath    - The D-Bus object path that should be an
+ *                            association endpoint but doesn't exist
+ *                            on D-Bus.
+ * @param[in] type          - The association type.  Gets used in the final
+ *                            association path of <objectPath>/<type>.
+ * @param[in] endpointPath  - The D-Bus path on the other side
+ *                            of the association. This path exists.
+ * @param[in] endpointType  - The endpoint association type. Gets used
+ *                            in the final association path of
+ *                            <endpointPath>/<endpointType>.
+ * @param[in] owner         - The service name that owns the association.
+ * @param[in,out] assocMaps - The association maps
+ */
+void addPendingAssociation(const std::string& objectPath,
+                           const std::string& type,
+                           const std::string& endpointPath,
+                           const std::string& endpointType,
+                           const std::string& owner,
+                           AssociationMaps& assocMaps);