diskimage-builder/diskimage_builder/block_device
wjunlu 864ae11509 Append detailed printing information when exec_sudo fails
This patch tries to add more detailed info by appending
error output to exec_sudo print.

In current implementation, only a simple static note `Exception:
exec_sudo failed` is printed:
```
INFO diskimage_builder.block_device.utils [-] Calling [sudo sgdisk
 /tmp/dib_image.jZaDPxtX/image0.raw -n 1:0:+550M -t 1:EF00 -c 1:ESP
 -n 2:0:+8M -t 2:EF02 -c 2:BSP -n 3:0:+2077M -t 3:8300 -c 3:root]
ERROR diskimage_builder.block_device.blockdevice [-] Create failed;
 rollback initiated
// ... ...
diskimage_builder.block_device.exception.BlockDeviceSetupException:
 exec_sudo failed
```

but the root reason is missing. We can’t get more error info to
make sure what the real root reason even a simple problem like
`command not found`, we have to reproduce locally and manually.

After this patch, the error message like:
```
INFO diskimage_builder.block_device.utils [-] Calling [sudo sgdisk
 /tmp/dib_image.jZaDPxtX/image0.raw -n 1:0:+550M -t 1:EF00 -c 1:ESP
 -n 2:0:+8M -t 2:EF02 -c 2:BSP -n 3:0:+2077M -t 3:8300 -c 3:root]
ERROR diskimage_builder.block_device.blockdevice [-] Create failed;
 rollback initiated
// ... ...
diskimage_builder.block_device.exception.BlockDeviceSetupException:
 exec_sudo failed: sudo: sgdisk: command not found
```
We can easily find the real problem and solve it.

Closes-Bug: #2024980

Change-Id: I9efcd9cb6621e6403df6de14f122b1cf371bd800
2023-06-25 08:02:58 +00:00
..
level0 Move localloop to exec_sudo 2018-06-29 11:22:24 +10:00
level1 Support LVM thin provisioning 2022-08-24 10:34:42 +12:00
level2 Add swap support 2023-03-06 14:54:35 +03:00
level3 Merge "Add swap support" 2023-03-21 06:38:57 +00:00
level4 Add swap support 2023-03-06 14:54:35 +03:00
tests Add swap support 2023-03-06 14:54:35 +03:00
__init__.py Clear __init__.py from cmd move 2017-05-11 18:52:14 +10:00
blockdevice.py Correct boot path to cover FIPS usage cases 2023-03-15 11:25:21 -07:00
cmd.py Uncap hacking 2020-02-24 10:34:46 +11:00
config.py Uncap hacking 2020-02-24 10:34:46 +11:00
exception.py Move exception to it's own file (again) 2017-05-20 06:44:39 +00:00
plugin.py Drop six usage 2020-06-05 12:04:37 +02:00
utils.py Append detailed printing information when exec_sudo fails 2023-06-25 08:02:58 +00:00