connection_reachable?

in chef/cookbooks/uber_helpers/libraries/node_utils.rb [646:673]


    def connection_reachable?(destination)
      unless macos? || windows? || debian_family?
        Chef::Log.warn('node.connection_reachable? called on non-macOS/windows/ubuntu device!')
        return false
      end
      status = false
      if macos?
        cmd = shell_out("/sbin/ping #{destination} -c 1")
      elsif debian_family?
        cmd = shell_out("/bin/ping #{destination} -c 2")
      elsif windows?
        powershell_cmd = "Test-Connection #{destination} -Count 1 -Quiet"
        cmd = powershell_out(powershell_cmd)
      end
      if cmd.stdout.nil? || cmd.stdout.empty?
        return status
      elsif macos? || debian_family?
        
        status = cmd.exitstatus.zero?
      elsif windows?
        
        
        status = Chef::JSONCompat.parse(cmd.stdout.chomp.downcase)
      end

      status
    end