Class: Y2Network::Presenters::InterfaceSummary
- Inherits:
-
Object
- Object
- Y2Network::Presenters::InterfaceSummary
- Includes:
- InterfaceStatus, Yast::I18n
- Defined in:
- src/lib/y2network/presenters/interface_summary.rb
Overview
This class converts a connection config configuration object into a string to be used in an AutoYaST summary or in a table.
Instance Attribute Summary collapse
- #name ⇒ String readonly
Instance Method Summary collapse
-
#initialize(name, config) ⇒ InterfaceSummary
constructor
Constructor.
- #text ⇒ Object
Methods included from InterfaceStatus
Constructor Details
#initialize(name, config) ⇒ InterfaceSummary
Constructor
41 42 43 44 45 |
# File 'src/lib/y2network/presenters/interface_summary.rb', line 41 def initialize(name, config) textdomain "network" @name = name @config = config end |
Instance Attribute Details
#name ⇒ String (readonly)
35 36 37 |
# File 'src/lib/y2network/presenters/interface_summary.rb', line 35 def name @name end |
Instance Method Details
#text ⇒ Object
47 48 49 50 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'src/lib/y2network/presenters/interface_summary.rb', line 47 def text interface = @config.interfaces.by_name(@name) hardware = interface ? interface.hardware : nil descr = hardware ? hardware.description : "" connection = @config.connections.by_name(@name) bullets = [] rich = "" if connection descr = connection.name if descr.empty? status = status_info(connection) bullets << _("Device Name: %s") % connection.name bullets << status bullets << connection.startmode.long_description bullets += aliases_info(connection) if connection.type.bonding? # TRANSLATORS: text label before list of included devices label = _("Bond Ports") bullets << "#{label}: #{connection.ports.join(" ")}" elsif connection.type.bridge? # TRANSLATORS: text label before list of ports label = _("Bridge Ports") bullets << "#{label}: #{connection.ports.join(" ")}" end parent = connection.find_parent(@config.connections) if parent parent_desc = if parent.type.bonding? # TRANSLATORS: text label before device which is parent for this device _("Bond device") else # TRANSLATORS: text label before device which is bridge for this device _("Bridge") end bullets << format("%s: %s", parent_desc, parent.name) end end if hardware.nil? || !hardware.exists? rich << "<b>(" << _("No hardware information") << ")</b><br>" else rich << "<b>(" << _("Not connected") << ")</b><br>" if !hardware.link rich << "<b>MAC : </b>" << hardware.mac << "<br>" if hardware.mac rich << "<b>BusID : </b>" << hardware.busid << "<br>" if hardware.busid # TODO: physical port id. Probably in hardware? end rich = Yast::HTML.Bold(descr) + "<br>" + rich if connection rich << Yast::HTML.List(bullets) else if hardware&.name && !hardware.name.empty? dev_name = _("Device Name: %s") % hardware.name rich << Yast::HTML.Bold(dev_name) << "<br>" end rich << "<p>" rich << _("The device is not configured. Press <b>Edit</b>\nto configure.\n") rich << "</p>" end rich end |