diff --git a/manila/share/drivers/container/container_helper.py b/manila/share/drivers/container/container_helper.py index cea4462061..81bd3daeb7 100644 --- a/manila/share/drivers/container/container_helper.py +++ b/manila/share/drivers/container/container_helper.py @@ -61,9 +61,11 @@ class DockerExecHelper(driver.ExecuteMixin): # provide any more possibilities for an exploitation than other # first-party drivers. + path = "{0}:/shares".format( + self.configuration.container_volume_mount_path) cmd = ["docker", "run", "-d", "-i", "-t", "--privileged", "-v", "/dev:/dev", "--name=%s" % name, - "-v", "/tmp/shares:/shares", image_name] + "-v", path, image_name] try: result = self._inner_execute(cmd) except (exception.ProcessExecutionError, OSError): diff --git a/manila/share/drivers/container/driver.py b/manila/share/drivers/container/driver.py index 251cf3beec..75b22086e1 100644 --- a/manila/share/drivers/container/driver.py +++ b/manila/share/drivers/container/driver.py @@ -70,6 +70,11 @@ container_opts = [ help="Helper which facilitates interaction with storage " "solution used to actually store data. By default LVM " "is used to provide storage for a share."), + cfg.StrOpt("container_volume_mount_path", + default="/tmp/shares", + help="Folder name in host to which logical volume will be " + "mounted prior to providing access to it from a " + "container."), ] diff --git a/manila/share/drivers/container/storage_helper.py b/manila/share/drivers/container/storage_helper.py index 0df3bb2220..c5570132c0 100644 --- a/manila/share/drivers/container/storage_helper.py +++ b/manila/share/drivers/container/storage_helper.py @@ -77,9 +77,8 @@ class LVMHelper(driver.ExecuteMixin): share_name) def _get_lv_folder(self, share_name): - # Provides folder name in hosts /tmp to which logical volume is - # mounted prior to providing access to it from a container. - return os.path.join("/tmp/shares", share_name) + return os.path.join(self.configuration.container_volume_mount_path, + share_name) def provide_storage(self, share_name, size): self._execute("lvcreate", "-p", "rw", "-L", diff --git a/manila/tests/share/drivers/container/test_container_helper.py b/manila/tests/share/drivers/container/test_container_helper.py index 2cf7da8b34..8f8ca68cae 100644 --- a/manila/tests/share/drivers/container/test_container_helper.py +++ b/manila/tests/share/drivers/container/test_container_helper.py @@ -34,6 +34,7 @@ class DockerExecHelperTestCase(test.TestCase): super(DockerExecHelperTestCase, self).setUp() self.fake_conf = configuration.Configuration(None) self.fake_conf.container_image_name = "fake_image" + self.fake_conf.container_volume_mount_path = "/tmp/shares" self.DockerExecHelper = container_helper.DockerExecHelper( configuration=self.fake_conf) diff --git a/manila/tests/share/drivers/container/test_storage_helper.py b/manila/tests/share/drivers/container/test_storage_helper.py index cae63a47dc..68cb9f98dd 100644 --- a/manila/tests/share/drivers/container/test_storage_helper.py +++ b/manila/tests/share/drivers/container/test_storage_helper.py @@ -34,6 +34,7 @@ class LVMHelperTestCase(test.TestCase): super(LVMHelperTestCase, self).setUp() self.share = fake_share() self.fake_conf = configuration.Configuration(None) + self.fake_conf.container_volume_mount_path = "/tmp/shares" self.LVMHelper = storage_helper.LVMHelper(configuration=self.fake_conf) def fake_exec_sync(self, *args, **kwargs): diff --git a/releasenotes/notes/mount-volume-path-ff3c3f83039e1a3f.yaml b/releasenotes/notes/mount-volume-path-ff3c3f83039e1a3f.yaml new file mode 100644 index 0000000000..e246bc9f66 --- /dev/null +++ b/releasenotes/notes/mount-volume-path-ff3c3f83039e1a3f.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - Added a new config option ``container_volume_mount_path``. + This option defines the path where ContainerShareDriver driver should + mount a logical volume on the host prior to providing access to it from + a container.