class Specinfra::Helper::DetectOs::Ios_xr < Specinfra::Helper::DetectOs
  def detect
    # CentOS has a os-release file too, but this should do the right thing
    if File.exists?('/etc/cisco-release')
      contents = {}
      File.read('/etc/cisco-release').split.collect {|x| x.split('=')}.each {|x| contents[x[0]] = x[1]}
      # This test should only work on a nexus platform in the native OS
      # It will fail in a guest/container shell, which should be picked up elsewhere
      if contents['ID'] == "ios_xr" && contents['ID_LIKE'] && contents['ID_LIKE'].include?('wrlinux')
        { :family => 'ios_xr', :release => contents['VERSION'] }
      end
    end
  end
end