6 Replies Latest reply on May 30, 2014 11:51 AM by Raja Mohan

    wait for a VGJ job

    Raja Mohan

      I am creating a VGJ for VMware using an XML, It spawns of a different job and the job goes and executes successfully (or not).

      The command I use to create a VM is as below

      blcli_execute Virtualization createVirtualGuest "$DIR_XML/vgpsmall"

       

      I attempted to sleep for a minute and then execute VM power status command by issuing the commands below in a while loop.

      Virtualization  getVirtualGuestKeyByServerName $VIRTUAL_GUEST1_NAME`

      Virtualization getVirtualGuestPowerStatus "$VIRT_ENTITY_KEY"`

       

      I can see in the application server log after the first command is issued to obtain Virtual Guest Key, it results in error and NSH script doesn't go anywhere after the error. Just hangs and doesn't proceed with waiting to attempt again

       

      The error message is

      bsatest2_rhel6 is not enrolled

       

      How do i wait on the main NSH script for this job to complete? Any thoughts?

        • 1. Re: wait for a VGJ job
          Bill Robinson

          why are you using separate jobs for this ?  wouldn't you run everything in sequence ?

          • 2. Re: wait for a VGJ job
            Raja Mohan

            I am not trying to, atleast that wasnt my intention. But when i execute the command createVirtualGuest it automatically spawns a new job. May be I am doing the whole thing wrong.

             

            1) Built the XML file

            2) run the XML file for VGJ  <--- This one spawns a new job

            3) wait for the VGJ to complete

            4) start the new guest

            5) Identify mac address for the new guest

            6) register in DNS

            4) execute provisioning

            Let me know if i can run it under the same NSH job, then how?

            • 3. Re: wait for a VGJ job
              Aryan Anantwar

              Hi Raja,

               

              the steps you are following looks good, but you have to keep in mind the execution flow.

              1) Built the XML file

              -- this is VGJ.xml containing the Virtual Guest Name hard coded in it.

              2) run the XML file for VGJ  <--- This one spawns a new job

              -- then you ran blcli_execute Virtualization createVirtualGuest "$DIR_XML/vgpsmall" command, which creates a new VGJ jov and starts execution. (Considering the executeNow = true)

              3) wait for the VGJ to complete

              -- this is critical one, how you are identifyin the completion of VGP job, Job status(success/failure)?

                 you can use, https://docs.bmc.com/docs/display/bsacli85/JobRun+-+getJobRunStatusByScheduleId this to get status of VG    job. depending on the result of this, further actions should get decided.

              4) start the new guest

              -- How you are trying to start the guest, if VGJ is successful then BSA itself enroll the new guest. the VM will be already running.

              5) Identify mac address for the new guest

              -- You can use blcli or nexec/nsh to get these details

              6) register in DNS

              -- using blpackage deploy or script you can achieve this

              4) execute provisioning

              -- I can't understand this, "execute provisioning" again why?

               

              Let me know if i can run it under the same NSH job, then how?

              if you wanted to do all above activities in single NSH script/job, then first design a flow of commands by keeping mind the above things.

               

              Regards,

              Aryan Anantwar

              1 of 1 people found this helpful
              • 4. Re: wait for a VGJ job
                Raja Mohan

                step 2 automatically spawns a new job.

                Aryan Anantwar step 3 is what i am having trouble with, not sure how to wait for the spawned job to successfully complete in my original NSH script. I am just creating a VM Guest (Its just skeleton with no OS), so i will have to discover this vm and provision the OS to this new VM guest.

                 

                I am starting vm guest using the command

                "blcli_execute Virtualization changeVirtualGuestPowerStatus "$VIRT_ENTITY_KEY" Start"

                • 5. Re: wait for a VGJ job
                  Raja Mohan

                  The VGJ file when set to autoexecute "false" in the XML, I am able to trigger the job using "blcli job execute $job_key" after getting the jobkey using example

                  blcli_execute Virtualization getDBKeyByGroupAndName /Workspace/RHEL6-64/virtualGuestJob VGPSMALL-RHEL6_JOB

                  followed by issuing command to execute the job using

                  blcli_execute Job execute $JOB_KEY

                  This works well, but still the problem of different spawned job vs. same NSH job.

                   

                  Is this a valid command? I dont see it in documentation for job

                  blcli_execute Job executeJobAndWait $JOB_KEY

                   

                  I notice it is valid for various other types like NSHScriptJob or DeployJob or audit job or snapshot job or batchjob or filedeployjob or patching job

                  blcli_execute NSHScriptJob executeJobAndWait $JOB_KEY

                  blcli_execute DeployJob executeJobAndWait $JOB_KEY

                  • 6. Re: wait for a VGJ job
                    Raja Mohan

                    I answered my own question, Looks like there is an undocumented command for

                     

                    blcli job executeJobAndWait $JOB_KEY

                     

                    I tried to test it from command line and it seems like working. My terminal is locked, the job is executing. Now I will do an integration testing in my script