blob: c547cf6d62b4f3be7e752644b5ced2213222d1ce [file] [log] [blame]
Andrew Geisslerbb7b5922019-02-08 14:16:48 -06001#include "src/associations.hpp"
Andrew Geissler20679262019-02-11 20:20:40 -06002#include "src/processing.hpp"
Andrew Geisslerbb7b5922019-02-08 14:16:48 -06003
Brad Bishopa098a372022-05-05 15:19:04 -04004const std::string defaultSourcePath = "/logging/entry/1";
5const std::string defaultDbusSvc = "xyz.openbmc_project.New.Interface";
6const std::string defaultFwdPath = {defaultSourcePath + "/" + "inventory"};
7const std::string defaultEndpoint =
Andrew Geisslerbb7b5922019-02-08 14:16:48 -06008 "/xyz/openbmc_project/inventory/system/chassis";
Brad Bishopa098a372022-05-05 15:19:04 -04009const std::string defaultRevPath = {defaultEndpoint + "/" + "error"};
10const std::string extraEndpoint = "/xyz/openbmc_project/differnt/endpoint";
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060011
12// Create a default AssociationOwnersType object
13AssociationOwnersType createDefaultOwnerAssociation()
14{
Brad Bishopa098a372022-05-05 15:19:04 -040015 AssociationPaths assocPathMap = {{defaultFwdPath, {defaultEndpoint}},
16 {defaultRevPath, {defaultSourcePath}}};
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060017 boost::container::flat_map<std::string, AssociationPaths> serviceMap = {
Brad Bishopa098a372022-05-05 15:19:04 -040018 {defaultDbusSvc, assocPathMap}};
19 AssociationOwnersType ownerAssoc = {{defaultSourcePath, serviceMap}};
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060020 return ownerAssoc;
21}
22
23// Create a default AssociationInterfaces object
24AssociationInterfaces
25 createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server)
26{
27 AssociationInterfaces interfaceAssoc;
28
Brad Bishopa098a372022-05-05 15:19:04 -040029 auto& iface = interfaceAssoc[defaultFwdPath];
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060030 auto& endpoints = std::get<endpointsPos>(iface);
Brad Bishopa098a372022-05-05 15:19:04 -040031 endpoints.push_back(defaultEndpoint);
32 server->add_interface(defaultFwdPath, defaultDbusSvc);
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060033
Brad Bishopa098a372022-05-05 15:19:04 -040034 auto& iface2 = interfaceAssoc[defaultRevPath];
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060035 auto& endpoints2 = std::get<endpointsPos>(iface2);
Brad Bishopa098a372022-05-05 15:19:04 -040036 endpoints2.push_back(defaultSourcePath);
37 server->add_interface(defaultRevPath, defaultDbusSvc);
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060038
39 return interfaceAssoc;
40}
41
42// Just add an extra endpoint to the first association
43void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc)
44{
Brad Bishopa098a372022-05-05 15:19:04 -040045 auto iface = interfaceAssoc[defaultFwdPath];
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060046 auto endpoints = std::get<endpointsPos>(iface);
Brad Bishopa098a372022-05-05 15:19:04 -040047 endpoints.push_back(extraEndpoint);
Andrew Geisslerbb7b5922019-02-08 14:16:48 -060048}
Andrew Geissler20679262019-02-11 20:20:40 -060049
Brad Bishopa098a372022-05-05 15:19:04 -040050// Create a default interfaceMapType with input values
Ed Tanous964681c2022-07-08 12:47:24 -070051InterfaceMapType createInterfaceMap(const std::string& path,
52 const std::string& connectionName,
53 const InterfaceNames& interfaceNames)
Andrew Geissler20679262019-02-11 20:20:40 -060054{
Ed Tanous964681c2022-07-08 12:47:24 -070055 ConnectionNames connectionMap{{connectionName, interfaceNames}};
56 InterfaceMapType interfaceMap{{path, connectionMap}};
57
Andrew Geissler20679262019-02-11 20:20:40 -060058 return interfaceMap;
59}
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050060
Brad Bishopa098a372022-05-05 15:19:04 -040061// Create a default interfaceMapType with 2 entries with the same
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050062// owner.
Brad Bishopa098a372022-05-05 15:19:04 -040063InterfaceMapType createDefaultInterfaceMap()
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050064{
Brad Bishopa098a372022-05-05 15:19:04 -040065 InterfaceMapType interfaceMap = {
66 {defaultSourcePath, {{defaultDbusSvc, {"a"}}}},
67 {defaultEndpoint, {{defaultDbusSvc, {"b"}}}}};
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050068
69 return interfaceMap;
70}