Class: Yast::InstNetworkCheckClient

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

Instance Method Summary collapse

Instance Method Details

#mainObject


21
22
23
24
25
26
27
28
29
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
146
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'src/lib/installation/clients/inst_network_check.rb', line 21

def main
  Yast.import "UI"
  #
  # Authors:  Lukas Ocilka <[email protected]>
  #
  # Purpose:  This script detects whether there is no active network.
  #    In such case, user can configure network manually.
  #    This should be used in the first stage installation.
  #
  # See More:  FATE #301967
  #
  # $Id$
  #

  textdomain "installation"

  Yast.import "NetworkService"
  Yast.import "Wizard"
  Yast.import "Popup"
  Yast.import "GetInstArgs"
  Yast.import "Directory"
  Yast.import "Icon"

  @enable_next = true
  @enable_back = true

  # Script can be called with some arguments
  #
  #
  # **Structure:**
  #
  #     [$[
  #        "dontskip" : true, // do not skipt the dialog even if network is configured
  #      ]]
  @argmap = GetInstArgs.argmap
  Builtins.y2milestone("Script args: %1", @argmap)

  # We don't need to run this script to setup the network
  # If some network is already running...
  if NetworkService.isNetworkRunning
    if Ops.get_boolean(@argmap, "dontskip", false) == true
      Builtins.y2milestone(
        "Network is already running, not skipping (forced)..."
      )
    else
      Builtins.y2milestone("Network is already running, skipping...")
      return :next
    end
  else
    Builtins.y2milestone(
      "No network configuration found, offering to set it up..."
    )
  end

  @displayinfo = UI.GetDisplayInfo
  @supports_images = Ops.get_boolean(@displayinfo, "HasImageSupport", false)

  Wizard.SetContents(
    # TRANSLATORS: dialog caption
    _("Network Setup"),
    VBox(
      VStretch(),
      RadioButtonGroup(
        Id("to_do_a_network_setup_or_not_to_do"),
        HBox(
          HStretch(),
          VBox(
            # TRANSLATORS: dialog label
            HBox(
              @supports_images ? HBox(Icon.Simple("warning"), HSpacing(2)) : Empty(),
              Left(
                Label(
                  _(
                    "No network setup has been found.\n" \
                    "It is important if using remote repositories,\n" \
                    "otherwise you can safely skip it.\n"
                  )
                )
              )
            ),
            VSpacing(2),
            # TRANSLATORS: dialog label
            Left(Label(_("Configure your network card now?"))),
            VSpacing(1),
            Frame(
              # TRANSLATORS: frame label
              _("Select"),
              MarginBox(
                1.5,
                1,
                VBox(
                  # TRANSLATORS: radio button
                  Left(
                    RadioButton(
                      Id("yes_do_run_setup"),
                      _("&Yes, Run the Network Setup"),
                      true
                    )
                  ),
                  # TRANSLATORS: radio button
                  Left(
                    RadioButton(
                      Id("no_do_not_run_setup"),
                      _("No, &Skip the Network Setup")
                    )
                  )
                )
              )
            )
          ),
          HStretch()
        )
      ),
      VStretch()
    ),
    # TRANSLATORS: help text, part 1/2
    _(
      "<p>The current installation system does not\nhave a configured network.</p>\n"
    ) +
      # TRANSLATORS: help text, part 2/2
      _(
        "<p>A configured network is needed for using remote repositories\n" \
        "or add-on products. If you do not use remote repositories, " \
        "skip the configuration.</p>\n"
      ),
    @enable_next,
    @enable_back
  )

  @ret = nil

  @run_setup = nil

  @return_this = :next

  loop do
    @ret = UI.UserInput

    case @ret
    when :next
      @option_selected = Convert.to_string(
        UI.QueryWidget(
          Id("to_do_a_network_setup_or_not_to_do"),
          :CurrentButton
        )
      )
      Builtins.y2milestone("Network setup? %1", @option_selected)

      # run net setup
      if @option_selected == "yes_do_run_setup"
        Builtins.y2milestone("Running inst_lan")
        @ret2 = WFM.call(
          "inst_lan",
          [GetInstArgs.argmap.merge("skip_detection" => true), { "hide_abort_button" => true }]
        )
        Builtins.y2milestone("inst_lan ret: %1", @ret2)

        # everything went fine
        if @ret2 == :next
          @return_this = :next
          break
          # something wrong or aborted
        else
          if @ret2.nil?
            # error popup
            Popup.Message(
              Builtins.sformat(
                _(
                  "Network configuration has failed.\nCheck the log file %1 for details."
                ),
                Ops.add(Directory.logdir, "/y2log")
              )
            )
          end
          UI.ChangeWidget(
            Id("to_do_a_network_setup_or_not_to_do"),
            :CurrentButton,
            "no_do_not_run_setup"
          )
          next
        end

        # skip net setup
      else
        Builtins.y2milestone("Skipping network setup")
        @return_this = :next
        break
      end
    when :back
      Builtins.y2milestone("Going back")
      @return_this = :back
      break
    when :abort
      if Popup.ConfirmAbort(:painless)
        @return_this = :abort
        break
      end
    else
      Builtins.y2error("Unknown ret: %1", @ret)
    end
  end

  @return_this

  # EOF
end