6 Replies Latest reply on Mar 5, 2013 2:25 AM by alexont

    Deep copy server-group via management API

    alexont Newbie

      Hi all,

       

      I'm trying to create a new server-group by making an exact copy of an existing one and adding it as new.

      The code is like :

       

          ModelControllerClient client = ModelControllerClient.Factory.create("localhost", 9999);
        

              // read the original

              final ModelNode srcAddress = new ModelNode();

              srcAddress.get("server-group").set("main-server-group");

             

              final ModelNode op = new ModelNode();

              op.get("address").set(srcAddress);

              op.get("operation").set("read-resource");

              op.get("recursive").set(true);      

              op.get("include-defaults").set(false);

             


          final ModelNode serverGroup = client.execute(op).get("result");

             

              // add it as new

              final ModelNode dstAddress = new ModelNode();

              dstAddress.get("server-group").set("new-server-group");


          serverGroup.get("address").set(dstAddress);

          serverGroup.get("operation").set("add");
        

              final ModelNode result = client.execute(serverGroup);

       

      But it fails with

       

      "domain-failure-description" => "JBAS014688: Wrong type for jvm. Expected [STRING] but was OBJECT"

       

      Any ideas of how this can be done?

       

      Thanks,

        Alex