VMware Cloud Community
msaxbury
Enthusiast
Enthusiast
Jump to solution

Dynamic vRO action Dropdown is not populating on machine blueprint, error "type cannot be null"

1. I have a basic machine blueprint (win2016 vsphere machine type) defined in my catalog.

2. I have created a custom vRO action that consists of the following javascript code:

var roles = new Array();

roles = System.getModule("com.vmware.o11n.plugin.chef.helpers").getRunlistCandidates(host);

System.log(host);

System.log(roles);

return roles;

It is calling an action supplied by the chef plugin and passing in the chef host, and returns a string array of chef roles, cookbook recipes.

3. I have created a new property definition named roles, defined it as type string, required, drop down, with external values, pointing it to the action, and populating the host value:

pastedImage_8.png

When I click select to choose the Script action, a new window pops up and I get the vRO tree populated showing my custom action and the chef plugin helper action successfully. I can choose either or and populate the value of the host without issue.

4. When I request the blueprint, I get the following error once the fields on the request form complete loading:

Unable to start action 'com.caresource.devopstransformation/getRunListCall'. Reason 'Action 'getRunListCall' in module 'com.caresource.devopstransformation' failed : type Cannot be null".

pastedImage_9.png

The drop down is empty. All other fields on the request are active and populate successfully.

Troubleshooting:

I can put the very same action in a vRO workflow and when I run it, I choose the host value based on the chef plugin and it completes successfully, printing out the host and the chef roles/run lists/cookbook/recipes in the log.

I can put the chef action my custom action is calling in a workflow and execute it successfully without issue.

I can point the property definition to the chef action, set the host to be the same, and it fails during the request with the same error.

Unable to start action 'com.vmware.o11n.plugin.chef.helpers/getRunlistCandidates'. Reason 'Action 'getRunlistCandidates' in module 'com.vmware.o11n.plugin.chef.helpers' failed : type Cannot be null'.

I can create a XaaS blueprint that executes the workflow that calls both of these actions and it completes fine without any errors.

Reply
0 Kudos
1 Solution

Accepted Solutions
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

Rebooted the vRA instance.

Chef default workflows are working. A workflow that passes in an input param of 'host' set to type 'CHEF:ChefHost'  successfully returns chef roles when calling the 'com.vmware.o11n.plugin.chef.helpers' chef action named 'getRunlistCandidates'.

If I print out the type of host "System.log(typeof host); it returns 'function' as the object.

I used host.toSource() to debug the function that was being passed into the chef workflows.

I then copied and modified the default 'com.vmware.o11n.plugin.chef.helpers' chef action named 'getRunlistCandidates' to build the object manually using the values from toSource(). I actually pass in the string name of the Chef host, from the property definition, and compare it to what is returned from CHEF:ChefHostManager.getChefHosts() to make sure I get the right one, as there could be multiple hosts configured.

pastedImage_4.png

Build the new object to pass to the original action code:

pastedImage_5.png

The original code of the action receives the new function and calls roles and cookbooks successfully returning candidates:

pastedImage_3.png

View solution in original post

Reply
0 Kudos
17 Replies
daphnissov
Immortal
Immortal
Jump to solution

Show a screenshot of this action, please. More than likely, you have not set the output type away from the default of null. vRA only accepts certain vRO types to be used in custom property actions.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

Both return type of Array/string, and my property definition is set to type of string from the previous screen capture.

My custom action:

pastedImage_0.png

The Chef action ( com.vmware.o11n.plugin.chef.helpers/getRunl8istCandidates ) it is calling:

pastedImage_1.png

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Seems right. Have you tried to simply remove the custom property definition from your blueprint and re-add it? Also, do you have any of the vRA 7.5 hot fixes applied?

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

Yes, i have deleted the property definition several times and recreated it.

Version: 7.5.0 (Build: 10053500) and up to date on all patches.

We have other existing properties tied to actions that are working successfully.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

here is the error from chrome dev tools:

[E] Unable to refresh request form from the server

Unable to start action 'com.vmware.o11n.plugin.chef.helpers/getRunlistCandidates'. Reason 'Action 'getRunlistCandidates' in module 'com.vmware.o11n.plugin.chef.helpers' failed : type Cannot be null'.

Error: {"errors":[{"code":84020,"source":null,"message":"Unable to start action 'com.vmware.o11n.plugin.chef.helpers/getRunlistCandidates'. Reason 'Action 'getRunlistCandidates' in module 'com.vmware.o11n.plugin.chef.helpers' failed : type Cannot be null'.","systemMessage":"84020-Unable to start action 'com.vmware.o11n.plugin.chef.helpers/getRunlistCandidates'. Reason 'Action 'getRunlistCandidates' in module 'com.vmware.o11n.plugin.chef.helpers' failed : type Cannot be null'.","moreInfoUrl":null}]}

    at https://labcloudcafe.lab.corp/vcac/gadgets/proxy/container=shell-default&refresh=-1&gadget=https%253...

    at processResponse (https://labcloudcafe.lab.corp/vcac/gadgets/js/core:rpc.js?container=shell-default&nocache=0&debug=0&...)

    at XMLHttpRequest.<anonymous> (https://labcloudcafe.lab.corp/vcac/gadgets/js/core:rpc.js?container=shell-default&nocache=0&debug=0&...)

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Try one thing:  Copy all the JS out of the Action you have there, and create a new one and set the return type immediately. Paste in the code. Configure this property definition to use that Action. Does it help? I've seen something weird in the past where the DB seemingly doesn't get updated with certain Action attributes and never figured out how/why.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

vRO - Created a new action, set return type to array, saved the action.

          Opened, pasted code, created input param, saved.

vRA - Deleted property definition, created new property def, but the new action did not show up.

vRO - Synchronized with default settings.

vRA - Created property, new action does not show up in select script action inventory.

          Deleted old property off the blueprint, logged out, logged back in.

          Created new property, script action list does not contain the new action.

This has happened before, not sure if there is a delay or sync process like there is with vSphere?

vRA - Tried from incognito tab, still not there, after 15mins

vRO - Verified signature, refreshed

vRA - Killed browser, tried again, set display order to zero, select script action window shows loading for 30 seconds, still no new action displays.

          Tried to just attach it to the actual chef action instead of my custom action, which is in the inventory, same error incognito window.

          Tried from non incognito window, same error.

          Deleted property from non incognito window, created new one, script action loading half a minute...

NO NEW ACTION LISTED!

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Yeah, there's a cache timeout that has to occur before it'll actively poll vRO for the eligible actions. As an alternative (although it may not be possible), you can cycle the vRO app service to force it. That'll obviously make vRO unavailable for a few minutes but it tends to work if in a hurry.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

I must have hit the cycle just right yesterday because it showed up after a refresh.....I don't have access to the appliance host to restart. i will let you know how it goes.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

same error creating new action setting the input type to "Array type of String"

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

The input parameter on the vRO action is of type CHEF:ChefHost:

pastedImage_0.png

If I change that to string, I don't the error in vRA, but the dropdown does not populate.

I don't see a type setting on the vRA side for the input, so I presume it is just passing string to vRO? I presume I need to translate a string into CHEFChefHost object?

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Ok, so this is what I was asking earlier (not the output). Is this action one that is being directly bound to a custom property, or is this one getting *called* by another action?

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

The Chef com.vmware.o11n.plugin.chef.helpers/getRunlistCandidates action requires a host input param that is of type CHEF:ChefHost:

pastedImage_0.png

You can see the print out of the host value and the type is 'function' if I call that action directly from a workflow:

pastedImage_1.png

It does not seem to like the internal calls to the getRoles and getCookbooks actions passing in the value of 'host' as type 'function'.

Both of those actions also have input 'host' as the same type CHEF:ChefHost. I will have to troubleshoot this later, as it was working successfully before and returning roles.

If I change the input param on my custom action, which calls the getRunlistCandidates action, making 'host' input a string, I don't get the error I originally reported in vRA, but the dropdown list is empty.

pastedImage_16.png

I print out the value of 'CHEFChefHostManager.getChefHosts()' method which is the same as the chef action. However, the type is 'object' vs 'function', and I also get errors related to the other action calls, which is why roles are not being returned:

pastedImage_15.png

The 'CHEFChefHostManager.getChefHosts()' method returns an array of CHEFChefHost:

pastedImage_8.png

CHEFChefHost is a rest api that takes several strings, including the chef 'hostname' which was passed in, and it contains an 'executeGet' method:

pastedImage_17.png

So....I am not sure why those other actions are failing on the passed in 'host' value.

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Ok, I had another look at your screenshots and should have mentioned this earlier. You have a single Action which takes a single input parameter called "host". That Action in turns calls another Action (the one provided by the OOTB Chef plugin) which consumes that parameter. The problem is, even though you map this Action in vRA correctly, the input parameter is of type CHEF:ChefHost which vRA cannot supply. So you're going to have to go about this in one of a couple different ways:

  1. In your parent Action, hard-code the Chef server using the object it expects.
  2. More likely:  Write or find an Action that returns all the Chef hosts configured in vRO as a format of type String. This would be mapped to one custom property.
    1. Bind the value of this custom property in your form as the input to your existing Action.
    2. You will have to have code that converts the type String to the expected type of CHEF:ChefHost. There may be an OOTB Action that does this.
    3. String gets converted to the proper type, and the return type is already set pushing values into the drop-down in your form.

For details on #2 and binding in particular, you may want to have a read of my tutorial here.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

I don't know how #1 could be accomplished, as javascript is a dynamic scripting language based on the value of the var?

I did already try #2 before you mentioned it, there is only 1 host right now, the one I need:

var getChefHosts = CHEFChefHostManager.getChefHosts();

It returns the type I need and the value I need:

pastedImage_0.png

Looks like 'getChefHosts.hostname' is a string:

pastedImage_1.png

However, if I pass just 'getChefHosts' to the chef action, it fails when it uses that value on a call to chef to get roles and cookbooks:

pastedImage_2.png

If I pass 'getChefHost.hostname' I get an error that hostname is property on the object. I have tried just name, displayname, nothing seems to work.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

Something is wrong with my chef plugin, i need to re-install and will test again.

Reply
0 Kudos
msaxbury
Enthusiast
Enthusiast
Jump to solution

daphnissov

Rebooted the vRA instance.

Chef default workflows are working. A workflow that passes in an input param of 'host' set to type 'CHEF:ChefHost'  successfully returns chef roles when calling the 'com.vmware.o11n.plugin.chef.helpers' chef action named 'getRunlistCandidates'.

If I print out the type of host "System.log(typeof host); it returns 'function' as the object.

I used host.toSource() to debug the function that was being passed into the chef workflows.

I then copied and modified the default 'com.vmware.o11n.plugin.chef.helpers' chef action named 'getRunlistCandidates' to build the object manually using the values from toSource(). I actually pass in the string name of the Chef host, from the property definition, and compare it to what is returned from CHEF:ChefHostManager.getChefHosts() to make sure I get the right one, as there could be multiple hosts configured.

pastedImage_4.png

Build the new object to pass to the original action code:

pastedImage_5.png

The original code of the action receives the new function and calls roles and cookbooks successfully returning candidates:

pastedImage_3.png

Reply
0 Kudos