Admin Alert: Porting an Image Catalog Between Power i Boxes using FTP
July 20, 2011 Joe Hertvik
In a recent article about creating and using image catalogs in lieu of CDs and DVDs for i operating system installations and upgrades, I didn’t discuss how to move image catalogs between different i/OS partitions that can be located many miles or time zones apart. To plug that hole, this issue I present two simple programs that enable you to move pre-loaded image catalogs between systems.
Why Move Image Catalogs?
For many organizations, their iSeries, System i, and Power i partitions may reside in different cities, states, or even countries. The production system frequently resides in one location while its matching Capacity BackUp (CBU) system resides in another. And your operations staff that works at the central office may be responsible for upgrading software at all locations.
While it’s becoming more common to download CDs and third-party software upgrades directly from a vendor, many vendors still send out upgrades on traditional CDs and DVDs and many administrators prefer it that way. In these cases, physical upgrade media must be loaded on different partitions at different locations before the software can be upgraded. With a shared image catalog that can be transferred between different machines, the staff can load the CD into an image catalog on one machine in the central office and then FTP and restore that image catalog to all machines in its network.
To facilitate that transfer, here’s my procedure for transferring image catalogs between different iSeries, Power i, and System i partitions.
A Six-Step System
If you have an image catalog and accompanying entries on a source Power i machine that you want to move to a target machine, you can easily move those objects by executing the following steps on your partitions.
Here’s how to perform each step.
Steps 1 and 2: Creating a virtual optical device and image catalog.
You can create a virtual optical device for reading image files through an image catalog by using the following Create Device Desc (Optical) (CRTDEVOPT) command.
CRTDEVOPT DEVD(OPTDEVICE) RSRCNAME(*VRT) TYPE(632B) TEXT('Virtual optical device')
The device type must be 632B (virtual optical device) for this device to process data from an image catalog. When loaded with an image catalog and image file from CD or DVD, this virtual optical device can be used for upgrading software the same as you would any other physical optical device. Create this device on both your source and your target machines.
Once you have your virtual devices created, create an image catalog for the device. The image catalog holds CD and DVD images as image file entries. Create your catalog by using this Create Image Catalog (CRTIMGCLG) command on the source machine.
CRTIMGCLG IMGCLG(IMG_CAT) DIR('/imagedir) TYPE(*OPT) CRTDIR(*YES)
Besides creating the image catalog, CRTIMGCLG also creates the AS/400 Integrated File System (AS/400 IFS) directory that will contain your image files (as specified in /imagedir value for the DIR parameter). For this example, you need only create the image catalog on your source machine. Step five will restore the catalog to your target machine.
Step 3: Create save files to transfer your image catalog and image files.
For the next step, you need to create two save files (SAVF). You’ll use one SAVF to save your source system image catalog and the second SAVF is used to save your source system image file entries. You need two SAVFs because we will be using two different commands to save each type of object. Per IBM recommendation, let’s name these SAVF files IMGCLGOBJ (for the image catalog) and IMGCLGDIR (for the image file directory).
You can easily create these save files with the following Create Save File (CRTSAVF) commands.
CRTSAVF FILE(QTEMP/IMGCLGOBJ) TEXT('Save file for image catalogs') CRTSAVF FILE(QTEMP/IMGCLGDIR) TEXT('Save file for image file directory')
Create these files on both the source and the target systems.
Step 4: Load your optical media to the image catalog and save it for transfer
Here’s a program I wrote to prepare your image catalog and image files for transfer to the target System. This program loads your CD or DVD to the image catalog and image files and then saves those objects to the save files your created in step three. Compile and run this program on your source system.
0001.00 PGM 0002.00 0003.00 DSPOPT VOL(*MOUNTED) DEV(OPT01) DATA(*FILATR) + 0004.00 PATH(/) /* Check to see if there is a CD + 0005.00 or DVD in the system optical media*/ 0006.00 MONMSG MSGID(OPT1660) EXEC(GOTO CMDLBL(NEXT)) /* + 0007.00 Skip image file loading if there is no CD + 0008.00 or DVD in the physical optical media */ 0009.00 0010.00 ADDIMGCLGE IMGCLG(IMAGE_CAT) FROMDEV(OPT01) + 0011.00 TOFILE(IMAGE_FILE) IMGCLGIDX(1) REPLACE(*YES) 0012.00 0013.00 NEXT: CLRSAVF FILE(library_name/IMGCLGOBJ) 0014.00 0015.00 CLRSAVF FILE(library_name/IMGCLGDIR) 0016.00 0017.00 CHGATR OBJ('/imagedir') ATR(*ALWSAV) + 0018.00 VALUE(*YES) SUBTREE(*ALL) /* Change the + 0019.00 image file directory to always save its + 0020.00 contents. Restore on target system may + 0021.00 not happen if this isn't set correctly */ 0022.00 0023.00 SAVOBJ OBJ(IMAGE_CAT) LIB(QUSRSYS) DEV(*SAVF) + 0024.00 OBJTYPE(*IMGCLG) SAVF(Library_name/IMGCLGOBJ) + 0025.00 /* save the current Image Catalog on the + 0026.00 system */ 0027.00 0028.00 SAV DEV('/QSYS.LIB/Library_name.LIB/IMGCLGDIR.FILE') + 0029.00 OBJ(('/imagedir')) /* Save the + 0030.00 current image catalog file directory */ 0031.00 0032.00 ENDPGM
This code performs the following functions:
Lines 3.00 through 12.00 check to see if there is a CD or DVD loaded into the system optical reader. If a CD/DVD is present, it loads that media to the image catalog as an image file in the target directory.
Lines 13.00 through 16.00 clear the save files in anticipation of saving the image catalog and its accompanying image file directory.
Lines 17.00 through 22.00 changes the object attributes on the image file directory and all its objects to allow those objects to be saved (*ALWLSAV). If *ALWSAV isn’t set up on these files, you may get an error message when the program saves your image files.
Lines 23.00 through 27.00 use the Save Object command (SAVOBJ) to save your image catalog to the IMGCLGOBJ save file.
Lines 28.00 through 31.00 use the Save command (SAV) to save the AS/400 IFS directory that contains your CD or DVD image files. This directory is saved to the IMGCLGDIR save file.
At this point, you can transfer your image catalog and image files to the target system.
Step 5: Use FTP to move the image catalog and image files to the target system.
Use the FTP techniques outlined in my FTP save file article to move the image catalog and image file save files from the source system to the target system. Once the save files are transferred, they can be used to recreate your image catalog and image files.
Step 6: Restore the saved image catalog and image files to the target system.
You can use the following code to restore the image catalog and its associated image files from your save files to the target system. Compile and run this program on your target system.
0001.00 PGM 0002.00 0003.00 LODIMGCLG IMGCLG(IMAGE_CAT) OPTION(*UNLOAD) /* Unload + 0004.00 the existing image catalog on the system*/ 0005.00 MONMSG MSGID(CPF0000) 0006.00 DLTIMGCLG IMGCLG(IMAGE_CAT) KEEP(*NO) /* Delete the + 0007.00 existing image catalog and all + 0008.00 its associated directories */ 0009.00 MONMSG MSGID(CPF0000) 0010.00 0011.00 RSTOBJ OBJ(IMAGE_CAT) SAVLIB(QUSRSYS) DEV(*SAVF) + 0012.00 OBJTYPE(*IMGCLG) SAVF(Library_name/IMGCLGOBJ) + 0013.00 MBROPT(*ALL) ALWOBJDIF(*ALL) /* Restore + 0014.00 the existing image catalog from the save file*/ 0015.00 RST DEV('/QSYS.LIB/Library_name.LIB/IMGCLGDIR.FILE') + 0016.00 OBJ(('/imagedir')) ALWOBJDIF(*ALL) /* + 0017.00 Restore the existing image file directory */ 0018.00 LODIMGCLG IMGCLG(IMAGE_CAT) OPTION(*LOAD) + 0019.00 DEV(OPTDEVICE) /* Reload the + 0020.00 image catalog */ 0021.00 LODIMGCLGE IMGCLG(IMAGE_CAT) IMGCLGIDX(1) + 0022.00 OPTION(*LOAD) /* Reload the first + 0023.00 image file image catalog entry (index+ 0024.00 one) */ 0025.00 VFYIMGCLG IMGCLG(IMAGE_CAT) TYPE(*OTHER) SORT(*YES) + 0026.00 /* Verify the image catalog for use */ 0027.00 0028.00 ENDPGM
This code performs the following functions:
Lines 0003.00 through 0010.00 unload the current image catalog on the target system and then they delete the image catalog and its associated image files.
Lines 0011.00 through 0017.00 restore the save image catalog and its associated image files from the source system.
Lines 0018.00 through 0020.00 reload the newly restored image catalog to the virtual optical device on the target system.
Lines 0021.00 through 0024.00 reload the first image catalog entry (index 1) back to the restored image catalog. Modify this code if you have more than one image file associated with your image catalog.
Lines 0025.00 through 0027.00 verify the image catalog and its associated image files to ensure that they are ready to use.
Using the Restored Image Catalog For Your Upgrades
After completing step 6, you can now use the virtual optical device name to load your software onto your target system. Simply use the name of the virtual optical device created in steps 1 and 2 as your installation device name.
Once you have this basic framework in place, it can be used to easily load and move CD and DVD images between any System i and Power i partitions on your network, providing a way to move installation and upgrade media between machines.