6 Replies Latest reply on Nov 27, 2019 7:53 AM by Martin Ponce

    A quicker way to set component variables

    Martin Ponce
      Share This:

      Hi guys,

       

      here I go again with an NSH scripting doubt!!

       

      I´m using an NSH scripts to import the Oracle instances, runing in servers (already handled by TSA) into Components in TSA.

      I had to set 4 instances variables with useful information about the instances.

       

       

      To set these variables, I have this part in a integration NSH Script :

       

      The problem with this 4 commands is it takes a long time to set each variable.

       

      So the question is : is there any command to set variables quicker for a Component?

       

      I was looking into the commands documented for Component command and I did not find anything else, besides the above command used.

       

      Any help, or guidance will be really apreciated!

      Thanks in advance.

      Martin

        • 1. Re: A quicker way to set component variables
          Bill Robinson

          use blcli_execute and not blcli.

           

          blcli_execute Component setPropertyValue xx yy zz

           

          and don't do FOO=`blcli xxx`

           

          what you are doing now is spinning up a jvm for each blcli call and it's terribly slow, hence the 'performance commands' - blcli_execute.

          • 2. Re: A quicker way to set component variables
            Martin Ponce

            Hi Bill,

             

            thanks for your response.

            Ok to use the blcli_execute.

             

            If I want to use blcli_execute in the AppServer, do I need to aquire the credentials?

            I´m running the script as BLAdmin.

            • 3. Re: A quicker way to set component variables
              Bill Robinson

              if you are running this in a nsh script job, you don't need to get creds, specific a role, or authentication profile.

              • 4. Re: A quicker way to set component variables
                Martin Ponce

                Bill,

                This way is many times quicker than I used. Thank you.

                But now I get some errors in execution time. Just a part of the script :

                 

                echo --------------

                echo Obteniendo la lista de todos las instancias ORACLE desde BL...

                DBKEY=`blcli_execute Template getDBKeyByGroupAndName "/TEST" "DB Oracle v.002"`

                COMPONENT_KEYS=`blcli_execute Component getAllComponentKeysByTemplateKey $DBKEY`

                while read COMPONENT_KEY

                do

                CNAME=`blcli_execute Component componentKeyToName "${COMPONENT_KEY}"`

                echo "${CNAME}" >>$DIR/listado_DDBB_ORACLE_BL.csv

                done <<< "$(awk 'NF' <<< "${COMPONENT_KEYS}")"

                echo --------------

                 

                I got this error when I run it:

                 

                Info 27/11/2019 09:10:43 --------------

                Info 27/11/2019 09:10:43 Obteniendo la lista de todos las instancias ORACLE desde BL...

                Error 27/11/2019 09:10:44 Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'Component.getAllComponentKeysByTemplateKey' but with mismatching arguments.

                Error 27/11/2019 09:10:45 Command execution failed. com.bladelogic.om.infra.cli.factory.CommandNotFoundException: Found command 'Component.componentKeyToName' but with mismatching arguments.

                Info 27/11/2019 09:10:45 --------------

                 

                and the file : $DIR/listado_DDBB_ORACLE_BL.csv is empty.

                And if I run this commands in an NSH cli works fine:

                 

                SERV1% blcli_execute Component componentKeyToName "DBKey:SComponentModelKeyImpl:2077069-6-3412726"

                RIO261

                SERV1% blcli_execute Server getServerIdByName "ARPOABP01"

                 

                I´m not sure why is happening this. using blcli instead of blcli_execute it worked.

                • 5. Re: A quicker way to set component variables
                  Bill Robinson

                  right - you need to stop doing VAR=`blcli_execute xxx` entirely.  it should be:

                  blcli_execute xxx

                  blcli_storeenv VAR

                   

                  blcli_execute Template getDBKeyByGroupAndName "/TEST" "DB Oracle v.002"

                  blcli_storeenv DBKEY

                  blcli_execute Component getAllComponentKeysByTemplateKey ${DBKEY}

                  blcli_storeenv COMPONENT_KEYS

                  while read COMPONENT_KEY

                       do

                        echo "${COMPONENT_KEY}"

                       blcli_execute Component componentKeyToName ${COMPONENT_KEY}

                       blcli_storeenv CNAME

                       echo "${CNAME}" >>$DIR/listado_DDBB_ORACLE_BL.csv

                  done <<< "$(awk 'NF' <<< "${COMPONENT_KEYS}")"

                   

                  what does the above show ?  do you see it echo out each component key ?

                  • 6. Re: A quicker way to set component variables
                    Martin Ponce

                    I changed all the blcli to blcli_execute and used blcli_storeenv.

                     

                    Excellent response time for the script. Solved the problem.

                     

                    thank you a lot Bill!

                    Martin