Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | Today | - | ||||
subprojects/ | H | 24-Nov-2022 | - | 21 | 15 | |
test/ | H | 11-May-2023 | - | 213 | 162 | |
.clang-format | H A D | 04-Sep-2024 | 3.7 KiB | 137 | 135 | |
.clang-tidy | H A D | 21-Jul-2023 | 11 KiB | 316 | 313 | |
.gitignore | H A D | 08-Jul-2022 | 42 | 4 | 3 | |
LICENSE | H A D | 07-Mar-2021 | 11.1 KiB | 202 | 169 | |
OWNERS | H A D | 19-Mar-2024 | 1.7 KiB | 53 | 48 | |
README.md | H A D | 21-Aug-2023 | 4 KiB | 130 | 92 | |
bmc_epoch.cpp | H A D | 29-Jul-2023 | 3.8 KiB | 153 | 115 | |
bmc_epoch.hpp | H A D | 04-Sep-2024 | 3.1 KiB | 116 | 51 | |
main.cpp | H A D | 05-Nov-2024 | 956 | 39 | 22 | |
manager.cpp | H A D | 04-Sep-2024 | 5.7 KiB | 199 | 163 | |
manager.hpp | H A D | 09-Apr-2024 | 4 KiB | 139 | 51 | |
meson.build | H A D | 01-Dec-2023 | 2.8 KiB | 91 | 64 | |
meson.options | H A D | 17-Aug-2023 | 774 | 28 | 21 | |
property_change_listener.hpp | H A D | 09-May-2023 | 626 | 27 | 19 | |
settings.cpp | H A D | 01-Dec-2023 | 1.1 KiB | 52 | 42 | |
settings.hpp | H A D | 09-Apr-2024 | 1 KiB | 43 | 25 | |
types.hpp | H A D | 05-Nov-2024 | 669 | 24 | 14 | |
utils.cpp | H A D | 27-Apr-2023 | 2.1 KiB | 81 | 66 | |
utils.hpp | H A D | 09-Apr-2024 | 4.4 KiB | 148 | 73 | |
xyz.openbmc_project.Time.Manager.service | H A D | 03-Jun-2022 | 332 | 14 | 11 |
README.md
1# Introduction 2 3`phosphor-time-manager` is the time manager service that implements D-Bus 4interface `xyz/openbmc_project/Time/EpochTime.interface.yaml`. The user can get 5or set the BMC's time via this interface. 6 7## Configuration 8 9phosphor-time-manager is configured by setting `-D` flags that correspond to 10options in `phosphor-time-manager/meson.options`. The option names become C++ 11preprocessor symbols that control which code is compiled into the program. 12 13- Compile phosphor-time-manager with default options: 14 15 ```bash 16 meson setup builddir 17 ninja -C builddir 18 ``` 19 20- Compile phosphor-time-manager with some configurable options: 21 22 ```bash 23 meson setup builddir -Dbuildtype=minsize -Dtests=disabled 24 ninja -C builddir 25 ``` 26 27- Generate test coverage report: 28 29 ```bash 30 meson setup builddir -Db_coverage=true -Dtests=enabled 31 ninja coverage -C builddir test 32 ``` 33 34### General usage 35 36The service `xyz.openbmc_project.Time.Manager` provides an object on D-Bus: 37 38- /xyz/openbmc_project/time/bmc 39 40where each object implements interface `xyz.openbmc_project.Time.EpochTime`. 41 42The user can directly get or set the property `Elapsed` of the objects to get or 43set the time. For example on an authenticated session: 44 45- To get BMC's time: 46 47 ```bash 48 ### With busctl on BMC 49 busctl get-property xyz.openbmc_project.Time.Manager \ 50 /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime Elapsed 51 52 ### With REST API on remote host 53 curl -b cjar -k https://${BMC_IP}/xyz/openbmc_project/time/bmc 54 ``` 55 56- To set BMC's time: 57 58 ```bash 59 ### With busctl on BMC 60 busctl set-property xyz.openbmc_project.Time.Manager \ 61 /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime \ 62 Elapsed t <value-in-microseconds> 63 64 ### With REST API on remote host 65 curl -b cjar -k -H "Content-Type: application/json" -X PUT \ 66 -d '{"data": 1487304700000000}' \ 67 https://${BMC_IP}/xyz/openbmc_project/time/bmc/attr/Elapsed 68 ``` 69 70### Time settings 71 72Getting BMC time is always allowed, but setting the time may not be allowed 73depending on the below two settings in the settings manager. 74 75- TimeSyncMethod 76 - NTP: The time is set via NTP server. 77 - MANUAL: The time is set manually. 78 79A summary of which cases the time can be set on BMC or HOST: 80 81| Mode | Set BMC Time | 82| ------ | ------------ | 83| NTP | Fail to set | 84| MANUAL | OK | 85 86- To set an NTP [server](https://tf.nist.gov/tf-cgi/servers.cgi): 87 88 ```bash 89 ### With busctl on BMC 90 busctl set-property xyz.openbmc_project.Network \ 91 /xyz/openbmc_project/network/eth0 \ 92 xyz.openbmc_project.Network.EthernetInterface NTPServers \ 93 as 1 "<ntp_server>" 94 95 ### With REST API on remote host 96 curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d \ 97 '{"data": ["<ntp_server>"] }' \ 98 https://${BMC_IP}/xyz/openbmc_project/network/eth0/attr/NTPServers 99 ``` 100 101- To go into NTP mode 102 103 ```bash 104 ### With busctl on BMC 105 busctl set-property xyz.openbmc_project.Settings \ 106 /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization \ 107 TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP" 108 109 ### With REST API on remote host 110 curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT -d \ 111 '{"data": "xyz.openbmc_project.Time.Synchronization.Method.NTP" }' \ 112 https://${BMC_IP}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod 113 ``` 114 115### Special note on changing NTP setting 116 117Starting from OpenBMC 2.6 (with systemd v239), systemd's timedated introduces a 118new beahvior that it checks the NTP services' status during setting time, 119instead of checking the NTP setting: 120 121- When NTP server is set to disabled, and the NTP service is stopping but not 122 stopped, setting time will get an error. 123 124In OpenBMC 2.4 (with systemd v236), the above will always succeed. 125 126This results in [openbmc/openbmc#3459][1], and the related test cases are 127updated to cooperate with this behavior change. 128 129[1]: https://github.com/openbmc/openbmc/issues/3459 130