10 Replies Latest reply on Feb 27, 2015 12:25 AM by Santhosh Kurimilla

    getRoleCreated/getUserCreated returns empty value

    Narahari Lakshminarayana

      Friends:

       

      I have the following code that is trying to get the RoleCreated property of a given job.  I don't seem to get the desired output.  Any ideas why and how to get that ?

      blcli_setjvmoption -Dcom.bladelogic.cli.execute.quietmode.enabled=true

      blcli_setjvmoption -Dcom.bladelogic.cli.execute.addnewline.enabled=true

       

       

      jobGroup="/USS Job Workspace/Presentation Services/Portal/Users/Narahari"

      blcli_execute JobGroup groupNameToId "$jobGroup"

      blcli_storeenv groupId

      #echo $groupId

      blcli_execute Job findAllByGroupId $groupId false

      blcli_storeenv the_list

       

       

      blcli_execute Utility setTargetObject

      blcli_execute Utility listLength

      blcli_storeenv arrLen

       

       

      blcli_execute Utility storeTargetObject "jobList"

       

       

      n=0

      x=0

      while [ "$n" -lt "$arrLen" ];

      do

        blcli_execute Utility setTargetObject "jobList"

        blcli_execute Utility listItemSelect "$n"

        blcli_execute Utility setTargetObject

       

        blcli_execute Job  getName

        blcli_storeenv thename

        #echo $thename

       

       

       

        if [ "$thename" = "ScriptTesterNarahari" ];

        then

        #echo "The Job is $thename"

        echo "Found the job $thename"

        echo "Now let us get the role created"

        blcli_execute Job  getRoleCreated

        blcli_storeenv rolecreated

        echo "Role Created: $rolecreated"

        fi

        n=$(( n+1 ))

      done

       

       

      C:\Users\nlakshmi\blscripts>nsh.bat getpropforjob.sh

      Found the job ScriptTesterNarahari

      Now let us get the role created

      Role Created:

        • 1. Re: getRoleCreated/getUserCreated returns empty value
          Bill Robinson

          the job object has to be loaded into memory when you run those commands.  in your script, it's not.

          while [ "$n" -lt "$arrLen" ];

          do

            blcli_execute Utility setTargetObject "jobList"

            blcli_execute Utility listItemSelect "$n"

            blcli_execute Utility setTargetObject

           

            blcli_execute Job  getName

            blcli_storeenv thename

          blcli_execute Job getRoleCreated

          blcli_storeenv roleCreated

          blcli_execute Job getUserCreated

          blcli_storeenv userCreated

          ...

          • 2. Re: Re: getRoleCreated/getUserCreated returns empty value
            Narahari Lakshminarayana

            Hello Bill:

             

            Thank you for that reply.

             

            I am indeed loading the object into memory otherwise the call itself will fail.

            But I am getting the value as empty.

             

            The following works.

            while [ "$n" -lt "$arrLen" ];

            do

              blcli_execute Utility setTargetObject "jobList"

              blcli_execute Utility listItemSelect "$n"

              blcli_execute Utility setTargetObject

             

              blcli_execute Job  getName

              blcli_storeenv thename

              echo $thename

            .....

            ....

             

               It is line after that aka the following fragment that does not work.

            blcli_execute Job getRoleCreated

              blcli_storeenv roleCreated

              echo "Role = $roleCreated"

              blcli_execute Job getUserCreated

              blcli_storeenv userCreated

              echo  "User = $userCreated"

             

            I get empty values back for role and user.

             

            cleanrpmlocks

            Role =

            User =

            ScriptTesterNarahari

            Role =

            User =

            ExportProperties

            Role =

            User =

            PropertyViewer

            Role =

            User =

            Generic_CopyFilesPaaS_Job

            Role =

            User =

            NSH_Generic_CopyFilesPaaS_Job

            Role =

            User =

            CopyGroupToGroupJob

            Role =

            User =

            getJobTypeForGivenJob

            Role =

            User =

            JobsForCPsInCE

            Role =

            User =

            -Narahari

            • 3. Re: Re: getRoleCreated/getUserCreated returns empty value
              Santhosh Kurimilla

              Yes, I have faced the same problem.

              It seems when we are using blcli_execute in a loop statement, it is saving the only result at the first iteration.

               

              As a workaround/fix, I used just blcli instead of blcli_execute.

              RES=$(blcli Server serverExists "${fname}")

               

              • 4. Re: Re: getRoleCreated/getUserCreated returns empty value
                Santhosh Kurimilla

                Just in addition to my previous response, I actually faced this issue when used in a function. And, of course the command in a for loop calls the function multiple times. 

                • 5. Re: getRoleCreated/getUserCreated returns empty value
                  Narahari Lakshminarayana

                  Hi Santhosh:

                  Thanks for your reply.

                   

                  In mycase I am able to get the name from the Job.  It is the role created value that I am not getting.  So blcli_execute is working in this

                   

                  Bill, you have any inputs.... please

                   

                  -Narahari

                  • 6. Re: getRoleCreated/getUserCreated returns empty value
                    Bill Robinson

                    can you show me an example of this loop problem because what you say makes no sense.

                    • 7. Re: getRoleCreated/getUserCreated returns empty value
                      Bill Robinson

                      it looks like a problem w/ the getRoleCreated and getUserCreated.  they don't seem to return anything.   and getting the ROLE_CREATED or USER_CREATED fails to return anything as well.

                       

                      what do you need this info for ?

                      • 8. Re: getRoleCreated/getUserCreated returns empty value
                        Narahari Lakshminarayana

                        Now that you asked why I need it, I started thinking and all I need is getName to work, which it does, so I am good.

                         

                        Moreover those props ROLE_CREATED, USER_CREATED are read-only.

                         

                        -Narahari

                        • 9. Re: getRoleCreated/getUserCreated returns empty value
                          Bill Robinson

                          yes - they are read only but they should return something right ??

                          • 10. Re: Re: getRoleCreated/getUserCreated returns empty value
                            Santhosh Kurimilla

                            Bill,


                            Unfortunately, I don't have the old logs and I am unable to reproduce it for now.

                            But, I had the issue where FRES parameter was either showing the same value (received from the first iteration result) or a null value. It was fixed after I changed to simple blcli and FRES=" " in the function.

                             

                            When I used just blcli:

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:23> rlkp=ASIXXXXXAP30.asia.xxxxx.com.

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:25> [ ASIXXXXXAP30.asia.xxxxxx.com. '=' NXDOMAIN ']'

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:29> fname=+validate_srvr:1> echo ASIXXXXXAP30.asia.xxxxx.com

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:29> fname=ASIXXXXXAP30.asia.xxxxx.com

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:30> [ ASIXXXXXAP30.asia.xxxxx.com '=' ASIXXXXXAP30.asia.xxxxx.com ']'

                            Error Feb 11, 2015 8:57:28 PM +validate_srvr:41> FRES=+validate_srvr:1> blcli Server serverExists ASIXXXXXAP30.asia.xxxxx.com

                            Error Feb 11, 2015 8:57:36 PM +validate_srvr:41> FRES=true

                            Error Feb 11, 2015 8:57:36 PM +validate_srvr:42> [ true '=' true ']'

                            Error Feb 11, 2015 8:57:36 PM +validate_srvr:44> fenroll=ASIXXXXXAP30.asia.xxxxx.com

                            Error Feb 11, 2015 8:57:36 PM +validate_srvr:45> echo 'Valid entry already exists with ASIXXXXXAP30.asia.xxxxx.com'

                             

                            Using blcli_execute:

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:26> rlkp=ASIXXXXXAP30.asia.XXXXX.com.

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:28> [ ASIXXXXXAP30.asia.XXXXX.com. '=' NXDOMAIN ']'

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:32> fname=+validate_srvr:1> echo ASIXXXXXAP30.asia.XXXXX.com

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:32> fname=ASIXXXXXAP30.asia.XXXXX.com

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:33> [ ASIXXXXXAP30.asia.XXXXX.com '=' ASIXXXXXAP30.asia.XXXXX.com ']'

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:45> blcli_execute Server serverExists ASIXXXXXAP30.asia.XXXXX.com

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:46> blcli_storeenv FRES

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:47> [ true '=' true ']'

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:49> fenroll=ASIXXXXXAP30.asia.XXXXX.com

                            Error Feb 27, 2015 10:45:43 AM +validate_srvr:50> echo 'Valid entry already exists with ASIXXXXXAP30.asia.XXXXX.com'

                             

                            Code snippet:

                                 #FRES=$(blcli Server serverExists "${fname}")

                                 blcli_execute Server serverExists "${fname}"

                                 blcli_storeenv FRES

                                 if [ $FRES = "true" ]

                                 then

                                  fenroll=${fname}

                                  echo "Valid entry already exists with ${fenroll}"

                                 else

                                  echo "Please start using ${fname}"

                                 fi

                             

                            Anyway, sorry if it was a misguidance.