10 Replies Latest reply on Nov 25, 2014 1:14 PM by richard mcleod

    Components per Server

    Steffen Kreis

      Hi,

       

      can somebody point me to the correct portion of blcli, that lets me find all components attached to a certain server ?

       

      Cheers

      Steffen

        • 1. Re: Components per Server

          Hi Steffen,

           

          You Can Use: Component : getAllComponentKeysByTemplateKeyAndServerId command.

          this command requires two input parameters.

           

          1. templateKey : Handle of the component template for which you want to obtain component handles.

          (for this value use getDBKeyByGroupAndName command )

           

          2. deviceId: ID of the server for which you want to obtain component handles.

          (for this value use getServerIdByName command)

           

           

           

          Component : getAllComponentKeysByTemplateKeyAndServerId command returns,a list of handles to all components that are based on a specified component template and server.

          Each component is always associated with one template and one server. Multiple components based on the same template can be associated with the same server.

          (Ref. BLCLI Help.)

           

           

          Regards,

          CLMTeam@Vyomlabs

          • 2. Re: Components per Server
            Steffen Kreis

            Hi,

             

            yeah i saw that one already.

            But i need that bit without the reference to the TemplateKey.

             

            By only looking at the server , i don't want to specify any template, but want to list all components attached to a server object across all existing Templates.

             

            So the result should be the same, as when you click "Components" on the Live-Browse view of a server.

             

            Regards

            Steffen

            • 3. Re: Components per Server

              Not really sure you will be able to get a direct blcli to do this.

               

              You can do this way:

               

              Get all templates in a template folder ( use a smart group to get all)

              for each template,

              get template key

              and getAllComponentKeysByTemplateKeyAndServerId

              • 4. Re: Components per Server
                Bill Robinson

                Look at ‘Component findAllLatestByDevice’ and pass in the server dbkey.

                • 5. Re: Components per Server
                  richard mcleod

                  Did you ever get anywhere with this? I'm stuck at this same point... I now have a list of components? how do I get any usable data out of them.

                   

                  blcli_execute Server getServerDBKeyByName "${server}"

                  blcli_storeenv sDBKey

                  blcli_execute Utility storeTargetObject s1DBKey

                  blcli_execute Utility setTargetObject $s1DBKey

                  blcli_execute Server getDeviceId

                  blcli_storeenv sDI

                  blcli_execute Component findAllLatestByDevice "${sDI}"

                  blcli_storeenv cIds

                   

                  cIds=[com.bladelogic.om.infra.model.component.ComponentImpl@6fea9f5b, com.bladelogic.om.infra.model.component.ComponentImpl@59cece51, com.bladelogic.om.infra.model.component.ComponentImpl@cb0955df]

                   

                  I use sed to get rid of the following chars [], from the list but what can I do with these values? I try to blcli_execute Utility setTargetObject but just receive an error about there being no named object. So I try blcli_execute Utility setInputAsTargetObject but receive an error about the input not being an expected type of java.lang.object.

                   

                  maybe its monday and im crazy but can we use list of data to get data from the component namespace? (get name, set permissions, delete, etc???)

                  • 6. Re: Components per Server
                    Bill Robinson

                    those are the component objects themselves.  what are you trying to get?  the db keys?  the ids ?  what are you trying to do w/ the list ?

                    • 7. Re: Components per Server
                      richard mcleod

                      get the dbkeys so I can apply an acl and grab the name for output

                      • 8. Re: Components per Server
                        Bill Robinson

                        blcli_execute Server getServerDBKeyByName "${server}"

                        blcli_storeenv sDBKey

                        blcli_execute Utility storeTargetObject s1DBKey

                        blcli_execute Utility setTargetObject $s1DBKey

                        blcli_execute Server getDeviceId

                        blcli_storeenv sDI

                        blcli_execute Component findAllLatestByDevice "${sDI}"

                        blcli_execute Component getDBKey

                        blcli_execute Utility  setTargetObject

                        blcli_execute Utility listPrint

                        blcli_storeenv componentKeys

                         

                        for componentKey in ${componentKeys}

                        do

                        xxx

                        don

                        • 9. Re: Components per Server
                          richard mcleod

                          bah i hate when it turns out to be so simple. thanks. will give a try after meeting

                          • 10. Re: Components per Server
                            richard mcleod

                            what a beaut!

                             

                            #script to add an acl policy to each component for a specified server

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

                             

                             

                            while getopts ":h:n:" opt;

                            do

                              case $opt in

                              h)

                              server="$OPTARG"

                              ;;

                              n)

                              policyName="$OPTARG"

                              ;;

                              \?)

                              echo "Incorrect options found!" >&2

                              exit 1

                              ;;

                             

                              echo "Option -$OPTARG requires an argument" >&2

                              exit 1

                              ;;

                              esac

                            done

                             

                            blcli_execute Server getServerDBKeyByName "${server}"

                            blcli_storeenv sDBKey

                            blcli_execute Utility storeTargetObject s1DBKey

                            blcli_execute Utility setTargetObject $s1DBKey

                            blcli_execute Server getDeviceId

                            blcli_storeenv sDI

                            blcli_execute Component findAllLatestByDevice "${sDI}"

                            blcli_execute Component getDBKey

                            blcli_execute Utility setTargetObject

                            blcli_execute Utility listPrint

                            blcli_storeenv cKeys

                             

                            for cKey in ${cKeys}

                            do

                             

                              blcli_execute Component componentIdToName "${cKey}"

                              blcli_storeenv cName

                              echo "Applying ACL Policy: $policyName on >> $cName <<"

                              blcli_execute Component applyAclPolicy "$cKey" "$policyName"

                              blcli_storeenv result

                             

                            done

                             

                             

                            #run like this
                            #whatever.nsh -h hostname -n AclPolicyName