def MX(domain, resolve=False, nameserver=None):
 dig = ['dig', '+short', str(domain), 'MX']
 if (nameserver is not None):
  dig.append('@{0}'.format(nameserver))
 cmd = __salt__['cmd.run_all'](dig, python_shell=False)
 if (cmd['retcode'] != 0):
  log.warning("dig returned exit code '{0}'. Returning empty list as fallback.".format(cmd['retcode']))
  return []
 stdout = [x.split() for x in cmd['stdout'].split('\n')]
 if resolve:
  return [(lambda x: [x[0], A(x[1], nameserver)[0]])(x) for x in stdout]
 return stdout

def MX ( domain , resolve = False , nameserver = None ) : dig = [ 'dig' , '+short' , str ( domain ) , 'MX' ] if ( nameserver is not None ) : dig . append ( '@{0}' . format ( nameserver ) ) cmd = __salt__ [ 'cmd.run_all' ] ( dig , python_shell = False ) if ( cmd [ 'retcode' ] != 0 ) : log . warning ( "dig returned exit code '{0}'. Returning empty list as fallback." . format ( cmd [ 'retcode' ] ) ) return [ ] stdout = [ x . split ( ) for x in cmd [ 'stdout' ] . split ( '\n' ) ] if resolve : return [ ( lambda x : [ x [ 0 ] , A ( x [ 1 ] , nameserver ) [ 0 ] ] ) ( x ) for x in stdout ] return stdout
return a list of lists for the mx of domain .