Class: Y2Network::Presenters::InterfacesSummary
- Inherits:
-
Object
- Object
- Y2Network::Presenters::InterfacesSummary
- Includes:
- InterfaceStatus, Yast::I18n, Yast::Logger
- Defined in:
- src/lib/y2network/presenters/interfaces_summary.rb
Overview
This class is responsible of creating text summaries for the connections of the Y2Network::Config given
Instance Attribute Summary collapse
- #config ⇒ Config readonly
Instance Method Summary collapse
-
#bonding_summary ⇒ String
Return a summary of the configured bonding interfaces.
-
#bridge_summary ⇒ String
Return a summary of the configured bridge interfaces.
-
#dhcp_summary ⇒ String
Return a summary of the interfaces configured with DHCP.
-
#initialize(config) ⇒ InterfacesSummary
constructor
Constructor.
-
#one_line_text ⇒ String
Generates a one line text summary for the configured interfaces.
-
#proposal_text ⇒ String
Generates a summary in RichText format for the configured interfaces.
-
#static_summary ⇒ String
Return a summary of the interfaces configured statically.
-
#text ⇒ String
Interfaces configuration summary in RichText format.
Methods included from InterfaceStatus
Constructor Details
#initialize(config) ⇒ InterfacesSummary
Constructor
42 43 44 45 46 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 42 def initialize(config) textdomain "network" @config = config end |
Instance Attribute Details
#config ⇒ Config (readonly)
37 38 39 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 37 def config @config end |
Instance Method Details
#bonding_summary ⇒ String
Return a summary of the configured bonding interfaces
146 147 148 149 150 151 152 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 146 def bonding_summary # TRANSLATORS: %s is the list of bonding interface names and included # devices like 'bond0 (br0, eth2)' _("Bonds: %s") % bonding_connections.map do |connection| "#{connection.name} (#{connection.ports.sort.join(", ")})" end end |
#bridge_summary ⇒ String
Return a summary of the configured bridge interfaces
135 136 137 138 139 140 141 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 135 def bridge_summary # TRANSLATORS: %s is a list of bridge interface names and their ports # like 'br0 (eth0, eth1)' _("Bridges: %s") % bridge_connections.map do |connection| "#{connection.name} (#{connection.ports.sort.join(", ")})" end end |
#dhcp_summary ⇒ String
Return a summary of the interfaces configured with DHCP
119 120 121 122 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 119 def dhcp_summary # TRANSLATORS: %s is the list of interfaces configured by DHCP _("Configured with DHCP: %s") % dhcp_ifaces.sort.join(", ") end |
#one_line_text ⇒ String
Generates a one line text summary for the configured interfaces.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 74 def one_line_text protocols = [] output = [] protocols << "DHCP" if config.connections.any?(&:dhcp?) protocols << "STATIC" if config.connections.any?(&:static?) output << protocols.first if protocols.uniq.size == 1 case config.connections.size when 0 return Yast::Summary.NotConfigured when 1 output << config.connections.first.interface else output << _("Multiple Interfaces") end output.join(" / ") end |
#proposal_text ⇒ String
Generates a summary in RichText format for the configured interfaces
105 106 107 108 109 110 111 112 113 114 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 105 def proposal_text items = [] items << list_item_for(dhcp_summary) unless dhcp_ifaces.empty? items << list_item_for(static_summary) unless static_ifaces.empty? items << list_item_for(bridge_summary) unless bridge_connections.empty? items << list_item_for(bonding_summary) unless bonding_connections.empty? items << list_item_for(Yast::Summary.NotConfigured) if items.empty? Yast::Summary.DevicesList(items) end |
#static_summary ⇒ String
Return a summary of the interfaces configured statically
127 128 129 130 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 127 def static_summary # TRANSLATORS: %s is the list of interfaces configured statically _("Statically configured: %s") % static_ifaces.sort.join(", ") end |
#text ⇒ String
Interfaces configuration summary in RichText format
51 52 53 54 55 56 57 58 59 60 61 |
# File 'src/lib/y2network/presenters/interfaces_summary.rb', line 51 def text overview = config.interfaces.map do |interface| connection = config.connections.by_name(interface.name) descr = interface.hardware ? interface.hardware.description : "" descr = interface.name if descr.empty? status = connection ? status_info(connection) : Yast::Summary.NotConfigured Yast::Summary.Device(descr, status) end Yast::Summary.DevicesList(overview) end |