Puppet Function: platform_get

Defined in:
lib/puppet/parser/functions/platform_get.rb
Function type:
Ruby 3.x API

Overview

platform_get()Any

Returns:

  • (Any)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/puppet/parser/functions/platform_get.rb', line 24

newfunction(:platform_get, type: :rvalue) do |_args|
  data = lookupvar('cisco')
  return '' if data.nil?
  pi = data['hardware']['type']
  # The following kind of string info is returned for Nexus.
  # - Nexus9000 C9396PX Chassis
  # - Nexus7000 C7010 (10 Slot) Chassis
  # - Nexus 6001 Chassis
  # - NX-OSv Chassis
  case pi
  when /Nexus\s?3\d\d\d/
    if function_platform_fretta([])
      cisco_hardware = 'n3k-f'
    else
      cisco_hardware = 'n3k'
    end
  when /Nexus\s?5\d\d\d/
    cisco_hardware = 'n5k'
  when /Nexus\s?6\d\d\d/
    cisco_hardware = 'n6k'
  when /Nexus\s?7\d\d\d/
    cisco_hardware = 'n7k'
  when /Nexus\s?9\d+\s\S+-EX/
    cisco_hardware = 'n9k-ex'
  when /(Nexus\s?9\d\d\d|NX-OSv Chassis)/
    if function_platform_fretta([])
      cisco_hardware = 'n9k-f'
    else
      cisco_hardware = 'n9k'
    end
  else
    fail Puppet::ParseError, "Unrecognized platform type: #{pi}\n#{__FILE__}"
  end
  cisco_hardware
end