[Quick Hint] Disable and Enable of vRA7 Services with vRO workflow

If you need to prevent people form deploying new VMs during a certain times. For example when one of your vRA third-party services are being backup and is offline.

The easiest way to achieve this is to disable the services that contain catalog items which you want to prevent form being deployed.

Now when we know the how, the only thing left is to automate this process and run it every night with vRO scheduled workflow.
We will create a workflow that disable the required services and schedule a second one to re-enable them back again in defined number of minutes.

First thing we need to do is to define required attributes.
One will hold a delay time for scheduling enable workflow.
Second will hold a list of services to disable/enable

Now add required Services to services Array

add services

It’s time to write some code. To disable services from defined array you have to run this code

for each (service in services){
	var host = vCACCAFEEntitiesFinder.getHostForEntity(service);
	var client = host.createCatalogClient().getCatalogServiceAdminService();	
	service.setStatus(vCACCAFEStatus.RETIRED);	
	System.log("Deactivating service...");
	client.updateService(service);
	System.log("Service: " + service.getName() + " deactivated.");
}

Calculate enable time

var delay = new Date().getTime(); 
delay = delay + 1000*60*enableDelay;
enableTime = new Date(d);

To enable services run this same loop but change service setStatus() line to

service.setStatus(vCACCAFEStatus.ACTIVE);

Now when everything is done schedule the disable workflow to run as you wish. I scheduled mine to run every day at 23:00

And we are done. Enjoy your vRA not failing deployments during Satellite backup time 😀