blob: 081f891fb8f5eb40367bf2b62ffa5d7f87df604d [file] [log] [blame]
Andrew Geisslerbb7b5922019-02-08 14:16:48 -06001#include "src/associations.hpp"
2
3const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1";
4const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface";
5const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"};
6const std::string DEFAULT_ENDPOINT =
7 "/xyz/openbmc_project/inventory/system/chassis";
8const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"};
9const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint";
10
11// Create a default AssociationOwnersType object
12AssociationOwnersType createDefaultOwnerAssociation()
13{
14 AssociationPaths assocPathMap = {{DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}},
15 {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}};
16 boost::container::flat_map<std::string, AssociationPaths> serviceMap = {
17 {DEFAULT_DBUS_SVC, assocPathMap}};
18 AssociationOwnersType ownerAssoc = {{DEFAULT_SOURCE_PATH, serviceMap}};
19 return ownerAssoc;
20}
21
22// Create a default AssociationInterfaces object
23AssociationInterfaces
24 createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server)
25{
26 AssociationInterfaces interfaceAssoc;
27
28 auto& iface = interfaceAssoc[DEFAULT_FWD_PATH];
29 auto& endpoints = std::get<endpointsPos>(iface);
30 endpoints.push_back(DEFAULT_ENDPOINT);
31 server->add_interface(DEFAULT_FWD_PATH, DEFAULT_DBUS_SVC);
32
33 auto& iface2 = interfaceAssoc[DEFAULT_REV_PATH];
34 auto& endpoints2 = std::get<endpointsPos>(iface2);
35 endpoints2.push_back(DEFAULT_SOURCE_PATH);
36 server->add_interface(DEFAULT_REV_PATH, DEFAULT_DBUS_SVC);
37
38 return interfaceAssoc;
39}
40
41// Just add an extra endpoint to the first association
42void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc)
43{
44 auto iface = interfaceAssoc[DEFAULT_FWD_PATH];
45 auto endpoints = std::get<endpointsPos>(iface);
46 endpoints.push_back(EXTRA_ENDPOINT);
47}