diff --git a/manila/share/drivers/ibm/gpfs.py b/manila/share/drivers/ibm/gpfs.py index ae139e5471..485d75ce57 100644 --- a/manila/share/drivers/ibm/gpfs.py +++ b/manila/share/drivers/ibm/gpfs.py @@ -139,6 +139,10 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, self.sshpool = None self.ssh_connections = {} self._gpfs_execute = None + if self.configuration.is_gpfs_node: + self.GPFS_PATH = '' + else: + self.GPFS_PATH = '/usr/lpp/mmfs/bin/' def do_setup(self, context): """Any initialization the share driver does while starting.""" @@ -236,7 +240,7 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, def _check_gpfs_state(self): try: - out, __ = self._gpfs_execute('mmgetstate', '-Y') + out, __ = self._gpfs_execute(self.GPFS_PATH + 'mmgetstate', '-Y') except exception.ProcessExecutionError as e: msg = (_('Failed to check GPFS state. Error: %(excmsg)s.') % {'excmsg': e}) @@ -269,7 +273,7 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, def _is_gpfs_path(self, directory): try: - self._gpfs_execute('mmlsattr', directory) + self._gpfs_execute(self.GPFS_PATH + 'mmlsattr', directory) except exception.ProcessExecutionError as e: msg = (_('%(dir)s is not on GPFS filesystem. Error: %(excmsg)s.') % {'dir': directory, 'excmsg': e}) @@ -320,8 +324,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, # create fileset for the share, link it to root path and set max size try: - self._gpfs_execute('mmcrfileset', fsdev, sharename, - '--inode-space', 'new') + self._gpfs_execute(self.GPFS_PATH + 'mmcrfileset', fsdev, + sharename, '--inode-space', 'new') except exception.ProcessExecutionError as e: msg = (_('Failed to create fileset on %(fsdev)s for ' 'the share %(sharename)s. Error: %(excmsg)s.') % @@ -331,8 +335,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, raise exception.GPFSException(msg) try: - self._gpfs_execute('mmlinkfileset', fsdev, sharename, '-J', - sharepath) + self._gpfs_execute(self.GPFS_PATH + 'mmlinkfileset', fsdev, + sharename, '-J', sharepath) except exception.ProcessExecutionError as e: msg = (_('Failed to link fileset for the share %(sharename)s. ' 'Error: %(excmsg)s.') % @@ -341,8 +345,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, raise exception.GPFSException(msg) try: - self._gpfs_execute('mmsetquota', fsdev + ':' + sharename, - '--block', '0:' + sizestr) + self._gpfs_execute(self.GPFS_PATH + 'mmsetquota', fsdev + ':' + + sharename, '--block', '0:' + sizestr) except exception.ProcessExecutionError as e: msg = (_('Failed to set quota for the share %(sharename)s. ' 'Error: %(excmsg)s.') % @@ -373,7 +377,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, # unlink and delete the share's fileset try: - self._gpfs_execute('mmunlinkfileset', fsdev, sharename, '-f', + self._gpfs_execute(self.GPFS_PATH + 'mmunlinkfileset', fsdev, + sharename, '-f', ignore_exit_code=ignore_exit_code) except exception.ProcessExecutionError as e: msg = (_('Failed unlink fileset for share %(sharename)s. ' @@ -383,7 +388,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, raise exception.GPFSException(msg) try: - self._gpfs_execute('mmdelfileset', fsdev, sharename, '-f', + self._gpfs_execute(self.GPFS_PATH + 'mmdelfileset', fsdev, + sharename, '-f', ignore_exit_code=ignore_exit_code) except exception.ProcessExecutionError as e: msg = (_('Failed delete fileset for share %(sharename)s. ' @@ -420,8 +426,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, ) try: - self._gpfs_execute('mmcrsnapshot', fsdev, snapshot['name'], - '-j', sharename) + self._gpfs_execute(self.GPFS_PATH + 'mmcrsnapshot', fsdev, + snapshot['name'], '-j', sharename) except exception.ProcessExecutionError as e: msg = (_('Failed to create snapshot %(snapshot)s. ' 'Error: %(excmsg)s.') % @@ -435,8 +441,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, fsdev = self._get_gpfs_device() try: - self._gpfs_execute('mmdelsnapshot', fsdev, snapshot['name'], - '-j', sharename) + self._gpfs_execute(self.GPFS_PATH + 'mmdelsnapshot', fsdev, + snapshot['name'], '-j', sharename) except exception.ProcessExecutionError as e: msg = (_('Failed to delete snapshot %(snapshot)s. ' 'Error: %(excmsg)s.') % @@ -464,8 +470,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, sizestr = '%sG' % new_size fsdev = self._get_gpfs_device() try: - self._gpfs_execute('mmsetquota', fsdev + ':' + sharename, - '--block', '0:' + sizestr) + self._gpfs_execute(self.GPFS_PATH + 'mmsetquota', fsdev + ':' + + sharename, '--block', '0:' + sizestr) except exception.ProcessExecutionError as e: msg = (_('Failed to set quota for the share %(sharename)s. ' 'Error: %(excmsg)s.') % @@ -571,8 +577,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, def _is_share_valid(self, fsdev, location): try: - out, __ = self._gpfs_execute('mmlsfileset', fsdev, '-J', - location, '-L', '-Y') + out, __ = self._gpfs_execute(self.GPFS_PATH + 'mmlsfileset', fsdev, + '-J', location, '-L', '-Y') except exception.ProcessExecutionError: msg = (_('Given share path %(share_path)s does not exist at ' 'mount point %(mount_point)s.') @@ -593,8 +599,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, def _get_share_name(self, fsdev, location): try: - out, __ = self._gpfs_execute('mmlsfileset', fsdev, '-J', - location, '-L', '-Y') + out, __ = self._gpfs_execute(self.GPFS_PATH + 'mmlsfileset', fsdev, + '-J', location, '-L', '-Y') except exception.ProcessExecutionError: msg = (_('Given share path %(share_path)s does not exist at ' 'mount point %(mount_point)s.') @@ -617,7 +623,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, new_share_name = share['name'] new_export_location = self._local_path(new_share_name) try: - self._gpfs_execute('mmunlinkfileset', fsdev, old_share_name, '-f') + self._gpfs_execute(self.GPFS_PATH + 'mmunlinkfileset', fsdev, + old_share_name, '-f') except exception.ProcessExecutionError: msg = _('Failed to unlink fileset for share %s.') % new_share_name LOG.exception(msg) @@ -625,8 +632,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, LOG.debug('Unlinked the fileset of share %s.', old_share_name) try: - self._gpfs_execute('mmchfileset', fsdev, old_share_name, - '-j', new_share_name) + self._gpfs_execute(self.GPFS_PATH + 'mmchfileset', fsdev, + old_share_name, '-j', new_share_name) except exception.ProcessExecutionError: msg = _('Failed to rename fileset for share %s.') % new_share_name LOG.exception(msg) @@ -635,8 +642,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, {'old_share': old_share_name, 'new_share': new_share_name}) try: - self._gpfs_execute('mmlinkfileset', fsdev, new_share_name, '-J', - new_export_location) + self._gpfs_execute(self.GPFS_PATH + 'mmlinkfileset', fsdev, + new_share_name, '-J', new_export_location) except exception.ProcessExecutionError: msg = _('Failed to link fileset for the share %s.' ) % new_share_name @@ -656,8 +663,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, LOG.debug('Changed the permission of share %s.', new_share_name) try: - out, __ = self._gpfs_execute('mmlsquota', '-j', new_share_name, - '-Y', fsdev) + out, __ = self._gpfs_execute(self.GPFS_PATH + 'mmlsquota', '-j', + new_share_name, '-Y', fsdev) except exception.ProcessExecutionError: msg = _('Failed to check size for share %s.') % new_share_name LOG.exception(msg) @@ -678,8 +685,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, # (units.Mi * KB = 1GB) if share_size < units.Mi: try: - self._gpfs_execute('mmsetquota', fsdev + ':' + new_share_name, - '--block', '0:1G') + self._gpfs_execute(self.GPFS_PATH + 'mmsetquota', fsdev + ':' + + new_share_name, '--block', '0:1G') except exception.ProcessExecutionError: msg = _('Failed to set quota for share %s.') % new_share_name LOG.exception(msg) @@ -693,8 +700,8 @@ class GPFSShareDriver(driver.ExecuteMixin, driver.GaneshaMixin, share_size = int(math.ceil(float(share_size) / units.Mi)) if orig_share_size != share_size * units.Mi: try: - self._gpfs_execute('mmsetquota', fsdev + ':' + - new_share_name, '--block', '0:' + + self._gpfs_execute(self.GPFS_PATH + 'mmsetquota', fsdev + + ':' + new_share_name, '--block', '0:' + str(share_size) + 'G') except exception.ProcessExecutionError: msg = _('Failed to set quota for share %s.' @@ -1027,10 +1034,14 @@ class CESHelper(NASHelperBase): def __init__(self, execute, config_object): super(CESHelper, self).__init__(execute, config_object) self._execute = execute + if self.configuration.is_gpfs_node: + self.GPFS_PATH = '' + else: + self.GPFS_PATH = '/usr/lpp/mmfs/bin/' def _execute_mmnfs_command(self, cmd, err_msg): try: - out, __ = self._execute('mmnfs', 'export', *cmd) + out, __ = self._execute(self.GPFS_PATH + 'mmnfs', 'export', *cmd) except exception.ProcessExecutionError as e: msg = (_('%(err_msg)s Error: %(e)s.') % {'err_msg': err_msg, 'e': e}) diff --git a/manila/tests/share/drivers/ibm/test_gpfs.py b/manila/tests/share/drivers/ibm/test_gpfs.py index 2325d4008b..18ca94979d 100644 --- a/manila/tests/share/drivers/ibm/test_gpfs.py +++ b/manila/tests/share/drivers/ibm/test_gpfs.py @@ -42,6 +42,7 @@ class GPFSShareDriverTestCase(test.TestCase): super(GPFSShareDriverTestCase, self).setUp() self._context = context.get_admin_context() self._gpfs_execute = mock.Mock(return_value=('', '')) + self.GPFS_PATH = '/usr/lpp/mmfs/bin/' self._helper_fake = mock.Mock() CONF.set_default('driver_handles_share_servers', False) @@ -398,8 +399,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._gpfs_execute = mock.Mock(return_value=0) self._driver._delete_share_snapshot(self.snapshot) self._driver._gpfs_execute.assert_called_once_with( - 'mmdelsnapshot', self.fakedev, self.snapshot['name'], - '-j', self.snapshot['share_name'] + self.GPFS_PATH + 'mmdelsnapshot', self.fakedev, + self.snapshot['name'], '-j', self.snapshot['share_name'] ) self._driver._get_gpfs_device.assert_called_once_with() @@ -412,8 +413,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._delete_share_snapshot, self.snapshot) self._driver._get_gpfs_device.assert_called_once_with() self._driver._gpfs_execute.assert_called_once_with( - 'mmdelsnapshot', self.fakedev, self.snapshot['name'], - '-j', self.snapshot['share_name'] + self.GPFS_PATH + 'mmdelsnapshot', self.fakedev, + self.snapshot['name'], '-j', self.snapshot['share_name'] ) def test_extend_share(self): @@ -426,10 +427,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._gpfs_execute = mock.Mock(return_value=True) self._driver._extend_share(self.share, 10) self._driver._gpfs_execute.assert_called_once_with( - 'mmsetquota', - self.fakedev + ':' + self.share['name'], - '--block', - '0:10G') + self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:10G') self._driver._get_gpfs_device.assert_called_once_with() def test__extend_share_exception(self): @@ -439,12 +438,9 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl ) self.assertRaises(exception.GPFSException, self._driver._extend_share, self.share, 10) - self._driver._gpfs_execute.assert_called_once_with('mmsetquota', - self.fakedev + - ':' + - self.share['name'], - '--block', - '0:10G') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:10G') self._driver._get_gpfs_device.assert_called_once_with() def test_update_access_allow(self): @@ -535,14 +531,16 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl fakeout = "mmgetstate::state:\nmmgetstate::active:" self._driver._gpfs_execute = mock.Mock(return_value=(fakeout, '')) result = self._driver._check_gpfs_state() - self._driver._gpfs_execute.assert_called_once_with('mmgetstate', '-Y') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmgetstate', '-Y') self.assertEqual(result, True) def test__check_gpfs_state_down(self): fakeout = "mmgetstate::state:\nmmgetstate::down:" self._driver._gpfs_execute = mock.Mock(return_value=(fakeout, '')) result = self._driver._check_gpfs_state() - self._driver._gpfs_execute.assert_called_once_with('mmgetstate', '-Y') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmgetstate', '-Y') self.assertEqual(result, False) def test__check_gpfs_state_wrong_output_exception(self): @@ -550,7 +548,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._gpfs_execute = mock.Mock(return_value=(fakeout, '')) self.assertRaises(exception.GPFSException, self._driver._check_gpfs_state) - self._driver._gpfs_execute.assert_called_once_with('mmgetstate', '-Y') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmgetstate', '-Y') def test__check_gpfs_state_exception(self): self._driver._gpfs_execute = mock.Mock( @@ -558,7 +557,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl ) self.assertRaises(exception.GPFSException, self._driver._check_gpfs_state) - self._driver._gpfs_execute.assert_called_once_with('mmgetstate', '-Y') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmgetstate', '-Y') def test__is_dir_success(self): fakeoutput = "directory" @@ -591,8 +591,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl def test__is_gpfs_path_ok(self): self._driver._gpfs_execute = mock.Mock(return_value=0) result = self._driver._is_gpfs_path(self.fakefspath) - self._driver._gpfs_execute.assert_called_once_with('mmlsattr', - self.fakefspath) + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmlsattr', self.fakefspath) self.assertEqual(result, True) def test__is_gpfs_path_exception(self): @@ -602,8 +602,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.assertRaises(exception.GPFSException, self._driver._is_gpfs_path, self.fakefspath) - self._driver._gpfs_execute.assert_called_once_with('mmlsattr', - self.fakefspath) + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmlsattr', self.fakefspath) def test__get_gpfs_device(self): fakeout = "Filesystem\n" + self.fakedev @@ -628,20 +628,17 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path = mock.Mock(return_value=self.fakesharepath) self._driver._get_gpfs_device = mock.Mock(return_value=self.fakedev) self._driver._create_share(self.share) - self._driver._gpfs_execute.assert_any_call('mmcrfileset', - self.fakedev, - self.share['name'], - '--inode-space', 'new') - self._driver._gpfs_execute.assert_any_call('mmlinkfileset', - self.fakedev, - self.share['name'], - '-J', self.fakesharepath) - self._driver._gpfs_execute.assert_any_call('mmsetquota', self.fakedev + - ':' + self.share['name'], - '--block', '0:' + sizestr) - self._driver._gpfs_execute.assert_any_call('chmod', - '777', - self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmcrfileset', self.fakedev, self.share['name'], + '--inode-space', 'new') + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmlinkfileset', self.fakedev, self.share['name'], + '-J', self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:' + sizestr) + self._driver._gpfs_execute.assert_any_call( + 'chmod', '777', self.fakesharepath) self._driver._local_path.assert_called_once_with(self.share['name']) self._driver._get_gpfs_device.assert_called_once_with() @@ -656,21 +653,19 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._create_share, self.share) self._driver._get_gpfs_device.assert_called_once_with() self._driver._local_path.assert_called_once_with(self.share['name']) - self._driver._gpfs_execute.assert_called_once_with('mmcrfileset', - self.fakedev, - self.share['name'], - '--inode-space', - 'new') + self._driver._gpfs_execute.assert_called_once_with( + self.GPFS_PATH + 'mmcrfileset', self.fakedev, self.share['name'], + '--inode-space', 'new') def test__delete_share(self): self._driver._gpfs_execute = mock.Mock(return_value=True) self._driver._get_gpfs_device = mock.Mock(return_value=self.fakedev) self._driver._delete_share(self.share) self._driver._gpfs_execute.assert_any_call( - 'mmunlinkfileset', self.fakedev, self.share['name'], - '-f', ignore_exit_code=[2]) + self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.share['name'], '-f', ignore_exit_code=[2]) self._driver._gpfs_execute.assert_any_call( - 'mmdelfileset', self.fakedev, self.share['name'], + self.GPFS_PATH + 'mmdelfileset', self.fakedev, self.share['name'], '-f', ignore_exit_code=[2]) self._driver._get_gpfs_device.assert_called_once_with() @@ -683,16 +678,16 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._delete_share, self.share) self._driver._get_gpfs_device.assert_called_once_with() self._driver._gpfs_execute.assert_called_once_with( - 'mmunlinkfileset', self.fakedev, self.share['name'], - '-f', ignore_exit_code=[2]) + self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.share['name'], '-f', ignore_exit_code=[2]) def test__create_share_snapshot(self): self._driver._gpfs_execute = mock.Mock(return_value=True) self._driver._get_gpfs_device = mock.Mock(return_value=self.fakedev) self._driver._create_share_snapshot(self.snapshot) self._driver._gpfs_execute.assert_called_once_with( - 'mmcrsnapshot', self.fakedev, self.snapshot['name'], - '-j', self.snapshot['share_name'] + self.GPFS_PATH + 'mmcrsnapshot', self.fakedev, + self.snapshot['name'], '-j', self.snapshot['share_name'] ) self._driver._get_gpfs_device.assert_called_once_with() @@ -705,8 +700,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._create_share_snapshot, self.snapshot) self._driver._get_gpfs_device.assert_called_once_with() self._driver._gpfs_execute.assert_called_once_with( - 'mmcrsnapshot', self.fakedev, self.snapshot['name'], - '-j', self.snapshot['share_name'] + self.GPFS_PATH + 'mmcrsnapshot', self.fakedev, + self.snapshot['name'], '-j', self.snapshot['share_name'] ) def test__create_share_from_snapshot(self): @@ -746,7 +741,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl result = self._driver._is_share_valid(self.fakedev, self.fakesharepath) self._driver._gpfs_execute.assert_called_once_with( - 'mmlsfileset', self.fakedev, '-J', self.fakesharepath, '-L', '-Y') + self.GPFS_PATH + 'mmlsfileset', self.fakedev, '-J', + self.fakesharepath, '-L', '-Y') if fakeout == "mmlsfileset::allocInodes:\nmmlsfileset::100096:": self.assertTrue(result) else: @@ -761,7 +757,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.fakesharepath) self._driver._gpfs_execute.assert_called_once_with( - 'mmlsfileset', self.fakedev, '-J', self.fakesharepath, '-L', '-Y') + self.GPFS_PATH + 'mmlsfileset', self.fakedev, '-J', + self.fakesharepath, '-L', '-Y') def test__is_share_valid_no_share_exist_exception(self): fakeout = "mmlsfileset::allocInodes:" @@ -772,7 +769,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.fakesharepath) self._driver._gpfs_execute.assert_called_once_with( - 'mmlsfileset', self.fakedev, '-J', self.fakesharepath, '-L', '-Y') + self.GPFS_PATH + 'mmlsfileset', self.fakedev, '-J', + self.fakesharepath, '-L', '-Y') def test__get_share_name(self): fakeout = "mmlsfileset::filesetName:\nmmlsfileset::existingshare:" @@ -791,7 +789,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.fakesharepath) self._driver._gpfs_execute.assert_called_once_with( - 'mmlsfileset', self.fakedev, '-J', self.fakesharepath, '-L', '-Y') + self.GPFS_PATH + 'mmlsfileset', self.fakedev, '-J', + self.fakesharepath, '-L', '-Y') def test__get_share_name_no_share_exist_exception(self): fakeout = "mmlsfileset::filesetName:" @@ -802,7 +801,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.fakesharepath) self._driver._gpfs_execute.assert_called_once_with( - 'mmlsfileset', self.fakedev, '-J', self.fakesharepath, '-L', '-Y') + self.GPFS_PATH + 'mmlsfileset', self.fakedev, '-J', + self.fakesharepath, '-L', '-Y') @ddt.data("mmlsquota::blockLimit:\nmmlsquota::1048577", "mmlsquota::blockLimit:\nmmlsquota::1048576", @@ -815,35 +815,27 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl actual_size, actual_path = self._driver._manage_existing( self.fakedev, self.share, self.fakeexistingshare) - self._driver._gpfs_execute.assert_any_call('mmunlinkfileset', - self.fakedev, - self.fakeexistingshare, - '-f') - self._driver._gpfs_execute.assert_any_call('mmchfileset', - self.fakedev, - self.fakeexistingshare, - '-j', self.share['name']) - self._driver._gpfs_execute.assert_any_call('mmlinkfileset', - self.fakedev, - self.share['name'], - '-J', self.fakesharepath) - self._driver._gpfs_execute.assert_any_call('chmod', - '777', - self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f') + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmlinkfileset', self.fakedev, self.share['name'], + '-J', self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + 'chmod', '777', self.fakesharepath) if fakeout == "mmlsquota::blockLimit:\nmmlsquota::1048577": - self._driver._gpfs_execute.assert_called_with('mmsetquota', - self.fakedev + ':' + - self.share['name'], - '--block', - '0:2G') + self._driver._gpfs_execute.assert_called_with( + self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:2G') self.assertEqual(2, actual_size) self.assertEqual('fakelocation', actual_path) elif fakeout == "mmlsquota::blockLimit:\nmmlsquota::0": - self._driver._gpfs_execute.assert_called_with('mmsetquota', - self.fakedev + ':' + - self.share['name'], - '--block', - '0:1G') + self._driver._gpfs_execute.assert_called_with( + self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:1G') self.assertEqual(1, actual_size) self.assertEqual('fakelocation', actual_path) else: @@ -861,7 +853,8 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_called_once_with(self.share['name']) self._driver._gpfs_execute.assert_called_once_with( - 'mmunlinkfileset', self.fakedev, self.fakeexistingshare, '-f') + self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f') def test__manage_existing_fileset_creation_exception(self): self._driver._local_path = mock.Mock(return_value=self.fakesharepath) @@ -874,10 +867,10 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name'])]) + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name'])]) def test__manage_existing_fileset_relink_exception(self): self._driver._local_path = mock.Mock(return_value=self.fakesharepath) @@ -890,12 +883,12 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name']), - mock.call('mmlinkfileset', self.fakedev, self.share['name'], '-J', - self.fakesharepath)]) + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']), + mock.call(self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath)]) def test__manage_existing_permission_change_exception(self): self._driver._local_path = mock.Mock(return_value=self.fakesharepath) @@ -908,12 +901,12 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name']), - mock.call('mmlinkfileset', self.fakedev, self.share['name'], '-J', - self.fakesharepath), + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']), + mock.call(self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath), mock.call('chmod', '777', self.fakesharepath)]) def test__manage_existing_checking_quota_of_fileset_exception(self): @@ -927,15 +920,15 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name']), - mock.call('mmlinkfileset', self.fakedev, self.share['name'], '-J', - self.fakesharepath), + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']), + mock.call(self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath), mock.call('chmod', '777', self.fakesharepath), - mock.call('mmlsquota', '-j', self.share['name'], '-Y', - self.fakedev)]) + mock.call(self.GPFS_PATH + 'mmlsquota', '-j', self.share['name'], + '-Y', self.fakedev)]) def test__manage_existing_unable_to_get_quota_of_fileset_exception(self): fakeout = "mmlsquota::blockLimit:" @@ -947,23 +940,20 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.share, self.fakeexistingshare) self._driver._local_path.assert_any_call(self.share['name']) - self._driver._gpfs_execute.assert_any_call('mmunlinkfileset', - self.fakedev, - self.fakeexistingshare, - '-f') - self._driver._gpfs_execute.assert_any_call('mmchfileset', - self.fakedev, - self.fakeexistingshare, - '-j', self.share['name']) - self._driver._gpfs_execute.assert_any_call('mmlinkfileset', - self.fakedev, - self.share['name'], - '-J', self.fakesharepath) - self._driver._gpfs_execute.assert_any_call('chmod', - '777', - self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f') + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']) + self._driver._gpfs_execute.assert_any_call( + self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath) + self._driver._gpfs_execute.assert_any_call( + 'chmod', '777', self.fakesharepath) self._driver._gpfs_execute.assert_called_with( - 'mmlsquota', '-j', self.share['name'], '-Y', self.fakedev) + self.GPFS_PATH + 'mmlsquota', '-j', self.share['name'], + '-Y', self.fakedev) def test__manage_existing_set_quota_of_fileset_less_than_1G_exception( self): @@ -980,17 +970,17 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name']), - mock.call('mmlinkfileset', self.fakedev, self.share['name'], '-J', - self.fakesharepath), + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']), + mock.call(self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath), mock.call('chmod', '777', self.fakesharepath), - mock.call('mmlsquota', '-j', self.share['name'], '-Y', - self.fakedev), - mock.call('mmsetquota', self.fakedev + ':' + self.share['name'], - '--block', '0:' + sizestr)]) + mock.call(self.GPFS_PATH + 'mmlsquota', '-j', self.share['name'], + '-Y', self.fakedev), + mock.call(self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:' + sizestr)]) def test__manage_existing_set_quota_of_fileset_grater_than_1G_exception( self): @@ -1007,17 +997,17 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._driver._local_path.assert_any_call(self.share['name']) self._driver._gpfs_execute.assert_has_calls([ - mock.call('mmunlinkfileset', self.fakedev, self.fakeexistingshare, - '-f'), - mock.call('mmchfileset', self.fakedev, self.fakeexistingshare, - '-j', self.share['name']), - mock.call('mmlinkfileset', self.fakedev, self.share['name'], '-J', - self.fakesharepath), + mock.call(self.GPFS_PATH + 'mmunlinkfileset', self.fakedev, + self.fakeexistingshare, '-f'), + mock.call(self.GPFS_PATH + 'mmchfileset', self.fakedev, + self.fakeexistingshare, '-j', self.share['name']), + mock.call(self.GPFS_PATH + 'mmlinkfileset', self.fakedev, + self.share['name'], '-J', self.fakesharepath), mock.call('chmod', '777', self.fakesharepath), - mock.call('mmlsquota', '-j', self.share['name'], '-Y', - self.fakedev), - mock.call('mmsetquota', self.fakedev + ':' + self.share['name'], - '--block', '0:' + sizestr)]) + mock.call(self.GPFS_PATH + 'mmlsquota', '-j', self.share['name'], + '-Y', self.fakedev), + mock.call(self.GPFS_PATH + 'mmsetquota', self.fakedev + ':' + + self.share['name'], '--block', '0:' + sizestr)]) def test_manage_existing(self): self._driver._manage_existing = mock.Mock(return_value=('1', @@ -1417,7 +1407,7 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl local_path) self._ces_helper._execute.assert_called_once_with( - 'mmnfs', 'export', 'list', '-n', local_path, '-Y') + self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', local_path, '-Y') @ddt.data('44.3.2.11', '1:2:3:4:5:6:7:8') def test__fix_export_data(self, ip): @@ -1456,7 +1446,7 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper._has_client_access(local_path, ip)) self._ces_helper._execute.assert_called_once_with( - 'mmnfs', 'export', 'list', '-n', local_path, '-Y') + self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', local_path, '-Y') def test_ces_remove_export_no_exports(self): mock_out = self.fake_ces_exports_not_found @@ -1467,7 +1457,7 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.remove_export(local_path, self.share) self._ces_helper._execute.assert_called_once_with( - 'mmnfs', 'export', 'list', '-n', local_path, '-Y') + self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', local_path, '-Y') def test_ces_remove_export_existing_exports(self): mock_out = self.fake_ces_exports @@ -1478,8 +1468,10 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.remove_export(local_path, self.share) self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'remove', local_path), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'remove', + local_path), ]) def test_ces_remove_export_exception(self): @@ -1505,9 +1497,10 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.allow_access(local_path, self.share, access) self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'add', local_path, '-c', - access['access_to'] + '(' + export_opts + ')')]) + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'add', local_path, + '-c', access['access_to'] + '(' + export_opts + ')')]) def test_ces_allow_access_existing_exports(self): mock_out = self.fake_ces_exports @@ -1525,9 +1518,11 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self.access) self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'change', local_path, '--nfsadd', - access['access_to'] + '(' + export_opts + ')')]) + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'change', local_path, + '--nfsadd', access['access_to'] + '(' + + export_opts + ')')]) def test_ces_allow_access_invalid_access_type(self): access = fake_share.fake_access(access_type='test') @@ -1556,9 +1551,10 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.deny_access(local_path, self.share, access) self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'change', local_path, '--nfsremove', - access['access_to'])]) + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'change', local_path, + '--nfsremove', access['access_to'])]) def test_ces_deny_access_exception(self): access = self.access @@ -1580,9 +1576,11 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.resync_access(local_path, self.share, access_rules) self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'add', local_path, '-c', - self.access['access_to'] + '(' + "access_type=rw" + ')') + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'add', local_path, + '-c', self.access['access_to'] + '(' + "access_type=rw" + + ')') ]) share_types.get_extra_specs_from_share.assert_called_once_with( self.share) @@ -1618,8 +1616,9 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl to_add = access_rules[0]['access_to'] + '(' + "access_type=rw" + ')' to_change = access_rules[1]['access_to'] + '(' + "access_type=ro" + ')' self._ces_helper._execute.assert_has_calls([ - mock.call('mmnfs', 'export', 'list', '-n', local_path, '-Y'), - mock.call('mmnfs', 'export', 'change', local_path, + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', + local_path, '-Y'), + mock.call(self.GPFS_PATH + 'mmnfs', 'export', 'change', local_path, '--nfsremove', SortedMatch(self.assertEqual, to_remove), '--nfsadd', to_add, '--nfschange', to_change) @@ -1634,4 +1633,4 @@ mmcesnfslsexport:nfsexports:HEADER:version:reserved:reserved:Path:Delegations:Cl self._ces_helper.resync_access(local_path, None, []) self._ces_helper._execute.assert_called_once_with( - 'mmnfs', 'export', 'list', '-n', local_path, '-Y') + self.GPFS_PATH + 'mmnfs', 'export', 'list', '-n', local_path, '-Y') diff --git a/releasenotes/notes/bug-1690785-fix-gpfs-path-91a354bc69bf6a47.yaml b/releasenotes/notes/bug-1690785-fix-gpfs-path-91a354bc69bf6a47.yaml new file mode 100644 index 0000000000..3d33594317 --- /dev/null +++ b/releasenotes/notes/bug-1690785-fix-gpfs-path-91a354bc69bf6a47.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Fixed the prerequisite of GPFS path export needed for initializing driver.