Connecting to a specific datastore for virtual machine deployment

When an OpenStack VMware compute node starts, you can define a set of available datastores (datastore_regex defined in nova.conf) to which the virtual machine can be deployed.

Specify a specific datastore

If you are going to deploy a virtual machine to a specified datastore, you can define "vmware:datastore" in the extra_specs parameter of the flavor. Complete the following steps.
  • Create a flavor.
    nova flavor-create flavor_datastore 7 2048 5 2
  • Specify the datastore in the extra_specs parameter of the flavor.
    nova flavor-key 7 set vmware:datastore=datastore1
  • Check the flavor.
    [root@icm filters]#nova flavor-show 7
    |-----------------------------------------------------------------------
    | Property                   |Value                                    |
    |-----------------------------------------------------------------------
    | OS-FLV-DISABLED:disabled   | False                                   |
    | OS-FLV-EXT-DATA:ephemeral  | 0                                       |
    | disk                       | 5                                       |
    | extra_specs                | {"vmware:datastore": "datastore1"}      |
    | id                         | 7                                       |
    | name                       | datastore-style                         |
    | os-flavor-access:is_public | True                                    |
    | ram                        | 2048                                    |
    | rxtx_factor                | 1.0                                     |
    | swap                       |                                         |
    | vcpus                      | 2                                       |
    ------------------------------------------------------------------------
  • Deploy the virtual machine with the flavor that has the specified datastore.
    nova boot --flavor 7 --image <image_id> --nic net-id=<network_id> <instance_name>
    Note: When you specify the datastore in the extra_specs parameter of the flavor, "vmware:datastore" must be used for the key.

Collaborative work with host aggregate

If you want to select the host with the correct datastore during the scheduler stage, without getting a result until the spawning stage if the host is incorrect, you must configure "AggregateInstanceExtraSpecsDatastoreFilter" before deploying a virtual machine. This parameter is a new filter that is implemented in the VMware driver that works together with the specified datastore in the flavor.

Using the "AggregateInstanceExtraSpecsDatastoreFilter" filter

  • Configure the nova.conf file of the compute node. Add the "AggregateInstanceExtraSpecsDatastoreFilter" filter for "scheduler_default_filters".
  • Restart the nova-api service.
  • Create a host aggregate by using the following command. The command returns the ID of the created aggregate.
    nova aggregate-create <name>
  • Add the host for the created aggregate.
    nova aggregate-add-host <id> <host>
    Note: The added VMware compute host here should contain the datastores that the aggregate metadata defines in the next step.
  • Define the metadata for the aggregate.
    nova aggregate-set-metadata <id> <key=value>
    To make the filter match the specified datastore in the flavor, "datastore" must be used for the key. For the value, a certain datastore or a set of datastores are available. For example:
    nova aggregate-set-metadata <id> datastore=datastore*
    After the preceding steps are complete, the datastore that is specified in the flavor matches the datastore regex in the metadata of the host aggregate.
    Note: