How to schedule snapshot tasks in vCenter with VCF Orchestrator

Learn how to schedule VM snapshot tasks in vCenter with VCF Orchestrator

Thank you very much for voting! The poll is still opened, so feel free to check it in.


vCenter allows us to schedule the creation and deletion of virtual machine snapshots—a highly useful feature. While the same functionality can be achieved using a pure VCF Orchestrator, today we will explore how to leverage the Orchestrator to configure this scheduler.

Plan

I will create a workflow that allows selecting a virtual machine to be scheduled for a snapshot. The workflow will support the following features:

  • one or more VMs
  • create a delete snapshot

Logic

Logic diagram

Virtual Machine management class

I already have a VirtualMachineManagement, therefore, I am going to extend it by adding more methods.

To work with a scheduler, it should be invoked in a context of the VM I want to work on.

Get Service Instance

In VCF Orchestrator, ServiceInstance is a core object that represents a connection to a vSphere environment, typically a vCenter Server instance.

What is ServiceInstance in vRO?
It is the root object for accessing the vSphere API in vRO.
It allows vRO scripts and workflows to interact with vCenter Server, retrieving various managed objects such as Virtual Machines, Hosts, Datacenters, Clusters, and more.

First, I need to define the virtual machine (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);
};

Get Service Instance function

Now that I have a ServiceInstance object, it contains an attribute called content, which is of type VcServiceContent. This object provides access to numerous managers, but the one I'm particularly interested in is the scheduledTaskManager.

Read the full story

Sign up now to read the full story and get access to all members-only posts.

Subscribe
Already have an account? Sign in
Great! Next, complete checkout for full access to CloudDepth.
Welcome back! You've successfully signed in.
You've successfully subscribed to CloudDepth.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.

This work by Leonid Belenkiy is licensed under Creative Commons Attribution 4.0 International