@depends(HAS_HDPARM)
def _hdparm(args, failhard=True):
 cmd = 'hdparm {0}'.format(args)
 result = __salt__['cmd.run_all'](cmd)
 if (result['retcode'] != 0):
  msg = '{0}: {1}'.format(cmd, result['stderr'])
  if failhard:
   raise CommandExecutionError(msg)
  else:
   log.warning(msg)
 return result['stdout']

@ depends ( HAS_HDPARM ) def _hdparm ( args , failhard = True ) : cmd = 'hdparm {0}' . format ( args ) result = __salt__ [ 'cmd.run_all' ] ( cmd ) if ( result [ 'retcode' ] != 0 ) : msg = '{0}: {1}' . format ( cmd , result [ 'stderr' ] ) if failhard : raise CommandExecutionError ( msg ) else : log . warning ( msg ) return result [ 'stdout' ]
execute hdparm fail hard when required return output when possible .