Changed 'plugins' directory name to 'lib' to reflect changes in 0.25+ puppet server.
This commit is contained in:
parent
05b0b8ab70
commit
24000d595c
6 changed files with 0 additions and 0 deletions
26
avahi/lib/puppet/parser/functions/avahi_service_port.rb
Normal file
26
avahi/lib/puppet/parser/functions/avahi_service_port.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
|
||||
module Puppet::Parser::Functions
|
||||
newfunction(:avahi_service_port, :type => :rvalue) do |args|
|
||||
|
||||
type, name, proto = /^_([^\.]*)\._([^\.]*)$/.match(args[0]).to_a
|
||||
|
||||
port = nil
|
||||
|
||||
File.open('/etc/services', 'r') do |fd|
|
||||
while (line = fd.gets)
|
||||
begin
|
||||
port = /^#{name}[ \t]+(\d+)\/#{proto}.*/.match(line)[1]
|
||||
break
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not port
|
||||
raise Puppet::ParseError, 'Failed to get port for service %s' % type
|
||||
end
|
||||
port
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue