1 /* 2 // Copyright (c) 2019 Intel 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 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 */ 16 #pragma once 17 18 #include <systemd/sd-id128.h> 19 20 namespace redfish 21 { 22 23 namespace systemd_utils 24 { 25 26 /** 27 * @brief Retrieve service root UUID 28 * 29 * @return Service root UUID 30 */ 31 32 inline const std::string getUuid() 33 { 34 std::string ret; 35 // This ID needs to match the one in ipmid 36 sd_id128_t appId{{0Xe0, 0Xe1, 0X73, 0X76, 0X64, 0X61, 0X47, 0Xda, 0Xa5, 37 0X0c, 0Xd0, 0Xcc, 0X64, 0X12, 0X45, 0X78}}; 38 sd_id128_t machineId{}; 39 40 if (sd_id128_get_machine_app_specific(appId, &machineId) == 0) 41 { 42 std::array<char, SD_ID128_STRING_MAX> str; 43 ret = sd_id128_to_string(machineId, str.data()); 44 ret.insert(8, 1, '-'); 45 ret.insert(13, 1, '-'); 46 ret.insert(18, 1, '-'); 47 ret.insert(23, 1, '-'); 48 } 49 50 return ret; 51 } 52 53 } // namespace systemd_utils 54 } // namespace redfish 55