1 2 3 Previous Next 31 Replies Latest reply on Nov 20, 2014 4:06 PM by Bill Robinson

    Bulk Server Properties Update

      Dear All,

       

              I want to update a single server property on many servers. Someone can help me out how to do this in bladelogic. Below is my actual script:

       

      OBP=`nexec <server_ip> prtdiag -v|grep OBP|awk '{print $2 $6}'`

      blcli -v BLAdmin Server setPropertyValueByName <server_ip> SOLARIS_OBP_VERSION $OBP

       

      instead of directly hardcoding the server_ip every time, i want to pass the list of the servers from my excel sheet/notepad/flat file. Someone please help me out to resolve this issue. If possible kindly update me with the script.

       

      Regards,

      Raghava

        • 1. Bulk Server Properties Update
          Bill Robinson

          if you have the name in your spreadsheet, and that is the name registered in bladelogic, then you can use the script above w/ a parameterized server name instead of the ip and a for or while loop.

           

          if that's not fast enough, you can build csv file for use w/ the bulkSetServerProperty blcli command (i think that is the name, look in the blcli reference).

           

          how are you going to execute this script to get the opb parameter you want?  via a job in bladelogic or from the commandline ?

          • 2. Bulk Server Properties Update

            Hi Bill,

             

                 Thanks for your update. I want to use this through Bladelogic commandline. Suggest me the best way to execution mode either job/command line.

             

            Could you explain more eloborate. How can I embed the bulkSetServerPropertyValues  property in below script.

            Could you modify and update me please.

             

            OBP=`nexec <server_ip> prtdiag -v|grep OBP|awk '{print $2 $6}'`

            blcli -v BLAdmin Server setPropertyValueByName <server_ip> SOLARIS_OBP_VERSION $OBP

            Server bulkSetServerPropertyValues /c/tmp server_list.csv

             

            Regards,

            Raghava

            • 3. Bulk Server Properties Update

              Hi Raghava,

               

              You can simply use the command:

               

              Server bulkSetServerPropertyValues /c/tmp server_list.csv

               

              This command will set all of the server properties you specify in your server_list.csv file. The contents of the file should look like this:

               

              server_name,property_name,property_value

               

              So if you wanted to set the property called: "location" for a server named: "server1.domain.com"  to the value: "Dallas"   you would use a line like this.....

               

              server1.domain.com,location,Dallas

               

              You can just copy and paste it and change the server name for each that you want to set the property.

               

              I hope that is clear.

              • 4. Bulk Server Properties Update
                Bill Robinson

                first run this to authenticate:

                blcred cred -acquire -profile <profile name> -username <user>

                 

                Then put this is a script and run it - obviously you need to put in the profile name and role name you want to use.

                 

                #!/bin/nsh

                blcli_setoption serviceProfileName <profile name>

                blcli_setoption roleName <role>

                blcli_connect

                 

                blcli_execute Server listAllServers

                blcli_storeenv serverList

                 

                for server in ${serverList}

                do

                     if [ `nexec ${server} uname -s` = 'SunOS` ]

                          then

                          OBP="`nexec ${server} prtdiag -v|grep OBP|awk '{print $2 $6}'`"

                          echo "${server},SOLARIS_OBP_VERSION,${OBP}" >> /tmp/$$.tmp

                     fi

                done

                 

                blcli_execute Server bulkSetServerPropertyValues /tmp/$$.tmp

                 

                rm -f $$.tmp

                1 of 1 people found this helpful
                • 5. Re: Bulk Server Properties Update

                  Dear Robin,

                   

                        Thanks for your reply. I followed as you said and I modified script with proper profile name and role name.

                   

                  Before executing the script I acquired the credentials for the BLAdmin as below:

                   

                  % blcred cred -acquire -profile BLAdmin -username BLAdmin

                  password:

                  Authentication succeeded: acquired session credential

                   

                  I creted script.txt and copied your script and modified profile name and role name as you mentioned.

                   

                  When I execute the script.txt and it gave me the below error. My App server OS is windows, so I'm executing this script from windows command prompt.

                   

                  % pwd

                  /cygdrive/c

                  % ./script.txt

                  Exception in thread "main" com.bladelogic.session.client.SessionLoginException: Could not find role fo

                  r user : BLAdmin

                          at com.bladelogic.cli.CliLoginOperations.selectRoleNonInteractively(CliLoginOperations.java:31

                  0)

                          at com.bladelogic.cli.CliLoginOperations.selectRoleInteractively(CliLoginOperations.java:222)

                          at com.bladelogic.cli.CliLoginOperations.selectRole(CliLoginOperations.java:138)

                          at com.bladelogic.session.client.SessionLoginManager.selectRole(SessionLoginManager.java:264)

                          at com.bladelogic.session.client.SessionLoginManager.login(SessionLoginManager.java:113)

                          at com.bladelogic.cli.CLIMain.loginToAppServer(CLIMain.java:669)

                  Exception in thread "main" com.bladelogic.session.client.SessionLoginException: Could not find role fo

                  r user : BLAdmin

                          at com.bladelogic.cli.CliLoginOperations.selectRoleNonInteractively(CliLoginOperations.java:31

                  0)

                          at com.bladelogic.cli.CliLoginOperations.selectRoleInteractively(CliLoginOperations.java:222)

                          at com.bladelogic.cli.CliLoginOperations.selectRole(CliLoginOperations.java:138)

                          at com.bladelogic.session.client.SessionLoginManager.selectRole(SessionLoginManager.java:264)

                          at com.bladelogic.session.client.SessionLoginManager.login(SessionLoginManager.java:113)

                          at com.bladelogic.cli.CLIMain.loginToAppServer(CLIMain.java:669)

                  No result has been created yet

                  ./script.txt:30: unmatched '

                   

                  line number 30 in script was :

                  blcli_execute Server bulkSetServerPropertyValues /tmp/$$.tmp

                   

                  My App Server OS Version : Windows 2003 Enterprise Edition 64-bit

                  APP Server : 8.0 SP7.

                   

                  Please don't get irritated with my question.

                   

                  Thanks,

                  Raghava

                  • 6. Re: Bulk Server Properties Update
                    Jim Campbell

                    Looks like it maybe got an invalid role name from:

                     

                    blcli_setoption roleName <role>

                    • 7. Re: Bulk Server Properties Update
                      Bill Robinson

                      And there is a problem on line 30 w/ an unmatched single quote…

                      • 8. Re: Bulk Server Properties Update

                        Hi Bill,

                         

                        Should I run the above script in plain NSH command prompt or it should be executed in the jython command prompt.

                         

                        Can you clarify this please, because I executed in NSH command prompt and it throws the above errors.

                         

                        Raghava

                        • 9. Re: Bulk Server Properties Update
                          Bill Robinson

                          it's a nsh script - run it like 'nsh <script> <args>'. 

                          • 10. Re: Bulk Server Properties Update

                            Bill,

                             

                            Can you please help me to complete this:

                             

                            1. I'm not able to execute the script which you posted. I executed the blcred command successfully.

                               So I traced that I'm not able to connect.

                             

                            #blcli_connect

                            com.bladelogic.session.client.SessionLoginException: Could not find role for user : BLAdmin

                                    at com.bladelogic.cli.CliLoginOperations.selectRoleNonInteractively(CliLoginOperations.java:310)

                                    at com.bladelogic.cli.CliLoginOperations.selectRoleInteractively(CliLoginOperations.java:222)

                                    at com.bladelogic.cli.CliLoginOperations.selectRole(CliLoginOperations.java:138)

                                    at com.bladelogic.session.client.SessionLoginManager.selectRole(SessionLoginManager.java:264)

                                    at com.bladelogic.session.client.SessionLoginManager.login(SessionLoginManager.java:113)

                                    at com.bladelogic.cli.CLIMain.loginToAppServer(CLIMain.java:669)

                             

                            2. Where can I pass the list of servers in the script

                             

                            Thanks in advance. Kindly help me.

                             

                            Raghava

                            • 11. Re: Bulk Server Properties Update
                              Bill Robinson

                              what did you put in here:

                              blcli_setoption serviceProfileName <profile name>

                              blcli_setoption roleName <role>

                              blcli_connect

                               

                              did you fill in a profile name and role name ?

                               

                              as far as listing the servers, right now this will run against all servers:

                              blcli_execute Server listAllServers

                              blcli_storeenv serverList

                               

                              you could change that to do something like:

                              serverList=$@

                               

                              and pass the list of servers like:

                               

                              nsh <script> server1 server2 server3 server4 ...

                              • 12. Re: Bulk Server Properties Update

                                Thanks for update. I'm using as below:

                                 

                                #!/bin/nsh

                                blcli_setoption serviceProfileName BLAdmin   -------- (my authentication profile name: BLAdmin)

                                blcli_setoption roleName BLAdmin                   

                                blcli_connect

                                blcli_execute Server listAllServers

                                blcli_storeenv serverList

                                for server in ${serverList}

                                do

                                if [ `nexec ${server} uname -s` = 'SunOS` ]

                                then

                                OBP="`nexec ${server} prtdiag -v|grep OBP|awk '{print $2 $6}'`"

                                echo "${server},SOLARIS_OBP_VERSION,${OBP}" >> /tmp/$$.tmp

                                fi

                                done

                                blcli_execute Server bulkSetServerPropertyValues /tmp/$$.tmp

                                 

                                ----------------------

                                 

                                My App server OS : Windows 2003 Enterprise Edition 64-bit.

                                 

                                If i'm wrong please correct me.

                                • 13. Re: Bulk Server Properties Update
                                  Bill Robinson

                                  Your role name is probably BLAdmins, not BLAdmin.

                                  • 14. Re: Bulk Server Properties Update

                                    Yes.. you are true.... Sorry I'm giving trouble to you.

                                    I checked it and rectified.

                                    I've executed the script, it showed all list of servers in the server group, in the end of output it gave me error like:

                                     

                                    ./script.txt:15: unmatched '

                                     

                                    where as my 15th line of the script is

                                    blcli_execute Server bulkSetServerPropertyValues /tmp/$$.tmp

                                     

                                    does this /tmp/$$.tmp supports in windows?

                                    1 2 3 Previous Next