summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-02-08 16:24:30 -0800
committerLuke Kanies <luke@puppetlabs.com>2011-02-08 16:24:30 -0800
commitefca35cbea836fac954fb655d76493f03b36e96f (patch)
treebead559fb4a20391cac95a0ff650b7ef24ceb561
parent025768fc69de268b3c01526a138f54dc5778b9c8 (diff)
downloadpuppet-efca35cbea836fac954fb655d76493f03b36e96f.tar.gz
puppet-efca35cbea836fac954fb655d76493f03b36e96f.tar.xz
puppet-efca35cbea836fac954fb655d76493f03b36e96f.zip
Finishing migration from puppet repo
The whole system seems to work again, as long as you run it against 2.6.next. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
-rw-r--r--lib/puppet/application/data.rb13
-rw-r--r--lib/puppet/application/data_baseclass.rb1
-rw-r--r--lib/puppet/interface.rb34
-rw-r--r--lib/puppet/interface/catalog/select.rb6
-rw-r--r--lib/puppet/interface/resource.rb4
5 files changed, 38 insertions, 20 deletions
diff --git a/lib/puppet/application/data.rb b/lib/puppet/application/data.rb
index cfbf4305a..8d98d4416 100644
--- a/lib/puppet/application/data.rb
+++ b/lib/puppet/application/data.rb
@@ -52,6 +52,8 @@ class Puppet::Application::Data < Puppet::Application
def setup
Puppet::Util::Log.newdestination :console
+ load_applications # Call this to load all of the apps
+
@verb, @arguments = command_line.args
@arguments ||= []
@@ -77,8 +79,15 @@ class Puppet::Application::Data < Puppet::Application
end
def actions(indirection)
- return [] unless app = Puppet::Application.find(indirection)
- return app.actions.sort { |a,b| a.to_s <=> b.to_s }
+ return [] unless interface = Puppet::Interface.interface(indirection)
+ interface.load_actions
+ return interface.actions.sort { |a,b| a.to_s <=> b.to_s }
+ end
+
+ def load_applications
+ command_line.available_subcommands.each do |app|
+ command_line.require_application app
+ end
end
end
diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb
index 95142b8ba..3f498f56f 100644
--- a/lib/puppet/application/data_baseclass.rb
+++ b/lib/puppet/application/data_baseclass.rb
@@ -60,6 +60,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application
@type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym
@interface = Puppet::Interface.interface(@type).new
+ @interface.format = format if format
validate
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 2be3df5d6..6e132f645 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -47,6 +47,21 @@ class Puppet::Interface
Kernel::exit(1)
end
+ # Try to find actions defined in other files.
+ def self.load_actions
+ path = "puppet/interface/#{name}"
+
+ autoloader.search_directories.each do |dir|
+ fdir = File.join(dir, path)
+ next unless FileTest.directory?(fdir)
+
+ Dir.glob("#{fdir}/*.rb").each do |file|
+ Puppet.info "Loading actions for '#{name}' from '#{file}'"
+ require file
+ end
+ end
+ end
+
# Return the interface name.
def self.name
@name || self.to_s.sub(/.+::/, '').downcase
@@ -94,7 +109,7 @@ class Puppet::Interface
Puppet::Util::Log.newdestination :console
- load_actions
+ self.class.load_actions
end
def set_terminus(from)
@@ -114,27 +129,12 @@ class Puppet::Interface
end
unless result
- raise "Could not #{verb} #{type} for #{name}"
+ raise "Could not #{method} #{indirection.name} for #{name}"
end
puts result.render(format.to_sym)
end
- # Try to find actions defined in other files.
- def load_actions
- path = "puppet/interface/#{self.class.name}"
-
- self.class.autoloader.search_directories.each do |dir|
- fdir = File.join(dir, path)
- next unless FileTest.directory?(fdir)
-
- Dir.glob("#{fdir}/*.rb").each do |file|
- Puppet.info "Loading actions for '#{self.class.name}' from '#{file}'"
- require file
- end
- end
- end
-
def indirections
Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
end
diff --git a/lib/puppet/interface/catalog/select.rb b/lib/puppet/interface/catalog/select.rb
index 6311a4a74..4bb49315c 100644
--- a/lib/puppet/interface/catalog/select.rb
+++ b/lib/puppet/interface/catalog/select.rb
@@ -1,4 +1,8 @@
# Select and show a list of resources of a given type.
Puppet::Interface::Catalog.action :select do |*args|
- puts "Selecting #{args.inspect}"
+ host = args.shift
+ type = args.shift
+ catalog = Puppet::Resource::Catalog.indirection.find(host)
+
+ catalog.resources.reject { |res| res.type != type }.each { |res| puts res }
end
diff --git a/lib/puppet/interface/resource.rb b/lib/puppet/interface/resource.rb
new file mode 100644
index 000000000..b9b007d00
--- /dev/null
+++ b/lib/puppet/interface/resource.rb
@@ -0,0 +1,4 @@
+require 'puppet/interface'
+
+class Puppet::Interface::Resource < Puppet::Interface
+end