VMware Cloud Community
unhappyvra
Enthusiast
Enthusiast
Jump to solution

Reconfigure action - change portgroup

Hi!

I'm trying to find a way to run "Reconfigure" action in the vRO to change network portgroup for my machine (and script some stuff-related changes in my environment, of course). It seems easy with other actions (like snapshots, power on/off" but not with this one. I figure out to get "Form", but when I tried vCACCAFERequestsHelper.getRequestFormForResourceAction(Reconfigure) i got "Form" i know nothing to do with Smiley Sad It is wrapped LiteralMap/lang.Iterable bla-bla...

var fields = vCACCAFERequestsHelper.getFormKeys(form) ----- Fields = provider-MachineName,provider-machineId,provider-operationId

So, anybody knows the right direction to crack this quest?

daphnissov​ - you are the expert with this "dark magic" - would appreciate any thoughts/help!

0 Kudos
1 Solution

Accepted Solutions
unhappyvra
Enthusiast
Enthusiast
Jump to solution

Found the solution in the official documentation: Using the vRealize Automation Plug-In Requests Workflows

var requestTemplate = vCACCAFERequestsHelper.getRequestForResourceAction(operation)

var jsonData = vCACCAFERequestsHelper.getResourceActionRequestData(requestTemplate);

var json = JSON.parse(jsonData);

json.nics[0].data.name = "My new portgroup";

json["Cafe.Shim.VirtualMachine.Reconfigure.Requestor"] = 1;

vCACCAFERequestsHelper.setResourceActionRequestData(requestTemplate, JSON.stringify(json));

request = System.getModule("com.vmware.library.vcaccafe.request").requestResourceActionWithRequestTemplate(operation, requestTemplate);

You still need some code to check that reconfigure request was successful Smiley Happy

View solution in original post

0 Kudos
4 Replies
unhappyvra
Enthusiast
Enthusiast
Jump to solution

Found the solution in the official documentation: Using the vRealize Automation Plug-In Requests Workflows

var requestTemplate = vCACCAFERequestsHelper.getRequestForResourceAction(operation)

var jsonData = vCACCAFERequestsHelper.getResourceActionRequestData(requestTemplate);

var json = JSON.parse(jsonData);

json.nics[0].data.name = "My new portgroup";

json["Cafe.Shim.VirtualMachine.Reconfigure.Requestor"] = 1;

vCACCAFERequestsHelper.setResourceActionRequestData(requestTemplate, JSON.stringify(json));

request = System.getModule("com.vmware.library.vcaccafe.request").requestResourceActionWithRequestTemplate(operation, requestTemplate);

You still need some code to check that reconfigure request was successful Smiley Happy

0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

I've actually never tried to do this as a day2 action because, generally, changing a network after a machine has been provisioned is somewhat antithesis to automation in the first place. Still, though, glad you found a solution and I hope it helps others here.

0 Kudos
unhappyvra
Enthusiast
Enthusiast
Jump to solution

I agree with you, it is not a right way for cloud environment. However, sometimes you have to move machines to new network due to changed business requirements (like 6 month later after provision). Not a big deal for fresh machine (just destroy and build a new in the right place), but a big deal when you have to support long-living machines. Like recently i got a request to move ~50 vRA machines from one network to another due to security requirements. Day-2 reconfigure action gave me ability to handle re-ip/dns changes for them in a user-friendly manner with a proper rollback scenario.

0 Kudos
Lie_DW
Contributor
Contributor
Jump to solution

Hi,

I need this too. Due to our network restrictions, I need to deploy the machine in a dedicated vlan who has 443 access to the appliance and the manager server. After the deployment of the machine and software components, I need to move the vm to the correct vlan with the correct IP.

I'm using an event subscription to change the IP settings on the machine with a powershell script and to change the portgroup in vCenter. However, I noticed the portgroup and ip do not change in vRA.

Well kind of, when I go to the properties of the vm in vRA, the primary address is the new one so that's good but the old one and old vlan are still showing in the network adapter grid.

This might be the solution Smiley Happy

0 Kudos