ZCM 11 imaging megapost – scripted multicasting

windows 7 novell blog banner

Just when I thought I’d finished all the ZCM imaging posts I remembered one more very useful piece I hadn’t covered – how to create an interactive bash script to create multicast session with minimal effort 🙂

As discussed earlier on in the series I found that ZCM imaging out-the-box didn’t suit our requirements in terms of getting brand new metal out the box and imaged without messing around with MAC addresses or running the risk of hardware rules running riot on existing PCs. As a result it also meant that ZCM server-side multicasting wasn’t going to work for us for a couple of reasons:

1) can’t use Multicast Imaging Bundles due to ZCM not knowing about the new PCs’ existence
2) technicians don’t have SSH access to the ZCM server to create multicast sessions manually on there
3) our switches don’t route multicast packets at the moment and we didn’t fancy reconfiguring the network to do that right now

At this point talking with my colleagues brought up the fact that they used to multicast rooms manually in the past using one of the other computers in the rooms as a “master” machine then firing out the (sysprepped) image to the rest of the machines. This seemed like the best way forward but only if it could be scripted \ automated.

Of course it can 😀

Set up your scripts

Looking back on the code it’s quite a simple process really, first thing you need is to create two scripts with matching entries in pxemenu.txt etc as covered in post 6 – I named mine win7image2013.mcm.s (master machine) and win7image2013.mc.s (slave machine)

Master machine process

So what does our Master machine script need to do?

  • notify user what will happen next
  • download and apply base image
  • ask user for parameters to create multicast session
  • create session and wait for slaves to join
  • apply add-on images and reboot

First things first, clear the screen and set some colours for later on:

#! /bin/bash
echo -en "33c"
#DEFINE COLOURS TO BE USED FOR SCRIPT ECHO COMMANDS
RED='\e[0;31m'
YELLOW='\e[1;33m'
GREEN='\e[0;32m'
NC='\e[0m'

After some funky ASCII art and additional code to show machine model and network status (more on that another time) I run a series of echo commands to tell the end-user what happens during the imaging process.
Note: the 20 minute statement was based on our (slow) imaging times that have been since found to be caused by a ZCM bug, click here for a fix that will reduce that time down to under 5 minutes!

echo -e "${NC}This process will set the current machine as the multicast MASTER node"
echo "all other machines will download their image from this machine"
echo
echo "******************************************************************"
echo " First we need to download the Windows 7 base image " 
echo " this will take about 20 minutes on most hardware "
echo " all data on the disk will be wiped during ths process "
echo "******************************************************************"
echo

Next we need run the standard img command to pull down our Windows 7 base image (I run zisedit -c before this but your might not want \ need that so haven’t included it below). We ask the tech to confirm the imaging process one more time before they start, if you don’t want this just use the img command on its own

read -s -n1 -p "Are you sure you want to image this machine? y/n" confirm
if [ "$confirm" = "y" ] ; then
img rp $PROXYADDR /var/opt/novell/zenworks/content-repo/images/WIN7_BASE.zmg
else
 echo
 echo
 echo -e "${RED}<---- Multicast imaging aborted ---->${NC}"
 echo
 read -p "Press [Enter] key to reboot..."
 reboot -f
fi

Once that’s done we need to ask the user what the name of the multicast session will be and how many slave machines they want to image. Once all the slaves join the session will automatically start.

echo -e "${YELLOW}Type a unique name for this Multicast session" 
echo -e "${YELLOW}---------------------------------------------" 
echo -e "${NC}this will need to be entered on each PC to be imaged when they are booted up"
echo "e.g. use the number of the room you are imaging at the moment"
echo
read session_name
echo
echo -e "${YELLOW}How many PCs do you want to image this session?"
echo -e "${YELLOW}-----------------------------------------------" 
echo -e "${NC}Imaging will not start until all machines have joined the session" 
echo "so don't set this number larger than the number of computers in the room"
echo "imaging will start when one of 3 events occurs"
echo
echo " -> the required number of machines join the session"
echo " -> the user presses the Start Session button"
echo " -> the 3 hour timeout period expires"
echo
echo "Please enter the number of PCs to image then press Enter..."
read numberofclients

Finally create the session using the img command with the -master switch and the variables defined above . We set a long timeout value in case someone leaves the room in between starting the slave machines (the -timeout value is measured in minutes)

echo
echo -e "${NC}Ready to create session named ${GREEN}$session_name ${NC}that will image ${GREEN}$numberofclients ${NC}PCs"
read -s -n1 -p "Are you sure you want to create this session? y/n" confirm
if [ "$confirm" = "y" ] ; then
img -session $session_name -master -clients=$numberofclients -timeout=180
img rp $PROXYADDR /var/opt/novell/zenworks/content-repo/images/addon-image/SCRIPTS.zmg
img rp $PROXYADDR /var/opt/novell/zenworks/content-repo/images/addon-image/DRIVERS.zmg
reboot -f
else
 echo
 echo
 echo -e "${RED}<---- Multicast session aborted ---->${NC}"
 echo
 read -p "Press [Enter] key to reboot..."
 reboot -f
fi

Slave machine process

The slave machine is similar to the Master but only needs one question to set up the multicast (name of session to join)

echo
echo "Type the unique name for this Multicast session" 
echo "-----------------------------------------------" 
echo "enter the session name you used when setting up the MASTER machine"
echo "e.g. this may be the number of the room you are imaging at the moment"
read session_name

Then set off the session with the trusty img command
If you use add-on images you’ll need to add those on the lines afterwards

img -session $session_name -client
img rp $PROXYADDR /var/opt/novell/zenworks/content-repo/images/addon-image/SCRIPTS.zmg
img rp $PROXYADDR /var/opt/novell/zenworks/content-repo/images/addon-image/DRIVERS.zmg

Multicast speed (or lack of)

In testing we’ve been unable to get our multicast times lower than 30 minutes despite Unicast finishing in 5 minutes, whether this is down to the host machine (i3 \ SSD so doubt it), network (possibly) or ZCM’s imaging engine (possibly) I don’t know but don’t be too disappointed if it doesn’t go like lightning.

In some cases we’ve managed to get away with unicasting as the image downloads so quickly with the progress bar speed fix that machines finish the download process before the next batch have been powered on, PXE booted and loaded the imaging environment.

This wasn’t the case beforehand (when the base image took 20 minutes+ to apply) and in those circumstances our upper limit was about 16-20 machines before the server choked so make sure you check out this thread if you have newer Intel chipsets in your machines!

Advertisements

2 Responses to ZCM 11 imaging megapost – scripted multicasting

  1. Roberto says:

    Hi there . . . Great post! I’ve been having a challenging time getting our networking team to allow Multicasting of packets; totally understand why. Following your scripts I would keep things locally within a given VLAN, correct? Can I use any machine as the Master?

    • gshaw0 says:

      Hi Roberto, yup that’s exactly why we set up with the local master machines – avoids all that messing around with routed multicast and any potential issues it may cause.

      From experience we found 20-25 machines max per master host worked best, also worked out nicely as one machine per room. The way I set the scripts up the master machine also gets imaged as once it’s finished the multicast session it doesn’t need reimaging and just carries on with the driver packs etc, which is a nice time saver.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: