Andrew Geissler | bb7b592 | 2019-02-08 14:16:48 -0600 | [diff] [blame] | 1 | #include "src/associations.hpp" |
Andrew Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 2 | #include "src/processing.hpp" |
Andrew Geissler | bb7b592 | 2019-02-08 14:16:48 -0600 | [diff] [blame] | 3 | |
| 4 | const std::string DEFAULT_SOURCE_PATH = "/logging/entry/1"; |
| 5 | const std::string DEFAULT_DBUS_SVC = "xyz.openbmc_project.New.Interface"; |
| 6 | const std::string DEFAULT_FWD_PATH = {DEFAULT_SOURCE_PATH + "/" + "inventory"}; |
| 7 | const std::string DEFAULT_ENDPOINT = |
| 8 | "/xyz/openbmc_project/inventory/system/chassis"; |
| 9 | const std::string DEFAULT_REV_PATH = {DEFAULT_ENDPOINT + "/" + "error"}; |
| 10 | const std::string EXTRA_ENDPOINT = "/xyz/openbmc_project/differnt/endpoint"; |
| 11 | |
| 12 | // Create a default AssociationOwnersType object |
| 13 | AssociationOwnersType 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 |
| 24 | AssociationInterfaces |
| 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 |
| 43 | void 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 Geissler | 2067926 | 2019-02-11 20:20:40 -0600 | [diff] [blame] | 49 | |
| 50 | // Create a default interface_map_type with input values |
| 51 | interface_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 Spinler | e0b0e3a | 2019-04-08 10:39:23 -0500 | [diff] [blame^] | 61 | |
| 62 | // Create a default interface_map_type with 2 entries with the same |
| 63 | // owner. |
| 64 | interface_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 | } |