Module: Yast::AutoinstallConftreeInclude

Defined in:
../../src/include/autoinstall/conftree.rb

Constant Summary

ALWAYS_CLONABLE_MODULES =
["software", "partitioning", "bootloader"]

Instance Method Summary (collapse)

Instance Method Details

- (Object) buttons

Creates an `HBox containing the buttons to be displayed below the summary column

Returns:

  • The `HBox widget.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File '../../src/include/autoinstall/conftree.rb', line 163

def buttons
  Wizard.HideNextButton
  Wizard.HideBackButton
  Wizard.HideAbortButton
  HBox(
    HSpacing(1),
    VBox(
      PushButton(Id(:read), _("&Clone")),
      PushButton(Id(:writeNow), _("&Apply to System"))
    ),
    HStretch(),
    VBox(
      PushButton(Id(:configure), _("&Edit")),
      PushButton(Id(:reset), _("Clea&r"))
    ),
    HSpacing(1)
  )
end

- (Object) configureModule(resource)

Configure module

Parameters:

  • resource (String)

    Module/Resource to configure

Returns:

  • (Object)


337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File '../../src/include/autoinstall/conftree.rb', line 337

def configureModule(resource)
  resourceMap = Ops.get(Y2ModuleConfig.ModuleMap, resource, {})
  resource = Y2ModuleConfig.getResource(resource)
  Builtins.y2debug("resource: %1", resource)

  module_auto = Ops.get_string(
    resourceMap,
    "X-SuSE-YaST-AutoInstClient",
    "none"
  )
  Builtins.y2debug("module_auto: %1", module_auto)

  Builtins.y2milestone("Mode::mode %1", Mode.mode)
  original_settings = WFM.CallFunction(module_auto, ["Export"])
  seq = WFM.CallFunction(module_auto, ["Change"])
  Builtins.y2milestone("Change response: %1", seq)
  if seq == :accept || seq == :next || seq == :finish
    new_settings = WFM.CallFunction(module_auto, ["Export"])
    if new_settings == nil
      Builtins.y2milestone("Importing original settings.")
      Popup.Error(_("The module returned invalid data."))
      WFM.CallFunction(module_auto, ["Import", original_settings])
      return :abort
    else
      Builtins.y2milestone("original=%1", original_settings)
      Builtins.y2milestone("new=%1", new_settings)
      if original_settings != new_settings
        WFM.CallFunction(module_auto, ["SetModified"])
        Profile.changed = true
        Profile.prepare = true
      end
    end
  else
    WFM.CallFunction(module_auto, ["Import", original_settings])
  end
  deep_copy(seq)
end

- (void) CreateDialog(currentGroup, currentModule)

This method returns an undefined value.

Create the complete dialog (called in wizard.ycp and in MainDialog())

Parameters:

  • currentGroup (String)

    Group to select.

  • currentModule (String)

    Module to select.



470
471
472
473
474
475
476
477
478
479
480
481
482
# File '../../src/include/autoinstall/conftree.rb', line 470

def CreateDialog(currentGroup, currentModule)
  currentGroup = "System" if "" == currentGroup || nil == currentGroup
  currentModule = "general" if "" == currentModule || nil == currentModule
  Wizard.SetContents(
    @title,
    layout(currentGroup, currentModule),
    AutoinstConfig.MainHelp,
    true,
    true
  )
  updateButtons(currentModule)
  nil
end

- (Object) details(module_name)

Creates a `VBox containg the summary of the specified module and the action buttons below.

Parameters:

  • module_name (String)

    The module to summarize.

Returns:

  • The `VBox widget.



186
187
188
189
190
191
192
193
194
195
196
# File '../../src/include/autoinstall/conftree.rb', line 186

def details(module_name)
  resourceMap = Ops.get(Y2ModuleConfig.ModuleMap, module_name, {})
  module_auto = Ops.get_string(
    resourceMap,
    "X-SuSE-YaST-AutoInstClient",
    "none"
  )
  summary = Convert.to_string(WFM.CallFunction(module_auto, ["Summary"]))
  summary = "" if nil == summary
  VBox(Left(Label(_("Details"))), RichText(summary), buttons)
end

- (Object) getGroup

Get the currently selected YaST group from the selection box widget.

Returns:

  • The currently selected group.



233
234
235
# File '../../src/include/autoinstall/conftree.rb', line 233

def getGroup
  Convert.to_string(UI.QueryWidget(Id(:groups), :CurrentItem))
end

- (Object) getModule

Get the currently selected Module from the selection box widget.

Returns:

  • The currently selected module.



240
241
242
# File '../../src/include/autoinstall/conftree.rb', line 240

def getModule
  Convert.to_string(UI.QueryWidget(Id(:modules), :CurrentItem))
end

- (Object) groups(selectedGroup)

Creates the group selection box with the specified YaST group selected.

Parameters:

  • selectedGroup (String)

    The group to select.

Returns:

  • The newly created `SelectionBox widget.



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
# File '../../src/include/autoinstall/conftree.rb', line 65

def groups(selectedGroup)
  itemList = []
  sortedGroups = Builtins.maplist(Y2ModuleConfig.GroupMap) { |k, v| k } # keys()
  sortedGroups = Builtins.sort(sortedGroups) do |a, b|
    aa = Builtins.tointeger(
      Ops.get_string(Y2ModuleConfig.GroupMap, [a, "SortKey"], "500")
    )
    bb = Builtins.tointeger(
      Ops.get_string(Y2ModuleConfig.GroupMap, [b, "SortKey"], "500")
    )
    aa != bb ? Ops.less_than(aa, bb) : Ops.less_than(a, b) # by "SortKey" or alphabetical
  end

  Builtins.foreach(sortedGroups) do |k|
    v = Ops.get(Y2ModuleConfig.GroupMap, k, {})
    desktop_file = Builtins.substring(
      Ops.get_string(v, "X-SuSE-DocTeamID", ""),
      4
    )
    translation = Builtins.dpgettext(
      "desktop_translations",
      "/usr/share/locale/",
      Ops.add(
        Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
        Ops.get_string(v, "Name", "")
      )
    )
    if translation ==
        Ops.add(
          Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
          Ops.get_string(v, "Name", "")
        )
      translation = Ops.get_string(v, "Name", "")
    end
    item = Item(
      Id(k),
      term(:icon, Ops.get_string(v, "Icon", "")),
      translation,
      k == selectedGroup
    )
    itemList = Builtins.add(itemList, item)
  end
  SelectionBox(Id(:groups), Opt(:notify), _("Groups"), itemList)
end

- (Object) initialize_autoinstall_conftree(include_target)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File '../../src/include/autoinstall/conftree.rb', line 10

def initialize_autoinstall_conftree(include_target)
  textdomain "autoinst"
  Yast.import "HTML"
  Yast.import "XML"
  Yast.import "Call"
  Yast.import "Label"
  Yast.import "Popup"
  Yast.import "Wizard"
  Yast.import "Report"
  Yast.import "AutoinstConfig"
  Yast.import "Profile"
  Yast.import "Mode"
  Yast.import "Stage"
  Yast.import "Icon"
  Yast.import "AutoinstSoftware"
  Yast.import "AutoinstClone"

  @title = _("Autoinstallation - Configuration")
  @show_source = false
end

- (Object) layout(preselectedGroup, preselectedModule)

Sets the high level layout to 3 columns:

  • left: the YaST groups are displayed in a selection box

  • middle: the modules of the selected group are displayed in a selection box

  • right: the summary of the selected module is displayed, action buttons below

Parameters:

  • preselectedGroup (String)

    The YaST group to preselect

  • preselectedModule (String)

    The module to preselect



206
207
208
209
210
211
212
213
214
215
216
217
218
# File '../../src/include/autoinstall/conftree.rb', line 206

def layout(preselectedGroup, preselectedModule)
  HBox(
    HWeight(33, groups(preselectedGroup)),
    HWeight(
      33,
      ReplacePoint(
        Id(:rp_modules),
        modules(preselectedGroup, preselectedModule)
      )
    ),
    HWeight(33, ReplacePoint(Id(:rp_details), details(preselectedModule)))
  )
end

- (Symbol) MainDialog

Menu interface

Parameters:

  • list

    menu items

Returns:

  • (Symbol)


507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
# File '../../src/include/autoinstall/conftree.rb', line 507

def MainDialog
  _Icons = {}
  Ops.set(_Icons, "Net_advanced", "network_advanced")
  func_ret = ""
  ret = nil
  currentGroup = "System"
  currentModule = "general"

  while true
    if AutoinstConfig.runModule != ""
      ret = :configure
      setModule(AutoinstConfig.runModule)
      AutoinstConfig.runModule = ""
    else
      event = UI.WaitForEvent
      ret = Ops.get(event, "ID")
      AutoinstConfig.runModule = ""
    end
    if ret == :groups
      updateModules
    elsif ret == :modules
      updateDetails
    elsif ret == :configure
      currentGroup = getGroup
      currentModule = getModule
      Builtins.y2debug("configure module: %1", currentModule)
      if currentModule != ""
        configret = configureModule(currentModule)
        Builtins.y2debug("configureModule ret : %1", configret)
        CreateDialog(currentGroup, currentModule)
      end
    elsif ret == :reset
      Profile.prepare = true
      Builtins.y2debug("reset")
      currentGroup = getGroup
      currentModule = getModule
      Builtins.y2debug("reset module: %1", currentModule)
      if currentModule != ""
        configret = resetModule(currentModule)
        Builtins.y2debug("resetModule ret : %1", configret)
        CreateDialog(currentGroup, currentModule)
      end
    elsif ret == :writeNow
      modulename = getModule
      if modulename != ""
        d = Ops.get(Y2ModuleConfig.ModuleMap, modulename, {})
        module_auto = ""
        if Builtins.haskey(d, "X-SuSE-YaST-AutoInstClient")
          module_auto = Ops.get_string(
            d,
            "X-SuSE-YaST-AutoInstClient",
            "none"
          )
        else
          module_auto = Builtins.sformat("%1_auto", modulename)
        end
        if Popup.YesNo(
            Builtins.sformat(
              _(
                "Do you really want to apply the settings of the module '%1' to your current system?"
              ),
              modulename
            )
          )
          Call.Function(module_auto, ["Write"])
        end
      end
    elsif ret == :read
      currentGroup = getGroup
      currentModule = getModule
      resetModule(currentModule)
      readModule(currentModule)
      if UI.WidgetExists(Id(:rp_details))
        # if dialog didn't replace wizard contents this is enough
        updateDetails
      else
        # otherwise we have to rebuild the complete wizard
        CreateDialog(currentGroup, currentModule)
      end
    elsif ret == "menu_tree" # source -> tree
      Builtins.y2debug("change to tree")
      @show_source = false
      Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
      menus
      CreateDialog(currentGroup, currentModule)
    elsif ret == "menu_open" # OPEN
      filename = UI.AskForExistingFile(
        AutoinstConfig.Repository,
        "*",
        _("Select a file to load.")
      )
      if filename != "" && filename != nil
        AutoinstConfig.currentFile = Convert.to_string(filename)

        pathComponents = Builtins.splitstring(
          Convert.to_string(filename),
          "/"
        )

        s = Ops.subtract(Builtins.size(pathComponents), 1)
        base = Ops.get_string(pathComponents, s, "default")
        readOkay = Profile.ReadXML(Convert.to_string(filename))
        Builtins.y2debug("Profile::ReadXML returned %1", readOkay)
        if readOkay
          Popup.ShowFeedback(
            _("Reading configuration data"),
            _("This may take a while")
          )
          Builtins.foreach(Profile.ModuleMap) do |p, d|
            # Set resource name, if not using default value
            resource = Ops.get_string(d, "X-SuSE-YaST-AutoInstResource", "")
            resource = p if resource == ""
            Builtins.y2debug("resource: %1", resource)
            tomerge = Ops.get_string(d, "X-SuSE-YaST-AutoInstMerge", "")
            module_auto = Ops.get_string(
              d,
              "X-SuSE-YaST-AutoInstClient",
              "none"
            )
            rd = Y2ModuleConfig.getResourceData(d, resource)
            WFM.CallFunction(module_auto, ["Import", rd]) if rd != nil
          end
          Popup.ClearFeedback
          Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
          menus
        else
          # opening/parsing the xml file failed
          Popup.Error(
            _("An error occurred while opening/parsing the XML file.")
          )
          Profile.Reset
        end
      end
      if UI.WidgetExists(Id(:class_source))
        ShowSource()
      else
        group = getGroup
        modulename = getModule

        contents = Empty()

        if group != ""
          contents = layout(group, modulename)
          caption = @title
          currentFile = AutoinstConfig.currentFile
          currentFile = Builtins.substring(
            currentFile,
            Ops.add(Builtins.findlastof(currentFile, "/"), 1)
          )
          if Ops.greater_than(Builtins.size(currentFile), 0)
            caption = Ops.add(Ops.add(caption, " - "), currentFile)
          end
          Wizard.SetContents(
            caption,
            contents,
            AutoinstConfig.MainHelp,
            true,
            true
          )
          Wizard.SetTitleIcon(
            Ops.get_string(_Icons, group, Builtins.tolower(group))
          )
          updateButtons(modulename)
        end
      end
      ret = :menu_open
    elsif ret == "menu_source" # Show SOURCE
      # save previously selected group and module,
      # so we can restore them afterwards
      @show_source = true
      Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
      menus
      currentGroup = getGroup
      currentModule = getModule
      ShowSource()
      ret = :menu_source
    elsif ret == "menu_save" # SAVE
      if AutoinstConfig.currentFile == ""
        filename = UI.AskForSaveFileName(
          AutoinstConfig.Repository,
          "*",
          _("Save as...")
        )
        if filename != nil
          AutoinstConfig.currentFile = Convert.to_string(filename)
        else
          next
        end
      end

      if Profile.Save(AutoinstConfig.currentFile)
        Popup.Message(
          Builtins.sformat(
            _("File %1 was saved successfully."),
            AutoinstConfig.currentFile
          )
        )
        #Profile::checkProfile();
        Profile.changed = false
      else
        Popup.Warning(_("An error occurred while saving the file."))
      end
      ret = :menu_save
    elsif ret == "menu_saveas" # SAVE AS
      SaveAs()
      ret = :menu_saveas
    elsif ret == "menu_new" # NEW
      Profile.Reset
      Builtins.foreach(Profile.ModuleMap) do |p, d|
        resource = Ops.get_string(d, "X-SuSE-YaST-AutoInstResource", "")
        resource = p if resource == ""
        resetModule(resource)
      end
      AutoinstConfig.currentFile = ""
      ShowSource() if UI.WidgetExists(Id(:class_source))
      group = getGroup
      module_name = getModule
      Wizard.SetContents(
        _("Available Modules"),
        layout(group, module_name),
        AutoinstConfig.MainHelp,
        true,
        true
      )
      updateButtons(module_name)
      ret = :menu_new
    elsif ret == "change_encryption"
      AutoinstConfig.ProfileEncrypted = !AutoinstConfig.ProfileEncrypted
      AutoinstConfig.ProfilePassword = ""
      Wizard.DeleteMenus # FIXME: sucks sucks sucks sucks sucks
      menus
    elsif ret == "write_to_system"
      if Popup.YesNo(
          _(
            "Do you really want to apply the settings of the profile to your current system?"
          )
        )
        Profile.Prepare
        oldMode = Mode.mode
        oldStage = Stage.stage
        Mode.SetMode("autoinstallation")
        Stage.Set("continue")
        WFM.CallFunction("inst_autopost", [])
        AutoinstSoftware.addPostPackages(
          Ops.get_list(Profile.current, ["software", "post-packages"], [])
        )

        # the following is needed since 10.3
        # otherwise the already configured network gets removed
        if !Builtins.haskey(Profile.current, "networking")
          Profile.current = Builtins.add(
            Profile.current,
            "networking",
            { "keep_install_network" => true }
          )
        end

        Pkg.TargetInit("/", false)
        WFM.CallFunction("inst_rpmcopy", [])
        WFM.CallFunction("inst_autoconfigure", [])
        Mode.SetMode(oldMode)
        Stage.Set(oldStage)
      end
    elsif ret == "menu_exit" || :cancel == ret # EXIT
      ret = :menu_exit
      if Profile.changed
        current = ""
        if AutoinstConfig.currentFile == ""
          current = "Untitled"
        else
          current = AutoinstConfig.currentFile
        end

        answer = Popup.AnyQuestion(
          _("Control file changed."),
          Builtins.sformat(_("Save the changes to %1?"), current),
          Label.YesButton,
          Label.NoButton,
          :focus_yes
        )
        SaveAs() if true == answer
      end
      break
    else
      s = Builtins.toterm(ret)
      ret = Builtins.symbolof(s)
      break
    end
  end
  Convert.to_symbol(ret)
end

This method returns an undefined value.

Sets the menus in the wizard.



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File '../../src/include/autoinstall/conftree.rb', line 378

def menus
  _Menu = []
  _Menu = Wizard.AddMenu(_Menu, _("&File"), "file-menu")
  _Menu = Wizard.AddMenu(_Menu, _("&View"), "view-menu")
  _Menu = Wizard.AddMenu(_Menu, _("&Classes"), "class-menu")
  _Menu = Wizard.AddMenu(_Menu, _("&Tools"), "tools-menu")

  _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&New"), "menu_new")
  _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&Open"), "menu_open")
  _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("&Save"), "menu_save")
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "file-menu",
    _("Save &As"),
    "menu_saveas"
  )
  _Menu = Wizard.AddSubMenu(_Menu, "file-menu", _("Im&port"), "file-import")
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "file-import",
    _("Import &Kickstart File"),
    "menu_kickstart"
  )
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "file-menu",
    _("Settin&gs"),
    "menu_settings"
  )
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "file-menu",
    AutoinstConfig.ProfileEncrypted ?
      _("Change to Decrypted") :
      _("Change to Encrypted"),
    "change_encryption"
  )
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "file-menu",
    _("Apply Profile to this System"),
    "write_to_system"
  )
  _Menu = Wizard.AddMenuEntry(_Menu, "file-menu", _("E&xit"), "menu_exit")
  if @show_source == true
    _Menu = Wizard.AddMenuEntry(
      _Menu,
      "view-menu",
      _("Configu&ration Tree"),
      "menu_tree"
    )
  else
    _Menu = Wizard.AddMenuEntry(
      _Menu,
      "view-menu",
      _("So&urce"),
      "menu_source"
    )
  end
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "class-menu",
    _("Cla&sses"),
    "menu_classes"
  )
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "class-menu",
    _("Me&rge Classes"),
    "menu_merge"
  )

  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "tools-menu",
    _("Create Reference Pro&file"),
    "menu_clone"
  )
  _Menu = Wizard.AddMenuEntry(
    _Menu,
    "tools-menu",
    _("Check &Validity of Profile"),
    "menu_valid"
  )
  Wizard.CreateMenu(_Menu)
  nil
end

- (Object) modules(group_name, selectedModule)

Creates the modules selection box displaying modules in the specified group. The specified YaST module is selected.

Parameters:

  • group_name (String)

    YaST group of modules to display.

  • selectedModule (String)

    Module to preselect.



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
# File '../../src/include/autoinstall/conftree.rb', line 115

def modules(group_name, selectedModule)
  Builtins.y2milestone("group_name: %1", group_name)
  itemList = []
  Builtins.foreach(Y2ModuleConfig.ModuleMap) do |k, v|
    # bnc #887115 comment #9: Desktop file is "hidden" and should not be shown at all
    next if v["Hidden"] == "true"

    if Ops.get_string(v, "X-SuSE-YaST-Group", "") == group_name
      desktop_file = Builtins.substring(
        Ops.get_string(v, "X-SuSE-DocTeamID", ""),
        4
      )
      translation = Builtins.dpgettext(
        "desktop_translations",
        "/usr/share/locale/",
        Ops.add(
          Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
          Ops.get_string(v, "Name", "")
        )
      )
      if translation ==
          Ops.add(
            Ops.add(Ops.add("Name(", desktop_file), ".desktop): "),
            Ops.get_string(v, "Name", "")
          )
        translation = Ops.get_string(v, "Name", "")
      end
      item = Item(
        Id(k),
        term(:icon, Ops.get_string(v, "Icon", "")),
        translation,
        k == selectedModule
      )
      itemList = Builtins.add(itemList, item)
    end
  end
  if 0 == Builtins.size(itemList)
    itemList = Builtins.add(
      itemList,
      Item(Id("none"), _("No modules available"))
    )
  end
  SelectionBox(Id(:modules), Opt(:notify), _("Modules"), itemList)
end

- (Object) readModule(module_name)

Read the setting of the specifed module from the current system.

Parameters:

  • module_name (String)

    The module to read in.



325
326
327
328
329
330
331
332
333
# File '../../src/include/autoinstall/conftree.rb', line 325

def readModule(module_name)
  resourceMap = Ops.get(Y2ModuleConfig.ModuleMap, module_name, {})
  auto = Ops.get_string(resourceMap, "X-SuSE-YaST-AutoInstClient", "")
  Call.Function(auto, ["Read"])
  Call.Function(auto, ["SetModified"])
  Profile.prepare = true
  Profile.changed = true
  true
end

- (Object) resetModule(resource)

Reset Configuration

Parameters:

  • resource (String)

    Module/Resource to reset

Returns:

  • (Object)


305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File '../../src/include/autoinstall/conftree.rb', line 305

def resetModule(resource)
  Builtins.y2debug("resource: %1", resource)
  resourceMap = Ops.get(Y2ModuleConfig.ModuleMap, resource, {})
  module_auto = Ops.get_string(
    resourceMap,
    "X-SuSE-YaST-AutoInstClient",
    "none"
  )
  if Builtins.haskey(Profile.current, resource)
    Profile.current = Builtins.remove(Profile.current, resource)
  end
  profile_resource = Y2ModuleConfig.getResource(resource)
  WFM.CallFunction(module_auto, ["Reset"])

  :next
end

- (Object) SaveAs



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
# File '../../src/include/autoinstall/conftree.rb', line 31

def SaveAs
  filename = UI.AskForSaveFileName(
    AutoinstConfig.Repository,
    "*",
    _("Save as...")
  )
  if filename != nil && Convert.to_string(filename) != ""
    AutoinstConfig.currentFile = Convert.to_string(filename)
    if Profile.Save(AutoinstConfig.currentFile)
      Popup.Message(
        Builtins.sformat(
          _("File %1 was saved successfully."),
          AutoinstConfig.currentFile
        )
      )
      #                Profile::checkProfile();
      Profile.changed = false
      pathComponents = Builtins.splitstring(
        Convert.to_string(filename),
        "/"
      )
      s = Ops.subtract(Builtins.size(pathComponents), 1)
      base = Ops.get_string(pathComponents, s, "default")
    else
      Popup.Warning(_("An error occurred while saving the file."))
    end
  end
  :next
end

- (Object) setGroup(group_name)

Set the group selection box to the specified YaST group.

Parameters:

  • group_name

    YaST group to select.



223
224
225
226
227
228
# File '../../src/include/autoinstall/conftree.rb', line 223

def setGroup(group_name)
  UI.ChangeWidget(Id(:groups), :CurrentItem, group_name)
  updateModules

  nil
end

- (Object) setModule(module_name)

Set the module selection box to the specified YaST module and update the details and group column.

Parameters:

  • module_name (String)

    The module to select.



270
271
272
273
274
275
276
277
278
279
280
# File '../../src/include/autoinstall/conftree.rb', line 270

def setModule(module_name)
  resourceMap = Ops.get(Y2ModuleConfig.ModuleMap, module_name, {})
  if {} != resourceMap
    group = Ops.get_string(resourceMap, "X-SuSE-YaST-Group", "")
    setGroup(group) if "" != group
    UI.ChangeWidget(Id(:modules), :CurrentItem, module_name)
    updateDetails
  end

  nil
end

- (Object) ShowSource

Show Source



488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File '../../src/include/autoinstall/conftree.rb', line 488

def ShowSource
  Profile.Prepare
  source = XML.YCPToXMLString(:profile, Profile.current)
  sourceView = RichText(Id(:class_source), Opt(:plainText), source)

  Wizard.SetTitleIcon("autoyast")
  Wizard.SetContents(
    _("Source"),
    sourceView,
    AutoinstConfig.MainHelp,
    true,
    true
  )
  nil
end

- (Object) updateButtons(selectedModule)

Updates the action button activation status. (Some modules are not clonable, some are not writeable).

Parameters:

  • selectedModule (String)

    The module to define the button status.



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File '../../src/include/autoinstall/conftree.rb', line 250

def updateButtons(selectedModule)
  # enable/disable write button
  if Builtins.contains(AutoinstConfig.noWriteNow, selectedModule)
    UI.ChangeWidget(Id(:writeNow), :Enabled, false)
  end

  # set read button status
  resourceMap = Y2ModuleConfig.ModuleMap.fetch(selectedModule, {})
  clonable = resourceMap["X-SuSE-YaST-AutoInstClonable"] == "true"

  clone_button_status = clonable || ALWAYS_CLONABLE_MODULES.include?(selectedModule)
  UI.ChangeWidget(Id(:read), :Enabled, clone_button_status)

  nil
end

- (Object) updateDetails



290
291
292
293
294
295
296
297
298
299
300
# File '../../src/include/autoinstall/conftree.rb', line 290

def updateDetails
  selectedModule = Convert.to_string(
    UI.QueryWidget(Id(:modules), :CurrentItem)
  )
  Builtins.y2milestone("module: %1", selectedModule)
  newDetails = details(selectedModule)
  UI.ReplaceWidget(Id(:rp_details), newDetails)
  updateButtons(selectedModule)

  nil
end

- (Object) updateModules



281
282
283
284
285
286
287
288
289
# File '../../src/include/autoinstall/conftree.rb', line 281

def updateModules
  selectedGroup = getGroup
  Builtins.y2milestone("group: %1", selectedGroup)
  newModules = modules(selectedGroup, "")
  UI.ReplaceWidget(Id(:rp_modules), newModules)
  updateDetails

  nil
end