3 Replies Latest reply on May 24, 2019 7:46 AM by iiliev

    VRO NSX Create Security Tag Problem

    thegrumpyengineer_zz Lurker

      Hi,

       

      I'm trying to get a workflow to generate a create a custom NSX Security group and tag.

       

      There is an inbuilt create group workflow which works fine but nothing for the tag itself.

       

      I have tried to adjust the create group one but having no luck. I was wondering if anyone could help.

       

      Current attempt:

       

      var dummy = new Array(1);

      var securityTagObj = new NSXSecurityTagDto("1", dummy);

       

      securityTagObj.name = "Test";

      securityTagObj.description = "Test description";

      securityTagObj.scope = "Global"

       

      securityTag = NSXSecurityTagController.createV2(connection, securityTagObj);

       

      The error I get returned is:

      Error in workflow xxxx org/apache/commons/beanutil/ConversionException

       

      I assume this is to do with the scope but not too sure where to go (I'm new at this so be kind!)

       

      I could get around this by using an http post query but I'd really rather use the plugin API.

        • 1. Re: VRO NSX Create Security Tag Problem
          eoinbyrne Hot Shot

          Looks like there is a Finder type for the available ScopeInfoDto list

           

           

          So, first check the vRO Inventory view under NSX to make sure some are available then try this to get the scope reference object it looks like you need

           

          var availableScopeDTOs = Server.findAllForType("NSX:ScopeInfoDto");

           

          I've not used the NSX plugin but this is how you can query the vRO server for it's inventory

          • 2. Re: VRO NSX Create Security Tag Problem
            thegrumpyengineer_zz Lurker

            Hiya, Thanks for your speedy response, that makes sense, however the InfoDto request seems to be responding weirdly..

             

            I've added this section to the code to pull the correct scope to pass on;

             

            var scopeDto = new Array();

            var availableScopes = Server.findAllForType(NSX:ScopeInfoDto");

            scopeDto[0] = availableScopes.filter(function(x){return x.name === "Global"});

             

            however I now get a conversion error

             

            'Cannot convert org.mozilla.javascript.NativeArray@xxxx to com.vmware.o11n.plugins.nsx.model.ScopeInfoDto

            • 3. Re: VRO NSX Create Security Tag Problem
              iiliev Champion
              VMware EmployeesCommunity Warriors

              Could you show the full code and also info on which line you are getting this error?

               

              What the error says is that you cannot convert an array of objects to a single ScopeInfoDto object. This can happen if you call a method that has a parameter of type ScopeInfoDto, but you are passing to it the scopeDto variable (which is an array, even when this array has only a single element, so you'll need to pass only a single element of this array, eg. scopeDto[0]).