5 Replies Latest reply on Feb 17, 2012 9:19 AM by Bill Robinson

    bulkAssignServersToGroup - device keys

    Narjit Najran



      I am trying to use the ServerGroup bulkAssignServersToGroup unreleased command but am getting a 'no matches found' error:


      blcli_execute ServerGroup bulkAssignServersToGroup "DBKey:SBLGroupModelKeyImpl:2048065-5692050" [2069004] false

      nsh: no matches found: [2069004]


      where 2069004 is the integer returned from Server getServerIdByName.


      I have also tried with the DBKey of the server and get the same error


      blcli_execute ServerGroup bulkAssignServersToGroup "DBKey:SBLGroupModelKeyImpl:2048065-5692050" [DBKey:SDeviceModelKeyImpl:2009196-2215093] false

      nsh: no matches found: [DBKey:SDeviceModelKeyImpl:2009196-2215093]


      The server does exist and I have tried with other servers.


      The command expects the following input

      groupDBKey  com.bladelogic.model.base.keys.SBLGroupKey  - the group to which the list of devices is to be assigned. 

      keys  java.util.List  - device keys. 

      existingServerCheck  Boolean


      I'm just not sure what variable type is expected for the device keys... and if it is one of the above then why am I seeing this error?


      Thanks in advance.

        • 1. bulkAssignServersToGroup - device keys
          Bill Robinson

          it expects a java.util.List - and it does not appear you are passing that.  i don't believe putting [] around a string makes it a list type object.

          • 2. bulkAssignServersToGroup - device keys

            An approach I thought might help is:


            1. Use Jython

                 connect to bl

                 define blcli_run method


            2. Jython does support java.util.List

                 import java.util

                 list = java.util.List()


                 blcli_run(jli,["ServerGroup","bulkAssignServersToGroup",groupid, keys, "false"])


            The only problem this approach has is that Jython won't run Java methods which are protected or private.

            So the java.util.List instantiation will return TypeError: No visible constructors for class (java.util.List).

            Only way to resolve this is changing the jython settings:


            # Setting this to false will allow Jython to provide access to
            # non-public fields, methods, and constructors of Java objects.
            .security.respectJavaAccessibility = false


            And that's something we won't be changing on all hosts running the script which uses the bulkAssignServersToGroup command. Does it have to be that tricky isn't there a smarter solution?

            • 3. Re: bulkAssignServersToGroup - device keys
              Bill Robinson

              Also – why not just loop through and add individually?  I don’t think it will be that much slower if you are using the perf commands.

              • 4. bulkAssignServersToGroup - device keys
                Narjit Najran

                When I pass an argument of type java.util.List I get a command found but with mismatching arguments error...


                Firstly I run something that returns a java.util.List


                % blcli_execute Server bulkAddServers /C/tmp TestServers.csv UTF-8 false

                [hostname1, hostname2]


                Then store it in a variable


                % blcli_storeenv server_list

                % echo $server_list

                [hostname1, hostname2]


                And pass it to the bulkAssignServersToGroup command


                % blcli_execute ServerGroup bulkAssignServersToGroup DBKey:SBLGroupModelKeyImpl:2048065-5692050 $server_list false


                which gives


                Command execution failed. com.bladelogic.cli.factory.CommandNotFoundException: Found command 'ServerGroup.bulkAssignServersToGroup' but with mismatching arguments.


                Guess I could try a different approach..

                • 5. bulkAssignServersToGroup - device keys
                  Bill Robinson

                  you are not passing in the server list as an actual java list type.  you're passing it as a string.  there is currently no way to build a list object from scratch in the blcli. 

                  1 of 1 people found this helpful