VMware Cloud Community
rlabinot
Enthusiast
Enthusiast
Jump to solution

VRA8 - Change the resourcesName with an vRO workflow

Hello,

I want to change the VM name using a vRO workflow. I have put a script that has an "InputProperties" as input but it is impossible to change the name, even the subscription workflow has an OK status.

Does somebody has here an example to show ? How can you change values of the properties of the VM ?

Thanks for you help.

1 Solution

Accepted Solutions
rlabinot
Enthusiast
Enthusiast
Jump to solution

It is now solved. The subscription must have the blocking mode enabled in vRA, otherwise the script in the vRO workflow "Compute Allocation" doesn't change the properties.

As said by pizzle85, an input/output from the script AND the workflow must be set. Example :

Inputs : inputProperties - Properties

Outputs : resourceNames - Array/string

var resourceNames = inputProperties.resourceNames;

System.log("VM Name before : " + resourceNames[0]);

resourceNames[0] = "myNewName";

System.log("VM Name after : " + resourceNames[0]);

View solution in original post

4 Replies
sprouse94
Enthusiast
Enthusiast
Jump to solution

Not sure if this is what you are looking for, new to Automation.  I was able to change the VM name based on user input, followed the information in this link:

https://www.stevenbright.com/2020/02/custom-hostname-generation-in-vrealize-automation-8/2/

The only issue I have now is it will generate a name that already exists in Virtual Center and fails.  Struggling to figure out how to check if the generated name already exists.  I find vcplugin examples but looks like that was taken out of version 8

Reply
0 Kudos
pizzle85
Expert
Expert
Jump to solution

In my blueprint i use the "name" field which will result in the VM being named <vmname>-something.

I have a workflow with a single script element.

Input: inputProperties properties

Output: resourceNames array/string

System.log(JSON.stringify(inputProperties))


resourceNames = new Array()


var props = JSON.parse(JSON.stringify(inputProperties))

System.log(props.resourceNames)

var split = props.resourceNames[0].split('-')

split.pop()

split.pop()

resourceNames.push(split.join('-'))

rlabinot
Enthusiast
Enthusiast
Jump to solution

It is now solved. The subscription must have the blocking mode enabled in vRA, otherwise the script in the vRO workflow "Compute Allocation" doesn't change the properties.

As said by pizzle85, an input/output from the script AND the workflow must be set. Example :

Inputs : inputProperties - Properties

Outputs : resourceNames - Array/string

var resourceNames = inputProperties.resourceNames;

System.log("VM Name before : " + resourceNames[0]);

resourceNames[0] = "myNewName";

System.log("VM Name after : " + resourceNames[0]);

reshp1986
Contributor
Contributor
Jump to solution

This helped me . How do we update MAC, VLAN etc 

Alternative for below in vRO8

virtualMachineAddOrUpdateProperties = new Properties ();
virtualMachineAddOrUpdateProperties.put('Name', hostname);
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.MacAddressType', 'static');
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.MacAddress', mac);
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.Name', "VLAN"+vlan);

Reply
0 Kudos