def linux_interfaces():
 ifaces = dict()
 ip_path = salt.utils.which('ip')
 ifconfig_path = (None if ip_path else salt.utils.which('ifconfig'))
 if ip_path:
  cmd1 = subprocess.Popen('{0} link show'.format(ip_path), shell=True, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
  cmd2 = subprocess.Popen('{0} addr show'.format(ip_path), shell=True, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
  ifaces = _interfaces_ip('{0}\n{1}'.format(salt.utils.to_str(cmd1), salt.utils.to_str(cmd2)))
 elif ifconfig_path:
  cmd = subprocess.Popen('{0} -a'.format(ifconfig_path), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
  ifaces = _interfaces_ifconfig(salt.utils.to_str(cmd))
 return ifaces

def linux_interfaces ( ) : ifaces = dict ( ) ip_path = salt . utils . which ( 'ip' ) ifconfig_path = ( None if ip_path else salt . utils . which ( 'ifconfig' ) ) if ip_path : cmd1 = subprocess . Popen ( '{0} link show' . format ( ip_path ) , shell = True , close_fds = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) . communicate ( ) [ 0 ] cmd2 = subprocess . Popen ( '{0} addr show' . format ( ip_path ) , shell = True , close_fds = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) . communicate ( ) [ 0 ] ifaces = _interfaces_ip ( '{0}\n{1}' . format ( salt . utils . to_str ( cmd1 ) , salt . utils . to_str ( cmd2 ) ) ) elif ifconfig_path : cmd = subprocess . Popen ( '{0} -a' . format ( ifconfig_path ) , shell = True , stdout = subprocess . PIPE , stderr = subprocess . STDOUT ) . communicate ( ) [ 0 ] ifaces = _interfaces_ifconfig ( salt . utils . to_str ( cmd ) ) return ifaces
obtain interface information for *nix/bsd variants .