Thank you for your votes! The poll is still open—feel free to check it out here.
Using vCenter, we can schedule the creation and deletion of virtual machine (VM) snapshots, a handy feature for managing VM states. While similar functionality can be implemented with pure VMware Cloud Foundation (VCF) Orchestrator, in this post, we’ll walk through how to configure snapshot scheduling using the Orchestrator.
Plan
We’re going to build a workflow that allows users to select one or more virtual machines and schedule snapshot operations. The workflow will support:
– Selecting one or multiple VMs
– Creating and deleting snapshots
Workflow Logic
Here’s a high-level overview of the logic used in the workflow:
[Insert visual logic diagram]
VirtualMachineManagement Class Enhancements
We already have a VirtualMachineManagement class in place. We’ll be extending it by adding new methods to support scheduling functionality.
When working with scheduled tasks, the operations are performed within the context of the target VM. So, we need to ensure we can access the correct VM environment via the vSphere API.
Getting the ServiceInstance
In VMware vRealize Orchestrator (vRO), the ServiceInstance object establishes a connection to the vSphere environment (typically a vCenter Server). It’s the root object for accessing the vSphere API.
What is a ServiceInstance in vRO?
A ServiceInstance is the primary entry point into the vSphere API. It allows scripts and workflows to access vCenter Server and retrieve managed objects such as Virtual Machines, Hosts, Datacenters, Clusters, and more.
First, we define the VM as a ServiceInstance:
VirtualMachineManagement.prototype.getServiceInstance = function (vmName) {
var sdkConnection = vm.sdkConnection;
var serviceInstanceReference = new VcManagedObjectReference();
serviceInstanceReference.type = “ServiceInstance”;
serviceInstanceReference.value = “ServiceInstance”;
return VcPlugin.convertToVimManagedObject(sdkConnection, serviceInstanceReference);
};
This function returns a ServiceInstance object for the specified VM. From here, we can access the content property, which is of type VcServiceContent. This object provides access to several managers, including the scheduledTaskManager, which is key to implementing our snapshot scheduler.
To continue reading the full tutorial and get access to all exclusive content, sign up for a subscription at CloudDepth.
Subscribe Now to Unlock Full Access.