VMware Cloud Community
romninja
Contributor
Contributor
Jump to solution

vRO java plugin error

We are creating a vRealize Orchestrator plugin for Storage automation.

Our plugin is based on the Model-driven archetype and vRO SDK 7.x. In our Model, we have defined objects like Volume and VolumeOpResult. Volume has a Finder defined while VolumeOpResult does not have a finder. In essence Volume is a Type, while VolumeOpResult is just a Scripting class. The VolumeOpResult has a property which returns a Volume.

We have a workflow GetVolume, which makes a call to the plugin method which returns a VolumeOpResult. We get the Volume object from the property of the VolumeOpResult and when we try to output the sane Volume object as an out param in the workflow we are getting the following error:

[2017-04-20 14:27:21.275] [E] Workflow:GetVolume / Scriptable task (item1) : ch.dunes.model.type.ConvertorException: Unable to convert object, 'Volume_Wrapper[_target=com.storage.model.Volume@47842112]' plugin exception reason : convertToResult() --> Finder 'Storage:Volume' : unexpected error 'ch.dunes.model.sdk.SDKFinderException: convertToResult() --> Finder 'Storage:Volume' id 'getInternalId()' is null for the Finder object 'Volume_Wrapper[_target=com.storage.model.Volume@47842112]''

[2017-04-20 14:27:21.307] [E] Workfow execution stack:

***

item: 'GetVolume/item1', state: 'failed', business state: 'null', exception: 'Unable to convert object, 'Volume_Wrapper[_target=com.storage.model.Volume@47842112]' plugin exception reason : convertToResult() --> Finder 'Storage:Volume' : unexpected error 'ch.dunes.model.sdk.SDKFinderException: convertToResult() --> Finder 'Storage:Volume' id 'getInternalId()' is null for the Finder object 'Volume_Wrapper[_target=com.storage.model.Volume@47842112]'''

workflow: 'compo' (ecd93d26-180b-482b-9abf-6b1365e3a2b0)

|  'attribute': name=vol type=Storage:Volume value=null

|  'input': name=volName type=string value=NP.7

|  'input': name=connection type=Storage:Connection value=dunes://service.dunes.ch/CustomSDKObject?id='gQcDdjyISAiDNKY3r6anFw'&dunesName='Storage:Connection'

|  'no outputs'

--workflow: 'GetVolume' (9bafe882-ce1d-41ae-80ed-465620bd8718)

  |  'attribute': name=vol type=Storage:Volume value=__NULL__

  |  'input': name=volName type=string value=NP.7

  |  'input': name=connection type=Storage:Connection value=dunes://service.dunes.ch/CustomSDKObject?id='gQcDdjyISAiDNKY3r6anFw'&dunesName='Storage:Connection'

  |  'output': name=outVol type=Storage:Volume value=null

*** End of execution stack.

Any suggestions on how to resolve the above error. Thank you in advance.

1 Solution

Accepted Solutions
islavov
VMware Employee
VMware Employee
Jump to solution

To return an object from scripting method this object should be linked to context, especially the framework should know the root id to 'automagically' (as you said) wrap the result. In case of a Singleton you don't have any context, this result object could been produced by every vCenter connection (in case your root objects are vCenter connections). In this case you should provide this information in your method's code. If the result object was 'Volume' then you could do this by using  code like this :

    @Autowired

    public ObjectFactory objectFactory;

    public  FoundObject convertToFoundObject(Sid rootId, Class<T> desiredType, T mo) {

        Sid id = objectFactory.assignId(desiredType, mo, rootId);

        return new FoundObject(mo, id);

    }

But in your case this unfortunately, you can't do this, because FoundObject is only provided by using it with findable objects . My recommendations is to change the method's return type to avoid using VolumeOpResult if possible.

View solution in original post

0 Kudos
6 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

This error means he code cannot fetch the ID from your Storage:Volume object instance. Probably property of VolumeOpResult that is supposed to return Volume object returns null, or maybe there is an error in your ID accessor that either returns null or throws an exception.

I'd suggest as a first step to add some more log statements in your workflows to track what is the content of the actual object values (Volume, VolumeOpResult, etc) and also check what you ID accessor - getInternalId() - does.

BTW, is your plug-in and workflows available somewhere to take a look?

0 Kudos
islavov
VMware Employee
VMware Employee
Jump to solution

Hi,

This method from which you are returning the VolumeOpResult instance - is it a custom method you have written? If this is the case, you have to :

- (1) Declare VolumeOpResult as type capable of propagating rootId. You can do this by using WrapDescriptor::propagateRootId method in your mapping class (the class extending AbstractMapping with all your wrapper descriptors and finders)

- (2) Additionally you may need to wrap the result object in the method you have written .

Which Type is this method you have written part of? If it is a method of a singleton then you should  definitely do step (2)

0 Kudos
romninja
Contributor
Contributor
Jump to solution

Yes, it is a method of a singleton. As you rightly said, I probably need to wrap the object, but how do I do that?

Should'nt the SDK do it automagically?

0 Kudos
islavov
VMware Employee
VMware Employee
Jump to solution

To return an object from scripting method this object should be linked to context, especially the framework should know the root id to 'automagically' (as you said) wrap the result. In case of a Singleton you don't have any context, this result object could been produced by every vCenter connection (in case your root objects are vCenter connections). In this case you should provide this information in your method's code. If the result object was 'Volume' then you could do this by using  code like this :

    @Autowired

    public ObjectFactory objectFactory;

    public  FoundObject convertToFoundObject(Sid rootId, Class<T> desiredType, T mo) {

        Sid id = objectFactory.assignId(desiredType, mo, rootId);

        return new FoundObject(mo, id);

    }

But in your case this unfortunately, you can't do this, because FoundObject is only provided by using it with findable objects . My recommendations is to change the method's return type to avoid using VolumeOpResult if possible.

0 Kudos
romninja
Contributor
Contributor
Jump to solution

Hi Islavov, thanks for your reply.

So from your post what I understand is, whatever I return from scripting object has to be Findable or a primitive and anything else wont work?

0 Kudos
islavov
VMware Employee
VMware Employee
Jump to solution

Actually this restriction applies only to methods of singletons. Other methods don't have this problem - methods of findable objects and methods of other objects produced by findables, have a basic context (actually this is rootId) propagated from the object on which the method was invoked - so these methods can return findables, primitives or objects of other types. But singletons's methods  should provide this context by their owns. For findable return values this is done by using FoundObject wrapper. But for other types , such wrapper is not provided - this is sometimes needed, but just is not implemented

0 Kudos