diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index e8572b6b..3350e398 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -332,6 +332,15 @@ Possible values: Related options: * cinder_enforce_multipath +"""), + cfg.StrOpt('cinder_mount_point_base', + default='/var/lib/glance/mnt', + help=""" +Directory where the NFS volume is mounted on the glance node. + +Possible values: + +* A string representing absolute path of mount point. """), ] @@ -531,9 +540,12 @@ class Store(glance_store.driver.Store): self.conf, self.backend_group).cinder_use_multipath enforce_multipath = getattr( self.conf, self.backend_group).cinder_enforce_multipath + mount_point_base = getattr( + self.conf, self.backend_group).cinder_mount_point_base else: use_multipath = self.conf.glance_store.cinder_use_multipath enforce_multipath = self.conf.glance_store.cinder_enforce_multipath + mount_point_base = self.conf.glance_store.cinder_mount_point_base properties = connector.get_connector_properties( root_helper, host, use_multipath, enforce_multipath) @@ -548,6 +560,9 @@ class Store(glance_store.driver.Store): try: connection_info = volume.initialize_connection(volume, properties) + if connection_info['driver_volume_type'] == 'nfs': + connection_info['mount_point_base'] = os.path.join( + mount_point_base, 'nfs') conn = connector.InitiatorConnector.factory( connection_info['driver_volume_type'], root_helper, conn=connection_info) diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py index 8850cef7..b7dea33a 100644 --- a/glance_store/tests/unit/test_cinder_store.py +++ b/glance_store/tests/unit/test_cinder_store.py @@ -148,6 +148,7 @@ class TestCinderStore(base.StoreBaseTest, def _test_open_cinder_volume(self, open_mode, attach_mode, error, multipath_supported=False, enforce_multipath=False): + self.config(cinder_mount_point_base=None) fake_volume = mock.MagicMock(id=str(uuid.uuid4()), status='available') fake_volumes = FakeObject(get=lambda id: fake_volume, detach=mock.Mock()) diff --git a/glance_store/tests/unit/test_multistore_cinder.py b/glance_store/tests/unit/test_multistore_cinder.py index 12ae7133..4b546da2 100644 --- a/glance_store/tests/unit/test_multistore_cinder.py +++ b/glance_store/tests/unit/test_multistore_cinder.py @@ -168,6 +168,7 @@ class TestMultiCinderStore(base.MultiStoreBaseTest, def _test_open_cinder_volume(self, open_mode, attach_mode, error, multipath_supported=False, enforce_multipath=False): + self.config(cinder_mount_point_base=None, group='cinder1') fake_volume = mock.MagicMock(id=str(uuid.uuid4()), status='available') fake_volumes = FakeObject(get=lambda id: fake_volume, detach=mock.Mock()) diff --git a/glance_store/tests/unit/test_opts.py b/glance_store/tests/unit/test_opts.py index 8243ec90..ff304b0d 100644 --- a/glance_store/tests/unit/test_opts.py +++ b/glance_store/tests/unit/test_opts.py @@ -75,6 +75,7 @@ class OptsTestCase(base.StoreBaseTest): 'cinder_catalog_info', 'cinder_endpoint_template', 'cinder_http_retries', + 'cinder_mount_point_base', 'cinder_os_region_name', 'cinder_state_transition_timeout', 'cinder_store_auth_address',