def _parse_quota(mount, opts):
 cmd = 'repquota -vp {0} {1}'.format(opts, mount)
 out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
 mode = 'header'
 if ('-u' in opts):
  quotatype = 'Users'
 elif ('-g' in opts):
  quotatype = 'Groups'
 ret = {quotatype: {}}
 for line in out:
  if (not line):
   continue
  comps = line.split()
  if (mode == 'header'):
   if ('Block grace time' in line):
    (blockg, inodeg) = line.split(';')
    blockgc = blockg.split(': ')
    inodegc = inodeg.split(': ')
    ret['Block Grace Time'] = blockgc[(-1):]
    ret['Inode Grace Time'] = inodegc[(-1):]
   elif line.startswith('-'):
    mode = 'quotas'
  elif (mode == 'quotas'):
   if (len(comps) < 8):
    continue
   if (not (comps[0] in ret[quotatype])):
    ret[quotatype][comps[0]] = {}
   ret[quotatype][comps[0]]['block-used'] = comps[2]
   ret[quotatype][comps[0]]['block-soft-limit'] = comps[3]
   ret[quotatype][comps[0]]['block-hard-limit'] = comps[4]
   ret[quotatype][comps[0]]['block-grace'] = comps[5]
   ret[quotatype][comps[0]]['file-used'] = comps[6]
   ret[quotatype][comps[0]]['file-soft-limit'] = comps[7]
   ret[quotatype][comps[0]]['file-hard-limit'] = comps[8]
   ret[quotatype][comps[0]]['file-grace'] = comps[9]
 return ret

def _parse_quota ( mount , opts ) : cmd = 'repquota -vp {0} {1}' . format ( opts , mount ) out = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) . splitlines ( ) mode = 'header' if ( '-u' in opts ) : quotatype = 'Users' elif ( '-g' in opts ) : quotatype = 'Groups' ret = { quotatype : { } } for line in out : if ( not line ) : continue comps = line . split ( ) if ( mode == 'header' ) : if ( 'Block grace time' in line ) : ( blockg , inodeg ) = line . split ( ';' ) blockgc = blockg . split ( ': ' ) inodegc = inodeg . split ( ': ' ) ret [ 'Block Grace Time' ] = blockgc [ ( - 1 ) : ] ret [ 'Inode Grace Time' ] = inodegc [ ( - 1 ) : ] elif line . startswith ( '-' ) : mode = 'quotas' elif ( mode == 'quotas' ) : if ( len ( comps ) < 8 ) : continue if ( not ( comps [ 0 ] in ret [ quotatype ] ) ) : ret [ quotatype ] [ comps [ 0 ] ] = { } ret [ quotatype ] [ comps [ 0 ] ] [ 'block-used' ] = comps [ 2 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'block-soft-limit' ] = comps [ 3 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'block-hard-limit' ] = comps [ 4 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'block-grace' ] = comps [ 5 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'file-used' ] = comps [ 6 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'file-soft-limit' ] = comps [ 7 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'file-hard-limit' ] = comps [ 8 ] ret [ quotatype ] [ comps [ 0 ] ] [ 'file-grace' ] = comps [ 9 ] return ret
parse the output from repquota .