Name Date Size #Lines LOC

..--

subprojects/H--2115

test/H--221170

.clang-formatH A D03-Mar-20253.7 KiB137135

.clang-tidyH A D30-May-202512.2 KiB326322

.gitignoreH A D01-Jul-202242 43

LICENSEH A D25-Aug-201611.1 KiB202169

OWNERSH A D12-Mar-20241.7 KiB5348

README.mdH A D18-Jul-20254 KiB13294

bmc_epoch.cppH A D24-Jul-20233.8 KiB153115

bmc_epoch.hppH A D16-Aug-20243.1 KiB11651

main.cppH A D22-Jul-2024956 3922

manager.cppH A D16-Aug-20245.7 KiB199163

manager.hppH A D01-Apr-20244 KiB13951

meson.buildH A D09-Jul-20252.5 KiB10174

meson.optionsH A D03-Mar-2025755 3326

property_change_listener.hppH A D28-Apr-2023626 2719

settings.cppH A D30-Nov-20231.1 KiB5242

settings.hppH A D01-Apr-20241 KiB4325

types.hppH A D22-Jul-2024669 2414

utils.cppH A D11-Apr-20232.1 KiB8166

utils.hppH A D01-Apr-20244.4 KiB14873

xyz.openbmc_project.Time.Manager.serviceH A D26-May-2022332 1411

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     meson compile -C builddir
18  ```
19
20- Compile phosphor-time-manager with some configurable options:
21
22  ```bash
23     meson setup builddir -Dbuildtype=minsize  -Dtests=false
24     meson compile -C builddir
25  ```
26
27- Generate test coverage report:
28
29  ```bash
30     meson setup builddir -Db_coverage=true -Dtests=true
31     meson compile -C builddir
32     meson test -C builddir
33     ninja -C builddir coverage
34  ```
35
36### General usage
37
38The service `xyz.openbmc_project.Time.Manager` provides an object on D-Bus:
39
40- /xyz/openbmc_project/time/bmc
41
42where each object implements interface `xyz.openbmc_project.Time.EpochTime`.
43
44The user can directly get or set the property `Elapsed` of the objects to get or
45set the time. For example on an authenticated session:
46
47- To get BMC's time:
48
49  ```bash
50  ### With busctl on BMC
51  busctl get-property xyz.openbmc_project.Time.Manager \
52      /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime Elapsed
53
54  ### With REST API on remote host
55  curl -b cjar -k https://${BMC_IP}/xyz/openbmc_project/time/bmc
56  ```
57
58- To set BMC's time:
59
60  ```bash
61  ### With busctl on BMC
62  busctl set-property xyz.openbmc_project.Time.Manager \
63      /xyz/openbmc_project/time/bmc xyz.openbmc_project.Time.EpochTime \
64      Elapsed t <value-in-microseconds>
65
66  ### With REST API on remote host
67  curl -b cjar -k -H "Content-Type: application/json" -X PUT \
68      -d '{"data": 1487304700000000}' \
69      https://${BMC_IP}/xyz/openbmc_project/time/bmc/attr/Elapsed
70  ```
71
72### Time settings
73
74Getting BMC time is always allowed, but setting the time may not be allowed
75depending on the below two settings in the settings manager.
76
77- TimeSyncMethod
78  - NTP: The time is set via NTP server.
79  - MANUAL: The time is set manually.
80
81A summary of which cases the time can be set on BMC or HOST:
82
83| Mode   | Set BMC Time |
84| ------ | ------------ |
85| NTP    | Fail to set  |
86| MANUAL | OK           |
87
88- To set an NTP [server](https://tf.nist.gov/tf-cgi/servers.cgi):
89
90  ```bash
91  ### With busctl on BMC
92  busctl set-property  xyz.openbmc_project.Network \
93     /xyz/openbmc_project/network/eth0 \
94     xyz.openbmc_project.Network.EthernetInterface NTPServers \
95     as 1 "<ntp_server>"
96
97  ### With REST API on remote host
98  curl -c cjar -b cjar -k -H "Content-Type: application/json" -X  PUT  -d \
99      '{"data": ["<ntp_server>"] }' \
100      https://${BMC_IP}/xyz/openbmc_project/network/eth0/attr/NTPServers
101  ```
102
103- To go into NTP mode
104
105  ```bash
106  ### With busctl on BMC
107  busctl set-property xyz.openbmc_project.Settings \
108      /xyz/openbmc_project/time/sync_method xyz.openbmc_project.Time.Synchronization \
109      TimeSyncMethod s "xyz.openbmc_project.Time.Synchronization.Method.NTP"
110
111  ### With REST API on remote host
112  curl -c cjar -b cjar -k -H "Content-Type: application/json" -X  PUT  -d \
113      '{"data": "xyz.openbmc_project.Time.Synchronization.Method.NTP" }' \
114      https://${BMC_IP}/xyz/openbmc_project/time/sync_method/attr/TimeSyncMethod
115  ```
116
117### Special note on changing NTP setting
118
119Starting from OpenBMC 2.6 (with systemd v239), systemd's timedated introduces a
120new beahvior that it checks the NTP services' status during setting time,
121instead of checking the NTP setting:
122
123- When NTP server is set to disabled, and the NTP service is stopping but not
124  stopped, setting time will get an error.
125
126In OpenBMC 2.4 (with systemd v236), the above will always succeed.
127
128This results in [openbmc/openbmc#3459][1], and the related test cases are
129updated to cooperate with this behavior change.
130
131[1]: https://github.com/openbmc/openbmc/issues/3459
132