9.3 VM Life Cycle Management

The Novell ZENworks Orchestrator maintains a library of VM images, hosts, and instances. Like physical resources, VMs can be grouped and they have facts that describe their attributes.

ZENworks orchestrator provides a JDL management API for the following tasks you can use jobs to perform on VMs, as illustrated in the following figure:

Figure 9-2 VM Lifecycle Management

You might want to provision a set of VMs at a certain time of day before the need arises. You also might create a job to shut down all VMs or a constrained group of VMs. You can perform these tasks programatically (using a job), manually (through the management console), or automatically on demand.

When performing tasks automatically, a job might make a request for an unavailable resource, which triggers a job to look for a suitable VM image and host. If located, the image is provisioned and the instance is initially reserved for calling a job to invoke the required logic to select, place, and use the newly provisioned resource.

For an example of this job, see sweeper.job.

VM operations are available on the ResourceInfo grid object, and VmHost operations are available on the VMHostInfo grid object. In addtion, as shown in Section 9.3.2, Provisioning Example, three provisioner events are fired when a provision action has completed, failed, or cancelled.

The API is equivalent to the actions available within the Orchestrator management console. The selection and placement of the VM host is governed by policies, priorities, queues, and ranking, similar to the processes used selecting resources.

Provisioning adapters on the Orchestrator Server abstract the VM. These adapters are special provisioning jobs that perform operations for each integration with different VM technologies. The following figure shows the VM host management interface that is using the Orchestrator console.

Figure 9-3 VM Host Management

9.3.1 VM Placement Policy

To provision virtual machines, a suitable host must be found. The following shows an example of a VM placement policy:

  <constraint type="vmhost">
      <eq fact="vmhost.enabled" value="true"
          reason="VmHost is not enabled" />
      <eq fact="vmhost.online" value="true"
          reason="VmHost is not online" />
      <eq fact="vmhost.shuttingdown" value="false"
          reason="VmHost is shutting down" />
      <lt fact="vmhost.vm.count" factvalue="vmhost.maxvmslots"
          reason="VmHost has reached maximum vmslots" />
     <ge fact="vmhost.virtualmemory.available"
         reason="VmHost has insufficient virtual memory for guest VM" />
      <contains fact="vmhost.vm.availableids"
                reason="VmImage is not available on this VmHost" />

9.3.2 Provisioning Example

This job example provisions a virtual machine and monitors whether provisioning completed successfully. The VM name is “webserver” and the job requires a VM to be discovered before it is run. After the provision has started, one of the three provisioner events is called.

1  class provision(Job):
3      def job_started_event(self):
4          vm = getMatrix().getGridObject(TYPE_RESOURCE,"webserver")
5          vm.provision()
6          self.setFact("job.autoterminate",False)
8      def provisioner_completed_event(self,params):
9          print "provision completed successfully"
10         self.setFact("job.autoterminate",True)
12     def provisioner_failed_event(self,params):
13         print "provision failed"
14         self.setFact("job.autoterminate",True)
16     def provisioner_cancelled_event(self,params):
17         print "provision cancelled"
18         self.setFact("job.autoterminate",True)

See additional provisioning examples in Section 9.4, Manual Management and Section 9.5, Automatically Provisioning a VM Server.