Skip to content

Commit

Permalink
Sync with upstream (Nexenta#208)
Browse files Browse the repository at this point in the history
* Sync with upstream

* Sync with upstream Nexenta#2
  • Loading branch information
deiter authored Mar 8, 2019
1 parent 32ce2e9 commit 55ec52d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
26 changes: 14 additions & 12 deletions cinder/tests/unit/volume/drivers/nexenta/test_nexenta5_nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,12 @@ def test__delete(self, rmdir):
@mock.patch('cinder.volume.drivers.nexenta.ns5.'
'nfs.NexentaNfsDriver._unmount_volume')
@mock.patch('oslo_concurrency.processutils.execute')
@mock.patch('cinder.privsep.fs.truncate')
@mock.patch('cinder.volume.drivers.nexenta.ns5.'
'nfs.NexentaNfsDriver.local_path')
@mock.patch('cinder.volume.drivers.nexenta.ns5.'
'nfs.NexentaNfsDriver._mount_volume')
def test_extend_volume(self, mount_volume, get_volume_local_path,
truncate_file, dd_command, unmount_volume):
execute_command, unmount_volume):
volume = fake_volume(self.ctxt)
root_helper = 'sudo cinder-rootwrap /etc/cinder/rootwrap.conf'
local_path = '/path/to/volume/file'
Expand All @@ -461,21 +460,24 @@ def test_extend_volume(self, mount_volume, get_volume_local_path,
count = (new_size - volume['size']) * units.Ki
mount_volume.return_value = True
get_volume_local_path.return_value = local_path
execute_command.return_value = True
unmount_volume.return_value = True
with mock.patch.object(self.drv, 'sparsed_volumes', False):
dd_command.return_value = True
self.assertIsNone(self.drv.extend_volume(volume, new_size))
dd_command.assert_called_with('dd', 'if=/dev/zero',
'of=%s' % local_path,
'bs=%d' % bs,
'seek=%d' % seek,
'count=%d' % count,
run_as_root=True,
root_helper=root_helper)
execute_command.assert_called_with('dd', 'if=/dev/zero',
'of=%s' % local_path,
'bs=%d' % bs,
'seek=%d' % seek,
'count=%d' % count,
run_as_root=True,
root_helper=root_helper)
with mock.patch.object(self.drv, 'sparsed_volumes', True):
truncate_file.return_value = True
self.assertIsNone(self.drv.extend_volume(volume, new_size))
truncate_file.assert_called_with('%dG' % new_size, local_path)
execute_command.assert_called_with('truncate', '-s',
'%dG' % new_size,
local_path,
run_as_root=True,
root_helper=root_helper)
mount_volume.assert_called_with(volume)
unmount_volume.assert_called_with(volume)

Expand Down
8 changes: 8 additions & 0 deletions cinder/volume/drivers/nexenta/ns5/iscsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ def __init__(self, *args, **kwargs):
self.origin_snapshot_template = (
self.configuration.nexenta_origin_snapshot_template)

@staticmethod
def get_driver_options():
return (
options.NEXENTA_CONNECTION_OPTS +
options.NEXENTA_ISCSI_OPTS +
options.NEXENTA_DATASET_OPTS
)

def do_setup(self, context):
self.nef = jsonrpc.NefProxy(self.driver_volume_type,
self.root_path,
Expand Down
13 changes: 12 additions & 1 deletion cinder/volume/drivers/nexenta/ns5/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ def __init__(self, *args, **kwargs):
self.origin_snapshot_template = (
self.configuration.nexenta_origin_snapshot_template)

@staticmethod
def get_driver_options():
return (
options.NEXENTA_CONNECTION_OPTS +
options.NEXENTA_NFS_OPTS +
options.NEXENTA_DATASET_OPTS
)

def do_setup(self, context):
self.nef = jsonrpc.NefProxy(self.driver_volume_type,
self.root_path,
Expand Down Expand Up @@ -463,7 +471,10 @@ def extend_volume(self, volume, new_size):
self._mount_volume(volume)
volume_file = self.local_path(volume)
if self.sparsed_volumes:
fs.truncate('%dG' % new_size, volume_file)
self._execute('truncate', '-s',
'%dG' % new_size,
volume_file,
run_as_root=True)
else:
seek = volume['size'] * units.Ki
count = (new_size - volume['size']) * units.Ki
Expand Down

0 comments on commit 55ec52d

Please sign in to comment.