mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add logs and correct pylint error
This commit is contained in:
parent
e31e22d96a
commit
82075c809c
1 changed files with 13 additions and 1 deletions
|
@ -26,10 +26,14 @@ from __future__ import absolute_import
|
|||
import os
|
||||
import os.path
|
||||
import time
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
||||
# Init logger
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -155,6 +159,8 @@ def formatted(name, fs_type='ext4', **kwargs):
|
|||
# to avoid lsblk failing although mkfs has succeeded
|
||||
# see https://github.com/saltstack/salt/issues/25775
|
||||
for i in range(10):
|
||||
|
||||
log.info('Check blk fstype attempt %s of 10', str(i+1))
|
||||
current_fs = _checkblk(name)
|
||||
|
||||
if current_fs == fs_type:
|
||||
|
@ -163,12 +169,18 @@ def formatted(name, fs_type='ext4', **kwargs):
|
|||
ret['changes'] = {'new': fs_type, 'old': current_fs}
|
||||
ret['result'] = True
|
||||
return ret
|
||||
time.sleep(3)
|
||||
|
||||
if current_fs == '':
|
||||
log.info('Waiting 3s before next check')
|
||||
time.sleep(3)
|
||||
else:
|
||||
break
|
||||
|
||||
ret['comment'] = 'Failed to format {0}'.format(name)
|
||||
ret['result'] = False
|
||||
return ret
|
||||
|
||||
|
||||
def _checkblk(name):
|
||||
'''
|
||||
Check if the blk exists and return its fstype if ok
|
||||
|
|
Loading…
Add table
Reference in a new issue