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

yast / d-installer / 4512499803

pending completion
4512499803

Pull #501

github

Unknown Committer
Unknown Commit Message
Pull Request #501: [web] Add DASD UI - first version

462 of 863 branches covered (53.53%)

Branch coverage included in aggregate %.

64 of 235 new or added lines in 9 files covered. (27.23%)

14 existing lines in 1 file now uncovered.

4668 of 6129 relevant lines covered (76.16%)

10.58 hits per line

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

94.64
/service/lib/dinstaller/dbus/storage/dasd.rb
1
# frozen_string_literal: true
2

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

22
require "dbus"
1✔
23
require "dinstaller/dbus/base_object"
1✔
24

25
module DInstaller
1✔
26
  module DBus
1✔
27
    module Storage
1✔
28
      # Class representing a DASD in the D-Bus tree
29
      class Dasd < BaseObject
1✔
30
        # YaST representation of the DASD
31
        #
32
        # @return [Y2S390::Dasd]
33
        attr_reader :dasd
1✔
34

35
        # Constructor
36
        #
37
        # @param dasd [Y2S390::Dasd] See {#dasd}
38
        # @param path [DBus::ObjectPath] Path in which the object is exported
39
        # @param logger [Logger, nil]
40
        def initialize(dasd, path, logger: nil)
1✔
41
          super(path, logger: logger)
23✔
42
          @dasd = dasd
23✔
43
        end
44

45
        # The device channel id
46
        #
47
        # @return [String]
48
        def id
1✔
49
          dasd.id
2✔
50
        end
51

52
        # Whether the device is enabled
53
        #
54
        # @return [Boolean]
55
        def enabled
1✔
56
          !dasd.offline?
2✔
57
        end
58

59
        # The associated device name
60
        #
61
        # @return [String] empty if the device is not enabled
62
        def device_name
1✔
63
          dasd.device_name || ""
2✔
64
        end
65

66
        # Whether the device is formatted
67
        #
68
        # @return [Boolean]
69
        def formatted
1✔
70
          dasd.formatted?
2✔
71
        end
72

73
        # Whether the DIAG access method is enabled
74
        #
75
        # YaST traditionally displays #use_diag, which is always false for disabled devices (see
76
        # more info about the YaST behavior regarding DIAG at DInstaller::Storage::DASD::Manager).
77
        # But displaying #diag_wanted is surely more useful. For enabled DASDs both values match
78
        # and for disabled DASDs #diag_wanted is more informative.
79
        #
80
        # @return [Boolean]
81
        def diag
1✔
82
          dasd.diag_wanted
2✔
83
        end
84

85
        # The DASD device type concatenating the cutype and devtype (i.e. 3990/E9 3390/0A)
86
        #
87
        # @return [String] empty if unknown
88
        def device_type
1✔
89
          dasd.device_type || ""
2✔
90
        end
91

92
        ECKD = "ECKD"
1✔
93
        FBA = "FBA"
1✔
94

95
        # Return the type from the device type
96
        #
97
        # @see https://github.com/SUSE/s390-tools/blob/master/dasd_configure#L162
98
        #
99
        # @return [String]
100
        def type_from(device_type)
1✔
101
          cu_type, dev_type = device_type.split
2✔
102
          return ECKD if cu_type.to_s.start_with?("3990", "2105", "2107", "1750", "9343")
2✔
103
          return FBA if cu_type.to_s.start_with?("6310")
2✔
104

105
          if cu_type.start_with?("3880")
2✔
NEW
106
            return ECKD if dev_type.start_with?("3390")
×
NEW
107
            return FBA if dev_type.start_with?("3370")
×
108
          end
109

NEW
110
          device_type
×
111
        end
112

113
        # The DASD type (ECKD, FBA)
114
        #
115
        # @return [String] empty if unknown
116
        def type
1✔
117
          dasd.type || type_from(device_type)
2✔
118
        end
119

120
        # Access type ('rw', 'ro')
121
        #
122
        # @return [String] empty if unknown
123
        def access_type
1✔
124
          dasd.access_type || ""
2✔
125
        end
126

127
        # Device status if known or 'unknown' if not
128
        #
129
        # @return [String] 'active', 'read_only', 'offline', 'no_format', or 'unknown'
130
        def status
1✔
131
          dasd.status.to_s
2✔
132
        end
133

134
        # Description of the partitions
135
        #
136
        # @return [String] empty if the information is unknown
137
        def partition_info
1✔
138
          dasd.partition_info || ""
2✔
139
        end
140

141
        # Sets the associated DASD object
142
        #
143
        # @note A properties changed signal is always emitted.
144
        #
145
        # @param value [Y2S390::Dasd]
146
        def dasd=(value)
1✔
147
          @dasd = value
2✔
148

149
          properties = interfaces_and_properties[DASD_DEVICE_INTERFACE]
2✔
150
          dbus_properties_changed(DASD_DEVICE_INTERFACE, properties, [])
2✔
151
        end
152

153
        # Interface name representing a DASD object
154
        DASD_DEVICE_INTERFACE = "org.opensuse.DInstaller.Storage1.DASD.Device"
1✔
155
        private_constant :DASD_DEVICE_INTERFACE
1✔
156

157
        dbus_interface DASD_DEVICE_INTERFACE do
1✔
158
          dbus_reader(:id, "s")
1✔
159
          dbus_reader(:enabled, "b")
1✔
160
          dbus_reader(:device_name, "s")
1✔
161
          dbus_reader(:formatted, "b")
1✔
162
          dbus_reader(:diag, "b")
1✔
163
          dbus_reader(:status, "s")
1✔
164
          dbus_reader(:type, "s")
1✔
165
          dbus_reader(:access_type, "s")
1✔
166
          dbus_reader(:partition_info, "s")
1✔
167
        end
168
      end
169
    end
170
  end
171
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