Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jhrcz/7573595f318926acc7c8 to your computer and use it in GitHub Desktop.
Save jhrcz/7573595f318926acc7c8 to your computer and use it in GitHub Desktop.
one-check-in-template-image-vs-image-owner
#!/bin/bash
# cat | bash -ls
# cat | VERBOSE=YES bash -ls
while read tplid
do
[ -n "$tplid" ] || continue
[ "$VERBOSE" = "YES" ] \
&& echo "tpl: $tplid"
while read imgname
do
[ -n "$imgname" ] || continue
[ "$VERBOSE" = "YES" ] \
&& echo " imgname: $imgname"
tplimgown=$( onetemplate show $tplid --xml | xmlstarlet sel -t -m "//VMTEMPLATE/TEMPLATE/DISK[IMAGE='$imgname']" -v IMAGE_UNAME -n )
imgown=$( oneimage show $imgname --xml 2>/dev/null | xmlstarlet sel -t -m '//IMAGE' -v UNAME -n 2>/dev/null )
[ -n "$imgown" ] || imgown="ERROR"
echo " tpl: $tplimgown"
echo " img: $imgown"
done < <( onetemplate show $tplid --xml | xmlstarlet sel --text -t -m '//VMTEMPLATE/TEMPLATE/DISK' -v IMAGE -n )
done < <( onetemplate list --xml | xmlstarlet sel -t -m '//VMTEMPLATE_POOL/VMTEMPLATE' -v ID -n )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment