Enable extend_share in HDFS driver
The extend_share is in Manila core, we can support the new API in the HDFS drivers. This patch adds methods to the driver along with its unit tests, and updates related docs. Implements: blueprint hdfs-native-extend-share Change-Id: Ia81291eda49dc20c3318f71c51d36682d2aae742
This commit is contained in:
parent
34274c9abd
commit
549f855a07
@ -49,6 +49,7 @@ Supported Operations
|
||||
- Create snapshot
|
||||
- Delete snapshot
|
||||
- Create share from snapshot
|
||||
- Extend share
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
@ -45,7 +45,7 @@ Mapping of share drivers and share features support
|
||||
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
|
||||
| Red Hat GlusterFS-Native | ? | ? | ? | ? | ? | ? |
|
||||
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
|
||||
| HDFS | ? | ? | ? | ? | ? | ? |
|
||||
| HDFS | DHSS = False (K) | \- | M | \- | K | K |
|
||||
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
|
||||
| Hitachi HNAS | DHSS = False (L) | L | L | \- | L | L |
|
||||
+----------------------------------------+-----------------------------+-----------------------+--------------+--------------+------------------------+----------------------------+
|
||||
@ -84,9 +84,9 @@ Mapping of share drivers and share access rules support
|
||||
+----------------------------------------+--------------+------------+------------+--------------+------------+------------+
|
||||
| Red Hat GlusterFS-Native | ? | ? | ? | ? | ? | ? |
|
||||
+----------------------------------------+--------------+------------+------------+--------------+------------+------------+
|
||||
| HDFS | ? | ? | ? | ? | ? | ? |
|
||||
| HDFS | \- | HDFS(K) | \- | \- | HDFS(K) | \- |
|
||||
+----------------------------------------+--------------+------------+------------+--------------+------------+------------+
|
||||
| Hitachi HNAS | NFS (L) | \- | \- | NFS (L) | \- | \- |
|
||||
| Hitachi HNAS | NFS (L) | \- | \- | NFS (L) | \- | \- |
|
||||
+----------------------------------------+--------------+------------+------------+--------------+------------+------------+
|
||||
| HP 3PAR | NFS,CIFS (K) | CIFS (K) | \- | \- | \- | \- |
|
||||
+----------------------------------------+--------------+------------+------------+--------------+------------+------------+
|
||||
@ -117,13 +117,13 @@ Mapping of share drivers and security services support
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| Red Hat GlusterFS-Native | ? | ? | ? |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| HDFS | ? | ? | ? |
|
||||
| HDFS | \- | \- | \- |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| Hitachi HNAS | \- | \- | \- |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| HP 3PAR | \- | \- | \- |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| Huawei | \- | \- | \- |
|
||||
| Huawei | \- | \- | \- |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
| Quobyte | \- | \- | \- |
|
||||
+----------------------------------------+------------------+-----------------+------------------+
|
||||
|
@ -159,6 +159,25 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
LOG.error(msg)
|
||||
raise exception.HDFSException(msg)
|
||||
|
||||
def _set_share_size(self, share, size=None):
|
||||
share_dir = '/' + share['name']
|
||||
|
||||
if not size:
|
||||
sizestr = six.text_type(share['size']) + 'g'
|
||||
else:
|
||||
sizestr = six.text_type(size) + 'g'
|
||||
|
||||
try:
|
||||
self._hdfs_execute(self._hdfs_bin, 'dfsadmin',
|
||||
'-setSpaceQuota', sizestr, share_dir)
|
||||
except exception.ProcessExecutionError as e:
|
||||
msg = (_('Failed to set space quota for the '
|
||||
'share %(sharename)s. Error: %(excmsg)s.') %
|
||||
{'sharename': share['name'],
|
||||
'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.HDFSException(msg)
|
||||
|
||||
def _create_share(self, share):
|
||||
"""Creates a share."""
|
||||
if share['share_proto'].lower() != 'hdfs':
|
||||
@ -167,7 +186,6 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
raise exception.HDFSException(msg)
|
||||
|
||||
share_dir = '/' + share['name']
|
||||
sizestr = six.text_type(share['size']) + 'g'
|
||||
|
||||
try:
|
||||
self._hdfs_execute(self._hdfs_bin, 'dfs',
|
||||
@ -180,16 +198,8 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
LOG.error(msg)
|
||||
raise exception.HDFSException(msg)
|
||||
|
||||
try:
|
||||
self._hdfs_execute(self._hdfs_bin, 'dfsadmin',
|
||||
'-setSpaceQuota', sizestr, share_dir)
|
||||
except exception.ProcessExecutionError as e:
|
||||
msg = (_('Failed to set space quota for the '
|
||||
'share %(sharename)s. Error: %(excmsg)s.') %
|
||||
{'sharename': share['name'],
|
||||
'excmsg': six.text_type(e)})
|
||||
LOG.error(msg)
|
||||
raise exception.HDFSException(msg)
|
||||
# set share size
|
||||
self._set_share_size(share)
|
||||
|
||||
try:
|
||||
self._hdfs_execute(self._hdfs_bin, 'dfsadmin',
|
||||
@ -360,6 +370,10 @@ class HDFSNativeShareDriver(driver.ExecuteMixin, driver.ShareDriver):
|
||||
LOG.error(msg)
|
||||
raise exception.HDFSException(msg)
|
||||
|
||||
def extend_share(self, share, new_size, share_server=None):
|
||||
"""Extend share storage."""
|
||||
self._set_share_size(share, new_size)
|
||||
|
||||
def _check_hdfs_state(self):
|
||||
try:
|
||||
(out, __) = self._hdfs_execute(self._hdfs_bin, 'fsck', '/')
|
||||
|
@ -90,15 +90,41 @@ class HDFSNativeShareDriverTestCase(test.TestCase):
|
||||
share_server=None)
|
||||
self.assertFalse(self._driver._get_share_path.called)
|
||||
|
||||
def test__create_share(self):
|
||||
def test__set_share_size(self):
|
||||
share_dir = '/' + self.share['name']
|
||||
sizestr = six.text_type(self.share['size']) + 'g'
|
||||
self._driver._hdfs_execute = mock.Mock(return_value=True)
|
||||
self._driver._set_share_size(self.share)
|
||||
self._driver._hdfs_execute.assert_called_once_with(
|
||||
'fake_hdfs_bin', 'dfsadmin', '-setSpaceQuota', sizestr, share_dir)
|
||||
|
||||
def test__set_share_size_exception(self):
|
||||
share_dir = '/' + self.share['name']
|
||||
sizestr = six.text_type(self.share['size']) + 'g'
|
||||
self._driver._hdfs_execute = mock.Mock(
|
||||
side_effect=exception.ProcessExecutionError)
|
||||
self.assertRaises(exception.HDFSException,
|
||||
self._driver._set_share_size, self.share)
|
||||
self._driver._hdfs_execute.assert_called_once_with(
|
||||
'fake_hdfs_bin', 'dfsadmin', '-setSpaceQuota', sizestr, share_dir)
|
||||
|
||||
def test__set_share_size_with_new_size(self):
|
||||
share_dir = '/' + self.share['name']
|
||||
new_size = 'fake_size'
|
||||
sizestr = new_size + 'g'
|
||||
self._driver._hdfs_execute = mock.Mock(return_value=True)
|
||||
self._driver._set_share_size(self.share, new_size)
|
||||
self._driver._hdfs_execute.assert_called_once_with(
|
||||
'fake_hdfs_bin', 'dfsadmin', '-setSpaceQuota', sizestr, share_dir)
|
||||
|
||||
def test__create_share(self):
|
||||
share_dir = '/' + self.share['name']
|
||||
self._driver._hdfs_execute = mock.Mock(return_value=True)
|
||||
self._driver._set_share_size = mock.Mock()
|
||||
self._driver._create_share(self.share)
|
||||
self._driver._hdfs_execute.assert_any_call(
|
||||
'fake_hdfs_bin', 'dfs', '-mkdir', share_dir)
|
||||
self._driver._hdfs_execute.assert_any_call(
|
||||
'fake_hdfs_bin', 'dfsadmin', '-setSpaceQuota', sizestr, share_dir)
|
||||
self._driver._set_share_size.assert_called_once_with(self.share)
|
||||
self._driver._hdfs_execute.assert_any_call(
|
||||
'fake_hdfs_bin', 'dfsadmin', '-allowSnapshot', share_dir)
|
||||
|
||||
@ -319,6 +345,13 @@ class HDFSNativeShareDriverTestCase(test.TestCase):
|
||||
self._driver._hdfs_execute.assert_called_once_with(
|
||||
*cmd, check_exit_code=True)
|
||||
|
||||
def test_extend_share(self):
|
||||
new_size = "fake_size"
|
||||
self._driver._set_share_size = mock.Mock()
|
||||
self._driver.extend_share(self.share, new_size)
|
||||
self._driver._set_share_size.assert_called_once_with(
|
||||
self.share, new_size)
|
||||
|
||||
def test__check_hdfs_state_healthy(self):
|
||||
fake_out = "fakeinfo\n...Status: HEALTHY"
|
||||
self._driver._hdfs_execute = mock.Mock(return_value=(fake_out, ''))
|
||||
|
Loading…
x
Reference in New Issue
Block a user