utility.cpp (e8c9cd649f37b4b43775ed4f3039701f771d836e) | utility.cpp (d262440dda885d8a1710ad9cedd5987a5a19701d) |
---|---|
1/** 2 * Copyright © 2017 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 20 unchanged lines hidden (view full) --- 29constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; 30constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; 31constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; 32 33using namespace phosphor::logging; 34using json = nlohmann::json; 35 36std::string getService(const std::string& path, const std::string& interface, | 1/** 2 * Copyright © 2017 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 --- 20 unchanged lines hidden (view full) --- 29constexpr auto MAPPER_BUSNAME = "xyz.openbmc_project.ObjectMapper"; 30constexpr auto MAPPER_PATH = "/xyz/openbmc_project/object_mapper"; 31constexpr auto MAPPER_INTERFACE = "xyz.openbmc_project.ObjectMapper"; 32 33using namespace phosphor::logging; 34using json = nlohmann::json; 35 36std::string getService(const std::string& path, const std::string& interface, |
37 sdbusplus::bus::bus& bus) | 37 sdbusplus::bus::bus& bus, bool logError) |
38{ 39 auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH, 40 MAPPER_INTERFACE, "GetObject"); 41 42 method.append(path); 43 method.append(std::vector<std::string>({interface})); 44 45 auto reply = bus.call(method); 46 47 std::map<std::string, std::vector<std::string>> response; 48 reply.read(response); 49 50 if (response.empty()) 51 { | 38{ 39 auto method = bus.new_method_call(MAPPER_BUSNAME, MAPPER_PATH, 40 MAPPER_INTERFACE, "GetObject"); 41 42 method.append(path); 43 method.append(std::vector<std::string>({interface})); 44 45 auto reply = bus.call(method); 46 47 std::map<std::string, std::vector<std::string>> response; 48 reply.read(response); 49 50 if (response.empty()) 51 { |
52 log<level::ERR>("Error in mapper response for getting service name", 53 entry("PATH=%s", path.c_str()), 54 entry("INTERFACE=%s", interface.c_str())); | 52 if (logError) 53 { 54 log<level::ERR>("Error in mapper response for getting service name", 55 entry("PATH=%s", path.c_str()), 56 entry("INTERFACE=%s", interface.c_str())); 57 } |
55 return std::string{}; 56 } 57 58 return response.begin()->first; 59} 60 61json loadJSONFromFile(const char* path) 62{ --- 80 unchanged lines hidden --- | 58 return std::string{}; 59 } 60 61 return response.begin()->first; 62} 63 64json loadJSONFromFile(const char* path) 65{ --- 80 unchanged lines hidden --- |