Greetings!
Please review the pull request #118: Ticket/2.7.x/9522 opened by (nanliu)
Some more information about the pull request:
- Opened: Thu Sep 15 20:21:51 UTC 2011
- Based on: puppetlabs:2.7.x (25b4cb689432a658f3ccf8985197c5986605d764)
- Requested merge: nanliu:ticket/2.7.x/9522 (8fc463af66fbeefa64b4d3f1f647f7815ae9daf4)
Description:
This patch resolves the following two issue.
- Network device config parsing doens't support - in hostname.
- ConfigurationError isn't declared.
Thanks!
The Pull Request Bot
Diff follows:
diff --git a/lib/puppet/util/network_device/config.rb b/lib/puppet/util/network_device/config.rb
index 17f4e25..f36b88f 100644
--- a/lib/puppet/util/network_device/config.rb
+++ b/lib/puppet/util/network_device/config.rb
@@ -2,6 +2,7 @@ require 'ostruct'
require 'puppet/util/loadedfile'
class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
+ class ConfigurationError < Puppet::Error; end
def self.main
@main ||= self.new
@@ -51,7 +52,7 @@ 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)
@@ -90,4 +91,4 @@ class Puppet::Util::NetworkDevice::Config < Puppet::Util::LoadedFile
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/unit/util/network_device/config_spec.rb b/spec/unit/util/network_device/config_spec.rb
index d9bd3d9..c4798aa 100755
--- a/spec/unit/util/network_device/config_spec.rb
+++ b/spec/unit/util/network_device/config_spec.rb
@@ -52,10 +52,10 @@ describe Puppet::Util::NetworkDevice::Config do
end
it "should increment line number even on commented lines" do
- @fd.stubs(:each).multiple_yields(' # comment','[router.puppetlabs.com]')
+ @fd.stubs(:each).multiple_yields(' # comment','[router-foo.puppetlabs.com]')
@config.read
- @config.devices.should be_include('router.puppetlabs.com')
+ @config.devices.should be_include('router-foo.puppetlabs.com')
end
it "should skip blank lines" do
@@ -79,7 +79,7 @@ describe Puppet::Util::NetworkDevice::Config do
end
it "should create a new device for each found device line" do
- @fd.stubs(:each).multiple_yields('[router.puppetlabs.com]', '[swith.puppetlabs.com]')
+ @fd.stubs(:each).multiple_yields('[router.puppetlabs.com]', '[test-switch.puppetlabs.com]')
@config.read
@config.devices.size.should == 2
-- 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.
