summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDominic Maraglia <dmaraglia@gmail.com>2011-05-03 17:59:26 -0700
committerDominic Maraglia <dmaraglia@gmail.com>2011-05-03 17:59:26 -0700
commite5b62d7424da24799c4d16f0e104fac3008e2b89 (patch)
tree7d2d710fa43c39dd35d96cc2db371c548a85518f /lib
parent94f0b0996ba628f4916bcf0978b29c584c15818b (diff)
parentd203853bc8b40732c2ba88a4e5396f00a1e3a4ec (diff)
downloadpuppet-e5b62d7424da24799c4d16f0e104fac3008e2b89.tar.gz
puppet-e5b62d7424da24799c4d16f0e104fac3008e2b89.tar.xz
puppet-e5b62d7424da24799c4d16f0e104fac3008e2b89.zip
Merge branch '2.7.x' of github.com:puppetlabs/puppet into 2.7.x
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application/help.rb1
-rw-r--r--lib/puppet/application/plugin.rb3
-rw-r--r--lib/puppet/face/catalog.rb21
-rw-r--r--lib/puppet/face/plugin.rb12
-rw-r--r--lib/puppet/face/report.rb5
-rw-r--r--lib/puppet/face/secret_agent.rb10
-rw-r--r--lib/puppet/file_serving/fileset.rb2
-rw-r--r--lib/puppet/interface/action.rb13
-rw-r--r--lib/puppet/interface/documentation.rb5
-rw-r--r--lib/puppet/interface/face_collection.rb1
-rw-r--r--lib/puppet/network/http/api/v1.rb2
11 files changed, 54 insertions, 21 deletions
diff --git a/lib/puppet/application/help.rb b/lib/puppet/application/help.rb
index 0d7767632..4829a2036 100644
--- a/lib/puppet/application/help.rb
+++ b/lib/puppet/application/help.rb
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
require 'puppet/application/face_base'
class Puppet::Application::Help < Puppet::Application::FaceBase
diff --git a/lib/puppet/application/plugin.rb b/lib/puppet/application/plugin.rb
new file mode 100644
index 000000000..2d0402e43
--- /dev/null
+++ b/lib/puppet/application/plugin.rb
@@ -0,0 +1,3 @@
+require 'puppet/application/face_base'
+class Puppet::Application::Plugin < Puppet::Application::FaceBase
+end
diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb
index 5f1f138ee..3e964c7fe 100644
--- a/lib/puppet/face/catalog.rb
+++ b/lib/puppet/face/catalog.rb
@@ -18,7 +18,10 @@ with '--format dot'.
action(:apply) do
summary "apply a Puppet::Resource::Catalog object"
- when_invoked do |catalog, options|
+ when_invoked do |options|
+ catalog = Puppet::Face[:catalog, "0.0.1"].find(Puppet[:certname]) or raise "Could not find catalog for #{Puppet[:certname]}"
+ catalog = catalog.to_ral
+
report = Puppet::Transaction::Report.new("apply")
report.configuration_version = catalog.version
@@ -39,20 +42,22 @@ with '--format dot'.
end
action(:download) do
- summary "download the catalog given the certname and facts"
+ summary "Download the catalog for the certname to the local filesystem."
- when_invoked do |certname, facts, options|
+ when_invoked do |options|
Puppet::Resource::Catalog.indirection.terminus_class = :rest
- facts_to_upload = {:facts_format => :b64_zlib_yaml, :facts => CGI.escape(facts.render(:b64_zlib_yaml))}
+ Puppet::Resource::Catalog.indirection.cache_class = nil
catalog = nil
retrieval_duration = thinmark do
- catalog = Puppet::Face[:catalog, '0.0.1'].find(certname, facts_to_upload)
+ catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname])
end
- catalog = catalog.to_ral
- catalog.finalize
catalog.retrieval_duration = retrieval_duration
catalog.write_class_file
- catalog
+
+ Puppet::Resource::Catalog.indirection.terminus_class = :yaml
+ Puppet::Face[:catalog, "0.0.1"].save(catalog)
+ Puppet.notice "Saved catalog for #{Puppet[:certname]} to yaml"
+ nil
end
end
end
diff --git a/lib/puppet/face/plugin.rb b/lib/puppet/face/plugin.rb
index 19060942a..4b45ed3a1 100644
--- a/lib/puppet/face/plugin.rb
+++ b/lib/puppet/face/plugin.rb
@@ -7,6 +7,10 @@ Puppet::Face.define(:plugin, '0.0.1') do
action :download do
summary "Download plugins from the configured master"
+ returns <<-EOT
+ An array containing the files actually downloaded.
+ This will be empty array when everything was in sync.
+ EOT
when_invoked do |options|
require 'puppet/configurer/downloader'
@@ -15,5 +19,13 @@ Puppet::Face.define(:plugin, '0.0.1') do
Puppet[:pluginsource],
Puppet[:pluginsignore]).evaluate
end
+
+ when_rendering :for_humans do |value|
+ if value.empty? then
+ "No plugins downloaded."
+ else
+ "Downloaded these plugins: #{value.join(', ')}"
+ end
+ end
end
end
diff --git a/lib/puppet/face/report.rb b/lib/puppet/face/report.rb
index dabf83702..f5b6d08ff 100644
--- a/lib/puppet/face/report.rb
+++ b/lib/puppet/face/report.rb
@@ -9,8 +9,9 @@ Puppet::Indirector::Face.define(:report, '0.0.1') do
action(:submit) do
when_invoked do |report, options|
begin
- Puppet::Transaction::Report.terminus_class = :rest
- report.save
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Face[:report, "0.0.1"].save(report)
+ Puppet.notice "Uploaded report for #{report.name}"
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not send report: #{detail}"
diff --git a/lib/puppet/face/secret_agent.rb b/lib/puppet/face/secret_agent.rb
index 50018cb13..99208b545 100644
--- a/lib/puppet/face/secret_agent.rb
+++ b/lib/puppet/face/secret_agent.rb
@@ -9,12 +9,14 @@ Puppet::Face.define(:secret_agent, '0.0.1') do
action(:synchronize) do
summary "run the secret agent, which makes the catalog and system match..."
- when_invoked do |certname, options|
+ when_invoked do |options|
Puppet::Face[:plugin, '0.0.1'].download
- facts = Puppet::Face[:facts, '0.0.1'].find(certname)
- catalog = Puppet::Face[:catalog, '0.0.1'].download(certname, facts)
- report = Puppet::Face[:catalog, '0.0.1'].apply(catalog)
+ Puppet::Face[:facts, '0.0.1'].upload
+
+ Puppet::Face[:catalog, '0.0.1'].download
+
+ report = Puppet::Face[:catalog, '0.0.1'].apply
Puppet::Face[:report, '0.0.1'].submit(report)
diff --git a/lib/puppet/file_serving/fileset.rb b/lib/puppet/file_serving/fileset.rb
index c020f036d..f29f70a53 100644
--- a/lib/puppet/file_serving/fileset.rb
+++ b/lib/puppet/file_serving/fileset.rb
@@ -59,7 +59,7 @@ class Puppet::FileServing::Fileset
end
def initialize(path, options = {})
- path = path.chomp(File::SEPARATOR)
+ path = path.chomp(File::SEPARATOR) unless path == File::SEPARATOR
raise ArgumentError.new("Fileset paths must be fully qualified") unless File.expand_path(path) == path
@path = path
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
index 203d80827..622371a4e 100644
--- a/lib/puppet/interface/action.rb
+++ b/lib/puppet/interface/action.rb
@@ -3,6 +3,7 @@ require 'puppet/interface/documentation'
require 'prettyprint'
class Puppet::Interface::Action
+ extend Puppet::Interface::DocGen
include Puppet::Interface::FullDocs
def initialize(face, name, attrs = {})
@@ -44,6 +45,7 @@ class Puppet::Interface::Action
########################################################################
# Documentation...
+ attr_doc :returns
def synopsis
output = PrettyPrint.format do |s|
s.text("puppet #{@face.name}")
@@ -74,8 +76,15 @@ class Puppet::Interface::Action
unless type.is_a? Symbol
raise ArgumentError, "The rendering format must be a symbol, not #{type.class.name}"
end
- return unless @when_rendering.has_key? type
- return @when_rendering[type].bind(@face)
+ # Do we have a rendering hook for this name?
+ return @when_rendering[type].bind(@face) if @when_rendering.has_key? type
+
+ # How about by another name?
+ alt = type.to_s.sub(/^to_/, '').to_sym
+ return @when_rendering[alt].bind(@face) if @when_rendering.has_key? alt
+
+ # Guess not, nothing to run.
+ return nil
end
def set_rendering_method_for(type, proc)
unless proc.is_a? Proc
diff --git a/lib/puppet/interface/documentation.rb b/lib/puppet/interface/documentation.rb
index 91db0e074..48e9a8b1a 100644
--- a/lib/puppet/interface/documentation.rb
+++ b/lib/puppet/interface/documentation.rb
@@ -6,7 +6,10 @@ class Puppet::Interface
# We need to identify an indent: the minimum number of whitespace
# characters at the start of any line in the text.
- indent = text.each_line.map {|x| x.index(/[^\s]/) }.compact.min
+ #
+ # Using split rather than each_line is because the later only takes a
+ # block on Ruby 1.8.5 / Centos, and we support that. --daniel 2011-05-03
+ indent = text.split(/\n/).map {|x| x.index(/[^\s]/) }.compact.min
if indent > 0 then
text.gsub!(/^[ \t\f]{0,#{indent}}/, '')
diff --git a/lib/puppet/interface/face_collection.rb b/lib/puppet/interface/face_collection.rb
index baa424692..12d3c56b1 100644
--- a/lib/puppet/interface/face_collection.rb
+++ b/lib/puppet/interface/face_collection.rb
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
require 'puppet/interface'
module Puppet::Interface::FaceCollection
diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb
index 61307f01e..388d54961 100644
--- a/lib/puppet/network/http/api/v1.rb
+++ b/lib/puppet/network/http/api/v1.rb
@@ -30,7 +30,7 @@ module Puppet::Network::HTTP::API::V1
method = indirection_method(http_method, indirection)
- params[:environment] = environment
+ params[:environment] = Puppet::Node::Environment.new(environment)
raise ArgumentError, "No request key specified in #{uri}" if key == "" or key.nil?