NFS/GlusterFS: Skip incorrectly formatted shares
Shares should always be of the form address:/volume. If they are
not (i.e., are missing the '/'), then skip them and issue a warning
message. This will prevent us from sending incorrect connection_info
dicts to Nova.
Closes-Bug: #1267253
Change-Id: Ic40cd0cdc862b44b0a7d3e5b1d7c4fee8ea1b28d
(cherry picked from commit 21ebf2898e
)
This commit is contained in:
parent
ec8ce6cdf2
commit
66873311e5
|
@ -289,6 +289,7 @@ class GlusterFsDriverTestCase(test.TestCase):
|
|||
config_data.append(self.TEST_EXPORT1)
|
||||
config_data.append('#' + self.TEST_EXPORT2)
|
||||
config_data.append(self.TEST_EXPORT2 + ' ' + self.TEST_EXPORT2_OPTIONS)
|
||||
config_data.append('broken:share_format')
|
||||
config_data.append('')
|
||||
drv._read_config_file(self.TEST_SHARES_CONFIG_FILE).\
|
||||
AndReturn(config_data)
|
||||
|
|
|
@ -280,6 +280,7 @@ class NfsDriverTestCase(test.TestCase):
|
|||
config_data.append('')
|
||||
config_data.append(self.TEST_NFS_EXPORT2 + ' ' +
|
||||
self.TEST_NFS_EXPORT2_OPTIONS)
|
||||
config_data.append('broken:share_format')
|
||||
drv._read_config_file(self.TEST_SHARES_CONFIG_FILE).\
|
||||
AndReturn(config_data)
|
||||
mox.ReplayAll()
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
import errno
|
||||
import os
|
||||
import re
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
|
@ -294,6 +295,11 @@ class RemoteFsDriver(driver.VolumeDriver):
|
|||
share_address = share_info[0].strip().decode('unicode_escape')
|
||||
share_opts = share_info[1].strip() if len(share_info) > 1 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
|
||||
|
||||
LOG.debug("shares loaded: %s", self.shares)
|
||||
|
|
Loading…
Reference in New Issue