-
-
Save anonymous/7e9f6a255db644bd54e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ipaddr' | |
module Puppet::Parser::Functions | |
# args -> ['ip address', [['name', 'CIDR network', vlanid],...]] | |
newfunction(:find_vlan_id, :type => :rvalue) do |args| | |
subnet = args[1].select do |name, net, vlan| | |
raise Puppet::ParseError, "2: " + name.to_s + "-" + net.to_s + "-" + vlan.to_s | |
IPAddr.new(net) === args[0] | |
end | |
return subnet ? subnet[2] : nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment