Class: Yast::SetupDhcp

Inherits:
Object
  • Object
show all
Includes:
Logger, Singleton
Defined in:
src/lib/network/clients/inst_setup_dhcp.rb

Instance Method Summary collapse

Instance Method Details

#mainObject


30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'src/lib/network/clients/inst_setup_dhcp.rb', line 30

def main
  nac = NetworkAutoconfiguration.instance
  set_dhcp_hostname! if Stage.initial

  if !nac.any_iface_active?
    nac.configure_dhcp
  else
    log.info("Automatic DHCP configuration not started - an interface is already configured")
  end

  # if this is not wrapped in a def, ruby -cw says
  # warning: possibly useless use of a literal in void context
  :next
end

#set_dhcp_hostname!Object

Write the DHCLIENT_SET_HOSTNAME in /etc/sysconfig/network/dhcp based on linuxrc sethostname cmdline option if provided or the default value defined in the control file if not.


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'src/lib/network/clients/inst_setup_dhcp.rb', line 58

def set_dhcp_hostname!
  DNS.dhcp_hostname =
    set_hostname_used? ? set_dhcp_hostname? : DNS.default_dhcp_hostname

  log.info("Write dhcp hostname default: #{DNS.dhcp_hostname}")
  SCR.Write(
    Yast::Path.new(".sysconfig.network.dhcp.DHCLIENT_SET_HOSTNAME"),
    DNS.dhcp_hostname ? "yes" : "no"
  )
  # Flush cache
  SCR.Write(
    Yast::Path.new(".sysconfig.network.dhcp"),
    nil
  )
end

#set_dhcp_hostname?Boolean

Check if set of DHCLIENT_SET_HOSTNAME in /etc/sysconfig/network/dhcp has been disable by linuxrc cmdline


49
50
51
52
53
# File 'src/lib/network/clients/inst_setup_dhcp.rb', line 49

def set_dhcp_hostname?
  set_hostname = Linuxrc.InstallInf("SetHostname")
  log.info("SetHostname: #{set_hostname}")
  set_hostname != "0"
end

#set_hostname_used?Boolean

Check whether the linuxrc sethostname option has been used or not


77
78
79
# File 'src/lib/network/clients/inst_setup_dhcp.rb', line 77

def set_hostname_used?
  Linuxrc.InstallInf("SetHostnameUsed") == "1"
end