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
createDefaultOwnerAssociation()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
createDefaultInterfaceAssociation(sdbusplus::asio::object_server * server)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
addEndpointToInterfaceAssociation(AssociationInterfaces & interfaceAssoc)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
createInterfaceMap(const std::string & path,const std::string & connectionName,const InterfaceNames & interfaceNames)51 InterfaceMapType createInterfaceMap(const std::string& path,
52 const std::string& connectionName,
53 const InterfaceNames& interfaceNames)
54 {
55 ConnectionNames connectionMap{{connectionName, interfaceNames}};
56 InterfaceMapType interfaceMap{{path, connectionMap}};
57
58 return interfaceMap;
59 }
60
61 // Create a default interfaceMapType with 2 entries with the same
62 // owner.
createDefaultInterfaceMap()63 InterfaceMapType createDefaultInterfaceMap()
64 {
65 InterfaceMapType interfaceMap = {
66 {defaultSourcePath, {{defaultDbusSvc, {"a"}}}},
67 {defaultEndpoint, {{defaultDbusSvc, {"b"}}}}};
68
69 return interfaceMap;
70 }
71