diff options
author | Gary Kotton <gkotton@vmware.com> | 2014-08-10 06:43:20 -0700 |
---|---|---|
committer | Gary Kotton <gkotton@vmware.com> | 2014-12-08 07:41:20 -0800 |
commit | 536e99041d67b7f9beff873c10dbb000744e84ee (patch) | |
tree | 4b2c55e1f9812cc0e3b16e8480b5800c82867196 | |
parent | 6f5fe6d2d787a32d653a395707590d32ddea1095 (diff) | |
download | nova-536e99041d67b7f9beff873c10dbb000744e84ee.tar.gz |
VMware: enable a cache prefix configuration parameter
Background:
Images that are stored in the cache folder will be stored in a folder whose
name is the image ID. In the event that an image is discovered to be no longer
used then a timestamp will be added to the image folder.
At each aging iteration we check if the image can be aged.
This is done by comparing the current nova compute time to the time embedded
in the timestamp. If the time exceeds the configured aging time then
the parent folder, that is the image ID folder, will be deleted.
That effectively ages the cached image.
If an image is used then the timestamps will be deleted.
When accessing a timestamp we make use of locking. This ensures that aging
will not delete an image during the spawn operation. When spawning
the timestamp folder will be locked and the timestamps will be purged.
This will ensure that a image is not deleted during the spawn.
In order to ensure that there is not a race between compute nodes each
compute node will have its own cache directory on the VMware datastore.
This is terrible costly when using more than one compute node (which is
a MUST for HA).
Due to the fact that we are using a nova lock utils if the compute nodes
have a shared file system then the locking is valid for all compute nodes.
In order to enable an administrator this option we provide a new
configuration parameter to enable multiple compute nodes to use the same
cache folder on the backend datastore. NOTE that this can only be done
when the compute nodes are running on the same host or the compute nodes
have a shared file system.
DocImpact
New variable - cache_prefix
This is in the vmware section
Change-Id: I02e758af19cf3a652a5c39d02904e73a1088fe60
-rw-r--r-- | nova/tests/unit/virt/vmwareapi/test_vmops.py | 17 | ||||
-rw-r--r-- | nova/virt/vmwareapi/vmops.py | 33 |
2 files changed, 43 insertions, 7 deletions
diff --git a/nova/tests/unit/virt/vmwareapi/test_vmops.py b/nova/tests/unit/virt/vmwareapi/test_vmops.py index dc6493d985..3e1f3f7235 100644 --- a/nova/tests/unit/virt/vmwareapi/test_vmops.py +++ b/nova/tests/unit/virt/vmwareapi/test_vmops.py @@ -1469,3 +1469,20 @@ class VMwareVMOpsTestCase(test.NoDBTestCase): pbm_default_policy='default-policy', group='vmware') extra_specs = self._vmops._get_extra_specs(flavor) self.assertEqual('flavor-policy', extra_specs.storage_policy) + + def test_get_base_folder_not_set(self): + self.flags(image_cache_subdirectory_name='vmware_base') + base_folder = self._vmops._get_base_folder() + self.assertEqual('vmware_base', base_folder) + + def test_get_base_folder_host_ip(self): + self.flags(my_ip='7.7.7.7', + image_cache_subdirectory_name='_base') + base_folder = self._vmops._get_base_folder() + self.assertEqual('7.7.7.7_base', base_folder) + + def test_get_base_folder_cache_prefix(self): + self.flags(cache_prefix='my_prefix', group='vmware') + self.flags(image_cache_subdirectory_name='_base') + base_folder = self._vmops._get_base_folder() + self.assertEqual('my_prefix_base', base_folder) diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py index d8d7a60442..df7ec380ec 100644 --- a/nova/virt/vmwareapi/vmops.py +++ b/nova/virt/vmwareapi/vmops.py @@ -57,8 +57,19 @@ from nova.virt.vmwareapi import vif as vmwarevif from nova.virt.vmwareapi import vim_util from nova.virt.vmwareapi import vm_util +vmops_opts = [ + cfg.StrOpt('cache_prefix', + help='The prefix for Where cached images are stored. This is ' + 'NOT the full path - just a folder prefix. ' + 'This should only be used when a datastore cache should ' + 'be shared between compute nodes. Note: this should only ' + 'be used when the compute nodes have a shared file ' + 'system.'), + ] CONF = cfg.CONF +CONF.register_opts(vmops_opts, 'vmware') + CONF.import_opt('image_cache_subdirectory_name', 'nova.virt.imagecache') CONF.import_opt('remove_unused_base_images', 'nova.virt.imagecache') CONF.import_opt('vnc_enabled', 'nova.vnc') @@ -151,13 +162,7 @@ class VMwareVMOps(object): self._root_resource_pool = vm_util.get_res_pool_ref(self._session, self._cluster) self._datastore_regex = datastore_regex - # Ensure that the base folder is unique per compute node - if CONF.remove_unused_base_images: - self._base_folder = '%s%s' % (CONF.my_ip, - CONF.image_cache_subdirectory_name) - else: - # Aging disable ensures backward compatibility - self._base_folder = CONF.image_cache_subdirectory_name + self._base_folder = self._get_base_folder() self._tmp_folder = 'vmware_temp' self._rescue_suffix = '-rescue' self._migrate_suffix = '-orig' @@ -166,6 +171,20 @@ class VMwareVMOps(object): self._imagecache = imagecache.ImageCacheManager(self._session, self._base_folder) + def _get_base_folder(self): + # Enable more than one compute node to run on the same host + if CONF.vmware.cache_prefix: + base_folder = '%s%s' % (CONF.vmware.cache_prefix, + CONF.image_cache_subdirectory_name) + # Ensure that the base folder is unique per compute node + elif CONF.remove_unused_base_images: + base_folder = '%s%s' % (CONF.my_ip, + CONF.image_cache_subdirectory_name) + else: + # Aging disable ensures backward compatibility + base_folder = CONF.image_cache_subdirectory_name + return base_folder + def _extend_virtual_disk(self, instance, requested_size, name, dc_ref): service_content = self._session.vim.service_content LOG.debug("Extending root virtual disk to %s", requested_size) |