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

yast / yast-autoinstallation / 13494013411

24 Feb 2025 08:44AM UTC coverage: 69.018% (+0.03%) from 68.993%
13494013411

push

github

web-flow
Merge pull request #881 from yast/merge_SLE-15-SP7

Added pervasive encryption fields (master)

6429 of 9315 relevant lines covered (69.02%)

10.35 hits per line

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

86.84
/src/modules/AutoinstPartPlan.rb
1
# File:  modules/AutoinstCommon.ycp
2
# Package:  Auto-installation/Partition
3
# Summary:  Module representing a partitioning plan
4
# Author:  Sven Schober (sschober@suse.de)
5
#
6
# $Id: AutoinstPartPlan.ycp 2813 2008-06-12 13:52:30Z sschober $
7
require "yast"
1✔
8
require "y2storage"
1✔
9
require "autoinstall/presenters/drive"
1✔
10

11
module Yast
1✔
12
  class AutoinstPartPlanClass < Module
1✔
13
    include Yast::Logger
1✔
14

15
    def main
1✔
16
      Yast.import "UI"
1✔
17
      textdomain "autoinst"
1✔
18

19
      Yast.include self, "autoinstall/common.rb"
1✔
20
      Yast.include self, "autoinstall/tree.rb"
1✔
21

22
      Yast.import "AutoinstCommon"
1✔
23
      Yast.import "Summary"
1✔
24
      Yast.import "Popup"
1✔
25
      Yast.import "Mode"
1✔
26
      Yast.import "Arch"
1✔
27

28
      # The general idea with this moduls is that it manages a single
29
      # partition plan (@plan) and the user can work on that
30
      # plan without having to specify that variable on each method
31
      # call.
32
      # This is on the one hand convenient for the user and on the
33
      # other hand we have control over the plan.
34

35
      # PRIVATE
36

37
      # The single plan instance managed by this module.
38
      #
39
      # The partition plan is technically a list of DriveT'.
40
      Reset()
1✔
41

42
      # default value of settings modified
43
      @modified = false
1✔
44

45
      # Devices which do not have any mount point, lvm_group or raid_name
46
      # These devices will not be taken in the AutoYaSt configuration file
47
      # but will be added to the skip_list in order not regarding it while
48
      # next installation. (bnc#989392)
49
      @skipped_devices = []
1✔
50
    end
51

52
    # Function sets internal variable, which indicates, that any
53
    # settings were modified, to "true"
54
    def SetModified
1✔
55
      Builtins.y2milestone("SetModified")
×
56
      @modified = true
×
57

58
      nil
×
59
    end
60

61
    # Functions which returns if the settings were modified
62
    #
63
    # @return [Boolean]  settings were modified
64
    def GetModified
1✔
65
      @modified
×
66
    end
67

68
    # PUBLIC INTERFACE
69

70
    # INTER FACE TO CONF TREE
71

72
    # Return summary of configuration
73
    #
74
    # @return  [String] configuration summary dialog
75
    def Summary
1✔
76
      summary = ""
1✔
77
      summary = Summary.AddHeader(summary, _("Drives"))
1✔
78
      if @plan.drives.empty?
1✔
79
        summary = Summary.AddLine(summary,
×
80
          _("Not yet cloned."))
81
      else
82
        # We are counting harddisks only (type CT_DISK)
83
        num = @plan.drives.size
1✔
84
        summary = Summary.AddLine(
1✔
85
          summary,
86
          (n_("%s drive in total", "%s drives in total", num) % num)
1✔
87
        )
88
        summary = Summary.OpenList(summary)
1✔
89
        @plan.drives.each do |drive|
1✔
90
          presenter = Y2Autoinstallation::Presenters::Drive.new(drive)
1✔
91
          summary = Summary.AddListItem(summary, presenter.ui_label)
1✔
92
          summary = Summary.OpenList(summary)
1✔
93
          presenter.partitions.each do |part|
1✔
94
            summary = Summary.AddListItem(summary, part.ui_label)
1✔
95
          end
96
          summary = Summary.CloseList(summary)
1✔
97
          summary = Summary.AddNewLine(summary)
1✔
98
        end
99
        summary = Summary.CloseList(summary)
1✔
100
      end
101
      summary
1✔
102
    end
103

104
    # Get all the configuration from a map.
105
    # When called by inst_auto<module name> (preparing autoinstallation data)
106
    # the list may be empty.
107
    # @param settings [Array<Hash>,Y2Storage::AutoinstProfile::PartitioningSection]
108
    #   An array of hashes describing each drive or a partitioning section object
109
    # @return  [Boolean] success
110
    def Import(settings)
1✔
111
      log.info("entering Import with #{settings.inspect}")
3✔
112

113
      @plan =
114
        if settings.is_a?(Y2Storage::AutoinstProfile::PartitioningSection)
3✔
115
          settings
2✔
116
        else
117
          Y2Storage::AutoinstProfile::PartitioningSection.new_from_hashes(settings || [])
1✔
118
        end
119

120
      true
3✔
121
    end
122

123
    # Gets the probed partitioning from the storage manager
124
    #
125
    # @return [Boolean]
126
    def Read
1✔
127
      devicegraph = Y2Storage::StorageManager.instance.probed
5✔
128
      @plan = Y2Storage::AutoinstProfile::PartitioningSection.new_from_storage(devicegraph)
5✔
129
      true
5✔
130
    end
131

132
    # Dump the settings to a map, for autoinstallation use.
133
    #
134
    # @return [Array<Hash>]
135
    def Export
1✔
136
      log.info("entering Export with #{@plan.inspect}")
6✔
137
      drives = @plan.to_hashes
6✔
138

139
      # Adding skipped devices to partitioning section.
140
      # These devices will not be taken in the AutoYaSt configuration file
141
      # but will be added to the skip_list in order not regarding it while
142
      # next installation. (bnc#989392)
143
      unless @skipped_devices.empty?
6✔
144
        skip_device = {}
×
145
        skip_device["initialize"] = true
×
146
        skip_device["skip_list"] = @skipped_devices.collect do |dev|
×
147
          { "skip_key" => "device", "skip_value" => dev }
×
148
        end
149
        drives << skip_device
×
150
      end
151

152
      drives
6✔
153
    end
154

155
    def Reset
1✔
156
      @plan = Y2Storage::AutoinstProfile::PartitioningSection.new
3✔
157
    end
158

159
    publish function: :SetModified, type: "void ()"
1✔
160
    publish function: :GetModified, type: "boolean ()"
1✔
161
    publish function: :updateTree, type: "void ()"
1✔
162
    publish function: :Summary, type: "string ()"
1✔
163
    publish function: :Import, type: "boolean (list <map>)"
1✔
164
    publish function: :Read, type: "boolean ()"
1✔
165
    publish function: :Export, type: "list <map> ()"
1✔
166
    publish function: :Reset, type: "void ()"
1✔
167
  end
168

169
  AutoinstPartPlan = AutoinstPartPlanClass.new
1✔
170
  AutoinstPartPlan.main
1✔
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

© 2026 Coveralls, Inc