Greetings!
Please review the pull request #113: Fix #7982 and some assorted network devices problems opened by (masterzen)
Some more information about the pull request:
- Opened: Wed Sep 14 18:45:52 UTC 2011
- Based on: puppetlabs:2.7.x (9e725e4b0c01ff1291e40350deb1845643f7a26b)
- Requested merge: masterzen:tickets/2.7.x/7982 (759547511364f900d6ece94e6311c8e54cff86cd)
Description:
Please find here 3 commits fixing #7982, #9164 and a last minute fix in the network device device.conf parsing.
Thanks!
The Pull Request Bot
Diff follows:
diff --git a/lib/puppet/application/device.rb b/lib/puppet/application/device.rb
index 977c5c0..d0b9387 100644
--- a/lib/puppet/application/device.rb
+++ b/lib/puppet/application/device.rb
@@ -196,6 +196,7 @@ Licensed under the Apache 2.0 License
Puppet.settings.set_value(:vardir, vardir, :cli)
Puppet.settings.set_value(:confdir, confdir, :cli)
Puppet.settings.set_value(:certname, certname, :cli)
+ Puppet::SSL::Host.reset
end
end
end
diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
index a06b1e2..28a0819 100644
--- a/lib/puppet/ssl/host.rb
+++ b/lib/puppet/ssl/host.rb
@@ -34,6 +34,10 @@ class Puppet::SSL::Host
@localhost
end
+ def self.reset
+ @localhost = nil
+ end
+
# This is the constant that people will use to mark that a given host is
# a certificate authority.
def self.ca_name
diff --git a/lib/puppet/util/network_device/config.rb b/lib/puppet/util/network_device/config.rb
index 17f4e25..afb9a15 100644
--- a/lib/puppet/util/network_device/config.rb
+++ b/lib/puppet/util/network_device/config.rb
@@ -51,10 +51,10 @@ class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
when /^\s*$/ # skip blank lines
count += 1
next
- when /^\[([\w.]+)\]\s*$/ # [device.fqdn]
+ when /^\[([\w.-]+)\]\s*$/ # [device.fqdn]
name = $1
name.chomp!
- raise ConfigurationError, "Duplicate device found at line #{count}, already found at #{device.line}" if devices.include?(name)
+ raise Puppet::Error, "Duplicate device found at line #{count}, already found at #{device.line}" if devices.include?(name)
device = OpenStruct.new
device.name = name
device.line = count
@@ -63,7 +63,7 @@ class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
when /^\s*(type|url)\s+(.+)$/
parse_directive(device, $1, $2, count)
else
- raise ConfigurationError, "Invalid line #{count}: #{line}"
+ raise Puppet::Error, "Invalid line #{count}: #{line}"
end
count += 1
}
@@ -85,8 +85,7 @@ class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
when "url"
device.url = ""
else
- raise ConfigurationError,
- "Invalid argument '#{var}' at line #{count}"
+ raise Puppet::Error, "Invalid argument '#{var}' at line #{count}"
end
end
diff --git a/spec/unit/application/device_spec.rb b/spec/unit/application/device_spec.rb
index f88c0c3..43048fb 100755
--- a/spec/unit/application/device_spec.rb
+++ b/spec/unit/application/device_spec.rb
@@ -338,6 +338,11 @@ describe Puppet::Application::Device do
@device.main
end
+ it "should expire all cached attributes" do
+ Puppet::SSL::Host.expects(:reset).twice
+
+ @device.main
+ end
end
end
end
diff --git a/spec/unit/ssl/host_spec.rb b/spec/unit/ssl/host_spec.rb
index 226acde..6551c8f 100755
--- a/spec/unit/ssl/host_spec.rb
+++ b/spec/unit/ssl/host_spec.rb
@@ -22,7 +22,7 @@ describe Puppet::SSL::Host, :fails_on_windows => true do
after do
# Cleaned out any cached localhost instance.
- Puppet::SSL::Host.instance_variable_set(:@localhost, nil)
+ Puppet::SSL::Host.reset
Puppet::SSL::Host.ca_location = :none
end
@@ -65,6 +65,12 @@ describe Puppet::SSL::Host, :fails_on_windows => true do
Puppet::SSL::Host.should respond_to(:localhost)
end
+ it "should allow to reset localhost" do
+ previous_host = Puppet::SSL::Host.localhost
+ Puppet::SSL::Host.reset
+ Puppet::SSL::Host.localhost.should_not == previous_host
+ end
+
it "should generate the certificate for the localhost instance if no certificate is available" do
host = stub 'host', :key => nil
Puppet::SSL::Host.expects(:new).returns host
diff --git a/spec/unit/util/network_device/config_spec.rb b/spec/unit/util/network_device/config_spec.rb
index d9bd3d9..8b24677 100755
--- a/spec/unit/util/network_device/config_spec.rb
+++ b/spec/unit/util/network_device/config_spec.rb
@@ -78,6 +78,13 @@ describe Puppet::Util::NetworkDevice::Config do
lambda { @config.read }.should raise_error
end
+ it "should accept device certname containing dashes" do
+ @fd.stubs(:each).yields('[router-1.puppetlabs.com]')
+
+ @config.read
+ @config.devices.should include('router-1.puppetlabs.com')
+ end
+
it "should create a new device for each found device line" do
@fd.stubs(:each).multiple_yields('[router.puppetlabs.com]', '[swith.puppetlabs.com]')
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
