1 2 Previous Next 18 Replies Latest reply on May 15, 2019 1:43 AM by Marie Farah dela Cruz

    Automated Staged Patching

    Marie Farah dela Cruz
      Share:|

      I want to be able to stage patching using BLCLI commands. Basically, have a parameter for Commit phase time so I can force the installation to happen at a certain time. I'm okay to put a hard-coded value for Simulate (say 5 hours ahead of the Commit phase) and run Stage phase after. I found some articles in the community that creates a dummy BLPackage and Deploy Job to assign the timings. Is there any other straightforward way to do that (probably using other BLCLI commands to inject the timing) or is that the only approach for what I want to do?

        • 1. Re: Automated Staged Patching
          Bill Robinson

          you wouldn't hard code anything.

          you would have a dummy advanced bldeploy job.  on that job you would set the schedule you want for simulate, stage, and commit.  that gets updated prior to any time you want to patch.  this can be done w/ the blcli.

          then you drop that dummy job on your patching job.

          then run the patching job.

          • 2. Re: Automated Staged Patching
            Marie Farah dela Cruz

            Hi Bill,

             

            I tried an NSH script I saw from the community. Basically it uses a template that contains the deploy job options. Upon my testing the resulting Deploy job got the Simulate, Stage and Commit timings but it doesn't seem to be followed.

             

            Here is my template job.

            And the resulting deploy job.

            My PAJ (called through as a parameter of the NSH script) completed but the remediation followed right away (ahead of the Simulate time set in the resulting deploy job).

            Commit phase completed ahead of the schedule as well.

            • 3. Re: Automated Staged Patching
              Bill Robinson

              can you share the script you are using to update the dummy job, set the patching job deploy options, etc ?

              • 4. Re: Automated Staged Patching
                Marie Farah dela Cruz

                I got the script from this link (https://communities.bmc.com.docs/DOC-17027), with a few modification to do successive analysis and remediation (noted below). We did not create a dummy job through the script though, but created a template deploy job with pre-defined timings.

                 

                #####################################################################

                # MAIN CODE

                #####################################################################

                maxCount=600

                interval=30

                templateJob="NONE"

                timeStamp="`date '+%Y%m%d-%H%M%S'`"

                   

                SCRIPT_ARGS=$@         # In case we need it later (i.e. for
                parameters etc)

                initScript "$@"

                 

                depotGroup="${parentDepotGroup}/${timeStamp}"

                jobGroup="${parentJobGroup}/${timeStamp}"

                patchingJobPath="${patchingJob%/*}" && print_debug2 "patchingJobPath=${patchingJobPath}"

                patchingJobName="${patchingJob##*/}" && print_debug2 "patchingJobName=${patchingJobName}"

                #patchRemJobName="prj-${timeStamp}" && print_debug2
                "patchRemJobName=${patchRemJobName}"

                targetServers="`echo ${targetServerList} | sed "s/ /,/g"`"

                 

                createDepotGroup

                createJobGroup

                checkVersion

                if [ "${bladeVersion}" = "8.0" ]

                      then

                      createExecutionTaskAndRun

                elif [ "${bladeVersion}" = "8.9" ]

                      then

                      runPatchingJob

                else

                      print_error "Version: ${bladeVersion} not recognized"

                fi

                processPatchingJobRun

                if [ ${count} -gt 0 ]

                      then

                      i=0

                      while [[ ${count} -gt 0 ]] && [[ ${i} -lt ${rerunPatchingJob} ]]

                         do

                         RemtimeStamp="`date '+%Y%m%d-%H%M%S'`"

                         patchRemJobName="${i}prj-${RemtimeStamp}" &&
                print_debug2
                "patchRemJobName=${patchRemJobName}"

                         i=${i}

                         blPackagePrefix="${i}autoPAJ_"

                         createRemediationJob

                         runRemediationJob

                         processRemediationJobRun

                         if [ "${remediationJobRunHadErrors}" = "true" ]

                          
                  
                then

                          
                   print_error
                "Remedation Job: ${jobGroup}/${patchRemJob} had errors, exiting..."

                         else

                          
                   runBatchDeployJob

                           

                          
                   processBatchDeployJobRun

                          
                   let i+=1

                          
                  
                if [ "${batchJobHadErrors}" = "true" ]

                                
                  
                then

                                
                   print_warn
                "Batch Job ${jobGroup}/${batchJobName} had errors..."

                          
                  
                else

                                
                   print_info
                "Batch Job ${jobGroup}/${batchJobName} completed successfully, software deployed..."

                          
                  
                fi  

                                
                  

                                
                   runPatchingJob

                                
                   processPatchingJobRun

                    
                          
                if [ ${count} -eq 0 ]

                                
                     
                then

                                      
                  print_info
                "Validation Patching Job shows no missing patches, success..."

                                
                  
                else

                                      
                  print_warn
                "Software still missing..."

                                
                  
                fi

                      fi

                   done

                     

                else

                      print_info "No missing software detected, skipping ${patchingJob}..."

                fi

                 

                #####

                # End of custom code

                #####

                cleanupEnv

                exit 0

                #####################################################################

                # END

                #####################################################################

                 

                • 5. Re: Automated Staged Patching
                  Bill Robinson

                  nothing in what you pasted associates the dummy job w/ the patching job. something needs to run PatchingJob setRemediationWithDeployOptions before you run the patching job.

                  • 6. Re: Automated Staged Patching
                    Marie Farah dela Cruz

                    The script I have runs the patching job first and then creates a patch remediation job that copies the setting from my template deploy job to its resulting deploy job. I can see the simulate, stage and commit times populated in the resulting deploy job, and I can also see the correct deploy job being called. I'm not sure why the timings are not followed. Do I really have to associate the dummy deploy job before running the patching job?

                    • 7. Re: Automated Staged Patching
                      Marie Farah dela Cruz

                      I tried to incorporate the command but got the following error.

                      Here's where I incorporated it:

                       

                      createRemediationJob_stagedPatching()

                      {

                      print_info "Creating Remediation Job: ${jobGroup}/${patchRemJobName}..."

                           if [ "${templateJob}" != "NONE" ]

                           then

                                templateJobPath="${templateJob%/*}"

                                templateJobName="${templateJob##*/}"

                                BLCLICMD=(DeployJob getDBKeyByGroupAndName "${templateJobPath}" "${templateJobName}")

                                     runBlcliCmd templateJobKey

                                BLCLICMD=(PatchRemediationJob createRemediationJobWithDeployOpts "${patchRemJobName}" "${jobGroup}" ${patchingJobRunKey} "${blPackagePrefix}" "${depotGroup}" "${jobGroup}" "${templateJobKey}")

                                BLCLICMD=(PatchingJob setRemediationWithDeployOptions ${patchingJobKey} "${blPackagePrefix}" "${depotGroup}" "${jobGroup}" ${templateJobKey})

                                runBlcliCmd patchingJobKey

                                echo "${patchingJobKey}"

                           else

                                BLCLICMD=(PatchRemediationJob createRemediationJob "${patchRemJobName}" "${jobGroup}"           ${patchingJobRunKey} "${blPackagePrefix}" "${depotGroup}" "${jobGroup}")

                           fi

                      runBlcliCmd remediationJobKey

                      }

                      • 8. Re: Automated Staged Patching
                        Bill Robinson
                        then creates a patch remediation job that copies the setting from my template deploy job to its resulting deploy job

                        not the script you posted...  can you attach the entire script you are using ?  you can use the 'advanced editor' mode to add attachments.

                         

                        the error you are getting means that the patching job got altered in such a way that there's a version mismatch between the patching job and the child analysis or remediation jobs.

                        • 9. Re: Automated Staged Patching
                          Marie Farah dela Cruz

                          Hi Bill,

                           

                          Attached is the NSH script I have modified to incorporate the PatchingJob setRemediationWithDeployOptions command (in createRemediationJob_stagedPatching function).

                           

                          I've also attached the job logs if it helps.

                          • 10. Re: Automated Staged Patching
                            Bill Robinson

                            delete the patching job and start clean.  i don't see any calls in my script that would cause the error w/ the version mismatch.

                             

                            as far as getting the schedule set, nothing in the script is setting the phase schedules on the dummy job.  you need to do that before applying the dummy job to the patching job.

                            • 11. Re: Automated Staged Patching
                              Marie Farah dela Cruz

                              In a different light Bill, is there any way to read the phase scheduled times from a deploy job or a PRJ using any of the BLCLI unsupported commands?

                              • 12. Re: Automated Staged Patching
                                Bill Robinson

                                why?  why can't you set the schedule you want on the dummy deploy ?

                                • 13. Re: Automated Staged Patching
                                  Marie Farah dela Cruz

                                  We can Bill. The question was actually for a different approach we're looking into.

                                   

                                  Our BLAdmins would like to know if there's any way to read the phase scheduled times from a deploy job or a PRJ using any of the BLCLI unsupported commands as it appears there's none at the moment?

                                  • 14. Re: Automated Staged Patching
                                    Bill Robinson

                                    why ?  what are they going to do w/ it ?

                                    1 2 Previous Next