Class: Yast::ProfileClass
- Inherits:
-
Module
- Object
- Module
- Yast::ProfileClass
- Defined in:
- ../../src/modules/Profile.rb
Instance Method Summary (collapse)
-
- (void) check_version(properties)
Read Profile properties and Version.
- - (Object) checkProfile
-
- (Hash) Compat(__current)
General compatibility issues.
-
- (Object) generalCompat
compatibility to new language,keyboard and timezone client in 10.1.
-
- (void) Import(profile)
Import Profile.
- - (Object) main
-
- (void) Prepare
Prepare Profile for saving and remove empty data structs.
-
- (void) Profile
Constructor.
-
- (Boolean) ReadProfileStructure(parsedControlFile)
Read YCP data as the control file.
-
- (Boolean) ReadXML(file)
Read XML into YCP data.
-
- (void) Reset
Reset profile to initial status.
-
- (Boolean) Save(file)
Save YCP data into XML.
-
- (Object) SaveProfileStructure(parsedControlFile)
Save the current data into a file to be read after a reboot.
-
- (Object) SaveSingleSections(dir)
Save sections of current profile to separate files.
-
- (Object) setElementByList(l, v, m)
this function is a replacement for this code: list l = [ “key1”,0,“key3” ]; m[ l ] = v; @return [Hash].
- - (Object) setLValue(l, v, m)
- - (Object) setMValue(l, v, m)
- - (Object) softwareCompat
-
- (Object) storageLibCompat
compatibility to new storage lib in 10.0.
Instance Method Details
- (void) check_version(properties)
This method returns an undefined value.
Read Profile properties and Version
270 271 272 273 274 275 276 277 |
# File '../../src/modules/Profile.rb', line 270 def check_version(properties) version = properties["version"] if version != "3.0" Builtins.y2milestone("Wrong profile version '#{version}'") else Builtins.y2milestone("AutoYaST Profile Version %1 Detected.", version) end end |
- (Object) checkProfile
784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
# File '../../src/modules/Profile.rb', line 784 def checkProfile file = Ops.add(Ops.add(AutoinstConfig.tmpDir, "/"), "valid.xml") Save(file) summary = "Some schema check failed!\n" + "Please attach your logfile to bug id 211014\n" + "\n" valid = true validators = [ [ _("Checking XML with RNG validation..."), Ops.add( Ops.add("/usr/bin/xmllint --noout --relaxng ", Directory.schemadir), "/autoyast/rng/profile.rng" ), "" ] ] if !Stage.cont && PackageSystem.Installed("jing") validators = Builtins.add( validators, [ _("Checking XML with RNC validation..."), Ops.add( Ops.add("/usr/bin/jing >&2 -c ", Directory.schemadir), "/autoyast/rnc/profile.rnc" ), "jing_sucks" ] ) end Builtins.foreach(validators) do |i| header = Ops.get_string(i, 0, "") cmd = Ops.add(Ops.add(Ops.get_string(i, 1, ""), " "), file) summary = Ops.add(Ops.add(summary, header), "\n") o = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd)) Builtins.y2debug("validation output: %1", o) summary = Ops.add(Ops.add(summary, cmd), "\n") summary = Ops.add( Ops.add(summary, Ops.get_string(o, "stderr", "")), "\n" ) summary = Ops.add(summary, "\n") if Ops.get_integer(o, "exit", 1) != 0 || Ops.get_string(i, 2, "") == "jing_sucks" && Ops.greater_than( Builtins.size(Ops.get_string(o, "stderr", "")), 0 ) valid = false end end if !valid Popup.Error(summary) Builtins.y2milestone( "Profile check failed please attach the log to bug id 211014: %1", summary ) end nil end |
- (Hash) Compat(__current)
General compatibility issues
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 |
# File '../../src/modules/Profile.rb', line 556 def Compat(__current) __current = deep_copy(__current) # scripts if Builtins.haskey(__current, "pre-scripts") || Builtins.haskey(__current, "post-scripts") || Builtins.haskey(__current, "chroot-scripts") pre = Ops.get_list(__current, "pre-scripts", []) post = Ops.get_list(__current, "post-scripts", []) chroot = Ops.get_list(__current, "chroot-scripts", []) scripts = { "pre-scripts" => pre, "post-scripts" => post, "chroot-scripts" => chroot } __current = Builtins.remove(__current, "pre-scripts") __current = Builtins.remove(__current, "post-scripts") __current = Builtins.remove(__current, "chroot-scripts") Ops.set(__current, "scripts", scripts) end # general old = false = Ops.get_map(__current, "general", {}) security = Ops.get_map(__current, "security", {}) report = Ops.get_map(__current, "report", {}) Builtins.foreach() do |k, v| if k == "keyboard" && Ops.is_string?(v) old = true elsif k == "encryption_method" old = true elsif k == "timezone" && Ops.is_string?(v) old = true end end new_general = {} if old Builtins.y2milestone("Old format, converting.....") Ops.set( new_general, "language", Ops.get_string(, "language", "") ) keyboard = {} Ops.set( keyboard, "keymap", Ops.get_string(, "keyboard", "") ) Ops.set(new_general, "keyboard", keyboard) clock = {} Ops.set( clock, "timezone", Ops.get_string(, "timezone", "") ) if Ops.get_string(, "hwclock", "") == "localtime" Ops.set(clock, "hwclock", "localtime") elsif Ops.get_string(, "hwclock", "") == "GMT" Ops.set(clock, "hwclock", "GMT") end Ops.set(new_general, "clock", clock) mode = {} if Builtins.haskey(, "reboot") Ops.set( mode, "reboot", Ops.get_boolean(, "reboot", false) ) end if Builtins.haskey(report, "confirm") Ops.set(mode, "confirm", Ops.get_boolean(report, "confirm", false)) report = Builtins.remove(report, "confirm") end Ops.set(new_general, "mode", mode) if Builtins.haskey(, "encryption_method") Ops.set( security, "encryption", Ops.get_string(, "encryption_method", "") ) end net = Ops.get_map(__current, "networking", {}) ifaces = Ops.get_list(net, "interfaces", []) newifaces = Builtins.maplist(ifaces) do |iface| newiface = Builtins.mapmap(iface) do |k, v| { Builtins.tolower(k) => v } end deep_copy(newiface) end Ops.set(net, "interfaces", newifaces) Ops.set(__current, "general", new_general) Ops.set(__current, "report", report) Ops.set(__current, "security", security) Ops.set(__current, "networking", net) end deep_copy(__current) end |
- (Object) generalCompat
compatibility to new language,keyboard and timezone client in 10.1
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File '../../src/modules/Profile.rb', line 148 def generalCompat if Builtins.haskey(@current, "general") if Builtins.haskey(Ops.get_map(@current, "general", {}), "keyboard") Ops.set( @current, "keyboard", Ops.get_map(@current, ["general", "keyboard"], {}) ) Ops.set( @current, "general", Builtins.remove(Ops.get_map(@current, "general", {}), "keyboard") ) end if Builtins.haskey(Ops.get_map(@current, "general", {}), "language") Ops.set( @current, "language", { "language" => Ops.get_string( @current, ["general", "language"], "" ) } ) Ops.set( @current, "general", Builtins.remove(Ops.get_map(@current, "general", {}), "language") ) end if Builtins.haskey(Ops.get_map(@current, "general", {}), "clock") Ops.set( @current, "timezone", Ops.get_map(@current, ["general", "clock"], {}) ) Ops.set( @current, "general", Builtins.remove(Ops.get_map(@current, "general", {}), "clock") ) end if Ops.get_boolean(@current, ["general", "mode", "final_halt"], false) script = { "filename" => "zzz_halt", "source" => "chkconfig autoyast off\nshutdown -h now" } if !Builtins.haskey(@current, "scripts") Ops.set(@current, "scripts", {}) end if !Builtins.haskey( Ops.get_map(@current, "scripts", {}), "init-scripts" ) Ops.set(@current, ["scripts", "init-scripts"], []) end Ops.set( @current, ["scripts", "init-scripts"], Builtins.add( Ops.get_list(@current, ["scripts", "init-scripts"], []), script ) ) end if Ops.get_boolean(@current, ["general", "mode", "final_reboot"], false) script = { "filename" => "zzz_reboot", "source" => "chkconfig autoyast off\nshutdown -r now" } if !Builtins.haskey(@current, "scripts") Ops.set(@current, "scripts", {}) end if !Builtins.haskey( Ops.get_map(@current, "scripts", {}), "init-scripts" ) Ops.set(@current, ["scripts", "init-scripts"], []) end Ops.set( @current, ["scripts", "init-scripts"], Builtins.add( Ops.get_list(@current, ["scripts", "init-scripts"], []), script ) ) end if Builtins.haskey( Ops.get_map(@current, "software", {}), "additional_locales" ) if !Builtins.haskey(@current, "language") Ops.set(@current, "language", {}) end Ops.set( @current, ["language", "languages"], Builtins.mergestring( Ops.get_list(@current, ["software", "additional_locales"], []), "," ) ) Ops.set( @current, "software", Builtins.remove( Ops.get_map(@current, "software", {}), "additional_locales" ) ) end end nil end |
- (void) Import(profile)
This method returns an undefined value.
Import Profile
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File '../../src/modules/Profile.rb', line 284 def Import(profile) profile = deep_copy(profile) Builtins.y2milestone("importing profile") @current = deep_copy(profile) check_version(Ops.get_map(@current, "properties", {})) # old style if Builtins.haskey(profile, "configure") || Builtins.haskey(profile, "install") __configure = Ops.get_map(profile, "configure", {}) __install = Ops.get_map(profile, "install", {}) if Builtins.haskey(profile, "configure") @current = Builtins.remove(@current, "configure") end if Builtins.haskey(profile, "install") @current = Builtins.remove(@current, "install") end tmp = Convert.convert( Builtins.union(__configure, __install), :from => "map", :to => "map <string, any>" ) @current = Convert.convert( Builtins.union(tmp, @current), :from => "map", :to => "map <string, any>" ) end # raise the network immediately after configuring it if Builtins.haskey(@current, "networking") && !Builtins.haskey( Ops.get_map(@current, "networking", {}), "start_immediately" ) Ops.set(@current, ["networking", "start_immediately"], true) Builtins.y2milestone("start_immediately set to true") end storageLibCompat # compatibility to new storage library (SL 10.0) generalCompat # compatibility to new language,keyboard and timezone (SL10.1) softwareCompat Builtins.y2debug("Current Profile=%1", @current) nil end |
- (Object) main
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File '../../src/modules/Profile.rb', line 13 def main Yast.import "UI" textdomain "autoinst" Yast.import "Stage" Yast.import "Mode" Yast.import "AutoinstConfig" Yast.import "XML" Yast.import "Label" Yast.import "Popup" Yast.import "ProductControl" Yast.import "Directory" Yast.import "FileUtils" Yast.import "PackageSystem" Yast.include self, "autoinstall/xml.rb" # The Complete current Profile @current = {} # defined in Y2ModuleConfig @ModuleMap = {} @changed = false @prepare = true Profile() end |
- (void) Prepare
This method returns an undefined value.
Prepare Profile for saving and remove empty data structs
334 335 336 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 374 375 376 377 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 |
# File '../../src/modules/Profile.rb', line 334 def Prepare return if !@prepare Popup.ShowFeedback( _("Collecting configuration data..."), _("This may take a while") ) e = [] Builtins.foreach(@ModuleMap) do |p, d| # bnc#887115 Hidden modules cannot be cloned next if d["Hidden"] == "true" # # Set resource name, if not using default value # resource = Ops.get_string(d, "X-SuSE-YaST-AutoInstResource", "") resource = p if resource == "" tomerge = Ops.get_string(d, "X-SuSE-YaST-AutoInstMerge", "") module_auto = Ops.get_string(d, "X-SuSE-YaST-AutoInstClient", "none") if Convert.to_boolean(WFM.CallFunction(module_auto, ["GetModified"])) resource_data = WFM.CallFunction(module_auto, ["Export"]) s = 0 if tomerge == "" if Ops.get_string(d, "X-SuSE-YaST-AutoInstDataType", "map") == "map" s = Builtins.size(Convert.to_map(resource_data)) else s = Builtins.size(Convert.to_list(resource_data)) end end if s != 0 || tomerge != "" if Ops.greater_than(Builtins.size(tomerge), 0) i = 0 tomergetypes = Ops.get_string( d, "X-SuSE-YaST-AutoInstMergeTypes", "" ) _MergeTypes = Builtins.splitstring(tomergetypes, ",") Builtins.foreach(Builtins.splitstring(tomerge, ",")) do |res| if Ops.get_string(_MergeTypes, i, "map") == "map" rd = Convert.convert( resource_data, :from => "any", :to => "map <string, any>" ) Ops.set(@current, res, Ops.get_map(rd, res, {})) else rd = Convert.convert( resource_data, :from => "any", :to => "map <string, any>" ) Ops.set(@current, res, Ops.get_list(rd, res, [])) end i = Ops.add(i, 1) end else Ops.set(@current, resource, resource_data) end elsif s == 0 e = Builtins.add(e, resource) end end end Builtins.foreach(@current) do |k, v| if !Builtins.haskey(@current, k) && !Builtins.contains(e, k) Ops.set(@current, k, v) end end Popup.ClearFeedback @prepare = false nil end |
- (void) Profile
This method returns an undefined value.
Constructor
46 47 48 49 50 51 52 53 54 55 |
# File '../../src/modules/Profile.rb', line 46 def Profile # # setup profile XML parameters for writing # profileSetup if Stage.initial SCR.Execute(path(".target.mkdir"), AutoinstConfig.profile_dir) end nil end |
- (Boolean) ReadProfileStructure(parsedControlFile)
Read YCP data as the control file
537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File '../../src/modules/Profile.rb', line 537 def ReadProfileStructure(parsedControlFile) @current = Convert.convert( SCR.Read(path(".target.ycp"), [parsedControlFile, {}]), :from => "any", :to => "map <string, any>" ) if @current == {} return false else Import(@current) end true end |
- (Boolean) ReadXML(file)
Read XML into YCP data
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 |
# File '../../src/modules/Profile.rb', line 673 def ReadXML(file) tmp = Convert.to_string(SCR.Read(path(".target.string"), file)) l = Builtins.splitstring(tmp, "\n") if tmp != nil && Ops.get(l, 0, "") == "-----BEGIN PGP MESSAGE-----" out = {} while Ops.get_string(out, "stdout", "") == "" UI.OpenDialog( VBox( Label( _("Encrypted AutoYaST profile. Enter the correct password.") ), Password(Id(:password), ""), PushButton(Id(:ok), Label.OKButton) ) ) p = "" = nil begin = UI.UserInput p = Convert.to_string(UI.QueryWidget(Id(:password), :Value)) end until == :ok UI.CloseDialog command = Builtins.sformat( "gpg2 -d --batch --passphrase \"%1\" %2", p, file ) out = Convert.convert( SCR.Execute(path(".target.bash_output"), command, {}), :from => "any", :to => "map <string, any>" ) end @current = XML.XMLToYCPString(Ops.get_string(out, "stdout", "")) AutoinstConfig.ProfileEncrypted = true # FIXME: rethink and check for sanity of that! # save decrypted profile for modifying pre-scripts if Stage.initial SCR.Write( path(".target.string"), file, Ops.get_string(out, "stdout", "") ) end else Builtins.y2debug("Reading %1", file) @current = XML.XMLToYCPFile(file) end if @current != {} && Builtins.size(@current) == 0 # autoyast has read the autoyast configuration file but something went wrong = _( "The XML parser reported an error while parsing the autoyast profile. The error message is:\n" ) = Ops.add(, XML.XMLError) Popup.Error() return false end Import(@current) true end |
- (void) Reset
This method returns an undefined value.
Reset profile to initial status
418 419 420 421 422 |
# File '../../src/modules/Profile.rb', line 418 def Reset Builtins.y2milestone("Resetting profile contents") @current = {} nil end |
- (Boolean) Save(file)
Save YCP data into XML
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 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
# File '../../src/modules/Profile.rb', line 427 def Save(file) Prepare() ret = false Builtins.y2debug("Saving data (%1) to XML file %2", @current, file) if AutoinstConfig.ProfileEncrypted xml = XML.YCPToXMLString(:profile, @current) if Ops.greater_than(Builtins.size(xml), 0) if AutoinstConfig.ProfilePassword == "" p = "" q = "" begin UI.OpenDialog( VBox( Label( _("Encrypted AutoYaST profile. Enter the password twice.") ), Password(Id(:password), ""), Password(Id(:password2), ""), PushButton(Id(:ok), Label.OKButton) ) ) = nil begin = UI.UserInput p = Convert.to_string(UI.QueryWidget(Id(:password), :Value)) q = Convert.to_string(UI.QueryWidget(Id(:password2), :Value)) end until == :ok UI.CloseDialog end while p != q AutoinstConfig.ProfilePassword = AutoinstConfig.ShellEscape(p) end dir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) command = Builtins.sformat( "gpg2 -c --armor --batch --passphrase \"%1\" --output %2/encrypted_autoyast.xml", AutoinstConfig.ProfilePassword, dir ) SCR.Execute(path(".target.bash_input"), command, xml) if Ops.greater_than( SCR.Read( path(".target.size"), Ops.add(dir, "/encrypted_autoyast.xml") ), 0 ) command = Builtins.sformat( "mv %1/encrypted_autoyast.xml %2", dir, file ) SCR.Execute(path(".target.bash"), command, {}) ret = true end end else ret = XML.YCPToXMLFile(:profile, @current, file) end ret end |
- (Object) SaveProfileStructure(parsedControlFile)
Save the current data into a file to be read after a reboot.
529 530 531 532 |
# File '../../src/modules/Profile.rb', line 529 def SaveProfileStructure(parsedControlFile) Builtins.y2milestone("Saving control file in YCP format") SCR.Write(path(".target.ycp"), parsedControlFile, @current) end |
- (Object) SaveSingleSections(dir)
Save sections of current profile to separate files
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 |
# File '../../src/modules/Profile.rb', line 491 def SaveSingleSections(dir) Prepare() Builtins.y2milestone("Saving data (%1) to XML single files", @current) sectionFiles = {} Builtins.foreach(@current) do |sectionName, section| sectionFileName = Ops.add( Ops.add(Ops.add(dir, "/"), sectionName), ".xml" ) tmpProfile = { sectionName => section } if XML.YCPToXMLFile(:profile, tmpProfile, sectionFileName) Builtins.y2milestone( "Wrote section %1 to file %2", sectionName, sectionFileName ) sectionFiles = Builtins.add( sectionFiles, sectionName, sectionFileName ) else Builtins.y2error( Builtins.sformat( _("Could not write section %1 to file %2."), sectionName, sectionFileName ) ) end end deep_copy(sectionFiles) end |
- (Object) setElementByList(l, v, m)
this function is a replacement for this code: list<any> l = [ “key1”,0,“key3” ]; m[ l ] = v; @return [Hash]
776 777 778 779 780 781 782 |
# File '../../src/modules/Profile.rb', line 776 def setElementByList(l, v, m) l = deep_copy(l) v = deep_copy(v) m = deep_copy(m) m = setMValue(l, v, m) deep_copy(m) end |
- (Object) setLValue(l, v, m)
753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
# File '../../src/modules/Profile.rb', line 753 def setLValue(l, v, m) l = deep_copy(l) v = deep_copy(v) m = deep_copy(m) i = Ops.get_integer(l, 0, 0) tmp = Builtins.remove(l, 0) if Ops.greater_than(Builtins.size(tmp), 0) if Ops.is_string?(Ops.get(tmp, 0)) Ops.set(m, i, setMValue(tmp, v, Ops.get_map(m, i, {}))) else Ops.set(m, i, setLValue(tmp, v, Ops.get_list(m, i, []))) end else Builtins.y2debug("setting %1 to %2", i, v) Ops.set(m, i, v) end deep_copy(m) end |
- (Object) setMValue(l, v, m)
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
# File '../../src/modules/Profile.rb', line 735 def setMValue(l, v, m) l = deep_copy(l) v = deep_copy(v) m = deep_copy(m) i = Ops.get_string(l, 0, "") tmp = Builtins.remove(l, 0) if Ops.greater_than(Builtins.size(tmp), 0) if Ops.is_string?(Ops.get(tmp, 0)) Ops.set(m, i, setMValue(tmp, v, Ops.get_map(m, i, {}))) else Ops.set(m, i, setLValue(tmp, v, Ops.get_list(m, i, []))) end else Builtins.y2debug("setting %1 to %2", i, v) Ops.set(m, i, v) end deep_copy(m) end |
- (Object) softwareCompat
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/modules/Profile.rb', line 106 def softwareCompat Ops.set(@current, "software", Ops.get_map(@current, "software", {})) if !Builtins.contains( Ops.get_list(@current, ["software", "packages"], []), "autoyast2-installation" ) Ops.set( @current, ["software", "packages"], Builtins.add( Ops.get_list(@current, ["software", "packages"], []), "autoyast2-installation" ) ) end # without autoyast2, <files ...> does not work if Builtins.haskey(@current, "files") && !Builtins.contains( Ops.get_list(@current, ["software", "packages"], []), "autoyast2" ) Ops.set( @current, ["software", "packages"], Builtins.add( Ops.get_list(@current, ["software", "packages"], []), "autoyast2" ) ) end # workaround for missing "REQUIRES" in content file to stay backward compatible # FIXME: needs a more sophisticated or compatibility breaking solution after SLES11 if Builtins.size(Ops.get_list(@current, ["software", "patterns"], [])) == 0 Ops.set(@current, ["software", "patterns"], ["base"]) end nil end |
- (Object) storageLibCompat
compatibility to new storage lib in 10.0
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 |
# File '../../src/modules/Profile.rb', line 59 def storageLibCompat newPart = [] Builtins.foreach(Ops.get_list(@current, "partitioning", [])) do |d| if Builtins.haskey(d, "is_lvm_vg") && Ops.get_boolean(d, "is_lvm_vg", false) == true d = Builtins.remove(d, "is_lvm_vg") Ops.set(d, "type", :CT_LVM) elsif Builtins.haskey(d, "device") && Ops.get_string(d, "device", "") == "/dev/md" Ops.set(d, "type", :CT_MD) elsif !Builtins.haskey(d, "type") Ops.set(d, "type", :CT_DISK) end # actually, this is not a compatibility hook for the new # storage lib. It's a hook to be compatibel with the autoyast # documentation for reusing partitions # Ops.set( d, "partitions", Builtins.maplist(Ops.get_list(d, "partitions", [])) do |p| if Builtins.haskey(p, "create") && Ops.get_boolean(p, "create", true) == false && Builtins.haskey(p, "partition_nr") Ops.set(p, "usepart", Ops.get_integer(p, "partition_nr", 0)) # useless default end if Builtins.haskey(p, "partition_id") # that's a bit strange. There is a naming mixup between # autoyast and the storage part of yast. Actually filesystem_id # does not make sense at all but in autoyast it is the # partition id (maybe that's because yast calls # the partition id "fsid" internally). # partition_id in the profile does not work at all, so we copy # that value to filesystem_id Ops.set(p, "filesystem_id", Ops.get_integer(p, "partition_id", 0)) end deep_copy(p) end ) newPart = Builtins.add(newPart, d) end Builtins.y2milestone("partitioning is now %1", newPart) Ops.set(@current, "partitioning", newPart) nil end |