From: Mikhail Khodos Date: Tue, 17 Jun 2014 20:28:04 +0000 (+0400) Subject: Fix nfs_shares config file parsing of spaces X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f453bb92b93e3c49136a3788d25b74a3ab95c204;p=openstack-build%2Fcinder-build.git Fix nfs_shares config file parsing of spaces Driver fails in case if 'nfs_shares' file lines contain more than one space between it's patrs. This patch fixes this. Change-Id: I446ab23f0ae06ec9e8ad18ebc1d79c705de47e4d --- diff --git a/cinder/tests/test_nexenta.py b/cinder/tests/test_nexenta.py index 2080f5ae2..6a2bc52d4 100644 --- a/cinder/tests/test_nexenta.py +++ b/cinder/tests/test_nexenta.py @@ -627,11 +627,11 @@ class TestNexentaNfsDriver(test.TestCase): self.mox.StubOutWithMock(self.drv, '_read_config_file') config_data = [ - '%s %s' % (self.TEST_EXPORT1, self.TEST_NMS1), - '# %s %s' % (self.TEST_EXPORT2, self.TEST_NMS2), + '%s %s' % (self.TEST_EXPORT1, self.TEST_NMS1), + '# %s %s' % (self.TEST_EXPORT2, self.TEST_NMS2), '', - '%s %s %s' % (self.TEST_EXPORT2, self.TEST_NMS2, - self.TEST_EXPORT2_OPTIONS) + '%s %s %s' % (self.TEST_EXPORT2, self.TEST_NMS2, + self.TEST_EXPORT2_OPTIONS) ] self.drv._read_config_file(self.TEST_SHARES_CONFIG_FILE).\ diff --git a/cinder/volume/drivers/nexenta/nfs.py b/cinder/volume/drivers/nexenta/nfs.py index d20cbf48f..4da76784c 100644 --- a/cinder/volume/drivers/nexenta/nfs.py +++ b/cinder/volume/drivers/nexenta/nfs.py @@ -23,6 +23,7 @@ import hashlib import os +import re from cinder import context from cinder import db @@ -381,12 +382,17 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921 if share.startswith('#'): continue - share_info = share.split(' ', 2) + share_info = re.split(r'\s+', share, 2) share_address = share_info[0].strip().decode('unicode_escape') nms_url = share_info[1].strip() share_opts = share_info[2].strip() if len(share_info) > 2 else None + if not re.match(r'.+:/.+', share_address): + LOG.warn("Share %s ignored due to invalid format. Must be of " + "form address:/export." % share_address) + continue + self.shares[share_address] = share_opts self.share2nms[share_address] = self._get_nms_for_url(nms_url)