Skip to content

Commit

Permalink
vmsdk: fix eventlog cli (#95)
Browse files Browse the repository at this point in the history
* change cli logic according to get_cc_eventlog() output
* edit docs describing get_cc_eventlog() usage

Signed-off-by: Ruoyu Ying <ruoyu.ying@intel.com>
  • Loading branch information
Ruoyu-y authored Jan 31, 2024
1 parent 038a84e commit 199bf83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ count = 5
event_logs = CCTrustedVmSdk.inst().get_cc_eventlog(start, count)
if event_logs is not None:
LOG.info("Total %d of event logs fetched.", len(event_logs.event_logs))
LOG.info("Total %d of event logs fetched.", len(event_logs))
# Dump event as formatted
event_logs.dump(is_raw=false)
for event in event_logs:
event_logs.dump()
```

Run [cc_event_log_cli.py](vmsdk/python/cc_event_log_cli.py) to execute the sample.
Expand All @@ -215,7 +216,7 @@ Run [cc_event_log_cli.py](vmsdk/python/cc_event_log_cli.py) to execute the sampl
$ sudo su
# source setupenv.sh
# cd vmsdk/python
# python3 cc_event_log_cli.py [-s <start_index_of_event_log>] [-c <count_of_event_logs>] [--out-format-raw <true/false>]
# python3 cc_event_log_cli.py [-s <start_index_of_event_log>] [-c <count_of_event_logs>]
```

Below is the description of the output of `get_cc_eventlog` API on Intel® TDX via VM SDK. Full event logs can be found in [API usage example](docs/API-usage-example.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/API-usage-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Following are the boot-time event log collected by [VMSDK's sample code](/vmsdk/
Please refer the event logs collected in container with runtime IMA part at [CCNP's sample output within Container](https://github.com/intel/confidential-cloud-native-primitives/blob/main/docs/sample-output-for-node-measurement-tool-full.txt)

```
$ python3 vmsdk/python/cc_event_log_cli.py --out-format-raw false
$ python3 vmsdk/python/cc_event_log_cli.py
cctrusted_vm.cvm DEBUG Successful open device node /dev/tdx_guest
cctrusted_vm.cvm DEBUG Successful read TDREPORT from /dev/tdx_guest.
cctrusted_vm.cvm DEBUG Successful parse TDREPORT.
Expand Down
10 changes: 3 additions & 7 deletions vmsdk/python/cc_event_log_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ def main():
help='index of first event log to fetch', dest='start')
parser.add_argument("-c", type=int, help="number of event logs to fetch",
dest="count")
parser.add_argument("--out-format-raw", default=True,
dest="out_format",
help="output format. Return raw when set as True.\
Return parsed info when set as False.",
type=lambda x: (str(x).lower() in ['true','1', 'yes']))
args = parser.parse_args()

event_logs = CCTrustedVmSdk.inst().get_cc_eventlog(args.start, args.count)
if event_logs is not None:
LOG.info("Total %d of event logs fetched.", len(event_logs.event_logs))
event_logs.dump(args.out_format)
LOG.info("Total %d of event logs fetched.", len(event_logs))
for event in event_logs:
event.dump()

if __name__ == "__main__":
main()

0 comments on commit 199bf83

Please sign in to comment.