Class: Yast::DeployingProposalClient

Inherits:
Client
  • Object
show all
Defined in:
src/lib/installation/clients/deploying_proposal.rb

Instance Method Summary collapse

Instance Method Details

#CallProposalScriptObject



198
199
200
201
202
203
204
# File 'src/lib/installation/clients/deploying_proposal.rb', line 198

def CallProposalScript
  progress_orig = Progress.set(false)
  WFM.CallFunction("inst_prepare_image", [])
  Progress.set(progress_orig)

  nil
end

#GenerateProposalTextObject



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'src/lib/installation/clients/deploying_proposal.rb', line 147

def GenerateProposalText
  im_conf = ImageInstallation.ImagesToUse

  ret = "<ul>\n"

  ret = if ImageInstallation.image_installation_available == false
    # TRANSLATORS: Installation overview
    Ops.add(
      Ops.add(
        Ops.add(ret, "<li>"),
        _("No installation images are available")
      ),
      "</li>"
    )
  elsif Ops.get_boolean(im_conf, "deploying_enabled", false) == true
    Ops.add(
      Ops.add(
        Ops.add(ret, "<li>"),
        Builtins.sformat(
          # TRANSLATORS: Installation overview
          # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>,
          # only visible text
          _(
            "Installation from images is enabled (<a href=\"%1\">disable</a>)."
          ),
          @im_do_disable
        )
      ),
      "</li>"
    )
  else
    Ops.add(
      Ops.add(
        Ops.add(ret, "<li>"),
        Builtins.sformat(
          # TRANSLATORS: Installation overview
          # IMPORTANT: Please, do not change the HTML link <a href="...">...</a>,
          # only visible text
          _(
            "Installation from images is disabled (<a href=\"%1\">enable</a>)."
          ),
          @im_do_enable
        )
      ),
      "</li>"
    )
  end

  Ops.add(ret, "</ul>\n")
end

#mainObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'src/lib/installation/clients/deploying_proposal.rb', line 30

def main
  textdomain "installation"

  Yast.import "Mode"
  Yast.import "ImageInstallation"
  Yast.import "Progress"
  Yast.import "Installation"
  Yast.import "Report"

  @func = Convert.to_string(WFM.Args(0))
  @param = Convert.to_map(WFM.Args(1))
  @ret = {}

  @im_do_enable = "deploying_enable"
  @im_do_disable = "deploying_disable"

  case @func
  when "MakeProposal"
    @force_reset = Ops.get_boolean(@param, "force_reset", false)
    @language_changed = Ops.get_boolean(@param, "language_changed", false)

    if @force_reset
      ImageInstallation.last_patterns_selected = [nil]
      ImageInstallation.changed_by_user = false
    end

    if ImageInstallation.changed_by_user == true &&
        Installation.image_installation == false
      Builtins.y2milestone("ImageInstallation already disabled by user")
    else
      CallProposalScript()
    end

    if Mode.installation
      @ret = {
        "preformatted_proposal" => GenerateProposalText(),
        "links"                 => [@im_do_enable, @im_do_disable],
        # TRANSLATORS: help text
        "help"                  => _(
          "<p><b>Installation from Images</b> is used to speed the installation up.\n" \
          "Images contain compressed snapshots of an installed system matching your\n" \
          "selection of patterns. The rest of the packages which are not contained in the\n" \
          "images will be installed from packages the standard way.</p>\n"
        ) +
          # TRANSLATORS: help text
          _(
            "<p>Note that when installing from images, the time stamps of all packages " \
            "originating from the images will\nnot match the installation date but rather " \
            "the date the image was created.</p>"
          ) +
          # TRANSLATORS: help text
          _(
            "<p>Installation from images is disabled by default if the current\n" \
            "pattern selection does not fit any set of images.</p>"
          )
      }
    else
      Builtins.y2error(
        "Installation from images should be used for new installation only!"
      )
      @ret = {
        "preformatted_proposal" => Builtins.sformat(
          _("Error: Images should not be used for mode: %1."),
          Mode.mode
        ),
        "warning_level"         => :error
      }
    end
  when "AskUser"
    @chosen_id = Ops.get(@param, "chosen_id")
    Builtins.y2milestone(
      "Images proposal change requested, id %1",
      @chosen_id
    )

    @old_status = Installation.image_installation

    Installation.image_installation = if @chosen_id == @im_do_disable
      false
    elsif @chosen_id == @im_do_enable
      true
    else
      !Installation.image_installation
    end

    # changed to true
    CallProposalScript() if Installation.image_installation

    if @old_status == false &&
        @old_status == Installation.image_installation
      Report.Message(
        _(
          "Cannot enable installation from images.\n" \
          "\n" \
          "Currently selected patterns do not fit the images\n" \
          "stored on the installation media.\n"
        )
      )
    end

    ImageInstallation.changed_by_user = true
    @ret = { "workflow_sequence" => :next }
  when "Description"
    @ret = {
      # this is a heading
      "rich_text_title" => _("Installation from Images"),
      # this is a menu entry
      "menu_title"      => _(
        "Installation from &Images"
      ),
      "id"              => "deploying"
    }
  end

  deep_copy(@ret)
end