diff options
author | kaustubh-d <kaustubh@clogeny.com> | 2013-07-15 16:57:05 +0530 |
---|---|---|
committer | adamedx <adamed@opscode.com> | 2013-07-23 10:34:06 -0700 |
commit | 81f636f9d524abcbcfa77ca2cc464ed75c94e3df (patch) | |
tree | be816c1ca893615a515e5584987739a2d6f7b21d /lib/chef/provider/ifconfig.rb | |
parent | ef7117b7b773204a48d431b1c04bb17f90758769 (diff) | |
download | chef-81f636f9d524abcbcfa77ca2cc464ed75c94e3df.tar.gz |
aix- abstract command generation for ifconfig.
Diffstat (limited to 'lib/chef/provider/ifconfig.rb')
-rw-r--r-- | lib/chef/provider/ifconfig.rb | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 0aacc9e616..17dab0ebf3 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -103,10 +103,7 @@ class Chef # check to see if load_current_resource found interface in ifconfig unless @current_resource.inet_addr unless @new_resource.device == "lo" - command = "ifconfig #{@new_resource.device} #{@new_resource.name}" - command << " netmask #{@new_resource.mask}" if @new_resource.mask - command << " metric #{@new_resource.metric}" if @new_resource.metric - command << " mtu #{@new_resource.mtu}" if @new_resource.mtu + command = add_command end converge_by ("run #{command} to add #{@new_resource}") do run_command( @@ -143,7 +140,7 @@ class Chef def action_delete # check to see if load_current_resource found the interface if @current_resource.device - command = "ifconfig #{@new_resource.device} down" + command = delete_command converge_by ("run #{command} to delete #{@new_resource}") do run_command( :command => command @@ -160,7 +157,7 @@ class Chef # check to see if load_current_resource found the interface # disables, but leaves config files in place. if @current_resource.device - command = "ifconfig #{@new_resource.device} down" + command = disable_command converge_by ("run #{command} to disable #{@new_resource}") do run_command( :command => command @@ -199,6 +196,23 @@ class Chef Chef::Log.info("#{@new_resource} deleted configuration file") end + private + def add_command + command = "ifconfig #{@new_resource.device} #{@new_resource.name}" + command << " netmask #{@new_resource.mask}" if @new_resource.mask + command << " metric #{@new_resource.metric}" if @new_resource.metric + command << " mtu #{@new_resource.mtu}" if @new_resource.mtu + command + end + + def disable_command + "ifconfig #{@new_resource.device} down" + end + + def delete_command + "ifconfig #{@new_resource.device} down" + end + end end end |