summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 01:51:23 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-09-05 01:51:23 +0000
commit617fe58626aa8a13af10071ca87f66d6363cf058 (patch)
treedb9974c675c3b73cae56a253386f716e83bc8b6f /lib/puppet/provider
parent8f39318ce46148c3bd483d790c965f277a4eb1c9 (diff)
Removing all of the changes I made towards refactoring in the last couple of days. They have all been moved into the sync-retrieve-refactor branch. This branch will soon become 0.19.0, and will not include that refactoring.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1555 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/provider')
-rwxr-xr-xlib/puppet/provider/cron/parsed.rb161
-rw-r--r--lib/puppet/provider/host/parsed.rb78
-rwxr-xr-xlib/puppet/provider/mount/parsed.rb171
-rw-r--r--lib/puppet/provider/package/portage.rb124
-rwxr-xr-xlib/puppet/provider/parsedfile.rb174
-rwxr-xr-xlib/puppet/provider/port/parsed.rb139
-rwxr-xr-xlib/puppet/provider/sshkey/parsed.rb56
7 files changed, 0 insertions, 903 deletions
diff --git a/lib/puppet/provider/cron/parsed.rb b/lib/puppet/provider/cron/parsed.rb
deleted file mode 100755
index 1626162bd..000000000
--- a/lib/puppet/provider/cron/parsed.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-require 'puppet/provider/parsedfile'
-
-Puppet::Type.type(:cron).provide :parsed, :parent => Puppet::Provider::ParsedFile do
- @fields = [:minute, :hour, :monthday, :month, :weekday, :command]
-
- # XXX This should be switched to use providers or something similar on
- # the backend.
- def self.defaulttype
- case Facter["operatingsystem"].value
- when "Solaris":
- return Puppet::FileType.filetype(:suntab)
- else
- return Puppet::FileType.filetype(:crontab)
- end
- end
-
- self.filetype = self.defaulttype()
-
- # We have to maintain separate file objects for every user, unfortunately.
- def self.filetype(user)
- @tabs ||= {}
- @tabs[user] ||= @filetype.new(user)
-
- @tabs[user]
- end
-
- # Parse a user's cron job into individual cron objects.
- #
- # Autogenerates names for any jobs that don't already have one; these
- # names will get written back to the file.
- #
- # This method also stores existing comments, and it stores all cron
- # jobs in order, mostly so that comments are retained in the order
- # they were written and in proximity to the same jobs.
- def self.parse(user, text)
- count = 0
-
- envs = []
- instances = []
- text.chomp.split("\n").each { |line|
- hash = {}
- case line
- when /^# Puppet Name: (.+)$/
- hash[:name] = $1
- next
- when /^#/:
- # add other comments to the list as they are
- instances << line
- next
- when /^\s*(\w+)\s*=\s*(.+)\s*$/:
- # Match env settings.
- if hash[:name]
- envs << line
- else
- instances << line
- end
- next
- when /^@(\w+)\s+(.+)/ # FreeBSD special cron crap
- fields().each do |field|
- next if field == :command
- hash[field] = :absent
- end
- hash[:special] = $1
- hash[:command] = $2
- else
- if match = /^(\S+) (\S+) (\S+) (\S+) (\S+) (.+)$/.match(line)
- fields().zip(match.captures).each { |param, value|
- if value == "*"
- hash[param] = [:absent]
- else
- if param == :command
- hash[param] = [value]
- else
- # We always want the 'is' value to be an
- # array
- hash[param] = value.split(",")
- end
- end
- }
- else
- # Don't fail on unmatched lines, just warn on them
- # and skip them.
- Puppet.warning "Could not match '%s'" % line
- next
- end
- end
-
- unless envs.empty?
- hash[:environment] = envs
- end
-
- hash[:user] = user
-
- instances << hash
-
- envs.clear
- count += 1
- }
-
- return instances
- end
-
- def self.retrieve(user)
- text = fileobj(user).read
- if text.nil? or text == ""
- return []
- else
- self.parse(user, text)
- end
- end
-
- # Another override. This will pretty much only ever have one user's instances,
- def self.store(instances)
- instances.find_all { |i| i.is_a? Hash }.collect { |i| i[:user] }.each do |user|
- fileobj(user).write(self.to_file(instances))
- end
- end
-
- # Convert the current object a cron-style string. Adds the cron name
- # as a comment above the cron job, in the form '# Puppet Name: <name>'.
- def self.to_record(hash)
- hash = {}
-
- str = ""
-
- str = "# Puppet Name: %s\n" % hash[:name]
-
- if @states.include?(:environment) and
- @states[:environment].should != :absent
- envs = @states[:environment].should
- unless envs.is_a? Array
- envs = [envs]
- end
-
- envs.each do |line| str += (line + "\n") end
- end
-
- line = nil
- if special = hash[:special]
- line = str + "@%s %s" %
- [special, hash[:command]]
- else
- line = str + self.class.fields.collect { |f|
- if hash[f] and hash[f] != :absent
- hash[f]
- else
- "*"
- end
- }.join(" ")
- end
-
- return line
- end
-
- # Override the mechanism for retrieving instances, because we're user-specific.
- def allinstances
- self.class.retrieve(@model[:user])
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb
deleted file mode 100644
index c606562a2..000000000
--- a/lib/puppet/provider/host/parsed.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-require 'puppet/provider/parsedfile'
-
-Puppet::Type.type(:host).provide :parsed, :parent => Puppet::Provider::ParsedFile do
- @path = "/etc/hosts"
- @filetype = Puppet::FileType.filetype(:flat)
-
- confine :exists => @path
-
- # Parse a host file
- #
- # This method also stores existing comments, and it stores all host
- # jobs in order, mostly so that comments are retained in the order
- # they were written and in proximity to the same jobs.
- def self.parse(text)
- count = 0
- instances = []
- text.chomp.split("\n").each { |line|
- hash = {}
- case line
- when /^#/, /^\s*$/:
- # add comments and blank lines to the list as they are
- instances << line
- else
- if line.sub!(/^(\S+)\s+(\S+)\s*/, '')
- hash[:ip] = $1
- hash[:name] = $2
-
- unless line == ""
- line.sub!(/\s*/, '')
- line.sub!(/^([^#]+)\s*/) do |value|
- aliases = $1
- unless aliases =~ /^\s*$/
- hash[:alias] = aliases.split(/\s+/)
- end
-
- ""
- end
- end
- else
- raise Puppet::Error, "Could not match '%s'" % line
- end
-
- if hash[:alias] == ""
- hash.delete(:alias)
- end
-
- instances << hash
-
- count += 1
- end
- }
-
- return instances
- end
-
- # Convert the current object into a host-style string.
- def self.to_record(hash)
- [:ip, :name].each do |n|
- unless hash.has_key? n
- raise ArgumentError, "%s is a required attribute for hosts" % n
- end
- end
-
- str = "%s\t%s" % [hash[:ip], hash[:name]]
-
- if hash.include? :alias
- if hash[:alias].is_a? Array
- str += "\t%s" % hash[:alias].join("\t")
- else
- raise ArgumentError, "Aliases must be specified as an array"
- end
- end
-
- str
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/mount/parsed.rb b/lib/puppet/provider/mount/parsed.rb
deleted file mode 100755
index b768d6c5e..000000000
--- a/lib/puppet/provider/mount/parsed.rb
+++ /dev/null
@@ -1,171 +0,0 @@
-require 'puppet/provider/parsedfile'
-
-Puppet::Type.type(:mount).provide :parsed, :parent => Puppet::Provider::ParsedFile do
- @filetype = Puppet::FileType.filetype(:flat)
-
- commands :mount => "mount", :umount => "umount", :df => "df"
-
- def self.init
- @platform = Facter["operatingsystem"].value
- case @platform
- when "Solaris":
- @path = "/etc/vfstab"
- @fields = [:device, :blockdevice, :path, :fstype, :pass, :atboot,
- :options]
- @defaults = [ nil ] * @fields.size
- when "Darwin":
- @filetype = Puppet::FileType.filetype(:netinfo)
- @filetype.format = "fstab"
- @path = "mounts"
- @fields = [:device, :path, :fstype, :options, :dump, :pass]
- @defaults = [ nil ] * @fields.size
-
- # How to map the dumped table to what we want
- @fieldnames = {
- "name" => :device,
- "dir" => :path,
- "dump_freq" => :dump,
- "passno" => :pass,
- "vfstype" => :fstype,
- "opts" => :options
- }
- else
- @path = "/etc/fstab"
- @fields = [:device, :path, :fstype, :options, :dump, :pass]
- @defaults = [ nil ] * 4 + [ "0", "2" ]
- end
-
- # Allow Darwin to override the default filetype
- unless defined? @filetype
- @filetype = Puppet::FileType.filetype(:flat)
- end
- end
-
- init
-
- confine :exists => @path
-
- def self.clear
- init
- super
- end
-
- # Parse a mount tab.
- #
- # This method also stores existing comments, and it stores all
- # mounts in order, mostly so that comments are retained in the
- # order they were written and in proximity to the same fses.
- def self.parse(text)
- # provide a single exception for darwin & netinfo
- if @filetype == Puppet::FileType.filetype(:netinfo)
- return parseninfo(text)
- end
- count = 0
-
- instances = []
- text.chomp.split("\n").each { |line|
- hash = {}
- case line
- when /^#/, /^\s*$/:
- # add comments and blank lines to the list as they are
- instances << line
- comment(line)
- else
- values = line.split(/\s+/)
- if @fields.length < values.length
- raise Puppet::Error, "Could not parse line %s" % line
- end
-
- values = @defaults.zip(values).collect { |d, v| v || d }
- unless @fields.length == values.length
- raise Puppet::Error, "Could not parse line %s" % line
- end
-
- @fields.zip(values).each do |field, value|
- hash[field] = value
- end
-
- instances << hash
- count += 1
- end
- }
-
- return instances
- end
-
- # Parse a netinfo table.
- def self.parseninfo(text)
- array = @fileobj.to_array(text)
-
- instances = []
- array.each do |record|
- hash = {}
- @fieldnames.each do |name, field|
- if value = record[name]
- if field == :options
- hash[field] = value.join(",")
- else
- hash[field] = value[0]
- end
- else
- raise ArgumentError, "Field %s was not provided" % [name]
- end
- end
-
- instances << hash
- end
-
- return instances
- end
-
- # Convert the current object into an fstab-style string.
- def self.to_record(hash)
- self.fields.collect do |field|
- if value = hash[field]
- value
- else
- raise Puppet::Error,
- "Could not retrieve value for %s" % field
- end
- end.join("\t")
- end
-
- # This only works when the mount point is synced to the fstab.
- def mount
- output = %x{#{command(:mount)} #{@model[:path]} 2>&1}
-
- unless $? == 0
- raise Puppet::Error, "Could not mount %s: %s" % [@model[:path], output]
- end
- end
-
- # This only works when the mount point is synced to the fstab.
- def unmount
- output = %x{#{command(:umount)} #{@model[:path]}}
-
- unless $? == 0
- raise Puppet::Error, "Could not unmount %s" % @model[:path]
- end
- end
-
- # Is the mount currently mounted?
- def mounted?
- platform = Facter["operatingsystem"].value
- df = command(:df)
- case Facter["operatingsystem"].value
- # Solaris's df prints in a very weird format
- when "Solaris": df = "#{command(:df)} -k"
- end
- %x{#{df}}.split("\n").find do |line|
- fs = line.split(/\s+/)[-1]
- if platform == "Darwin"
- fs == "/private/var/automount" + @model[:path] or
- fs == @model[:path]
- else
- fs == @model[:path]
- end
- end
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/package/portage.rb b/lib/puppet/provider/package/portage.rb
deleted file mode 100644
index 873f63f68..000000000
--- a/lib/puppet/provider/package/portage.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-Puppet::Type.type(:package).provide :portage do
- desc "Provides packaging support for Gentoo's portage system."
-
- commands :emerge => "emerge", :eix => "eix"
-
- defaultfor :operatingsystem => :gentoo
-
- def self.list
- search_format = /(\S+) (\S+) \[(.*)\] \[(\S*)\] ([\S]*) (.*)/
- result_fields = [:category, :name, :version, :version_available,
- :vendor, :description]
- command = "#{command(:eix)} --format \"{<installedversions>}<category> <name> [<installedversions>] [<best>] <homepage> <description>{}\""
-
- begin
- search_output = execute( command )
-
- packages = []
- search_output.each do |search_result|
- match = search_format.match( search_result )
-
- if( match )
- package = {:ensure => :present}
- result_fields.zip( match.captures ) { |field, value| package[field] = value }
- if self.is_a? Puppet::Type and type = @model[:type]
- package[:type] = type
- elsif self.is_a? Module and self.respond_to? :name
- package[:type] = self.name
- else
- raise Puppet::DevError, "Cannot determine package type"
- end
- if package[:version]
- package[:version] = package[:version].split.last
- end
-
- packages.push( Puppet.type(:package).installedpkg(package) )
- end
- end
-
- return packages
- rescue Puppet::ExecutionFailure => detail
- raise Puppet::PackageError.new(detail)
- end
- end
-
- def install
- if @model[:version]
- # We must install a specific version
- package_name = "=#{@model[:name]}-#{@model[:version]}"
- else
- package_name = @model[:name]
- end
- command = "EMERGE_DEFAULT_OPTS=\"\" #{command(:emerge)} #{package_name}"
- begin
- output = execute( command )
- rescue Puppet::ExecutionFailure => detail
- raise Puppet::PackageError.new(detail)
- end
- end
-
- def uninstall
- if @model[:version]
- # We must uninstall a specific version
- package_name = "=#{@model[:name]}-#{@model[:version]}"
- else
- package_name = @model[:name]
- end
- command ="EMERGE_DEFAULT_OPTS=\"\" #{command(:emerge)} --unmerge #{package_name}"
- begin
- output = execute( command )
- rescue Puppet::ExecutionFailure => detail
- raise Puppet::PackageError.new(detail)
- end
- end
-
- def update
- self.install
- end
-
- def query
- search_format = /(\S+) (\S+) \[(.*)\] \[(\S*)\] ([\S]*) (.*)/
- result_fields = [:category, :name, :version, :version_available, :vendor, :description]
-
- search_field = @model[:name].include?( '/' ) ? "--category-name" : "--name"
- command = "#{command(:eix)} --format \"<category> <name> [<installedversions>] [<best>] <homepage> <description>\" --exact #{search_field} #{@model[:name]}"
-
- begin
- search_output = execute( command )
-
- packages = []
- search_output.each do |search_result|
- match = search_format.match( search_result )
-
- if( match )
- package = {}
- result_fields.zip( match.captures ) { |field, value| package[field] = value unless value.empty? }
- package[:ensure] = package[:version] ? :present : :absent
- package[:version] = package[:version].split.last if package[:version]
- packages << package
- end
- end
-
- case packages.size
- when 0
- return nil
- when 1
- return packages[0]
- else
- self.fail "More than one package with the specified name [#{@model[:name]}], please use category/name to disambiguate"
- end
- rescue Puppet::ExecutionFailure => detail
- raise Puppet::PackageError.new(detail)
- end
- end
-
- def latest
- return self.query[:version_available]
- end
-
- def versionable?
- true
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
deleted file mode 100755
index f690c03a4..000000000
--- a/lib/puppet/provider/parsedfile.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-require 'puppet'
-
-class Puppet::Provider::ParsedFile < Puppet::Provider
- class << self
- attr_accessor :filetype, :fields
- attr_reader :path
- attr_writer :fileobj
- end
-
- # Override 'newstate' so that all states default to having the
- # correct parent type
- def self.newstate(name, options = {}, &block)
- options[:parent] ||= Puppet::State::ParsedParam
- super(name, options, &block)
- end
-
- # Add another type var.
- def self.initvars
- @instances = []
- super
- end
-
- # Add a non-object comment or whatever to our list of instances
- def self.comment(line)
- @instances << line
- end
-
- # Override the default Puppet::Type method, because instances
- # also need to be deleted from the @instances hash
- def self.delete(child)
- if @instances.include?(child)
- @instances.delete(child)
- end
- super
- end
-
- # Initialize the object if necessary.
- def self.fileobj
- @fileobj ||= @filetype.new(@path)
-
- @fileobj
- end
-
- # Return the header placed at the top of each generated file, warning
- # users that modifying this file manually is probably a bad idea.
- def self.header
-%{# HEADER: This file was autogenerated at #{Time.now}
-# HEADER: by puppet. While it can still be managed manually, it
-# HEADER: is definitely not recommended.\n}
- end
-
- # Parse a file
- #
- # Subclasses must override this method.
- def self.parse(text)
- raise Puppet::DevError, "Parse was not overridden in %s" %
- self.name
- end
-
- # If they change the path, we need to get rid of our cache object
- def self.path=(path)
- @fileobj = nil
- @path = path
- end
-
- # Retrieve the text for the file. Returns nil in the unlikely
- # event that it doesn't exist.
- def self.retrieve
- text = fileobj.read
- if text.nil? or text == ""
- # there is no file
- return []
- else
- self.parse(text)
- end
- end
-
- # Write out the file.
- def self.store(instances)
- if instances.empty?
- Puppet.notice "No %s instances for %s" % [self.name, @path]
- else
- fileobj.write(self.to_file(instances))
- end
- end
-
- # Collect all Host instances convert them into literal text.
- def self.to_file(instances)
- str = self.header()
- unless instances.empty?
- # Reject empty hashes and those with :ensure == :absent
- str += instances.reject { |obj|
- obj.is_a? Hash and (obj.empty? or obj[:ensure] == :absent)
- }.collect { |obj|
- # If it's a hash, convert it, otherwise just write it out
- if obj.is_a?(Hash)
- to_record(obj)
- else
- obj.to_s
- end
- }.join("\n") + "\n"
-
- return str
- else
- Puppet.notice "No %s instances" % self.name
- return ""
- end
- end
-
- # A Simple wrapper method that subclasses can override, so there's more control
- # over how instances are retrieved.
- def allinstances
- self.class.retrieve
- end
-
- def clear
- super
- @instances = nil
- end
-
- # Return a hash that maps to our info, if possible.
- def hash
- @instances = allinstances()
-
- if @instances and h = @instances.find do |o|
- o.is_a? Hash and o[:name] == @model[:name]
- end
- @me = h
- else
- @me = {}
- if @instances.empty?
- @instances = [@me]
- else
- @instances << @me
- end
- end
-
- return @me
- end
-
- def initialize(model)
- super
-
- @instances = nil
- end
-
- def store(hash = nil)
- hash ||= self.model.to_hash
-
- unless @instances
- self.hash
- end
-
- if hash.empty?
- @me.clear
- else
- hash.each do |name, value|
- if @me[name] != hash[name]
- @me[name] = hash[name]
- end
- end
-
- @me.each do |name, value|
- unless hash.has_key? name
- @me.delete(name)
- end
- end
- end
-
- self.class.store(@instances)
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/port/parsed.rb b/lib/puppet/provider/port/parsed.rb
deleted file mode 100755
index d65a0777f..000000000
--- a/lib/puppet/provider/port/parsed.rb
+++ /dev/null
@@ -1,139 +0,0 @@
-require 'puppet/provider/parsedfile'
-
-Puppet::Type.type(:port).provide :parsed, :parent => Puppet::Provider::ParsedFile do
-
- @filetype = Puppet::FileType.filetype(:flat)
- @path = "/etc/services"
-
- # Parse a services file
- #
- # This method also stores existing comments, and it stores all port
- # info in order, mostly so that comments are retained in the order
- # they were written and in proximity to the same ports.
- def self.parse(text)
- count = 0
- instances = []
- namehash = {} # For merging
- text.chomp.split("\n").each { |line|
- hash = {}
- case line
- when /^#/, /^\s*$/:
- # add comments and blank lines to the list as they are
- instances << line
- else
- if line.sub!(/^(\S+)\s+(\d+)\/(\w+)\s*/, '')
- hash[:name] = $1
- hash[:number] = $2
- hash[:protocols] = [$3]
-
- unless line == ""
- line.sub!(/^([^#]+)\s*/) do |value|
- aliases = $1
-
- # Remove any trailing whitespace
- aliases.strip!
- unless aliases =~ /^\s*$/
- hash[:alias] = aliases.split(/\s+/)
- end
-
- ""
- end
-
- line.sub!(/^\s*#\s*(.+)$/) do |value|
- desc = $1
- unless desc =~ /^\s*$/
- hash[:description] = desc.sub(/\s*$/, '')
- end
-
- ""
- end
- end
- else
- if line =~ /^\s+\d+/ and
- Facter["operatingsystem"].value == "Darwin"
- #Puppet.notice "Skipping wonky OS X port entry %s" %
- # line.inspect
- next
- end
- raise Puppet::Error, "Could not match '%s'" % line
- end
-
- # If there's already a service with this name, then check
- # to see if the only difference is the proto; if so, just
- # add our proto and walk away
- if obj = namehash[hash[:name]]
- if portmerge(obj, hash)
- next
- end
- end
-
- instances << hash
- namehash[hash[:name]] = hash
-
- count += 1
- end
- }
-
- return instances
- end
-
- def self.portmerge(base, hash)
- unless base.has_key?(:protocols)
- return false
- end
-
- # This method is only called from parsing, so we only worry
- # about 'is' values.
- proto = base[:protocols]
-
- if proto.nil? or proto == :absent
- # We are an unitialized object; we've got 'should'
- # values but no 'is' values
- return false
- end
-
- # If this is happening, our object exists
- base[:ensure] = :present
-
- if hash[:protocols]
- # The protocol can be a symbol, so...
- if proto.is_a?(Symbol)
- proto = []
- end
- # Check to see if it already includes our proto
- unless proto.include?(hash[:protocols])
- # We are missing their proto
- proto += hash[:protocols]
- base[:protocols] = proto
- end
- end
-
- if hash.include?(:description) and ! base.include?(:description)
- base[:description] = hash[:description]
- end
-
- return true
- end
-
- # Convert the current object into one or more services entry.
- def self.to_record(hash)
- hash[:protocols].collect { |proto|
- str = "%s\t%s/%s" % [hash[:name], hash[:number], proto]
-
- if value = hash[:alias] and value != :absent
- str += "\t%s" % value.join(" ")
- else
- str += "\t"
- end
-
- if value = hash[:description] and value != :absent
- str += "\t# %s" % value
- else
- str += "\t"
- end
- str
- }.join("\n")
- end
-end
-
-# $Id$
diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb
deleted file mode 100755
index e1dbeaad6..000000000
--- a/lib/puppet/provider/sshkey/parsed.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require 'puppet/provider/parsedfile'
-
-Puppet::Type.type(:sshkey).provide :parsed, :parent => Puppet::Provider::ParsedFile do
- @filetype = Puppet::FileType.filetype(:flat)
- @path = "/etc/ssh/ssh_known_hosts"
- @fields = [:name, :type, :key]
-
- # Parse an sshknownhosts file
- #
- # This method also stores existing comments, and it stores all host
- # jobs in order, mostly so that comments are retained in the order
- # they were written and in proximity to the same jobs.
- def self.parse(text)
- count = 0
- instances = []
- text.chomp.split("\n").each { |line|
- hash = {}
- case line
- when /^#/, /^\s*$/:
- # add comments and blank lines to the list as they are
- instances << line
- else
- hash = {}
- fields().zip(line.split(" ")).each { |param, value|
- hash[param] = value
- }
-
- if hash[:name] =~ /,/
- names = hash[:name].split(",")
- hash[:name] = names.shift
- hash[:alias] = names
- end
-
- if hash[:alias] == ""
- hash.delete(:alias)
- end
-
- instances << hash
- count += 1
- end
- }
-
- return instances
- end
-
- # Convert the current object into an entry for a known-hosts file.
- def self.to_record(hash)
- name = hash[:name]
- if hash.include?(:alias)
- name += "," + hash[:alias].join(",")
- end
- [name, hash[:type], hash[:key]].join(" ")
- end
-end
-
-# $Id$