From 09b11bf8e4e399571938e27047d42eac581dffd8 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Fri, 19 Dec 2014 05:15:24 -0500 Subject: [PATCH 1/3] Access dictionary values correctly in salt.modules.mdadm.destroy Fixes #19115 --- salt/modules/mdadm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/modules/mdadm.py b/salt/modules/mdadm.py index 30651e3a48..183aac8d17 100644 --- a/salt/modules/mdadm.py +++ b/salt/modules/mdadm.py @@ -128,7 +128,7 @@ def destroy(device): if __salt__['cmd.retcode'](stop_cmd): for number in details['members']: - zero_cmd.append(number['device']) + zero_cmd.append(details['members'][number]['device']) __salt__['cmd.retcode'](zero_cmd) # Remove entry from config file: From 588ffdace66503c22d7e369242ec577bd8729972 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Fri, 19 Dec 2014 05:43:30 -0500 Subject: [PATCH 2/3] Correctly convert command list into string and do not error if conf file missing. Fixes #19117 --- salt/modules/mdadm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/salt/modules/mdadm.py b/salt/modules/mdadm.py index 183aac8d17..5d881c679b 100644 --- a/salt/modules/mdadm.py +++ b/salt/modules/mdadm.py @@ -123,8 +123,8 @@ def destroy(device): except CommandExecutionError: return False - stop_cmd = ['mdadm', '--stop', device] - zero_cmd = ['mdadm', '--zero-superblock'] + stop_cmd = ' '.join(['mdadm', '--stop', device]) + zero_cmd = ' '.join(['mdadm', '--zero-superblock']) if __salt__['cmd.retcode'](stop_cmd): for number in details['members']: @@ -137,7 +137,10 @@ def destroy(device): else: cfg_file = '/etc/mdadm.conf' - __salt__['file.replace'](cfg_file, 'ARRAY {0} .*'.format(device), '') + try: + __salt__['file.replace'](cfg_file, 'ARRAY {0} .*'.format(device), '') + except SaltInvocationError: + pass if __salt__['raid.list']().get(device) is None: return True From a833d89b2c97ceea5a997015a978643059a6c11c Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Fri, 19 Dec 2014 06:36:51 -0500 Subject: [PATCH 3/3] Redoing some changes --- salt/modules/mdadm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/modules/mdadm.py b/salt/modules/mdadm.py index 5d881c679b..aeadb2e983 100644 --- a/salt/modules/mdadm.py +++ b/salt/modules/mdadm.py @@ -123,13 +123,13 @@ def destroy(device): except CommandExecutionError: return False - stop_cmd = ' '.join(['mdadm', '--stop', device]) - zero_cmd = ' '.join(['mdadm', '--zero-superblock']) + stop_cmd = ['mdadm', '--stop', device] + zero_cmd = ['mdadm', '--zero-superblock'] - if __salt__['cmd.retcode'](stop_cmd): + if __salt__['cmd.retcode'](stop_cmd, python_shell=False): for number in details['members']: zero_cmd.append(details['members'][number]['device']) - __salt__['cmd.retcode'](zero_cmd) + __salt__['cmd.retcode'](zero_cmd, python_shell=False) # Remove entry from config file: if __grains__.get('os_family') == 'Debian':