From 9afdf1fa429cd5f81f68d27e172af208d6118e22 Mon Sep 17 00:00:00 2001 From: luke Date: Thu, 21 Sep 2006 19:43:45 +0000 Subject: Adding an Autoload instance to Type.rb so that I can load all known types for documentation purposes. And, of course, loading all types in puppetdoc. Also updating zone.rb to fix markdown's stupidity in trying to interpret the ERB template, and adding some timeouts to puppettest.rb git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1651 980ebf18-57e1-0310-9a29-db15c13687c0 --- bin/puppetdoc | 5 +++++ lib/puppet/type.rb | 20 +++++++++++++++++--- lib/puppet/type/zone.rb | 16 +++++++++------- test/lib/puppettest.rb | 10 +++++++++- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/bin/puppetdoc b/bin/puppetdoc index 3b3d2babb..8185ed773 100755 --- a/bin/puppetdoc +++ b/bin/puppetdoc @@ -89,6 +89,9 @@ rescue GetoptLong::InvalidOption => detail end def scrub(text) + + # Stupid markdown + #text = text.gsub("<%=", "<%=") # For text with no carriage returns, there's nothing to do. if text !~ /\n/ return text @@ -191,6 +194,8 @@ orderInfo: 4 } types = {} + Puppet::Type.loadall + Puppet::Type.eachtype { |type| next if type.name == :puppet next if type.name == :component diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 0e0628202..13caf1973 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -128,6 +128,11 @@ class Type < Puppet::Element end + # Load all types. Only currently used for documentation. + def self.loadall + typeloader.loadall + end + # Do an on-demand plugin load def self.loadplugin(name) unless Puppet[:pluginpath].split(":").include?(Puppet[:plugindest]) @@ -213,12 +218,11 @@ class Type < Puppet::Element end unless @types.include? name - begin - require "puppet/type/#{name}" + if typeloader.load(name) unless @types.include? name Puppet.warning "Loaded puppet/type/#{name} but no class was created" end - rescue LoadError => detail + else # If we can't load it from there, try loading it as a plugin. loadplugin(name) end @@ -227,6 +231,16 @@ class Type < Puppet::Element @types[name] end + def self.typeloader + unless defined? @typeloader + @typeloader = Puppet::Autoload.new(self, + "puppet/type", :wrap => false + ) + end + + @typeloader + end + # class methods dealing with type instance management public diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index de94e51ca..c882e199c 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -287,21 +287,23 @@ end desc %{The text to go into the sysidcfg file when the zone is first booted. The best way is to use a template: +

                 # $templatedir/sysidcfg
                 system_locale=en_US
                 timezone=GMT
                 terminal=xterms
                 security_policy=NONE
-                root_password=<%= password %>
+                root_password=<%= password %>
                 timeserver=localhost
-                name_service=DNS {domain_name=<%= domain %>
-                        name_server=<%= nameserver %>}
-                network_interface=primary {hostname=<%= realhostname %>
-                        ip_address=<%= ip %>
-                        netmask=<%= netmask %>
+                name_service=DNS {domain_name=<%= domain %>
+                        name_server=<%= nameserver %>}
+                network_interface=primary {hostname=<%= realhostname %>
+                        ip_address=<%= ip %>
+                        netmask=<%= netmask %>
                         protocol_ipv6=no
-                        default_route=<%= defaultroute %>}
+                        default_route=<%= defaultroute %>}
                 nfs4_domain=dynamic
+            
And then call that: diff --git a/test/lib/puppettest.rb b/test/lib/puppettest.rb index bff410060..4fa7a676f 100644 --- a/test/lib/puppettest.rb +++ b/test/lib/puppettest.rb @@ -179,7 +179,15 @@ module PuppetTest Puppet::Log.close # Just in case there are processes waiting to die... - Process.waitall + require 'timeout' + + begin + Timeout::timeout(5) do + Process.waitall + end + rescue Timeout::Error + # just move on + end if File.stat("/dev/null").mode & 007777 != 0666 File.open("/tmp/nullfailure", "w") { |f| f.puts self.class -- cgit