Novell Cool Solutions

Computing the Bundle Content Payload Size for ZENworks 7.x Linux Management



By:

December 4, 2009 10:38 am

Reads:6,117

Comments:0

Score:Unrated

Print/PDF

Contents:

Introduction

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

Problem

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.

System Environment

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.

Solution

Instructions

  • This script will provide the content size (in KB) for the ZENworks bundle of type package, you-patch or file .
  • The supported bundle types are package ,you-patch and file . The package type is equivalent to RPM Package Bundle, you-patch type is equivalent to YaST Online Update(YOU) Patch Bundle and file type is for File Bundle. The default value for bundle type is package. It is an optional argument.
  • User should provide the bundle name, version and bundle type and its folder path in zlman semantics.
  • Target is target platform of the packages present in the RPM Package, YOU Patch or File bundle. It is an optional argument.
Note:
-The data provided may not be consistent if bundles of given type exists with duplicate names.
-The size of bundle metadata is not included in the total bundle content size.
-For remotely hosted postgres database, user may need to provide appropriate arguments for all the psql commands in the script.
eg psql -d zenworks -U zenadmin -h <hostip> -p 5432 -c ” .. ” ;
– If prompted for postgres database connection password, provide this from the hibernate.cfg.xml at /etc/opt/novell/zenworks/ path.

Steps

Do the following on the ZLM Primary Server:

  1. Copy the content of the below script to a file say bundle_size.sh.
  2. Set the /root/.zlmanrc file to username as administrator and its password, to the skip interactive prompt.
  3. Ensure that /root/.pgpass is set with database connection.password from the /etc/opt/novell/zenworks/hibernate.cfg.xml file. If prompted, provide this password for local/remote postgres connection.
  4. Run the script on the zlm server as per the usage syntax given below.

Script

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 


0 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 50 votes, average: 0.00 out of 5 (0 votes, average: 0.00 out of 5)
You need to be a registered member to rate this post.
Loading...Loading...

Tags:
Categories: Uncategorized

0

Disclaimer: This content is not supported by Novell. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

Comment

RSS