Method: LinuxAdmin::NetworkInterfaceRH#save
- Defined in:
- lib/linux_admin/network_interface/network_interface_rh.rb
#save ⇒ Boolean
Writes the contents of @interface_config to @interface_file as ‘key`=`value` pairs and resets the interface
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/linux_admin/network_interface/network_interface_rh.rb', line 171 def save old_contents = @interface_file.file? ? File.read(@interface_file) : "" stop_success = stop # Stop twice because when configure both ipv4 and ipv6 as dhcp, ipv6 dhcp client will # exit and leave a /var/run/dhclient6-eth0.pid file. Then stop (ifdown eth0) will try # to kill this exited process so it returns 1. In the second call, this `.pid' file # has been deleted and ifdown returns 0. # See: https://bugzilla.redhat.com/show_bug.cgi?id=1472396 stop_success = stop unless stop_success return false unless stop_success File.write(@interface_file, @interface_config.delete_blanks.collect { |k, v| "#{k}=#{v}" }.join("\n")) unless start File.write(@interface_file, old_contents) start return false end reload end |