Class: Bosh::Agent::Platform::Centos::Network

Inherits:
Linux::Network show all
Includes:
Exec
Defined in:
lib/bosh_agent/platform/centos/network.rb

Instance Method Summary collapse

Methods inherited from Linux::Network

#dns, #setup_dhcp_from_settings, #setup_networking, #setup_networking_from_settings

Constructor Details

#initialize(template_dir) ⇒ Network

Returns a new instance of Network.



5
6
7
# File 'lib/bosh_agent/platform/centos/network.rb', line 5

def initialize(template_dir)
  super
end

Instance Method Details

#restart_dhclientObject



33
34
35
36
# File 'lib/bosh_agent/platform/centos/network.rb', line 33

def restart_dhclient
  @logger.info("Restarting network to restart dhclient")
  sh "service network restart"
end

#restart_networking_serviceObject



18
19
20
21
# File 'lib/bosh_agent/platform/centos/network.rb', line 18

def restart_networking_service
  @logger.info("Restarting network")
  sh "service network restart"
end

#write_dhcp_confObject



23
24
25
26
27
28
29
30
31
# File 'lib/bosh_agent/platform/centos/network.rb', line 23

def write_dhcp_conf
  template = ERB.new(load_erb("dhclient_conf.erb"), 0, '%<>-')
  result = template.result(binding)
  updated = Bosh::Agent::Util::update_file(result, '/etc/dhcp/dhclient.conf')
  if updated
    @logger.info("Updated dhclient.conf")
    restart_dhclient
  end
end

#write_network_interfacesObject



9
10
11
12
13
14
15
16
# File 'lib/bosh_agent/platform/centos/network.rb', line 9

def write_network_interfaces
  template = ERB.new(load_erb("centos-ifcfg.erb"), 0, '%<>-')
  networks.each do |name, network|
    result = template.result(binding)
    Bosh::Agent::Util::update_file(result, "/etc/sysconfig/network-scripts/ifcfg-#{name}")
  end
  restart_networking_service
end