Skip to content

Use ifcfg script name in case DEVICE parameter is not specified on redhat network_config provider #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/puppet/provider/network_config/redhat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ def self.parse_file(filename, contents)
#
props.merge!({:family => :inet})

# If there is no DEVICE property in the interface configuration we retrieve
# the interface name from the file name itself
unless props.has_key?(:name)
props.merge!({:name => filename.split("ifcfg-")[1]})
end

# The FileMapper mixin expects an array of providers, so we return the
# single interface wrapped in an array
[props]
Expand Down
5 changes: 5 additions & 0 deletions spec/fixtures/provider/network_config/redhat_spec/eth1-dhcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
BOOTPROTO=dhcp
DHCPCLASS=
HWADDR=00:50:56:B2:00:1B
ONBOOT=yes
7 changes: 6 additions & 1 deletion spec/unit/provider/network_config/redhat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ def fixture_data(file)
end
end

describe 'when DEVICE is not present' do
let(:data) { described_class.parse_file('ifcfg-eth1', fixture_data('eth1-dhcp'))[0] }
it { data[:name].should == 'eth1' }
end

end

describe "when formatting resources" do
Expand Down Expand Up @@ -430,7 +435,7 @@ def fixture_data(file)
File.expects(:unlink).never
described_class.stubs(:perform_write)
described_class.dirty_file!('/not/a/real/file')
described_class.flush_file('/not/a/real/file')
described_class.flush_file('/not/a/real/file')
}
end
end