Nova/Blueprints/vmware-sdrs-datastore-cluster

Objective
The functional request for VCenter driver to support datastore cluster allows the end user to specify the datastore cluster name defined in VCenter, so that VCenter driver can select datastore from user-defined datastore cluster, or utilize SDRS to deploy VM to the appropriate datastore in ths cluster.

Scope
The typical VCenter use case is 'create VM from template'. This blueprint will only consider to utilize SDRS when creating VM from VCenter template. If the VM image is located in Glance repository, not in VCenter, the existing implementation in VCenter driver code is still the preferred way to deploy VM. This blueprint will not propose any change to that.

Related Documents
TODO

Terminology
SDRS - Storage DRS allows to manage the aggregated resources of a datastore cluster. When Storage DRS is enabled, it provides recommendations for virtual machine disk placement and migration to balance space and I/O resources across the datastores in the datastore cluster. Refer to https://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.resmgmt.doc_50%2FGUID-19B6F05F-D285-4ACB-9B13-24A1DE9B4058.html

Datastore - The Datastore represents a storage location for virtual machine files. A storage location can be a VMFS volume, a directory on Network Attached Storage, or a local file system path. Refer to http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.Datastore.html

StoragePod - The StoragePod data object aggregates the storage resources of associated Datastore objects into a single storage resource for use by virtual machines. Refer to http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.apiref.doc/vim.StoragePod.html

Assumptions, Dependencies and Constrains
If SDRS is utilized to select datastore, the VM image need to be created as a template in VCenter, so that SDRS will automatically execute VM provisioning task.

A blueprint (https://blueprints.launchpad.net/nova/+spec/deploy-vcenter-templates-from-vmware-nova-driver) was create to support VCenter template. It is a prerequisite to support SDRS functionality. The code review link for this blueprint is https://review.openstack.org/#/c/34903/

Overview
TODO

Filter datastore with datastore_cluster_name
Each VM requires a folder or directory for its virtual disks and files. When creating a VM in vCenter inventory, it is required to select a datastore for the virtual machine's configuration and other files and all of the virtual disks. OpenStack end users may need to associate one Nova compute node with one VCenter datastore cluster to schedule the file placement, as they does for VCenter compute resource cluster.

This blueprint proposes a way to allow the end user to speicify a datastore cluster name in Nova configuration file, so that VCenter driver can filter the datastores associated with the user defined datastore cluster, in order to deploy VM to a appropriate datastore.

Deploy VM to SDRS datastore cluster
SDRS allows VCenter to accomplish intelligent initial placement and on-going space & load balancing of VMs across datastores in the same datastore cluster. OpenStack end users can utilize SDRS to help them select the right datastore to place VM files.

This blueprint proposes a way to let Nova VCenter driver utilize SDRS to deply VM. If the end user need to use SDRS functionality, the VM image must be a VCenter template, and the datastore cluster name is also need to be specified in Nova configuration file.

External Interfaces
Two new VCenter driver options need to be defined in nova.conf. They will take effect, only if Nova compute driver is VCenter driver.

The first option is 'datastore_cluster_name'. This option lets the end user to specify the name of datastore cluster (StoragePod object) defined in VCenter. By default, the value of this option is not defined. An example of the definition of this option is:


 * 1) The name of a datastore cluster. Used only if compute_driver is
 * 2) vmwareapi.VMwareVCDriver. (string value)
 * 3) datastore_cluster_name=

The second option is 'use_SDRS'. This is a boolean option. The end user can use it to request SDRS to select datastore, instead of VCenter driver. This option will take effect, only if datastore_cluster_name is also specified. The default value of this option is false. An example of the definition of this option is:


 * 1) Select datastore by SDRS. Used only if compute_driver is
 * 2) vmwareapi.VMwareVCDriver. (boolean value)
 * 3) use_SDRS=false

These two options need to specified along with datastore_regex. Their effect is described by Table 1.

Existing implementation
The existing VCenter driver of Nova has a simple logic to select datastore before deploy a VM. Driver code queries all datastores, or the datastore associated with user defined compute resource cluster (ClusterComputeResource object), for VCenter. The datastore who has the largest free space, will be selected as the on to place VM files. Refer to 'get_datastore_ref_and_name' in vm_util.py.

https://github.com/openstack/nova/blob/f454defc2be6859a63db2f1dacb34524c9b6e288/nova/virt/vmwareapi/vm_util.py

VCenter driver also defines an option named 'datastore_regex' which assists to select backend storage datastore. Refer to 'datastore_regex' in nova.conf.sample.

https://github.com/openstack/nova/blob/95a0c7221a89651b192a838ba527d31ef8c638e1/etc/nova/nova.conf.sample

Implementing User Case - Filter datastore with datastore_cluster_name
The existing implementation of VCenter driver to select a datastore is located in function get_datastore_ref_and_name. The new flow of get_datastore_ref_and_name is illustrated by Figure 1.

TODO: Figure 1

In this flow chart, get_datastore_from_datastore_cluster is new function or code piece to query all the datastores associated with user defined datastore cluster (StoragePod object). The list of datastores is recorded in 'childEntity' property of a StoragePod object.

If both compute resource cluster and datastore cluster are not specified, VCenter driver will select a datastore from all datastores in VCenter. That is same as the existing behavior.

If compute resource cluster is specified, and datastore cluster is not specified, VCenter will select a datastore from the ones associated with that compute resource cluster. That is same as the existing behavior.

If datastore resource cluster is specified, and compute resource cluster is not specified, VCenter will select a datastore from the ones associated with that datastore cluster.

If both compute resource cluster and datastore cluster are specified, VCenter will select a datastore from the ones which is associated with that compute resource cluster, and is also associated with that datastore cluster.

datastore_regex will filter the datastore name. Its behavior will not change.

Implementing User Case - Deploy VM on SDRS datastore cluster
SDRS has two modes. One is manual mode, and the other is fully automated mode.

In manual mode, vCenter will make recommendations for virtual machine files, but will not perform automatic tasks. In automated mode, files will be migrated by VCenter automatically to optimize resource usage.

RecommendDatastores is the API to get the SDRS recommended task. It accepts input parameters very similar as cloneVM_Task. If SDRS is not fully automated, the RecommendDatastores call will generate recommended VM provision task which requires ApplyStorageDrsRecommendation_Task to execute. If SDRS is fully automated, RecommendDatastores will automatically execute the task.

In spawn of VCenter driver, the logic need to be adjusted to utilize SDRS. The new flow is illustrated by Figure 2.

TODO: Figure 2

In this chart the black rectangles and lines are the existing flow of VCenter driver. The blue rectangles and lines are the flow proposed by blueprint Deploy VM from Template (https://blueprints.launchpad.net/nova/+spec/deploy-vcenter-templates-from-vmware-nova-driver), which is the prerequisite of this implementation. The green rectangles and lines are the flow proposed by this blueprint.

If the image is located in Glance repository, VCenter driver will select a datastore, upload the image and create the VM. In this case, if datastore_cluster_name is speicified by the end user, it will take effect in select_datastore procedure, in order to filter the datastore from the user defined datastore cluster.

If the image is a template in VCenter, and the end user does not specify to deploy VM to SDRS datastore, VCenter driver will select a datastore and call cloneVM_Task to deploy the VM. In this case, if datastore_cluster_name is speicified by the end user, it will take effect in select_datastore procedure, in order to filter the datastore from the user defined datastore cluster.

If the image is a template in VCenter and the end user specify to use SDRS, VCenter driver will call RecommendDatastores to deploy the VM to the user defined datastore cluster. If SDRS is not fully automated, ApplyStorageDrsRecommendation_Task will be called to execute the best recommendation.

Performance, Scalability and Redundancy
TODO

Future Enhancement
TODO

Issues and Risks
TODO

Appendix
TODO