blob: 632e5ffd6a658885707e727f80618c37d09075bf [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
4const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1";
5const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface";
6const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"};
7const std::string DEFAULT_ENDPOINT =
8 "/xyz/openbmc_project/inventory/system/chassis";
9const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"};
10const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint";
11
12// Create a default AssociationOwnersType object
13AssociationOwnersType createDefaultOwnerAssociation()
14{
15 AssociationPaths assocPathMap = {{DEFAULT_FWD_PATH, {DEFAULT_ENDPOINT}},
16 {DEFAULT_REV_PATH, {DEFAULT_SOURCE_PATH}}};
17 boost::container::flat_map<std::string, AssociationPaths> serviceMap = {
18 {DEFAULT_DBUS_SVC, assocPathMap}};
19 AssociationOwnersType ownerAssoc = {{DEFAULT_SOURCE_PATH, serviceMap}};
20 return ownerAssoc;
21}
22
23// Create a default AssociationInterfaces object
24AssociationInterfaces
25 createDefaultInterfaceAssociation(sdbusplus::asio::object_server* server)
26{
27 AssociationInterfaces interfaceAssoc;
28
29 auto& iface = interfaceAssoc[DEFAULT_FWD_PATH];
30 auto& endpoints = std::get<endpointsPos>(iface);
31 endpoints.push_back(DEFAULT_ENDPOINT);
32 server->add_interface(DEFAULT_FWD_PATH, DEFAULT_DBUS_SVC);
33
34 auto& iface2 = interfaceAssoc[DEFAULT_REV_PATH];
35 auto& endpoints2 = std::get<endpointsPos>(iface2);
36 endpoints2.push_back(DEFAULT_SOURCE_PATH);
37 server->add_interface(DEFAULT_REV_PATH, DEFAULT_DBUS_SVC);
38
39 return interfaceAssoc;
40}
41
42// Just add an extra endpoint to the first association
43void addEndpointToInterfaceAssociation(AssociationInterfaces& interfaceAssoc)
44{
45 auto iface = interfaceAssoc[DEFAULT_FWD_PATH];
46 auto endpoints = std::get<endpointsPos>(iface);
47 endpoints.push_back(EXTRA_ENDPOINT);
48}
Andrew Geissler20679262019-02-11 20:20:40 -060049
50// Create a default interface_map_type with input values
51interface_map_type createInterfaceMap(
52 const std::string& path, const std::string& connection_name,
53 const boost::container::flat_set<std::string>& interface_names)
54{
55 boost::container::flat_map<std::string,
56 boost::container::flat_set<std::string>>
57 connectionMap = {{connection_name, interface_names}};
58 interface_map_type interfaceMap = {{path, connectionMap}};
59 return interfaceMap;
60}
Matt Spinlere0b0e3a2019-04-08 10:39:23 -050061
62// Create a default interface_map_type with 2 entries with the same
63// owner.
64interface_map_type createDefaultInterfaceMap()
65{
66 interface_map_type interfaceMap = {
67 {DEFAULT_SOURCE_PATH, {{DEFAULT_DBUS_SVC, {"a"}}}},
68 {DEFAULT_ENDPOINT, {{DEFAULT_DBUS_SVC, {"b"}}}}};
69
70 return interfaceMap;
71}