Hello community, here is the log from the commit of package salt-shaptools for openSUSE:Factory checked in at 2019-12-16 15:20:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/salt-shaptools (Old) and /work/SRC/openSUSE:Factory/.salt-shaptools.new.4691 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "salt-shaptools" Mon Dec 16 15:20:47 2019 rev:6 rq:757272 version:0.2.6 Changes: -------- --- /work/SRC/openSUSE:Factory/salt-shaptools/salt-shaptools.changes 2019-12-09 21:36:05.962077454 +0100 +++ /work/SRC/openSUSE:Factory/.salt-shaptools.new.4691/salt-shaptools.changes 2019-12-16 15:20:48.487128181 +0100 @@ -1,0 +2,6 @@ +Wed Dec 11 10:16:53 UTC 2019 - Xabier Arbulu <[email protected]> + +- Version 0.2.6 + * Add option to configure multiple sbd disks + +------------------------------------------------------------------- Old: ---- salt-shaptools-0.2.5.tar.gz New: ---- salt-shaptools-0.2.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ salt-shaptools.spec ++++++ --- /var/tmp/diff_new_pack.7bWYX2/_old 2019-12-16 15:20:48.895128011 +0100 +++ /var/tmp/diff_new_pack.7bWYX2/_new 2019-12-16 15:20:48.903128008 +0100 @@ -19,7 +19,7 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.2.5 +Version: 0.2.6 Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management ++++++ salt-shaptools-0.2.5.tar.gz -> salt-shaptools-0.2.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/salt/__init__.py new/salt-shaptools-0.2.6/salt/__init__.py --- old/salt-shaptools-0.2.5/salt/__init__.py 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/salt/__init__.py 2019-12-16 09:03:42.874852476 +0100 @@ -6,4 +6,4 @@ :since: 2018-11-30 """ -__version__ = "0.2.1" +__version__ = "0.2.6" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/salt/modules/crmshmod.py new/salt-shaptools-0.2.6/salt/modules/crmshmod.py --- old/salt-shaptools-0.2.5/salt/modules/crmshmod.py 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/salt/modules/crmshmod.py 2019-12-16 09:03:42.878852476 +0100 @@ -304,7 +304,8 @@ if sbd: cmd = '{cmd} --enable-sbd'.format(cmd=cmd) if sbd_dev: - cmd = '{cmd} -s {sbd_dev}'.format(cmd=cmd, sbd_dev=sbd_dev) + sbd_str = ' '.join(['-s {}'.format(sbd) for sbd in sbd_dev]) + cmd = '{cmd} {sbd_str}'.format(cmd=cmd, sbd_str=sbd_str) if quiet: cmd = '{cmd} -q'.format(cmd=cmd) @@ -334,7 +335,8 @@ if sbd: cmd = '{cmd} -S'.format(cmd=cmd) if sbd_dev: - cmd = '{cmd} -s {sbd_dev}'.format(cmd=cmd, sbd_dev=sbd_dev) + sbd_str = ' '.join(['-s {}'.format(sbd) for sbd in sbd_dev]) + cmd = '{cmd} {sbd_str}'.format(cmd=cmd, sbd_str=sbd_str) if quiet: cmd = '{cmd} -q'.format(cmd=cmd) @@ -346,6 +348,44 @@ return return_code +def _manage_multiple_sbd(sbd_enabled, sbd_dev): + ''' + crmsh doesn't support multiple sbd disk usage by now. This method workaround this scenario + modifying the /etc/syconfig/sbd file before running crmsh + ''' + # sbd disks are managed as list, but individual disk is accepted to be more compatible + if sbd_dev and not isinstance(sbd_dev, list): + sbd_dev = [sbd_dev] + + # return sbd_dev + + if not sbd_enabled or not sbd_dev or len(sbd_dev) == 1: + return sbd_enabled, sbd_dev + + LOGGER.warning('crmsh will say that sbd is not configured') + + sbd_str = ' '.join(['-d {}'.format(sbd) for sbd in sbd_dev]) + cmd = 'sbd {disks} create'.format(disks=sbd_str) + return_code = __salt__['cmd.retcode'](cmd) + if return_code: + raise exceptions.SaltInvocationError('sbd disks could not be formatted properly') + + cmd = '{crm_command} cluster init sbd -s {sbd}'.format(crm_command=CRM_COMMAND, sbd=sbd_dev[0]) + return_code = __salt__['cmd.retcode'](cmd) + if return_code: + raise exceptions.SaltInvocationError('crm cluster init sbd failed') + + __salt__['file.replace']( + path='/etc/sysconfig/sbd', + pattern='^SBD_DEVICE=.*', + repl='SBD_DEVICE={}'.format(';'.join(sbd_dev)), + append_if_not_found=True + ) + + # return None, None to avoid sbd configuration in crmsh + return None, None + + def cluster_init( name, watchdog=None, @@ -384,13 +424,16 @@ salt '*' crm.cluster_init hacluster ''' + # Workaournd while multiple sbd disks are not supported by crmsh + sbd, sbd_dev = _manage_multiple_sbd(sbd, sbd_dev) + # INFO: 2 different methods are created to make easy to read/understand # and create the corresponing UT if __salt__['crm.version']: return _crm_init( name, watchdog, interface, unicast, admin_ip, sbd, sbd_dev, quiet) - LOGGER.warn('The parameter name is not considered!') + LOGGER.warning('The parameter name is not considered!') return _ha_cluster_init( watchdog, interface, unicast, admin_ip, sbd, sbd_dev, quiet) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/salt/states/crmshmod.py new/salt-shaptools-0.2.6/salt/states/crmshmod.py --- old/salt-shaptools-0.2.5/salt/states/crmshmod.py 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/salt/states/crmshmod.py 2019-12-16 09:03:42.878852476 +0100 @@ -123,6 +123,7 @@ sbd_dev sbd device path. To be used "sbd" parameter must be used too. If None, the sbd is set as diskless. + This parameter can be a string (meaning one disk) or a list with multiple disks quiet: execute the command in quiet mode (no output) """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/salt-shaptools.changes new/salt-shaptools-0.2.6/salt-shaptools.changes --- old/salt-shaptools-0.2.5/salt-shaptools.changes 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/salt-shaptools.changes 2019-12-16 09:03:42.878852476 +0100 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Wed Dec 11 10:16:53 UTC 2019 - Xabier Arbulu <[email protected]> + +- Version 0.2.6 + * Add option to configure multiple sbd disks + +------------------------------------------------------------------- Tue Dec 3 06:41:36 UTC 2019 - nick wang <[email protected]> - Version 0.2.5 @@ -18,13 +24,13 @@ Thu Oct 31 14:58:19 UTC 2019 - Xabier Arbulu <[email protected]> - Create package version 0.2.2 updating how additional_dvds is used - in netweavermod + in netweavermod ------------------------------------------------------------------- Wed Aug 7 12:54:03 UTC 2019 - Xabier Arbulu Insausti <[email protected]> - Create first salt modules and states to manage SAP Netweaver - * Install ASCS SAP instance in a idempotent way + * Install ASCS SAP instance in a idempotent way ------------------------------------------------------------------- Tue Jun 11 11:34:25 UTC 2019 - Xabier Arbulu Insausti <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/salt-shaptools.spec new/salt-shaptools-0.2.6/salt-shaptools.spec --- old/salt-shaptools-0.2.5/salt-shaptools.spec 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/salt-shaptools.spec 2019-12-16 09:03:42.878852476 +0100 @@ -19,7 +19,7 @@ # See also https://en.opensuse.org/openSUSE:Specfile_guidelines Name: salt-shaptools -Version: 0.2.5 +Version: 0.2.6 Release: 0 Summary: Salt modules and states for SAP Applications and SLE-HA components management diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/salt-shaptools-0.2.5/tests/unit/modules/test_crmshmod.py new/salt-shaptools-0.2.6/tests/unit/modules/test_crmshmod.py --- old/salt-shaptools-0.2.5/tests/unit/modules/test_crmshmod.py 2019-12-09 03:44:43.029007691 +0100 +++ new/salt-shaptools-0.2.6/tests/unit/modules/test_crmshmod.py 2019-12-16 09:03:42.878852476 +0100 @@ -352,11 +352,12 @@ with patch.dict(crmshmod.__salt__, {'cmd.retcode': mock_cmd_run}): result = crmshmod._crm_init( - 'hacluster', 'dog', 'eth1', True, '192.168.1.50', True, 'sbd_dev', True) + 'hacluster', 'dog', 'eth1', True, '192.168.1.50', True, ['dev1', 'dev2'], True) assert result mock_cmd_run.assert_called_once_with( - '{} cluster init -y -n {} -w {} -i {} -u -A {} --enable-sbd -s {} -q'.format( - crmshmod.CRM_COMMAND, 'hacluster', 'dog', 'eth1', '192.168.1.50', 'sbd_dev')) + '{} cluster init -y -n {} -w {} -i {} -u -A {} ' + '--enable-sbd -s {} -s {} -q'.format( + crmshmod.CRM_COMMAND, 'hacluster', 'dog', 'eth1', '192.168.1.50', 'dev1', 'dev2')) def test_ha_cluster_init_basic(self): ''' @@ -385,33 +386,114 @@ 'network.get_hostname': mock_get_hostname, 'network.interface_ip': mock_interface_ip}): result = crmshmod._ha_cluster_init( - 'dog', 'eth1', True, '192.168.1.50', True, 'sbd_dev', True) + 'dog', 'eth1', True, '192.168.1.50', True, ['dev1', 'dev2'], True) assert result == 0 mock_watchdog.assert_called_once_with('dog') mock_corosync.assert_called_once_with('1.0.1.0', 'node') mock_interface_ip.assert_called_once_with('eth1') mock_cmd_run.assert_called_once_with( - '{} -y -i {} -A {} -S -s {} -q'.format( - crmshmod.HA_INIT_COMMAND, 'eth1', '192.168.1.50', 'sbd_dev')) + '{} -y -i {} -A {} -S -s {} -s {} -q'.format( + crmshmod.HA_INIT_COMMAND, 'eth1', '192.168.1.50', 'dev1', 'dev2')) + def test_manage_multiple_sbd(self): + + sbd, devs = crmshmod._manage_multiple_sbd(None, None) + assert sbd is None + assert devs is None + + sbd, devs = crmshmod._manage_multiple_sbd(True, 'disk') + assert sbd is True + assert devs == ['disk'] + + def test_manage_multiple_sbd_workaround(self): + + mock_cmd_run = MagicMock(side_effect=[0, 0]) + mock_file_replace = MagicMock(return_code=0) + + with patch.dict(crmshmod.__salt__, { + 'cmd.retcode': mock_cmd_run, + 'file.replace': mock_file_replace}): + sbd, devs = crmshmod._manage_multiple_sbd(True, ['disk1', 'disk2']) + + mock_cmd_run.assert_has_calls([ + mock.call('sbd -d disk1 -d disk2 create'), + mock.call('{} cluster init sbd -s {}'.format(crmshmod.CRM_COMMAND, 'disk1')) + ]) + mock_file_replace.assert_called_once_with( + path='/etc/sysconfig/sbd', + pattern='^SBD_DEVICE=.*', + repl='SBD_DEVICE={}'.format(';'.join(['disk1', 'disk2'])), + append_if_not_found=True + ) + assert sbd is None + assert devs is None + + def test_manage_multiple_sbd_workaround_errors(self): + + mock_cmd_run = MagicMock(side_effect=[1, 0]) + + with patch.dict(crmshmod.__salt__, { + 'cmd.retcode': mock_cmd_run}): + with pytest.raises(exceptions.SaltInvocationError) as err: + crmshmod._manage_multiple_sbd(True, ['disk1', 'disk2']) + + assert 'sbd disks could not be formatted properly' in str(err.value) + mock_cmd_run.assert_called_once_with('sbd -d disk1 -d disk2 create') + + mock_cmd_run = MagicMock(side_effect=[0, 1]) + + with patch.dict(crmshmod.__salt__, { + 'cmd.retcode': mock_cmd_run}): + with pytest.raises(exceptions.SaltInvocationError) as err: + crmshmod._manage_multiple_sbd(True, ['disk1', 'disk2']) + + assert 'crm cluster init sbd failed' in str(err.value) + mock_cmd_run.assert_has_calls([ + mock.call('sbd -d disk1 -d disk2 create'), + mock.call('{} cluster init sbd -s {}'.format(crmshmod.CRM_COMMAND, 'disk1')) + ]) + + @mock.patch('salt.modules.crmshmod._manage_multiple_sbd') @mock.patch('salt.modules.crmshmod._crm_init') - def test_cluster_init_crm(self, crm_init): + def test_cluster_init_crm(self, crm_init, manage_sbd): ''' Test cluster_init with crm option ''' + + manage_sbd.return_value = ('sbd', 'devs') + with patch.dict(crmshmod.__salt__, {'crm.version': True}): crm_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1') assert value == 0 crm_init.assert_called_once_with( - 'hacluster', 'dog', 'eth1', None, None, None, None, None) + 'hacluster', 'dog', 'eth1', None, None, 'sbd', 'devs', None) + crm_init.reset_mock() - @mock.patch('logging.Logger.warn') + with patch.dict(crmshmod.__salt__, {'crm.version': True}): + crm_init.return_value = 0 + value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', sbd_dev=['disk1', 'disk2']) + assert value == 0 + crm_init.assert_called_once_with( + 'hacluster', 'dog', 'eth1', None, None, 'sbd', 'devs', None) + crm_init.reset_mock() + + with patch.dict(crmshmod.__salt__, {'crm.version': True}): + crm_init.return_value = 0 + value = crmshmod.cluster_init('hacluster', 'dog', 'eth1', sbd_dev='disk1') + assert value == 0 + crm_init.assert_called_once_with( + 'hacluster', 'dog', 'eth1', None, None, 'sbd', 'devs', None) + + @mock.patch('logging.Logger.warning') + @mock.patch('salt.modules.crmshmod._manage_multiple_sbd') @mock.patch('salt.modules.crmshmod._ha_cluster_init') - def test_cluster_init_ha(self, ha_cluster_init, logger): + def test_cluster_init_ha(self, ha_cluster_init, manage_sbd, logger): ''' Test cluster_init with ha_cluster_init option ''' + manage_sbd.return_value = ('sbd', 'devs') + with patch.dict(crmshmod.__salt__, {'crm.version': False}): ha_cluster_init.return_value = 0 value = crmshmod.cluster_init('hacluster', 'dog', 'eth1') @@ -419,7 +501,7 @@ logger.assert_called_once_with( 'The parameter name is not considered!') ha_cluster_init.assert_called_once_with( - 'dog', 'eth1', None, None, None, None, None) + 'dog', 'eth1', None, None, 'sbd', 'devs', None) def test_crm_join_basic(self): '''
