Module: Yast::IscsiServerWidgetsInclude
- Defined in:
- ../../src/include/iscsi-server/widgets.rb
Instance Method Summary (collapse)
-
- (Object) getAuthItems
create items for incoming table.
-
- (Object) getDialogValues(user, pass)
dialog to add/modify user and password.
-
- (Object) getIncomingValues
get values for incoming authentication.
-
- (Object) getOutgoingValues
get values for outgoing authentication.
-
- (Object) handleAuth(key, event)
**************** Target Auth ******************* handle authentication dialog.
-
- (Object) handleLUN(key, event)
************** LUN Detail Dialog ****************************.
- - (Object) handleModify(key, event)
- - (Object) handleTable(table, event)
-
- (Object) initAddTarget(key)
************** Add Target Dialog ****************** initialize function for create new target.
-
- (Object) initGlobal(key)
initialize discovery authentication or authentication for given target.
-
- (Object) initGlobalValues(values)
**************** Global Dialog *********************.
- - (Object) initialize_iscsi_server_widgets(include_target)
- - (Object) initiSNS(key)
-
- (Object) initModify(key)
init values for modifying target (read it from stored map).
-
- (Object) initTable(key)
initialize target dialog.
- - (Object) LUNDetailDialog(values_before)
- - (Object) parseRow(value)
- - (Object) saveConfiguration(key, event)
-
- (Object) setAuthIn(status)
set incoming authentication enabled/disabled status.
-
- (Object) setAuthOut(status)
set outgoing authentication enabled/disabled status.
-
- (Object) storeAddTarget(option_id, option_map)
save values.
-
- (Object) storeGlobal(option_id, option_map)
save discovery authentication or authentication for given target.
- - (Object) storeiSNS(option_id, option_map)
- - (Object) storeLUN(option_id, option_map)
- - (Object) storeModify(option_id, option_map)
-
- (Object) validateAddTarget(key, event)
validate function checks if target/lun are unique and not empty.
-
- (Object) validateGlobal(key, event)
validate functions checks the secret for incoming and outgoing cannot be same.
- - (Object) validateiSNS(key, event)
Instance Method Details
- (Object) getAuthItems
create items for incoming table
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File '../../src/include/iscsi-server/widgets.rb', line 453 def getAuthItems inc_items = [] count = -1 while Ops.less_than(count, Ops.subtract(Builtins.size(@inc_auth), 1)) count = Ops.add(count, 1) inc_items = Builtins.add( inc_items, Item( Id(count), Ops.get_string(@inc_auth, [count, "USER"], ""), "*****" ) ) end deep_copy(inc_items) end |
- (Object) getDialogValues(user, pass)
dialog to add/modify user and password
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File '../../src/include/iscsi-server/widgets.rb', line 314 def getDialogValues(user, pass) UI.OpenDialog( VBox( InputField(Id(:p_user), Opt(:hstretch), _("Username"), user), Password(Id(:p_pass), _("Password"), pass), ButtonBox( PushButton(Id(:ok), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) ) cycle = true while cycle case Convert.to_symbol(UI.UserInput) when :ok user = Builtins.tostring(UI.QueryWidget(Id(:p_user), :Value)) pass = Builtins.tostring(UI.QueryWidget(Id(:p_pass), :Value)) UI.CloseDialog cycle = false when :cancel cycle = false UI.CloseDialog end end if Ops.greater_than(Builtins.size(user), 0) && Ops.greater_than(Builtins.size(pass), 0) return [user, pass] else return [] end end |
- (Object) getIncomingValues
get values for incoming authentication
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File '../../src/include/iscsi-server/widgets.rb', line 278 def getIncomingValues values = [] if Convert.to_boolean(UI.QueryWidget(Id(:auth_in), :Value)) == true count = -1 while Ops.less_than(count, Ops.subtract(Builtins.size(@inc_auth), 1)) count = Ops.add(count, 1) values = Builtins.add( values, Builtins.sformat( "%1 %2", Ops.get_string(@inc_auth, [count, "USER"], ""), Ops.get_string(@inc_auth, [count, "PASS"], "") ) ) end return deep_copy(values) else return [] end end |
- (Object) getOutgoingValues
get values for outgoing authentication
300 301 302 303 304 305 306 307 308 309 310 311 |
# File '../../src/include/iscsi-server/widgets.rb', line 300 def getOutgoingValues if Convert.to_boolean(UI.QueryWidget(Id(:auth_out), :Value)) == true values = Builtins.sformat( "%1 %2", UI.QueryWidget(Id(:user_out), :Value), UI.QueryWidget(Id(:pass_out), :Value) ) return values else return "" end end |
- (Object) handleAuth(key, event)
**************** Target Auth ******************* handle authentication dialog
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 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/include/iscsi-server/widgets.rb', line 747 def handleAuth(key, event) event = deep_copy(event) if Ops.get_string(event, "EventReason", "") == "ValueChanged" status = false # enable/disable none/incoming/outgoing authentication case Ops.get_symbol(event, "ID") when :auth_none status = Convert.to_boolean(UI.QueryWidget(Id(:auth_none), :Value)) setAuthIn(!status) setAuthOut(!status) when :auth_in status = Convert.to_boolean(UI.QueryWidget(Id(:auth_in), :Value)) setAuthIn(status) when :auth_out status = Convert.to_boolean(UI.QueryWidget(Id(:auth_out), :Value)) setAuthOut(status) end end # add/edit/delete incoming authentication if Ops.get_string(event, "EventReason", "") == "Activated" case Ops.get_symbol(event, "ID") when :add @values = getDialogValues("", "") Builtins.y2milestone("Add authentication values") if Builtins.size(@values) == 2 user = Ops.get(@values, 0, "") pass = Ops.get(@values, 1, "") count = Builtins.size( Convert.to_list(UI.QueryWidget(Id(:incoming_table), :Items)) ) Ops.set( @inc_auth, Builtins.size(@inc_auth), { "USER" => user, "PASS" => pass } ) UI.ChangeWidget(Id(:incoming_table), :Items, getAuthItems) end when :edit @curr = Builtins.tointeger( UI.QueryWidget(Id(:incoming_table), :CurrentItem) ) Builtins.y2milestone("Modify authentication values") if @curr != nil user = Ops.get_string(@inc_auth, [@curr, "USER"], "") pass = Ops.get_string(@inc_auth, [@curr, "PASS"], "") values = getDialogValues(user, pass) if Builtins.size(values) == 2 user2 = Ops.get(values, 0, "") pass2 = Ops.get(values, 1, "") rows = Convert.convert( UI.QueryWidget(Id(:incoming_table), :Items), :from => "any", :to => "list <term>" ) Ops.set(@inc_auth, @curr, { "USER" => user2, "PASS" => pass2 }) UI.ChangeWidget(Id(:incoming_table), :Items, getAuthItems) end end when :delete @del = UI.QueryWidget(Id(:incoming_table), :CurrentItem) Builtins.y2milestone("Delete authentication value") if @del != nil if Popup.ContinueCancel(_("Really delete the selected item?")) count = 0 temp_map = {} while Ops.less_than(count, Builtins.size(@inc_auth)) if Ops.less_than(count, @del) Ops.set(temp_map, count, Ops.get(@inc_auth, count)) elsif count == @del else Ops.set( temp_map, Ops.subtract(count, 1), Ops.get(@inc_auth, count) ) end count = Ops.add(count, 1) end @inc_auth = deep_copy(temp_map) UI.ChangeWidget(Id(:incoming_table), :Items, getAuthItems) else Builtins.y2milestone("Delete canceled") end end end end if Builtins.size(Convert.to_list(UI.QueryWidget(:incoming_table, :Items))) == 0 UI.ChangeWidget(:edit, :Enabled, false) UI.ChangeWidget(:delete, :Enabled, false) else UI.ChangeWidget(:edit, :Enabled, true) UI.ChangeWidget(:delete, :Enabled, true) end nil end |
- (Object) handleLUN(key, event)
************** LUN Detail Dialog ****************************
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 |
# File '../../src/include/iscsi-server/widgets.rb', line 1025 def handleLUN(key, event) event = deep_copy(event) enable = false if Convert.to_boolean(UI.QueryWidget(:fileio, :Value)) == true enable = true end UI.ChangeWidget(:file_path, :Enabled, enable) UI.ChangeWidget(:browse, :Enabled, enable) UI.ChangeWidget(:scsi_id, :Enabled, enable) UI.ChangeWidget(:sectors, :Enabled, !enable) if Ops.get_string(event, "EventReason", "") == "Activated" && Ops.get(event, "WidgetID") == :browse file = UI.AskForExistingFile("/", "", _("Select file or device")) UI.ChangeWidget(:file_path, :Value, file) if file != nil end nil end |
- (Object) handleModify(key, event)
899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
# File '../../src/include/iscsi-server/widgets.rb', line 899 def handleModify(key, event) event = deep_copy(event) if Ops.get_string(event, "EventReason", "") == "Activated" case Ops.get_symbol(event, "WidgetID") when :delete @del = UI.QueryWidget(Id(:lun_table), :CurrentItem) if @del != nil if Popup.ContinueCancel(_("Really delete the selected item?")) Builtins.y2milestone("Delete LUN %1 from table", @del) items = [] count = 0 Builtins.foreach( Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) ) do |row| if count != @del items = Builtins.add( items, Item( Id(Builtins.size(items)), Ops.get_string(row, 1, ""), Ops.get_string(row, 2, "") ) ) end count = Ops.add(count, 1) end UI.ChangeWidget(Id(:lun_table), :Items, items) else Builtins.y2milestone("Delete canceled") end end when :edit @items = Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) @edit_pos = Builtins.tointeger( UI.QueryWidget(:lun_table, :CurrentItem) ) @ret_map = LUNDetailDialog( { "KEY" => "Lun", "VALUE" => Ops.get_string(@items, [@edit_pos, 2], "") } ) if @ret_map != {} Ops.set( @items, @edit_pos, Item( Id(@edit_pos), Ops.get_string(@ret_map, "KEY", ""), Ops.get_string(@ret_map, "VALUE", "") ) ) UI.ChangeWidget(:lun_table, :Items, @items) end when :add @add_map = LUNDetailDialog( { "KEY" => "Lun", "VALUE" => Builtins.tostring( Builtins.size( Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) ) ) } ) if @add_map != {} items = Convert.to_list(UI.QueryWidget(:lun_table, :Items)) items = Builtins.add( items, Item( Id(Builtins.size(items)), Ops.get_string(@add_map, "KEY", ""), Ops.get_string(@add_map, "VALUE", "") ) ) UI.ChangeWidget(:lun_table, :Items, items) end end end if Builtins.size(Convert.to_list(UI.QueryWidget(:lun_table, :Items))) == 0 UI.ChangeWidget(:edit, :Enabled, false) UI.ChangeWidget(:delete, :Enabled, false) else UI.ChangeWidget(:edit, :Enabled, true) UI.ChangeWidget(:delete, :Enabled, true) end nil end |
- (Object) handleTable(table, event)
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 |
# File '../../src/include/iscsi-server/widgets.rb', line 394 def handleTable(table, event) event = deep_copy(event) ret = nil if Ops.get_string(event, "EventReason", "") == "Activated" case Ops.get_symbol(event, "ID") when :add # goto AddDialog() (initAddTarget) ret = :add when :delete # add a new item if Popup.ContinueCancel(_("Really delete this item?")) del = Builtins.tointeger( UI.QueryWidget(Id(:server), :CurrentItem) ) target = Ops.get_string( Convert.to_term(UI.QueryWidget(Id(:server), term(:Item, del))), 1, "" ) IscsiServerFunctions.setDelChanges(target) IscsiServerFunctions.removeTarget( Ops.get_string( Convert.to_term(UI.QueryWidget(Id(:server), term(:Item, del))), 1, "" ) ) initTable("") end when :edit # edit new item @edit = Builtins.tointeger( UI.QueryWidget(Id(:server), :CurrentItem) ) @curr_target = Ops.get_string( Convert.to_term(UI.QueryWidget(Id(:server), term(:Item, @edit))), 1, "" ) if IscsiServerFunctions.setModifChanges(@curr_target) == 0 Builtins.y2milestone("modified %1", @curr_target) else Builtins.y2error("%1 already modified", @curr_target) end # goto EditDialog() (initModify) ret = :edit end end if Builtins.size(Convert.to_list(UI.QueryWidget(:server, :Items))) == 0 UI.ChangeWidget(:edit, :Enabled, false) UI.ChangeWidget(:delete, :Enabled, false) else UI.ChangeWidget(:edit, :Enabled, true) UI.ChangeWidget(:delete, :Enabled, true) end ret end |
- (Object) initAddTarget(key)
************** Add Target Dialog ****************** initialize function for create new target
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 |
# File '../../src/include/iscsi-server/widgets.rb', line 617 def initAddTarget(key) # some proposed values target = "iqn" date = Ops.get_string( Convert.convert( SCR.Execute(path(".target.bash_output"), "date +%Y-%m"), :from => "any", :to => "map <string, any>" ), "stdout", "" ) domain = Ops.get_string( Convert.convert( SCR.Execute(path(".target.bash_output"), "dnsdomainname"), :from => "any", :to => "map <string, any>" ), "stdout", "" ) uuid = Ops.get_string( Convert.convert( SCR.Execute(path(".target.bash_output"), "uuidgen"), :from => "any", :to => "map <string, any>" ), "stdout", "" ) uuid = Builtins.deletechars(uuid, "\n") if Ops.greater_than(Builtins.size(domain), 0) domain = Ops.get(Builtins.splitstring(domain, "\n"), 0, "") tmp_list = Builtins.splitstring(domain, ".") domain = Builtins.sformat( "%1.%2", Ops.get(tmp_list, 1, ""), Ops.get(tmp_list, 0, "") ) else domain = "com.example" end target = Builtins.deletechars( Builtins.sformat("%1.%2.%3", target, date, domain), "\n" ) Builtins.y2milestone("init values for add_target %1", target) UI.ChangeWidget(Id(:target), :Value, target) UI.ChangeWidget(Id(:identifier), :Value, uuid) # UI::ChangeWidget(`id(`lun), `Value, tostring(IscsiServerFunctions::getNextLun()) ); nil end |
- (Object) initGlobal(key)
initialize discovery authentication or authentication for given target
568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
# File '../../src/include/iscsi-server/widgets.rb', line 568 def initGlobal(key) if Ops.greater_than(Builtins.size(@curr_target), 0) initGlobalValues( Ops.get_list(IscsiServerFunctions.getConfig, @curr_target, []) ) else #if (size(IscsiServerFunctions::getConfig()["auth"]:[])>0) initGlobalValues( Ops.get_list(IscsiServerFunctions.getConfig, "auth", []) ) end nil end |
- (Object) initGlobalValues(values)
**************** Global Dialog *********************
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 |
# File '../../src/include/iscsi-server/widgets.rb', line 515 def initGlobalValues(values) values = deep_copy(values) setAuthIn(false) setAuthOut(false) user = "" pass = "" # incoming authentication @inc_auth = {} count = 0 Builtins.foreach(values) do |auth| if Ops.get_string(auth, "KEY", "") == "IncomingUser" user = Ops.get( Builtins.splitstring(Ops.get_string(auth, "VALUE", ""), " "), 0, "" ) pass = Ops.get( Builtins.splitstring(Ops.get_string(auth, "VALUE", ""), " "), 1, "" ) Ops.set(@inc_auth, count, { "USER" => user, "PASS" => pass }) count = Ops.add(count, 1) setAuthIn(true) end if Ops.get_string(auth, "KEY", "") == "OutgoingUser" UI.ChangeWidget( Id(:user_out), :Value, Ops.get( Builtins.splitstring(Ops.get_string(auth, "VALUE", ""), " "), 0, "" ) ) UI.ChangeWidget( Id(:pass_out), :Value, Ops.get( Builtins.splitstring(Ops.get_string(auth, "VALUE", ""), " "), 1, "" ) ) setAuthOut(true) end end UI.ChangeWidget(Id(:incoming_table), :Items, getAuthItems) nil end |
- (Object) initialize_iscsi_server_widgets(include_target)
34 35 36 37 38 39 40 41 42 43 |
# File '../../src/include/iscsi-server/widgets.rb', line 34 def (include_target) textdomain "iscsi-server" Yast.import "IscsiServerFunctions" Yast.import "Label" Yast.import "IP" # **************** global funcions and variables ***** @curr_target = "" @modify_record = "" @inc_auth = {} end |
- (Object) initiSNS(key)
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
# File '../../src/include/iscsi-server/widgets.rb', line 470 def initiSNS(key) ac = false ip = "" Builtins.foreach(Ops.get_list(IscsiServerFunctions.getConfig, "iSNS", [])) do |row| if Ops.get_string(row, "KEY", "") == "iSNSAccessControl" ac = Ops.get_string(row, "VALUE", "No") == "Yes" ? true : false end if Ops.get_string(row, "KEY", "") == "iSNSServer" ip = Ops.get_string(row, "VALUE", "") end end UI.ChangeWidget(:isns_ac, :Value, ac) UI.ChangeWidget(:isns_ip, :Value, ip) nil end |
- (Object) initModify(key)
init values for modifying target (read it from stored map)
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 |
# File '../../src/include/iscsi-server/widgets.rb', line 851 def initModify(key) inc_items = [] Builtins.foreach( Convert.convert( IscsiServerFunctions.editTarget(@curr_target), :from => "list", :to => "list <map <string, any>>" ) ) do |row| case Ops.get_string(row, "KEY", "") when "Target" UI.ChangeWidget( Id(:target), :Value, Ops.get( Builtins.splitstring(Ops.get_string(row, "VALUE", ""), ":"), 0, "" ) ) UI.ChangeWidget(Id(:target), :Enabled, false) UI.ChangeWidget( Id(:identifier), :Value, Ops.get( Builtins.splitstring(Ops.get_string(row, "VALUE", ""), ":"), 1, "" ) ) UI.ChangeWidget(Id(:identifier), :Enabled, false) when "Lun" inc_items = Builtins.add( inc_items, Item( Id(Builtins.size(inc_items)), Ops.get_string(row, "KEY", ""), Ops.get_string(row, "VALUE", "") ) ) # put it into table UI.ChangeWidget(Id(:lun_table), :Items, inc_items) end end nil end |
- (Object) initTable(key)
initialize target dialog
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
# File '../../src/include/iscsi-server/widgets.rb', line 378 def initTable(key) count = 0 inc_items = [] # create items from targets if Ops.greater_than(Builtins.size(IscsiServerFunctions.getTargets), 0) Builtins.foreach(IscsiServerFunctions.getTargets) do |key2, value| inc_items = Builtins.add(inc_items, Item(Id(count), key2)) count = Ops.add(count, 1) end end # put it into table UI.ChangeWidget(Id(:server), :Items, inc_items) nil end |
- (Object) LUNDetailDialog(values_before)
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File '../../src/include/iscsi-server/widgets.rb', line 136 def LUNDetailDialog(values_before) values_before = deep_copy(values_before) previous = parseRow(Ops.get_string(values_before, "VALUE", "")) ret_map = {} lun_dialog = VBox( Left( HWeight( 3, InputField( Id(:lun), Opt(:hstretch), "LUN", Ops.get_string(previous, "lun", "0") ) ) ), VSpacing(2), RadioButtonGroup( Id(:rb), VBox( Left( RadioButton( Id(:fileio), Opt(:notify), "Type=fileio", Ops.get_boolean(previous, "fileio", true) ) ), HBox( InputField( Id(:file_path), Opt(:hstretch), _("Path:"), Ops.get_string(previous, "path", "") ), VBox(Label(""), PushButton(Id(:browse), _("Browse"))) ), InputField( Id(:scsi_id), Opt(:hstretch), "ScsiId:", Ops.get_string(previous, "scsi_id", "") ), VSpacing(2), Left( RadioButton( Id(:nullio), Opt(:notify), "Type=nullio", Ops.get_boolean(previous, "nullio", false) ) ), InputField( Id(:sectors), Opt(:hstretch), _("Sectors:"), Ops.get_string(previous, "sectors", "") ) ) ), Left( ButtonBox( PushButton(Id(:ok), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) ) UI.OpenDialog(lun_dialog) UI.ChangeWidget(Id(:lun), :ValidChars, "0123456789") ret = :nil while ret != :ok && ret != :cancel enable = false if Convert.to_boolean(UI.QueryWidget(:fileio, :Value)) == true enable = true end UI.ChangeWidget(:file_path, :Enabled, enable) UI.ChangeWidget(:browse, :Enabled, enable) UI.ChangeWidget(:scsi_id, :Enabled, enable) UI.ChangeWidget(:sectors, :Enabled, !enable) if ret == :browse file = UI.AskForExistingFile("/", "", _("Select file or device")) UI.ChangeWidget(:file_path, :Value, file) if file != nil end ret = Convert.to_symbol(UI.UserInput) end if ret == :cancel ret_map = {} else lun = Convert.to_string(UI.QueryWidget(:lun, :Value)) value = lun if Convert.to_boolean(UI.QueryWidget(:fileio, :Value)) == true value = Builtins.sformat( "%1 Path=%2,Type=fileio", value, Convert.to_string(UI.QueryWidget(:file_path, :Value)) ) scsi_id = Convert.to_string(UI.QueryWidget(:scsi_id, :Value)) if Ops.greater_than(Builtins.size(scsi_id), 0) value = Builtins.sformat("%1,ScsiId=%2", value, scsi_id) end else value = Builtins.sformat("%1 Type=nullio", value) sectors = Convert.to_string(UI.QueryWidget(:sectors, :Value)) if Ops.greater_than(Builtins.size(sectors), 0) value = Builtins.sformat("%1,Sectors=%2", value, sectors) end end ret_map = { "KEY" => "Lun", "VALUE" => value } end UI.CloseDialog deep_copy(ret_map) end |
- (Object) parseRow(value)
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 |
# File '../../src/include/iscsi-server/widgets.rb', line 45 def parseRow(value) ret = {} # if nothing only LUN return { "lun" => value } if Builtins.find(value, " ") == -1 # extract Lun pos = Builtins.find(value, " ") Ops.set(ret, "lun", Builtins.substring(value, 0, pos)) value = Builtins.substring(value, pos, Builtins.size(value)) # extract Type pos = Builtins.find(value, "Type=") pos2 = Builtins.findfirstof( Builtins.substring(value, pos, Builtins.size(value)), " ," ) type = Builtins.substring( value, Ops.add(pos, Builtins.size("Type=")), pos2 != nil ? Ops.subtract(pos2, Builtins.size("Type=")) : Builtins.size(value) ) if pos != -1 if type == "fileio" Ops.set(ret, "fileio", true) Ops.set(ret, "nullio", false) else Ops.set(ret, "fileio", false) Ops.set(ret, "nullio", true) end end # extract Path pos = Builtins.find(value, "Path=") pos2 = Builtins.findfirstof( Builtins.substring(value, pos, Builtins.size(value)), " ," ) if pos != -1 Ops.set( ret, "path", Builtins.substring( value, Ops.add(pos, Builtins.size("Path=")), pos2 != nil ? Ops.subtract(pos2, Builtins.size("Path=")) : Builtins.size(value) ) ) end # extract ScsiId pos = Builtins.find(value, "ScsiId=") pos2 = Builtins.findfirstof( Builtins.substring(value, pos, Builtins.size(value)), " ," ) if pos != -1 Ops.set( ret, "scsi_id", Builtins.substring( value, Ops.add(pos, Builtins.size("ScsiId=")), pos2 != nil ? Ops.subtract(pos2, Builtins.size("ScsiId=")) : Builtins.size(value) ) ) end # extract ScsiId pos = Builtins.find(value, "Sectors=") pos2 = Builtins.findfirstof( Builtins.substring(value, pos, Builtins.size(value)), " ," ) if pos != -1 Ops.set( ret, "sectors", Builtins.substring( value, Ops.add(pos, Builtins.size("Sectors=")), pos2 != nil ? Ops.subtract(pos2, Builtins.size("Sectors=")) : Builtins.size(value) ) ) end deep_copy(ret) end |
- (Object) saveConfiguration(key, event)
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File '../../src/include/iscsi-server/widgets.rb', line 347 def saveConfiguration(key, event) event = deep_copy(event) if Ops.is_string?(Ops.get(event, "ID")) && Ops.get_string(event, "ID", "") == "save" filename = UI.AskForSaveFileName("/", "*", _("Save as...")) if filename != nil && Convert.to_string(filename) != "" if IscsiServerFunctions.SaveIntoFile(Convert.to_string(filename)) Popup.Message( Builtins.sformat(_("File %1 was saved successfully."), filename) ) 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 end nil end |
- (Object) setAuthIn(status)
set incoming authentication enabled/disabled status
252 253 254 255 256 257 258 259 260 261 262 263 264 |
# File '../../src/include/iscsi-server/widgets.rb', line 252 def setAuthIn(status) Builtins.y2milestone("Status of AuthIncoming %1", status) UI.ChangeWidget(Id(:incoming_table), :Enabled, status) UI.ChangeWidget(Id(:auth_in), :Value, status) UI.ChangeWidget(Id(:add), :Enabled, status) UI.ChangeWidget(Id(:edit), :Enabled, status) UI.ChangeWidget(Id(:delete), :Enabled, status) UI.ChangeWidget(Id(:auth_none), :Value, !status) if status nil end |
- (Object) setAuthOut(status)
set outgoing authentication enabled/disabled status
267 268 269 270 271 272 273 274 275 |
# File '../../src/include/iscsi-server/widgets.rb', line 267 def setAuthOut(status) Builtins.y2milestone("Status of AuthOutgoing %1", status) UI.ChangeWidget(Id(:user_out), :Enabled, status) UI.ChangeWidget(Id(:pass_out), :Enabled, status) UI.ChangeWidget(Id(:auth_out), :Value, status) UI.ChangeWidget(Id(:auth_none), :Value, !status) if status nil end |
- (Object) storeAddTarget(option_id, option_map)
save values
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 |
# File '../../src/include/iscsi-server/widgets.rb', line 689 def storeAddTarget(option_id, option_map) option_map = deep_copy(option_map) old = [] target = Builtins.tostring( Builtins.sformat( "%1:%2", UI.QueryWidget(Id(:target), :Value), UI.QueryWidget(Id(:identifier), :Value) ) ) # string lun = sformat("%1 Path=%2,Type=fileio",UI::QueryWidget(`id(`lun), `Value), UI::QueryWidget(`id(`path), `Value) ); # add/modify that values items = [] Builtins.foreach( Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) ) do |row| items = Builtins.add( items, { "KEY" => Ops.get_string(row, 1, ""), "VALUE" => Ops.get_string(row, 2, "") } ) end Builtins.y2milestone("Add target %1", target) IscsiServerFunctions.addNewTarget(target, items) @curr_target = target nil end |
- (Object) storeGlobal(option_id, option_map)
save discovery authentication or authentication for given target
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 |
# File '../../src/include/iscsi-server/widgets.rb', line 584 def storeGlobal(option_id, option_map) option_map = deep_copy(option_map) if Ops.greater_than(Builtins.size(@curr_target), 0) IscsiServerFunctions.setTargetAuth( @curr_target, getIncomingValues, getOutgoingValues ) IscsiServerFunctions.saveNewTarget(@curr_target) else IscsiServerFunctions.setAuth(getIncomingValues, getOutgoingValues) end nil end |
- (Object) storeiSNS(option_id, option_map)
500 501 502 503 504 505 506 507 508 509 510 511 |
# File '../../src/include/iscsi-server/widgets.rb', line 500 def storeiSNS(option_id, option_map) option_map = deep_copy(option_map) ip = "" if Convert.to_boolean(UI.QueryWidget(:isns_ac, :Value)) ip = Convert.to_string(UI.QueryWidget(:isns_ip, :Value)) end ac = Convert.to_boolean(UI.QueryWidget(:isns_ac, :Value)) ? "Yes" : "No" ac = "" if ip == "" IscsiServerFunctions.setiSNS(ip, ac) nil end |
- (Object) storeLUN(option_id, option_map)
1046 1047 1048 1049 1050 1051 |
# File '../../src/include/iscsi-server/widgets.rb', line 1046 def storeLUN(option_id, option_map) option_map = deep_copy(option_map) lun = Convert.to_string(UI.QueryWidget(:lun, :Value)) nil end |
- (Object) storeModify(option_id, option_map)
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
# File '../../src/include/iscsi-server/widgets.rb', line 1001 def storeModify(option_id, option_map) option_map = deep_copy(option_map) items = [] Builtins.foreach( Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) ) do |row| items = Builtins.add( items, { "KEY" => Ops.get_string(row, 1, ""), "VALUE" => Ops.get_string(row, 2, "") } ) end IscsiServerFunctions.setLUN(@curr_target, items) nil end |
- (Object) validateAddTarget(key, event)
validate function checks if target/lun are unique and not empty
725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
# File '../../src/include/iscsi-server/widgets.rb', line 725 def validateAddTarget(key, event) event = deep_copy(event) target = Builtins.tostring(UI.QueryWidget(Id(:target), :Value)) # string lun = tostring( UI::QueryWidget(`id(`lun), `Value) ); type = "no" if Builtins.size(target) == 0 && Popup.Error(_("The target cannot be empty.")) == nil || IscsiServerFunctions.ifExists("Target", target) && Popup.Error(_("The target already exists.")) == nil UI.SetFocus(Id(:target)) return false end # if ((size(lun)==0 && (Popup::Error(_("The logical unit definition cannot be empty."))==nil))|| # ( IscsiServerFunctions::ifExists("Lun", lun) && (Popup::Error(_("The logical unit already exists."))==nil))){ # UI::SetFocus(`id(`lun)); # return false; # } true end |
- (Object) validateGlobal(key, event)
validate functions checks the secret for incoming and outgoing cannot be same
601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File '../../src/include/iscsi-server/widgets.rb', line 601 def validateGlobal(key, event) event = deep_copy(event) ret = false if !Builtins.contains(getIncomingValues, getOutgoingValues) ret = true else Popup.Error( _( "Cannot use the same secret for incoming and outgoing authentication." ) ) end ret end |
- (Object) validateiSNS(key, event)
487 488 489 490 491 492 493 494 495 496 497 498 |
# File '../../src/include/iscsi-server/widgets.rb', line 487 def validateiSNS(key, event) event = deep_copy(event) ip = Convert.to_string(UI.QueryWidget(:isns_ip, :Value)) valid = true if Ops.greater_than(Builtins.size(ip), 0) valid = IP.Check(ip) else valid = true end Popup.Error(_("Invalid IP address.")) if !valid valid end |