VMware Cloud Community
KiranMuddaiahHP
Contributor
Contributor

Custom naming template supports only one VM resource name.

I am using workflow to generate the hostnames for VM's it working for name generation for single VM as part of same deployment but when I try to provision more one VM Instance which are going to part of same deployment getting following error. Need an expert advise how to enable support for multiple instances in  Custom naming template

KiranMuddaiahHP_0-1641467787853.png

 

Reply
0 Kudos
9 Replies
bdamian
Expert
Expert

Are you adding the numerical part at the end of the Naming Template? ( ${######} ) 

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
Reply
0 Kudos
KiranMuddaiahHP
Contributor
Contributor

No, Below is the setting used, then names and numbers are generated using is vRO workflow

KiranMuddaiahHP_0-1641478477009.png

 

Reply
0 Kudos
j_dubs
Enthusiast
Enthusiast

What does your workflow look like and when are you calling it?

Reply
0 Kudos
bdamian
Expert
Expert

Why don't you try with a Name Template like: ${resource.name}-${######}?

I understand that you have a workflow that change the name of the resource but I'm not sure if the error isn't fired before.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
KiranMuddaiahHP
Contributor
Contributor

The Name Template that asking me to try is not meeting our requirements and hence had to write vRO flows to generate the hostnames

Reply
0 Kudos
thjelm
Contributor
Contributor

The error indicates that your workflow output array 'resourceNames' only contains one element.

Are you sure you're pushing all the names into the array?

Reply
0 Kudos
KiranMuddaiahHP
Contributor
Contributor

It is an array but with array[0], we need to rewrite the script for to support multiple array items based on the selection number of instances. I am not sure how to write that script

Reply
0 Kudos
j_dubs
Enthusiast
Enthusiast

Assuming your ABX workflow is subscribed at "Compute Provision" - this is some sample vRO code to pack up the array.  Ours is only fit for one VM resource, but no reason you cannot extend this for a higher count:

//action code.  previous code does our hostname allocations, validations, etc.
//input: (string)validatedHostname
//you will want to change this to a string array

customProperties = inputProperties.customProperties || new Properties();
resourceNames = inputProperties.resourceNames;

resourceNames[0] = validatedHostname;

//add more here based on your logic...
//resourceNames[1] = "hostname2";
//resourceNames[2] = "hostname3";

System.log("Attempting to send new hostname back in payload: " + validatedHostname);
System.log("New/updated resource names: " + resourceNames);
}

 

Is this what you are looking for?

Reply
0 Kudos
KiranMuddaiahHP
Contributor
Contributor

@j_dubs Thank you for help, this is working now.

Reply
0 Kudos