Class: Yast::NetworkAutoconfiguration
- Inherits:
-
Object
- Object
- Yast::NetworkAutoconfiguration
- Includes:
- Logger, Singleton, Wicked
- Defined in:
- src/lib/network/network_autoconfiguration.rb
Overview
The class is responsible for generating / proposing automatic configuration during installation workflow
Constant Summary collapse
- BASH_PATH =
Path.new(".target.bash")
Constants included from Wicked
Instance Method Summary collapse
-
#any_iface_active? ⇒ Boolean
Checks if any of available interfaces is configured and active.
- #configure_dhcp ⇒ Object
-
#configure_dns ⇒ Object
Propose DNS and Hostname setup.
-
#configure_hosts ⇒ Object
Proposes updates for /etc/hosts.
-
#configure_virtuals ⇒ Object
Propose configuration for virtual devices.
Methods included from Wicked
#parse_ntp_servers, #reload_config
Instance Method Details
#any_iface_active? ⇒ Boolean
Checks if any of available interfaces is configured and active
returns [Boolean] true when at least one interface is active
47 48 49 |
# File 'src/lib/network/network_autoconfiguration.rb', line 47 def any_iface_active? config.interfaces.any? { |c| config.connections.by_name(c.name) && active_config?(c.name) } end |
#configure_dhcp ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'src/lib/network/network_autoconfiguration.rb', line 51 def configure_dhcp Yast::Lan.Read(:cache) Yast.include self, "network/routines.rb" # TODO: needed only for phy_connected # find out network devices suitable for dhcp autoconfiguration. # Such device has to: # - be unconfigured # - physically connected to a network # (it speeds up the initialization phase of installer - bnc#872319) dhcp_cards = config.interfaces.select do |c| next false if config.connections.by_name(c.name) phy_connected?(c.name) end log.info "Candidates for enabling DHCP: #{dhcp_cards.inspect}" # TODO: time consuming, some progress would be nice dhcp_cards.each { |d| setup_dhcp(d) } activate_changes(dhcp_cards.map(&:name)) # drop devices without dhcp lease inactive_devices = dhcp_cards.select { |c| !active_config?(c.name) } log.info "Inactive devices: #{inactive_devices}" inactive_devices.each { |c| delete_config(c) } # setup route flag active_devices = dhcp_cards - inactive_devices if active_devices.size == 1 # just one dhcp device, nothing to care of set_default_route_flag(active_devices.first, "yes") else # try to find just one dhcp aware device for allowing default route # if there is more than one dhcp devices enabled for setting default # route (DHCLIENT_SET_DEFAULT_ROUTE = "yes"). bnc#868187 active_devices.find { |d| set_default_route_flag_if_wan_dev?(d.name) } end activate_changes(dhcp_cards.map(&:name)) end |
#configure_dns ⇒ Object
Propose DNS and Hostname setup
112 113 114 115 116 |
# File 'src/lib/network/network_autoconfiguration.rb', line 112 def configure_dns DNS.Read # handles NetworkConfig too log.info("NetworkAutoconfiguration: proposing DNS / Hostname configuration") DNS.Write end |
#configure_hosts ⇒ Object
Proposes updates for /etc/hosts
Expected to be used for updating target system's config. Currently it only updates /etc/hosts with static IP if any.
122 123 124 125 126 |
# File 'src/lib/network/network_autoconfiguration.rb', line 122 def configure_hosts Host.Read Host.ResolveHostnameToStaticIPs Host.Write end |
#configure_virtuals ⇒ Object
Propose configuration for virtual devices
It checks if any of supported virtual machines were installed. If found, propose virtual device(s) configuration
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'src/lib/network/network_autoconfiguration.rb', line 97 def configure_virtuals return if !virtual_proposal_required? log.info("NetworkAutoconfiguration: proposing virtual devices") Lan.ProposeVirtualized # avoid restarting network (installation can run via ssh, vnc, ...) # Moreover virtual devices are not needed during first stage. So, it can # wait for rebooting into just installed target return if Lan.yast_config == Lan.system_config Lan.yast_config.write end |