Adding support to extend attached ScaleIO volumes

Implementing necessary mathods and rescaning storage
as necessary to support extending ScaleIO volumes
which are currently attached.

Change-Id: Icb9fc4fe1c16c34d8de9287046045d0837b7e80e
This commit is contained in:
Eric Young 2018-02-16 12:41:30 -05:00
parent e3b969dfd1
commit e500fd8873
3 changed files with 60 additions and 6 deletions

View File

@ -15,6 +15,7 @@
import json import json
import os import os
import requests import requests
import six
from six.moves import urllib from six.moves import urllib
from oslo_concurrency import lockutils from oslo_concurrency import lockutils
@ -39,6 +40,7 @@ class ScaleIOConnector(base.BaseLinuxConnector):
VOLUME_NOT_MAPPED_ERROR = 84 VOLUME_NOT_MAPPED_ERROR = 84
VOLUME_ALREADY_MAPPED_ERROR = 81 VOLUME_ALREADY_MAPPED_ERROR = 81
GET_GUID_CMD = ['/opt/emc/scaleio/sdc/bin/drv_cfg', '--query_guid'] GET_GUID_CMD = ['/opt/emc/scaleio/sdc/bin/drv_cfg', '--query_guid']
RESCAN_VOLS_CMD = ['/opt/emc/scaleio/sdc/bin/drv_cfg', '--rescan']
def __init__(self, root_helper, driver=None, def __init__(self, root_helper, driver=None,
device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT, device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
@ -488,5 +490,45 @@ class ScaleIOConnector(base.BaseLinuxConnector):
raise exception.BrickException(message=msg) raise exception.BrickException(message=msg)
def extend_volume(self, connection_properties): def extend_volume(self, connection_properties):
# TODO(walter-boring): is this possible? """Update the local kernel's size information.
raise NotImplementedError
Try and update the local kernel's size information
for a ScaleIO volume.
"""
LOG.info("ScaleIO rescan volumes: %(cmd)s",
{'cmd': self.RESCAN_VOLS_CMD})
try:
(out, err) = self._execute(*self.RESCAN_VOLS_CMD, run_as_root=True,
root_helper=self._root_helper)
LOG.debug("Rescan volumes %(cmd)s: stdout=%(out)s",
{'cmd': self.RESCAN_VOLS_CMD, 'out': out})
except putils.ProcessExecutionError as e:
msg = (_("Error querying volumes: %(err)s") % {'err': e.stderr})
LOG.error(msg)
raise exception.BrickException(message=msg)
volume_paths = self.get_volume_paths(connection_properties)
if volume_paths:
return self.get_device_size(volume_paths[0])
# if we got here, the volume is not mapped
msg = (_("Error extending ScaleIO volume"))
LOG.error(msg)
raise exception.BrickException(message=msg)
def get_device_size(self, device):
"""Get the size in bytes of a volume."""
(out, _err) = self._execute('blockdev', '--getsize64',
device, run_as_root=True,
root_helper=self._root_helper)
var = six.text_type(out.strip())
LOG.debug("Device %(dev)s size: %(var)s",
{'dev': device, 'var': var})
if var.isnumeric():
return int(var)
else:
return None

View File

@ -267,7 +267,16 @@ class ScaleIOConnectorTestCase(test_connector.ConnectorTestCase):
self.test_disconnect_volume() self.test_disconnect_volume()
def test_extend_volume(self): @mock.patch.object(os.path, 'exists', return_value=True)
self.assertRaises(NotImplementedError, @mock.patch.object(scaleio.ScaleIOConnector, '_find_volume_path')
self.connector.extend_volume, @mock.patch.object(scaleio.ScaleIOConnector, 'get_device_size')
self.fake_connection_properties) def test_extend_volume(self,
mock_device_size,
mock_find_volume_path,
mock_exists):
mock_device_size.return_value = 16
mock_find_volume_path.return_value = "emc-vol-vol1"
extended_size = self.connector.extend_volume(
self.fake_connection_properties)
self.assertEqual(extended_size,
mock_device_size.return_value)

View File

@ -0,0 +1,3 @@
---
features:
- Added ability to extend attached ScaleIO volumes