VMware Cloud Community
emerson132
Enthusiast
Enthusiast
Jump to solution

vRO script actions for vRA

I originally posted this in the vRA forum but it hasn't had any replies, it may be better off in here anyway.

I am trying to create property relationships for vRA using script actions.

Hello All,

I would greatly appreciate some help please. I have created a vRO action that should give a user an option of which storage policy to apply to a VM at request, depending of if it is to be a dual site vm or a single site VM.

I have created a Property Group with 2 property defiinitions

Definition 1 -
AvailabilitySelector
Drop Down Box
PreDefined Values - Single Site / Multi Site

Definition 2 -
VirtualMachine.Disk0.StorageReservationPolicy
Label - Storage Policy
Data Type - String
Display Advice - Dropdown
External Values
Pointed to my vRO Action item

vRO Action Item
// High Avalability to storage selection
if(AvailabilitySelector)
{
switch(AvailabilitySelector) {
  case "Dual Site":
   return ["3PAR FC"]
   break;
  case "Single Site":
   return ["3PAR NL"]
   break;
    };
  }
else {
return ["Please Select availability"];
};

Now when I go to request to catalog item I get an error:

Unable to refresh request form from the server System exception.

I get this error as soon as the request page loads, I can see the dropdown menu for site collector, but the Storage Profile dropdown never populates.

Any help here would be greatly appreciated, I am pretty stuck at the moment.

Thanks

Dean

Reply
0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Hello Dean,

  What is the return type for the action? String? If so, your problem is that you are returning a single element Array of strings because you are enclosing your strings in square brackets - which is an Array in JS Smiley Wink Additionally, your vRA provides pre defined values "Single Site" and "Multi Site", but your vRO Action is testing for "Single Site" and "Dual Site".

It seems that you are dealing with strings so returning the wrong object type could result in the behavior you are seeing. So, update your action to:

// High Avalability to storage selection

if(AvailabilitySelector)

{

switch(AvailabilitySelector) {

  case "Multi Site":

  return "3PAR FC"

  break;

  case "Single Site":

  return "3PAR NL"

  break;

    };

  }

else {

return "Please Select availability";

};

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

Reply
0 Kudos
3 Replies
Burke-
VMware Employee
VMware Employee
Jump to solution

Hello Dean,

  What is the return type for the action? String? If so, your problem is that you are returning a single element Array of strings because you are enclosing your strings in square brackets - which is an Array in JS Smiley Wink Additionally, your vRA provides pre defined values "Single Site" and "Multi Site", but your vRO Action is testing for "Single Site" and "Dual Site".

It seems that you are dealing with strings so returning the wrong object type could result in the behavior you are seeing. So, update your action to:

// High Avalability to storage selection

if(AvailabilitySelector)

{

switch(AvailabilitySelector) {

  case "Multi Site":

  return "3PAR FC"

  break;

  case "Single Site":

  return "3PAR NL"

  break;

    };

  }

else {

return "Please Select availability";

};

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
Reply
0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Dean,

The predefined values for your first field are Single Site / Multi Site, but in your action your switch statements checks for Dual Site and Single Site.

This means that if the action is called with Multi Site argument, there will be no matching case statement, hence no return will be reached, and the action will return undefined value.

The fix is to add one more case "Multi Site": statement, or a default: statement to handle all unexpected input values.

BTW, you don't need both return and break statements in a given case; just a return is enough.

emerson132
Enthusiast
Enthusiast
Jump to solution

THanks to both of you for your replies, I'm on holiday his week as soon as I get back I'll check.

MUch appreciated i hope hope it is something as simple as that  

Reply
0 Kudos