From e0e9c0ed9199f625cb40d2c2a04fd9d3f8524187 Mon Sep 17 00:00:00 2001 From: JordanP Date: Tue, 3 Feb 2015 15:27:39 +0100 Subject: [PATCH] Scality SOFS : Use ensure_tree from fileutils To avoid code duplication, use fileutils.ensure_tree from openstack/common instead of reinventing the wheel Change-Id: If75a7c79eb063fe8987f34e8e9acc5fda97e8c6e --- cinder/volume/drivers/scality.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cinder/volume/drivers/scality.py b/cinder/volume/drivers/scality.py index 99729a1b2..12431800f 100644 --- a/cinder/volume/drivers/scality.py +++ b/cinder/volume/drivers/scality.py @@ -17,7 +17,6 @@ Scality SOFS Volume Driver. """ -import errno import os import urllib2 @@ -93,20 +92,13 @@ class ScalityDriver(driver.VolumeDriver): LOG.warn(msg) raise exception.VolumeBackendAPIException(data=msg) - def _makedirs(self, path): - try: - os.makedirs(path) - except OSError as e: - if e.errno != errno.EEXIST: - raise - @lockutils.synchronized('mount-sofs', 'cinder-sofs', external=True) def _mount_sofs(self): config = self.configuration.scality_sofs_config mount_path = self.configuration.scality_sofs_mount_point sysdir = os.path.join(mount_path, 'sys') - self._makedirs(mount_path) + fileutils.ensure_tree(mount_path) if not os.path.isdir(sysdir): self._execute('mount', '-t', 'sofs', config, mount_path, run_as_root=True) @@ -134,8 +126,7 @@ class ScalityDriver(driver.VolumeDriver): self._mount_sofs() voldir = os.path.join(self.configuration.scality_sofs_mount_point, self.configuration.scality_sofs_volume_dir) - if not os.path.isdir(voldir): - self._makedirs(voldir) + fileutils.ensure_tree(voldir) def check_for_setup_error(self): """Returns an error if prerequisites aren't met.""" -- 2.45.2