source: other-projects/hathitrust/vagrant-solr-cluster/trunk/modules/stdlib/lib/puppet/parser/functions/is_mac_address.rb@ 30960

Last change on this file since 30960 was 30960, checked in by davidb, 8 years ago

Switch to using Puppet to provision machine. Strongly based on files developed for spark-hdfs cluster

File size: 566 bytes
Line 
1#
2# is_mac_address.rb
3#
4
5module Puppet::Parser::Functions
6 newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
7Returns true if the string passed to this function is a valid mac address.
8 EOS
9 ) do |arguments|
10
11 if (arguments.size != 1) then
12 raise(Puppet::ParseError, "is_mac_address(): Wrong number of arguments "+
13 "given #{arguments.size} for 1")
14 end
15
16 mac = arguments[0]
17
18 if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then
19 return true
20 else
21 return false
22 end
23
24 end
25end
26
27# vim: set ts=2 sw=2 et :
Note: See TracBrowser for help on using the repository browser.