Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
Contents:
ZENworks 7.x Linux Management allows to create Bundles that contains several imported software packages or files of definite sizes. The bundle has property such as name, description, target files, version, type, and imported file count. As part of this solution, before performing ZENworks bundle deployment to the managed devices user can obtain its content size (in KB), based on its bundle type, version and packages target
ZENworks Bundle does not provide the payload content size of its imported files for a given bundle type, deployed version and target packages. The bundle containing collection of softwares or files can be of varying size ranging from few KBs to MBs. The bundle content size is approximate summation of all its imported files size. The payload size of bundle grows in case of OS update or patches to even few GBs. Distribution of these assigned bundle’s content with varying payload data from the ZLM server to the multiple managed devices can be time-intensive, depending on assignment to the group of devices at different geographical locations with limited bandwidth for network communication. The bundle content size information allows to effectively plan the schedule of its deployment and subsequent installation on the managed devices, thus allowing to manage the content download rate, and balance load on the ZLM server during the period.
The solution to compute the ZENworks bundle content size, is applicable to the ZENworks 7.2 Linux Management and the ZENworks 7.3 Linux Management servers with Postgres as its embedded datastore.
Do the following on the ZLM Primary Server:
Usage:
sh bundle_size.sh -f [bundle-folder-path] -b [bundle-name] -o [bundle-type] -t [target]
Example:
sh bundle_size.sh -f SLES10-SP3-Folder -b SLES10-SP3-Online-bundle -o package -t target
#!/bin/bash
usage()
{
echo USAGE:
echo -e "${BOLD}sh" $0 -f [bundle-folder-path] -b [bundle-name] -o [bundle-type] -t [target] -h ${NORMAL}
echo "For example : sh $0 -f SLES10-Folder -b SLES10-bundle -o package ( or file ) -t target(optional) "
echo "Use zlman bl [folder ] to list the bundles present on the server "
echo ""
exit 1
}
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BOLD='\033[1m'
NORMAL='\033[m'
if [ $# -ne 2 ] && [ $# -ne 4 ] && [ $# -ne 6 ] && [ $# -ne 8 ]; then
usage
fi
bundle_type=""
if [ $# -ne 0 ] ; then
while getopts :b:f:o:t:h option
do
case "$option" in
b) bundle_name="$OPTARG";;
o) bundle_type="$OPTARG";;
t) target="$OPTARG";;
f) path="$OPTARG";;
h) usage;;
?) usage
esac
done
fi
verify_target()
{
supportedTargets=$(/opt/novell/zenworks/bin/zlman tl )
for supportedTarget in $supportedTargets; do
if [ $target == $supportedTarget ]; then
return 1
fi
done
return 0
}
if [ -z $bundle_type ]; then
bundle_type="package"
fi
if [ ! -z $target ]; then
verify_target $target
if [ $? == 0 ]; then
echo -e "${RED}Error: Specified target \"$target\" is not supported by your ZLM server${NORMAL}\n"
exit
fi
fi
echo ""
echo -e " The bundle [${BOLD}$bundle_name${NORMAL}] has following version(s) of the supported types :${GREEN}"
zlman blv "$path/$bundle_name"
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not run \"zlman blv\" command on the server${NORMAL} !"
exit 1
fi
echo -e "${NORMAL}"
while true ;
do
echo -n " Enter one of the above bundle version : "
read version
echo ""
if [ ! -z $version ] && [ ! -z $target ];
then
if [ "$bundle_type" == "package" ] || [ "$bundle_type" == "you-patch" ]; then
psql -d zenworks -U zenadmin -c "select count(*) from zen_package where pkgid in ( select bp.pkgid from bundle_package bp , zen_bundle b where b.bndlid=bp.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type') and ( pkgmgr='managedrpm' or pkgmgr = 'patchrpm') and osid in(select osid from os_targets where name in ('$target' ) )" > /tmp/bunpack
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
psql -d zenworks -U zenadmin -c "select sum(filesize/1024) as filesize_kb from zen_package where pkgid in ( select bp.pkgid from bundle_package bp , zen_bundle b where b.bndlid=bp.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type') and ( pkgmgr='managedrpm' or pkgmgr='patchrpm' ) and osid in(select osid from os_targets where name in ('$target' ) )" > /tmp/bunsize
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
elif [ "$bundle_type" == "file" ]; then
psql -d zenworks -U zenadmin -c "select count(*) from unix_file where fileid in ( select fileid from bundle_file where bndlfileid in ( select bndlfile_id from bundle_file_ostarget where osid in ( select osid from os_targets where name='$target')) and fileid in ( select distinct bf.fileid from bundle_file bf, zen_bundle b where b.bndlid=bf.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type' )) " >/tmp/bunpack
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
psql -d zenworks -U zenadmin -c "select sum(filesize)/1024 as fb_size_kb from unix_file where fileid in ( select fileid from bundle_file where bndlfileid in ( select bndlfile_id from bundle_file_ostarget where osid in ( select osid from os_targets where name='$target')) and fileid in ( select distinct bf.fileid from bundle_file bf, zen_bundle b where b.bndlid=bf.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type' )) " >/tmp/bunsize
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
else
echo -e " ${RED}Not a supported bundle type for specified bundle version and target${NORMAL}"
fi
elif [ ! -z $version ]
then
if [ "$bundle_type" == "package" ] || [ "$bundle_type" == "you-patch" ]; then
psql -d zenworks -U zenadmin -c "select count(*) as packages from zen_package where pkgid in ( select bp.pkgid from bundle_package bp , zen_bundle b where b.bndlid=bp.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type') and ( pkgmgr='managedrpm' or pkgmgr='patchrpm' ) " > /tmp/bunpack;
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
psql -d zenworks -U zenadmin -c "select sum((filesize/1024)) as filesize_kb from zen_package where pkgid in ( select bp.pkgid from bundle_package bp , zen_bundle b where b.bndlid=bp.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type') and ( pkgmgr='managedrpm' or pkgmgr='patchrpm') " > /tmp/bunsize
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
elif [ "$bundle_type" == "file" ]; then
psql -d zenworks -U zenadmin -c " select count(*) from unix_file where fileid in (select distinct bf.fileid from bundle_file bf , zen_bundle b where b.bndlid=bf.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type' ) " >/tmp/bunpack
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
psql -d zenworks -U zenadmin -c " select sum(filesize)/1024 as fb_size_kb from unix_file where fileid in (select distinct bf.fileid from bundle_file bf , zen_bundle b where b.bndlid=bf.bndlid and b.name='$bundle_name' and b.version='$version' and b.type='$bundle_type' ) " > /tmp/bunsize
if [ $? -gt 0 ]
then
echo -e "${RED}Failure: Could not fetch from database${NORMAL} "
exit 1
fi
else
echo -e " ${RED}Not a supported bundle type for specified bundle version ${NORMAL}"
fi
else
echo -e "${RED} Warning: Verify the bundle version or existing target platform for the bundle :$bundle_name' ! ${NORMAL}"
fi
bunsize=`grep "[0-9]" /tmp/bunsize | grep -v row | tr -s " "`
bunpack=`grep "[0-9]" /tmp/bunpack | grep -v row | tr -s " "`
if [ ! -z $bunsize ]
then
if [ "$bundle_type" == "package" ] ;then
bunsize=$((bunsize 1))
echo -e " ${BOLD}The bundle contains (${YELLOW}$bunpack${NORMAL}${BOLD} ) $bundle_type(s) with payload size ~= ${YELLOW}$bunsize${NORMAL} ${BOLD}(KB)"
elif [ "$bundle_type" == "you-patch" ];then
bunsize=$((bunsize 1))
echo -e " ${BOLD}The $bundle_type bundle contains (${YELLOW}$bunpack${NORMAL}${BOLD} ) RPM(s) with payload size ~= ${YELLOW}$bunsize${NORMAL} ${BOLD}(KB)"
elif [ "$bundle_type" == "file" ];then
echo -e " ${BOLD}The bundle contains (${YELLOW}$bunpack${NORMAL}${BOLD} ) $bundle_type(s) with payload size ~= ${YELLOW}$bunsize${NORMAL} ${BOLD}(KB)"
else
echo ""
fi
else
echo " The bundle content payload size ~= 0 (KB)"
fi
echo ""
rm -f /tmp/bunsize
rm -f /tmp/bunpack
echo -ne " ${NORMAL}Would you like to proceed with another bundle version [y/n]? : "
read input
if [ $input == 'n' ]
then
exit 1
fi
done