1 #include "src/associations.hpp"
2 #include "src/processing.hpp"
3 
4 const std::string defaultSourcePath = "/logging/entry/1";
5 const std::string defaultDbusSvc = "xyz.openbmc_project.New.Interface";
6 const std::string defaultFwdPath = {defaultSourcePath + "/" + "inventory"};
7 const std::string defaultEndpoint =
8     "/xyz/openbmc_project/inventory/system/chassis";
9 const std::string defaultRevPath = {defaultEndpoint + "/" + "error"};
10 const std::string extraEndpoint = "/xyz/openbmc_project/differnt/endpoint";
11 
12 // Create a default AssociationOwnersType object
13 AssociationOwnersType createDefaultOwnerAssociation()
14 {
15     AssociationPaths assocPathMap = {{defaultFwdPath, {defaultEndpoint}},
16                                      {defaultRevPath, {defaultSourcePath}}};
17     boost::container::flat_map<std::string, AssociationPaths> serviceMap = {
18         {defaultDbusSvc, assocPathMap}};
19     AssociationOwnersType ownerAssoc = {{defaultSourcePath, serviceMap}};
20     return ownerAssoc;
21 }
22 
23 // Create a default AssociationInterfaces object
24 AssociationInterfaces
25     createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server)
26 {
27     AssociationInterfaces interfaceAssoc;
28 
29     auto& iface = interfaceAssoc[defaultFwdPath];
30     auto& endpoints = std::get<endpointsPos>(iface);
31     endpoints.push_back(defaultEndpoint);
32     server->add_interface(defaultFwdPath, defaultDbusSvc);
33 
34     auto& iface2 = interfaceAssoc[defaultRevPath];
35     auto& endpoints2 = std::get<endpointsPos>(iface2);
36     endpoints2.push_back(defaultSourcePath);
37     server->add_interface(defaultRevPath, defaultDbusSvc);
38 
39     return interfaceAssoc;
40 }
41 
42 // Just add an extra endpoint to the first association
43 void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc)
44 {
45     auto iface = interfaceAssoc[defaultFwdPath];
46     auto endpoints = std::get<endpointsPos>(iface);
47     endpoints.push_back(extraEndpoint);
48 }
49 
50 // Create a default interfaceMapType with input values
51 InterfaceMapType createInterfaceMap(
52     const std::string& path, const std::string& connectionName,
53     const boost::container::flat_set<std::string>& interfaceNames)
54 {
55     boost::container::flat_map<std::string,
56                                boost::container::flat_set<std::string>>
57         connectionMap = {{connectionName, interfaceNames}};
58     InterfaceMapType interfaceMap = {{path, connectionMap}};
59     return interfaceMap;
60 }
61 
62 // Create a default interfaceMapType with 2 entries with the same
63 // owner.
64 InterfaceMapType createDefaultInterfaceMap()
65 {
66     InterfaceMapType interfaceMap = {
67         {defaultSourcePath, {{defaultDbusSvc, {"a"}}}},
68         {defaultEndpoint, {{defaultDbusSvc, {"b"}}}}};
69 
70     return interfaceMap;
71 }
72