• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-network / 4859584370

pending completion
4859584370

Pull #1327

github

Unknown Committer
Unknown Commit Message
Pull Request #1327: [WIP] Firmware configured interface

81 of 81 new or added lines in 7 files covered. (100.0%)

9240 of 11493 relevant lines covered (80.4%)

20.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.38
/src/lib/y2network/presenters/interface_summary.rb
1
# Copyright (c) [2019] SUSE LLC
2
#
3
# All Rights Reserved.
4
#
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of version 2 of the GNU General Public License as published
7
# by the Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
# more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, contact SUSE LLC.
16
#
17
# To contact SUSE LLC about this file by physical or electronic mail, you may
18
# find current contact information at www.suse.com.
19

20
require "yast"
1✔
21
require "y2network/presenters/interface_status"
1✔
22
require "network/wicked"
1✔
23

24
Yast.import "Summary"
1✔
25
Yast.import "HTML"
1✔
26

27
module Y2Network
1✔
28
  module Presenters
1✔
29
    # This class converts a connection config configuration object into a string to be used
30
    # in an AutoYaST summary or in a table.
31
    class InterfaceSummary
1✔
32
      include Yast::I18n
1✔
33
      include InterfaceStatus
1✔
34
      include Yast::Wicked
1✔
35

36
      # @return [String]
37
      attr_reader :name
1✔
38

39
      # Constructor
40
      #
41
      # @param name [String] name of device to describe
42
      # @param config [Y2Network::Config]
43
      def initialize(name, config)
1✔
44
        textdomain "network"
15✔
45
        @name = name
15✔
46
        @config = config
15✔
47
      end
48

49
      def text
1✔
50
        interface = @config.interfaces.by_name(@name)
15✔
51
        hardware = interface ? interface.hardware : nil
15✔
52
        descr = hardware ? hardware.description : ""
15✔
53

54
        connection = @config.connections.by_name(@name)
15✔
55
        bullets = []
15✔
56
        rich = ""
15✔
57

58
        if connection
15✔
59
          descr = connection.name if descr.empty?
12✔
60

61
          status = status_info(connection)
12✔
62

63
          bullets << _("Device Name: %s") % connection.name
12✔
64
          bullets << status
12✔
65
          bullets << connection.startmode.long_description
12✔
66
          bullets += aliases_info(connection)
12✔
67

68
          if connection.type.bonding?
12✔
69
            # TRANSLATORS: text label before list of included devices
70
            label = _("Bond Ports")
×
71
            bullets << "#{label}: #{connection.ports.join(" ")}"
×
72
          elsif connection.type.bridge?
12✔
73
            # TRANSLATORS: text label before list of ports
74
            label = _("Bridge Ports")
×
75
            bullets << "#{label}: #{connection.ports.join(" ")}"
×
76
          end
77

78
          parent = connection.find_parent(@config.connections)
12✔
79
          if parent
12✔
80
            parent_desc = if parent.type.bonding?
×
81
              # TRANSLATORS: text label before device which is parent for this device
82
              _("Bond device")
×
83
            else
84
              # TRANSLATORS: text label before device which is bridge for this device
85
              _("Bridge")
×
86
            end
87
            bullets << format("%s: %s", parent_desc, parent.name)
×
88
          end
89
        end
90

91
        if hardware.nil? || !hardware.exists?
15✔
92
          rich << "<b>(" << _("No hardware information") << ")</b><br>"
4✔
93
        else
94
          rich << "<b>(" << _("Not connected") << ")</b><br>" if !hardware.link
11✔
95
          rich << "<b>MAC : </b>" << hardware.mac << "<br>" if hardware.mac
11✔
96
          rich << "<b>BusID : </b>" << hardware.busid << "<br>" if hardware.busid
11✔
97
          # TODO: physical port id. Probably in hardware?
98
        end
99

100
        rich = Yast::HTML.Bold(descr) + "<br>" + rich
15✔
101
        if connection
15✔
102
          rich << Yast::HTML.List(bullets)
12✔
103
        else
104
          if hardware&.name && !hardware.name.empty?
3✔
105
            dev_name = _("Device Name: %s") % hardware.name
1✔
106
            rich << Yast::HTML.Bold(dev_name) << "<br>"
1✔
107

108
          end
109
          extension = firmware_configured_by?(hardware&.name)
3✔
110

111
          if extension
3✔
112
            rich << "<p><b>" << _("The device is configured by: ") << "</b>" << extension << "</p>"
×
113
          else
114
            rich << "<p>"
3✔
115
            rich << _("The device is not configured. Press <b>Edit</b>\nto configure.\n")
3✔
116
            rich << "</p>"
3✔
117
          end
118
        end
119
        rich
15✔
120
      end
121

122
    private
1✔
123

124
      def aliases_info(config)
1✔
125
        config.ip_aliases.map do |alias_|
12✔
126
          "#{alias_.address} (#{alias_.label})"
×
127
        end
128
      end
129
    end
130
  end
131
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc