Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
scripts: Collect script now shows osbuilder file
Browse files Browse the repository at this point in the history
Changed the collect script to display the contents of the
osbuilder metadata file which provides details of the image.

Partially fixes #237.

Signed-off-by: James O. D. Hunt <[email protected]>
  • Loading branch information
jodh-intel committed Apr 20, 2018
1 parent 4281bc3 commit 72056eb
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions data/kata-collect-data.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ typeset -r script_version="@VERSION@ (commit @COMMIT@)"

typeset -r unknown="unknown"

typeset -r osbuilder_file="/var/lib/osbuilder/osbuilder.yaml"

# Maximum number of errors to show for a single system component
# (such as runtime or proxy).
PROBLEM_LIMIT=${PROBLEM_LIMIT:-50}
Expand Down Expand Up @@ -347,8 +349,8 @@ show_runtime()
}

# Parameter 1: Path to disk image file.
# Returns: Agent version string, or "$unknown" on error.
get_agent_version()
# Returns: Details of the image, or "$unknown" on error.
get_image_details()
{
local img="$1"

Expand All @@ -361,7 +363,7 @@ get_agent_version()
local partition
local count
local mountpoint
local version
local contents
local expected

loop_device=$(loopmount_image "$img")
Expand Down Expand Up @@ -392,16 +394,13 @@ get_agent_version()

mountpoint=$(mount_partition "$partition_path")

agent="/bin/@PROJECT_TYPE@-agent"

version=$(chroot "$mountpoint" "$agent" --version 2>/dev/null)
contents=$(read_osbuilder_file "${mountpoint}")
[ -z "$contents" ] && contents="$unknown"

unmount_partition "$mountpoint"
release_device "$loop_device"

[ -z "$version" ] && version="$unknown"

echo "$version"
echo "$contents"
}

# Returns: Full path to the image file.
Expand Down Expand Up @@ -493,23 +492,41 @@ release_device()
losetup -d "$device"
}

show_agent_version()
# Retrieve details of the image containing
# the rootfs used to boot the virtual machine.
show_image_details()
{
local image
local version
local details

image=$(get_image_file)
version=$(get_agent_version "$image")

heading "Agent"

msg "version:"
heading "Image details"

show_quoted_text "$version"
if [ -n "$image" ]
then
details=$(get_image_details "$image")
show_quoted_text "$details"
else
msg "No image"
fi

separator
}

read_osbuilder_file()
{
local rootdir="$1"

[ -n "$rootdir" ] || die "need root directory"

local file="${rootdir}/${osbuilder_file}"

[ ! -e "$file" ] && return

cat "$file"
}

main()
{
args=$(getopt \
Expand Down Expand Up @@ -552,7 +569,7 @@ main()
show_meta
show_runtime
show_runtime_configs
show_agent_version
show_image_details
show_log_details
show_container_mgr_details
show_package_versions
Expand Down

0 comments on commit 72056eb

Please sign in to comment.