_MikeW_
Enthusiast
Enthusiast

[vRA 8.X] vRO workflow for RedHat registration/de-registration during provisioning/deletion

Is there any good documentation on how to deal with RedHat registration for VM creation/deletion? What I really need is for the VM workflow to run a script or command line on creation (if RedHat) and similarly when the VM is deleted. I just can't find any decent source of documentation on how to manage that for v8.

Can anyone point me to a similar project walk through that would be helpful?

0 Kudos
4 Replies
_MikeW_
Enthusiast
Enthusiast

Poking around in the provided workflows in vRO in v8 I found "Run program in guest".

var host = vm.sdkConnection;

var guestOperationsManager = host.guestOperationsManager;

var guestAuth = new VcNamePasswordAuthentication();

guestAuth.username = vmUsername;

guestAuth.password = vmPassword;

guestAuth.interactiveSession = interactiveSession;


var guestProgramSpec = new VcGuestProgramSpec();

guestProgramSpec.programPath = programPath;

guestProgramSpec.arguments = arguments;

guestProgramSpec.workingDirectory = workingDirectory;

guestProgramSpec.envVariables = environment;


var processManager = guestOperationsManager.processManager;

result = processManager.startProgramInGuest(vm , guestAuth , guestProgramSpec);

So it looks like I can use this as a baseline to trigger my commands I need run. My only question is how to capture the "VC:Virtualmachine" that triggered the subscription to run? I am wondering if there is a better way to do it than

vmName = inputProperties.get("resourceNames")[0];

var allVMs = VcPlugin.getAllVirtualMachines(null, vmName);

var vm = allVMs[0];

...

0 Kudos
xian_
Expert
Expert

That's what cloud-init​ is for.

0 Kudos
_MikeW_
Enthusiast
Enthusiast

Which, as I said is only useful for provisioning, not deletion so not a real solution... unless you know a way to trigger a cloud-init on delete w/o doing what im already trying to do (run a command on a subscription event.

0 Kudos
xian_
Expert
Expert

0 Kudos