[go: up one dir, main page]

Menu

[r3]: / rexx / BUILD.EXEC  Maximize  Restore  History

Download this file

190 lines (166 with data), 15.3 kB

/*                                                                              
VMLMAT: VM Linux Management and Archival Tool.                                  
Copyright (c) 2007, Ronnie Michael, BMC Software Inc.                           
                                                                                
All rights reserved.                                                            
                                                                                
Redistribution and use in source and binary forms, with                         
or without modification, are permitted provided that the following              
conditions are met:                                                             
                                                                                
    * Redistributions of source code must retain the above copyright            
 notice, this list of conditions and the following disclaimer.                  
  * Redistributions in binary form must reproduce the above copyright           
 notice, this list of conditions and the following disclaimer                   
in the documentation and/or other materials provided with the                   
 distribution.                                                                  
    * Neither the name of the BMC Software Inc. nor the names of its            
contributors may be used to endorse or promote products derived                 
 from this software without specific prior written permission.                  
                                                                                
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS             
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT               
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR           
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT            
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,           
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT               
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,           
 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON              
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR              
 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT                
 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY                
 OF SUCH DAMAGE.                                                                
*/                                                                              
/* Change cpysrv1 to the correct vm account of your web/cpy server              
                                                                                
  Note that the script will wait 30 secs for the Linux shutdown                 
 to complete. You may modify this value if needed based on your                 
 experience of your machines.                                                   
                                                                                
Input is command and hostname.                                                  
Output is function and a post event (bkpost) routine to wake up                 
copy server                                                                     
*/                                                                              
/* Routine uses WAKEUP to receive msgs         */                               
/* and also issues a 'SET MSG IUCV' command.         */                         
Trace 'Off'                                                                     
'Dropbuf 0'                                                                     
"WAKEUP +0 (IUCVMSG"                                                            
 call m_wait                                                                    
   /* when its time to quit, come here                        */                
 xit:                                                                           
   'WAKEUP RESET';        /* turn on IUCV msgs    */                            
   exit;                                                                        
                                                                                
/* the console msgs are rc=6, IUCVMSG are rc=5               */                 
m_wait: procedure expose hostx cpysrv1 mdf mdt                                  
flag = '0000'                                                                   
cpysrv1= 'LNXS390'                                                              
say 'Build Script Started'                                                      
do forever                                                                      
   'Makebuf'                 /* Get a buffer               */                   
   'wakeup (iucvmsg'         /* wait for a msg             */                   
   if rc /=5 then leave;   /* Leave when its not an iucvmsg */                  
   parse pull mtype uid text hostx mdf mdt/* parse the msg      */              
   if uid = cpysrv1 then do                                                     
      if text = 'LINK'     /* command to link device */                         
      then call llnk                                                            
      if text = 'DETACH'   /* command to detach device */                       
      then call dlnk                                                            
      if text = 'STAT'     /* determine status of guest */                      
      then call stat                                                            
      if text = 'DOWN'     /* bring down the guest */                           
      then call dlnx                                                            
      if text = 'UP'       /* bring up the guest */                             
      then call ulnx                                                            
      'Dropbuf'                 /* Drop buffer  */                              
    end                                                                         
   end                                                                          
return                                                                          
                                                                                
/* Routine that shuts down the z/Series Linux */                                
                                                                                
    hdown: procedure expose hostx                                               
     say 'shutdn ' hostx                                                        
     Call Diag 08,'CP SEND ' hostx   " shutdown -h now"                         
     'sleep 30 sec'                                                             
    return                                                                      
                                                                                
/* This routine waits until the VM guest is down */                             
/* it will keep checking until HCPCQU045E or other message */                   
    ckdown: procedure expose hostx cpysrv1                                      
    say 'ckstat ' hostx                                                         
    var1 = hostx                                                                
    ncnt = 0                                                                    
    do while var1 = hostx & ncnt < 60                                           
     'sleep 1 sec'                                                              
     ncnt = ncnt + 1                                                            
     'PIPE CP QUERY' hostx '| VAR QHOSTX'                                       
      Parse Var qhostx var1 var2 var3 var3 var4                                 
    end                                                                         
   if ncnt < 60                                                                 
    then Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 1'                         
    else do                                                                     
    say hostx ' did not come down'                                              
/* send return code 10 that the host did not come down after 60 seconds*/       
    Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 10'                             
   end                                                                          
   return                                                                       
                                                                                
/* This routine waits until the VM guest is up */                               
/* it will keep checking until var1 = hostx or other message */                 
    ckup: procedure expose hostx cpysrv1                                        
    say 'ckstat ' hostx                                                         
    var1 = 'HCPCQU045E'                                                         
    ncnt = 0                                                                    
    do while var1 = 'HCPCQU045E' & ncnt < 60                                    
     'sleep 1 sec'                                                              
      ncnt = ncnt + 1                                                           
     'PIPE CP QUERY' hostx '| VAR QHOSTX'                                       
      Parse Var qhostx var1 var2 var3 var3 var4                                 
    end                                                                         
   if ncnt < 60                                                                 
    then Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 2'                         
    else do                                                                     
    say hostx ' did not come up'                                                
/* send return code 20 that the host did not come up after 60 seconds */        
    Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 20'                             
   end                                                                          
   return                                                                       
/* This procedure is to link minidisk */                                        
                                                                                
   llnk: procedure expose hostx cpysrv1 mdf mdt                                 
     say 'linking ' hostx                                                       
     'send cp ' cpysrv1 || ' link ' hostx ||' '  mdf || ' '  mdt || ' m'        
 say 'send cp ' cpysrv1 || ' link ' hostx ||' '  mdf || ' '  mdt || ' m'        
     Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 3'                             
  return                                                                        
                                                                                
/* This procedure is to detach minidisk  */                                     
                                                                                
  dlnk: procedure expose hostx cpysrv1 mdf mdt                                  
     say 'detaching ' hostx                                                     
/*the actual value should be in mdt but mdf and mdt are positional*/            
/*from the msg parse so mdf contains the mdt value from cpysrv1 */              
     'send cp ' cpysrv1 || ' detach ' mdf                                       
     say 'send cp ' cpysrv1 || ' detach ' mdf                                   
     Call Diag 08,'CP SEND ' cpysrv1 || ' BKPOST 4'                             
  return                                                                        
                                                                                
/* This procedure is to get the status of the specific hostname */              
                                                                                
  stat: procedure expose hostx cpysrv1                                          
     say 'stat ' hostx                                                          
     'PIPE CP QUERY' hostx '| VAR QHOSTX'                                       
     Parse Var qhostx var1 var2 var3 var3 var4                                  
     if var1 = 'HCPCQU045E' /* message that it is down */                       
     then call dtat cpysrv1                                                     
     if var1 = hostx        /* value that it is up */                           
     then call utat cpysrv1                                                     
   return                                                                       
                                                                                
   utat: procedure expose cpysrv1                                               
     Call Diag 08,'CP SEND ' cpysrv1 || ' BKSUP 1'                              
   return                                                                       
                                                                                
   dtat: procedure expose cpysrv1                                               
     Call Diag 08,'CP SEND ' cpysrv1 || ' BKSUP 0'                              
   return                                                                       
                                                                                
/* This procedure is to shutdown the hostname */                                
                                                                                
  dlnx: procedure expose hostx cpysrv1                                          
     say 'shutdown ' hostx                                                      
     call hdown hostx                                                           
     say 'logoff ' hostx                                                        
     'send cp ' hostx || ' logoff'                                              
     call ckdown hostx cpysrv1                                                  
   return                                                                       
                                                                                
/* This procedure is to bring up the hostname */                                
                                                                                
ulnx: procedure expose hostx cpysrv1                                            
     say 'logon ' hostx                                                         
     'xautolog' hostx                                                           
      call ckup hostx cpsyrv1                                                   
   return                                                                       
/*                                                                              
                                                                                
*/