Module: Yast::IscsiLioServerWidgetsInclude
- Defined in:
- ../../src/include/iscsi-lio-server/widgets.rb
Instance Method Summary (collapse)
- - (Object) AddClntDialog
- - (Object) AuthTerm(discovery)
- - (Object) ChangeTpgItems(id, value, items)
- - (Object) CheckLun(l, other, silent)
- - (Object) CheckName(n, other)
- - (Object) CheckPath(p, other)
- - (Object) ClntAuthDialog(clnt)
-
- (Object) CopyClntDialog
Copy exisiting LUN, i.e.
- - (Object) createClntLun(tgt, tpg, clnt, lun, tlun)
- - (Object) GetAuthString(am)
- - (Object) GetById(it, id)
-
- (Object) getDialogValues(user, pass)
dialog to add/modify user and password.
-
- (Object) GetIncomingValues
get values for incoming authentication.
- - (Object) GetLunList(lmap)
-
- (Object) GetOutgoingValues
get values for outgoing authentication.
-
- (Object) handleAuth(key, event)
**************** Target Auth ******************* handle authentication dialog.
- - (Object) handleClient(key, event)
- - (Object) handleModify(key, event)
- - (Object) handleTable(table, event)
-
- (Object) initAddTarget(key)
************** Add Target Dialog ****************** initialize function for create new target.
- - (Object) initClient(key)
-
- (Object) initGlobal(key)
initialize discovery authentication or authentication for given target.
-
- (Object) initGlobalValues(auth)
**************** Global Dialog *********************.
- - (Object) initialize_iscsi_lio_server_widgets(include_target)
-
- (Object) initModify(key)
init values for modifying target (read it from stored map).
-
- (Object) initTable(key)
initialize target dialog.
- - (Object) LUNDetailDialog(pos, items)
- - (Object) LUNMapDialog(clnt)
- - (Object) RemoveById(it, id)
- - (Object) removeClntLun(tgt, tpg, clnt, lun)
-
- (Object) SetAuthIn(status)
set incoming authentication enabled/disabled status.
-
- (Object) SetAuthOut(status)
set outgoing authentication enabled/disabled status.
- - (Object) storeAddTarget(option_id, option_map)
- - (Object) storeClient(option_id, option_map)
-
- (Object) storeGlobal(option_id, option_map)
save discovery authentication or authentication for given target.
- - (Object) storeModify(option_id, option_map)
- - (Object) TpgIdFromTpgItem(s)
- - (Object) TpgItemFromTpgId(i)
- - (Object) uiTarget
-
- (Object) validateAddTarget(key, event)
validate function checks if target/tpg are unique and not empty.
- - (Object) validateClient(key, event)
-
- (Object) validateGlobal(key, event)
validate functions checks the secret for incoming and outgoing cannot be same.
Instance Method Details
- (Object) AddClntDialog
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 611 def AddClntDialog Builtins.y2milestone("AddClntDialog") ret = {} dlg = VBox( MarginBox( 4, 1, VBox( Left(Label(_("Initiator name:"))), MinWidth(50, InputField(Id(:clnt), Opt(:hstretch), "", "")), VSpacing(0.5), Left(CheckBox(Id(:import), _("Import LUNs from TPG"), true)) ) ), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) UI.OpenDialog(dlg) sym = :nil while sym != :ok && sym != :cancel sym = Convert.to_symbol(UI.UserInput) Builtins.y2milestone("AddClntDialog sym:%1", sym) if sym == :ok txt = "" s = Convert.to_string(UI.QueryWidget(Id(:clnt), :Value)) txt = _("Initiator name must not be empty!") if Builtins.isempty(s) Builtins.y2milestone("Changed_lun: %1 new initiator name: %2", @changed_lun, s) # Don't check IscsiLioData.GetClntList(@curr_target, @curr_tpg) for existing # initiator name. It's allowed to have several LUNs accessable for same initiator. # TODO: verify whether it's necessary to check @changed_lun here? if @changed_lun.has_key?(s) txt = _("Initiator name already exists!") end # TODO: check initiator name for valid chars (depends on solution for fate #318406) if !Builtins.isempty(txt) sym = :again UI.SetFocus(Id(:clnt)) Popup.Error(txt) else Ops.set(ret, "clnt", s) Ops.set( ret, "import", Convert.to_boolean(UI.QueryWidget(Id(:import), :Value)) ) end end end UI.CloseDialog Builtins.y2milestone("AddClntDialog ret:%1", ret) deep_copy(ret) end |
- (Object) AuthTerm(discovery)
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 202 def AuthTerm(discovery) no_auth = Empty() if discovery no_auth = VBox( Left( CheckBox(Id(:auth_none), Opt(:notify), _("No Authentication"), true) ), VSpacing(1.5) ) end t = VBox( no_auth, Left( CheckBox( Id(:auth_in), Opt(:notify), _("Incoming Authentication"), false ) ), HBox( InputField(Id(:user_in), Opt(:hstretch), _("Username")), Password(Id(:pass_in), _("Password")) ), VSpacing(1.5), Left( CheckBox( Id(:auth_out), Opt(:notify), _("Outgoing Authentication"), false ) ), HBox( InputField(Id(:user_out), Opt(:hstretch), _("Username")), Password(Id(:pass_out), _("Password")) ) ) deep_copy(t) end |
- (Object) ChangeTpgItems(id, value, items)
385 386 387 388 389 390 391 392 393 394 395 396 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 385 def ChangeTpgItems(id, value, items) Builtins.y2milestone("ChangeTpgItems id:%1 value:%2", id, value) if value != nil it = Ops.get(items.value, id, Empty()) Ops.set(it, 2, TpgItemFromTpgId(value)) Ops.set(items.value, id, it) UI.ChangeWidget(Id(:lun), :Items, items.value) UI.ChangeWidget(Id(:lun), :CurrentItem, id) end nil end |
- (Object) CheckLun(l, other, silent)
243 244 245 246 247 248 249 250 251 252 253 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 243 def CheckLun(l, other, silent) other = deep_copy(other) s = Builtins.tostring(l) ret = Builtins.isempty(Builtins.filter(other) do |i| Ops.get_string(i, 1, "") == s end) Builtins.y2milestone("CheckLun other:%1", other) Builtins.y2milestone("CheckLun l:%1 ret:%2", l, ret) Popup.Error(_("Selected LUN is already in use!")) if !ret && !silent ret end |
- (Object) CheckName(n, other)
255 256 257 258 259 260 261 262 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 255 def CheckName(n, other) other = deep_copy(other) ret = Builtins.isempty(Builtins.filter(other) do |i| Ops.get_string(i, 2, "") == n end) Popup.Error(_("Selected Name is already in use!")) if !ret ret end |
- (Object) CheckPath(p, other)
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 264 def CheckPath(p, other) other = deep_copy(other) ret = Ops.get_boolean(IscsiLioData.CheckPath(p), 0, false) if !ret Popup.Error( _("Selected Path must be either block device or normal file!") ) end if ret && !Builtins.isempty(Builtins.filter(other) do |i| Ops.get_string(i, 3, "") == p end) Popup.Error(_("Selected Path is already in use!")) ret = false end ret end |
- (Object) ClntAuthDialog(clnt)
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 563 def ClntAuthDialog(clnt) Builtins.y2milestone("ClntAuthDialog clnt:%1", clnt) lmap = {} if Builtins.haskey(@changed_auth, clnt) lmap = Ops.get(@changed_auth, clnt, {}) else lmap = IscsiLioData.GetAuth(@curr_target, @curr_tpg, clnt) end Builtins.y2milestone("ClntAuthDialog auth already set") if !lmap.empty? auth_dialog = VBox( MarginBox(6, 2, AuthTerm(false)), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) UI.OpenDialog(auth_dialog) initGlobalValues(lmap) sym = :nil while sym != :ok && sym != :cancel ev = UI.WaitForEvent sym = Event.IsWidgetActivatedOrSelectionChanged(ev) sym = Event.IsWidgetValueChanged(ev) if sym == nil Builtins.y2milestone("ClntAuthDialog event:%1 sym:%2", ev, sym) handleAuth("", ev) if sym != nil if sym == :ok lmap = {} if !validateGlobal("", {}) sym = :again else _in = GetIncomingValues() out = GetOutgoingValues() Ops.set(lmap, "incoming", _in) Ops.set(lmap, "outgoing", out) if Builtins.size(_in) == 0 && Builtins.size(out) == 0 sym = :again Popup.Error(_("Need to enable at least one Authentification!")) end end elsif sym == :cancel lmap = nil end end UI.CloseDialog Ops.set(@changed_auth, clnt, lmap) if lmap != nil deep_copy(lmap) end |
- (Object) CopyClntDialog
Copy exisiting LUN, i.e. give additional initiator access to the LUN (which is allowed, makes sense e.g. with multipath)
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 670 def CopyClntDialog Builtins.y2milestone("CopyClntDialog") ret = "" dlg = VBox( MarginBox( 4, 1, VBox( Left(Label(_("New initiator name:"))), MinWidth(50, InputField(Id(:clnt), Opt(:hstretch), "", "")) ) ), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) UI.OpenDialog(dlg) sym = :nil while sym != :ok && sym != :cancel sym = Convert.to_symbol(UI.UserInput) Builtins.y2milestone("CopyClntDialog sym:%1", sym) if sym == :ok txt = "" s = Convert.to_string(UI.QueryWidget(Id(:clnt), :Value)) txt = _("Initiator name must not be empty!") if Builtins.isempty(s) if Builtins.haskey(@changed_lun, s) || Builtins.contains( IscsiLioData.GetClntList(@curr_target, @curr_tpg), s ) txt = _("Initiator name already exists!") end if !Builtins.isempty(txt) sym = :again UI.SetFocus(Id(:clnt)) Popup.Error(txt) else ret = s end end end UI.CloseDialog Builtins.y2milestone("CopyClntDialog ret:%1", ret) ret end |
- (Object) createClntLun(tgt, tpg, clnt, lun, tlun)
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1477 def createClntLun(tgt, tpg, clnt, lun, tlun) ret = IscsiLioData.DoCreateClntLun(tgt, tpg, clnt, lun, tlun) if !ret txt = Builtins.sformat( _("Problem adding LUN %4:%5 for initiator %3 in %1:%2"), tgt, tpg, clnt, lun, tlun ) Popup.Error(txt) end ret end |
- (Object) GetAuthString(am)
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1232 def GetAuthString(am) am = deep_copy(am) ret = "" ret = _("Incoming") if !Builtins.isempty(Ops.get_list(am, "incoming", [])) if !Builtins.isempty(Ops.get_list(am, "outgoing", [])) ret = Ops.add(ret, "/") if !Builtins.isempty(ret) ret = Ops.add(ret, _("Outgoing")) end ret = _("None") if Builtins.isempty(ret) ret end |
- (Object) GetById(it, id)
759 760 761 762 763 764 765 766 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 759 def GetById(it, id) it = deep_copy(it) id = deep_copy(id) Builtins.y2milestone("GetById id:%1", id) t = Ops.get(Builtins.filter(it) { |i| Ops.get(i, [0, 0], 99) == id }, 0, Empty( )) deep_copy(t) end |
- (Object) getDialogValues(user, pass)
dialog to add/modify user and password
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 718 def getDialogValues(user, pass) UI.OpenDialog( VBox( InputField(Id(:p_user), Opt(:hstretch), _("Username"), user), Password(Id(:p_pass), _("Password"), pass), HBox( PushButton(Id(:ok), _("OK")), PushButton(Id(:cancel), _("Cancel")) ) ) ) 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 !Builtins.isempty(user) && !Builtins.isempty(pass) return [user, pass] else return [] end end |
- (Object) GetIncomingValues
get values for incoming authentication
76 77 78 79 80 81 82 83 84 85 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 76 def GetIncomingValues values = [] if Convert.to_boolean(UI.QueryWidget(Id(:auth_in), :Value)) == true values = [ Convert.to_string(UI.QueryWidget(Id(:user_in), :Value)), Convert.to_string(UI.QueryWidget(Id(:pass_in), :Value)) ] end deep_copy(values) end |
- (Object) GetLunList(lmap)
1222 1223 1224 1225 1226 1227 1228 1229 1230 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1222 def GetLunList(lmap) lmap = deep_copy(lmap) s = "" Builtins.foreach(lmap) do |l1, l2| s = Ops.add(s, "-") if !Builtins.isempty(s) s = Ops.add(s, Builtins.sformat("%1:%2", l1, l2)) end s end |
- (Object) GetOutgoingValues
get values for outgoing authentication
88 89 90 91 92 93 94 95 96 97 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 88 def GetOutgoingValues values = [] if Convert.to_boolean(UI.QueryWidget(Id(:auth_out), :Value)) == true values = [ Convert.to_string(UI.QueryWidget(Id(:user_out), :Value)), Convert.to_string(UI.QueryWidget(Id(:pass_out), :Value)) ] end deep_copy(values) end |
- (Object) handleAuth(key, event)
**************** Target Auth ******************* handle authentication dialog
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 181 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 nil end |
- (Object) handleClient(key, event)
1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1281 def handleClient(key, event) event = deep_copy(event) if Ops.get_string(event, "EventReason", "") == "Activated" case Ops.get_symbol(event, "WidgetID") when :delete del = Convert.to_integer( UI.QueryWidget(Id(:clnt_table), :CurrentItem) ) if del != nil if Popup.ContinueCancel(_("Really delete the selected item?")) Builtins.y2milestone( "handleClient Delete Client %1 from table", del ) it = Convert.convert( UI.QueryWidget(:clnt_table, :Items), :from => "any", :to => "list <term>" ) clnt = Ops.get_string(GetById(it, del), 1, "") if !Builtins.contains(@del_clnt, clnt) @del_clnt = Builtins.add(@del_clnt, clnt) end Builtins.y2milestone("handleClient del_clnt:%1", @del_clnt) if Builtins.haskey(@changed_lun, clnt) @changed_lun = Builtins.remove(@changed_lun, clnt) end if Builtins.haskey(@changed_auth, clnt) @changed_auth = Builtins.remove(@changed_auth, clnt) end it = RemoveById(it, del) UI.ChangeWidget(Id(:clnt_table), :Items, it) else Builtins.y2milestone("handleClient: Delete canceled") end end when :edit_lun edit_pos = Builtins.tointeger( UI.QueryWidget(:clnt_table, :CurrentItem) ) items = Convert.convert( UI.QueryWidget(:clnt_table, :Items), :from => "any", :to => "list <term>" ) it = Ops.get(items, edit_pos, Empty()) s = Ops.get_string(it, 1, "") Builtins.y2milestone("handleClient pos:%1 clnt:%2", edit_pos, s) lm = LUNMapDialog(s) Builtins.y2milestone("handleClient lun_map:%1", lm) if lm != nil Ops.set(it, 2, GetLunList(lm)) Ops.set(items, edit_pos, it) UI.ChangeWidget(:clnt_table, :Items, items) UI.ChangeWidget(:clnt_table, :CurrentItem, edit_pos) end when :edit_auth edit_pos = Builtins.tointeger( UI.QueryWidget(:clnt_table, :CurrentItem) ) items = Convert.convert( UI.QueryWidget(:clnt_table, :Items), :from => "any", :to => "list <term>" ) it = Ops.get(items, edit_pos, Empty()) s = Ops.get_string(it, 1, "") Builtins.y2milestone("handleClient pos:%1 clnt:%2", edit_pos, s) auth = ClntAuthDialog(s) if auth != nil Builtins.y2milestone("handleClient auth is set") Ops.set(it, 3, GetAuthString(auth)) Ops.set(items, edit_pos, it) UI.ChangeWidget(:clnt_table, :Items, items) UI.ChangeWidget(:clnt_table, :CurrentItem, edit_pos) end when :add ret = AddClntDialog() if !Builtins.isempty(ret) && !Builtins.isempty(Ops.get_string(ret, "clnt", "")) items = Convert.convert( UI.QueryWidget(:clnt_table, :Items), :from => "any", :to => "list <term>" ) auth = _("Disabled") c = Ops.get_string(ret, "clnt", "") if IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) auth = GetAuthString({}) Ops.set(@changed_auth, c, {}) end lmap = {} if Ops.get_boolean(ret, "import", false) lmap = Builtins.mapmap( IscsiLioData.GetLun(@curr_target, @curr_tpg) ) { |l, m| { l => l } } end Builtins.y2milestone("handleClient clnt:%1 lmap:%2", c, lmap) Ops.set(@changed_lun, c, lmap) it = Item(Id(Builtins.size(items)), c, GetLunList(lmap), auth) items = Builtins.add(items, it) UI.ChangeWidget(:clnt_table, :Items, items) UI.ChangeWidget( :clnt_table, :CurrentItem, Ops.subtract(Builtins.size(items), 1) ) end when :copy edit_pos = Builtins.tointeger( UI.QueryWidget(:clnt_table, :CurrentItem) ) items = Convert.convert( UI.QueryWidget(:clnt_table, :Items), :from => "any", :to => "list <term>" ) it = Ops.get(items, edit_pos, Empty()) s = Ops.get_string(it, 1, "") Builtins.y2milestone("handleClient pos:%1 clnt:%2", edit_pos, s) c = CopyClntDialog() if !Builtins.isempty(c) auth = _("Disabled") if IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) m = {} if Builtins.haskey(@changed_auth, s) m = Ops.get(@changed_auth, s, {}) else m = IscsiLioData.GetAuth(@curr_target, @curr_tpg, s) end auth = GetAuthString(m) Ops.set(@changed_auth, c, m) end lmap = {} if Builtins.haskey(@changed_lun, s) lmap = Ops.get(@changed_lun, s, {}) else lmap = IscsiLioData.GetClntLun(@curr_target, @curr_tpg, s) end Ops.set(@changed_lun, c, lmap) Builtins.y2milestone("handleClient clnt:%1", c) it2 = Item(Id(Builtins.size(items)), c, GetLunList(lmap), auth) items = Builtins.add(items, it2) UI.ChangeWidget(:clnt_table, :Items, items) UI.ChangeWidget( :clnt_table, :CurrentItem, Ops.subtract(Builtins.size(items), 1) ) end end end enab = !Builtins.isempty( Convert.to_list(UI.QueryWidget(:clnt_table, :Items)) ) UI.ChangeWidget(:edit_lun, :Enabled, enab) UI.ChangeWidget(:delete, :Enabled, enab) UI.ChangeWidget(:copy, :Enabled, enab) enab = enab && IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) UI.ChangeWidget(:edit_auth, :Enabled, enab) nil end |
- (Object) handleModify(key, event)
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 929 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) it = Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) it = RemoveById(it, @del) UI.ChangeWidget(Id(:lun_table), :Items, it) 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) ) Builtins.y2milestone( "handleModify pos:%1 items:%2", @edit_pos, @items ) @ret = LUNDetailDialog(@edit_pos, @items) Builtins.y2milestone("handleModify ret:%1", @ret) if @ret != Empty() Ops.set(@items, @edit_pos, @ret) UI.ChangeWidget(:lun_table, :Items, @items) UI.ChangeWidget(:lun_table, :CurrentItem, @edit_pos) end when :add @items = Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) @ret = LUNDetailDialog(-1, @items) if @ret != Empty() @items = Builtins.add(@items, @ret) UI.ChangeWidget(:lun_table, :Items, @items) UI.ChangeWidget( :lun_table, :CurrentItem, Ops.subtract(Builtins.size(@items), 1) ) end end end enab = !Builtins.isempty( Convert.to_list(UI.QueryWidget(:lun_table, :Items)) ) UI.ChangeWidget(:edit, :Enabled, enab) UI.ChangeWidget(:delete, :Enabled, enab) nil end |
- (Object) handleTable(table, event)
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 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 809 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 # remove a item @del = UI.QueryWidget(Id(:server), :CurrentItem) Builtins.y2milestone("handleTable del:%1", @del) if @del != nil if Popup.ContinueCancel(_("Really delete the selected item?")) it = Convert.convert( UI.QueryWidget(Id(:server), :Items), :from => "any", :to => "list <term>" ) i = GetById(it, @del) Builtins.y2milestone("handleTable item:%1", i) if IscsiLioData.DelTarget( Ops.get_string(i, 1, ""), Builtins.tointeger(Ops.get_string(i, 2, "-1")) ) it = RemoveById(it, @del) UI.ChangeWidget(Id(:server), :Items, it) IscsiLioData.UpdateConfig end else Builtins.y2milestone("handleTable Delete canceled") end end when :edit # edit new item @edit = Builtins.tointeger( UI.QueryWidget(Id(:server), :CurrentItem) ) @t = Convert.to_term( UI.QueryWidget(Id(:server), term(:Item, @edit)) ) Builtins.y2milestone("handleTable num:%1 t:%2", @edit, @t) @curr_target = Ops.get_string(@t, 1, "") @curr_tpg = Builtins.tointeger(Ops.get_string(@t, 2, "")) Builtins.y2milestone( "handleTable tgt:%1 tpg:%2", @curr_target, @curr_tpg ) ret = :edit end end empt = Builtins.isempty(Convert.to_list(UI.QueryWidget(:server, :Items))) UI.ChangeWidget(:edit, :Enabled, !empt) UI.ChangeWidget(:delete, :Enabled, !empt) ret end |
- (Object) initAddTarget(key)
************** Add Target Dialog ****************** initialize function for create new target
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1104 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 !Builtins.isempty(domain) 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(:tpg), :ValidChars, String.CDigit) UI.ChangeWidget(Id(:tpg), :Value, "1") ip = Convert.convert( UI.QueryWidget(Id(:ipaddr), :Items), :from => "any", :to => "list <term>" ) Builtins.y2milestone("Items: %1", ip) s = Ops.get_string(ip, [0, 1], "") Builtins.y2milestone("initAddTarget ip:%1", s) UI.ChangeWidget(Id(:ipaddr), :Value, s) UI.ChangeWidget(Id(:port), :ValidChars, String.CDigit) UI.ChangeWidget(Id(:port), :Value, "3260") UI.ChangeWidget(Id(:auth), :Value, true) nil end |
- (Object) initClient(key)
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1244 def initClient(key) Builtins.y2milestone("initClient %1 %2", @curr_target, @curr_tpg) UI.ChangeWidget( Id(:target), :Value, Ops.get(Builtins.splitstring(@curr_target, ":"), 0, "") ) UI.ChangeWidget(Id(:target), :Enabled, false) UI.ChangeWidget( Id(:identifier), :Value, Ops.get(Builtins.splitstring(@curr_target, ":"), 1, "") ) UI.ChangeWidget(Id(:identifier), :Enabled, false) UI.ChangeWidget(Id(:tpg), :Value, Builtins.tostring(@curr_tpg)) UI.ChangeWidget(Id(:tpg), :Enabled, false) clnt = IscsiLioData.GetClntList(@curr_target, @curr_tpg) Builtins.y2milestone("initClient clnt:%1", clnt) inc_items = [] auth = _("Disabled") tgt_auth = IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) Builtins.foreach(clnt) do |s| if tgt_auth m = IscsiLioData.GetAuth(@curr_target, @curr_tpg, s) auth = GetAuthString(m) end luns = GetLunList(IscsiLioData.GetClntLun(@curr_target, @curr_tpg, s)) inc_items = Builtins.add( inc_items, Item(Id(Builtins.size(inc_items)), s, luns, auth) ) end UI.ChangeWidget(Id(:clnt_table), :Items, inc_items) nil end |
- (Object) initGlobal(key)
initialize discovery authentication or authentication for given target
127 128 129 130 131 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 127 def initGlobal(key) initGlobalValues(IscsiLioData.GetAuth("", 0, "")) nil end |
- (Object) initGlobalValues(auth)
**************** Global Dialog *********************
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 100 def initGlobalValues(auth) auth = deep_copy(auth) user = "" pass = "" # incoming authentication if !Builtins.isempty(Ops.get_list(auth, "incoming", [])) user = Ops.get_string(auth, ["incoming", 0], "") pass = Ops.get_string(auth, ["incoming", 1], "") end UI.ChangeWidget(Id(:user_in), :Value, user) UI.ChangeWidget(Id(:pass_in), :Value, pass) SetAuthIn(!Builtins.isempty(Ops.get_list(auth, "incoming", []))) # outgoing authentication user = "" pass = "" if !Builtins.isempty(Ops.get_list(auth, "outgoing", [])) user = Ops.get_string(auth, ["outgoing", 0], "") pass = Ops.get_string(auth, ["outgoing", 1], "") end UI.ChangeWidget(Id(:user_out), :Value, user) UI.ChangeWidget(Id(:pass_out), :Value, pass) SetAuthOut(!Builtins.isempty(Ops.get_list(auth, "outgoing", []))) nil end |
- (Object) initialize_iscsi_lio_server_widgets(include_target)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 34 def (include_target) textdomain "iscsi-lio-server" Yast.import "IscsiLioData" Yast.import "Label" Yast.import "Event" Yast.import "ContextMenu" Yast.import "IP" # **************** global funcions and variables ***** @curr_target = "" @curr_tpg = 1 @changed_lun = {} @changed_auth = {} @del_clnt = [] end |
- (Object) initModify(key)
init values for modifying target (read it from stored map)
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 898 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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 870 def initModify(key) inc_items = [] Builtins.y2milestone("initModify %1 %2", @curr_target, @curr_tpg) UI.ChangeWidget( Id(:target), :Value, Ops.get(Builtins.splitstring(@curr_target, ":"), 0, "") ) UI.ChangeWidget(Id(:target), :Enabled, false) UI.ChangeWidget( Id(:identifier), :Value, Ops.get(Builtins.splitstring(@curr_target, ":"), 1, "") ) UI.ChangeWidget(Id(:identifier), :Enabled, false) UI.ChangeWidget(Id(:tpg), :Value, Builtins.tostring(@curr_tpg)) UI.ChangeWidget(Id(:tpg), :Enabled, false) ipp = Ops.get( IscsiLioData.GetNetworkPortal(@curr_target, @curr_tpg), 0, "" ) Builtins.y2milestone("initModify ipp:%1", ipp) ip, port = IscsiLioData.GetIpAndPort(ipp) UI.ChangeWidget( Id(:ipaddr), :Value, ip || "" ) UI.ChangeWidget(Id(:ipaddr), :Enabled, true) UI.ChangeWidget( Id(:port), :Value, port || "" ) UI.ChangeWidget(Id(:port), :Enabled, true) UI.ChangeWidget( Id(:auth), :Value, IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) ) lun = IscsiLioData.GetLunList(@curr_target, @curr_tpg) Builtins.y2milestone("initModify lun:%1", lun) Builtins.foreach(lun) do |l| inc_items = Builtins.add( inc_items, Item( Id(Builtins.size(inc_items)), Ops.get_integer(l, 0, 99), Ops.get_string(l, 1, ""), Ops.get_string(l, 2, "") ) ) end UI.ChangeWidget(Id(:lun_table), :Items, inc_items) nil end |
- (Object) initTable(key)
initialize target dialog
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 772 def initTable(key) count = 0 inc_items = [] # create items from targets tgt = IscsiLioData.GetTargets cur = 0 tgt.each do |target| inc_items = Builtins.add( inc_items, Item( Id(count), target[0] || "", Builtins.tostring(target[1] || 0), target[2] ? _("Enabled") : _("Disabled") ) ) Builtins.y2milestone( "tgt:%1 tpg:%2 enabled:%3 ctgt:%4 ctpg:%5", target[0] || "", target[1] || 0, target[2] || false, @curr_target, @curr_tpg ) if @curr_target == (target[0] || "") && @curr_tpg == (target[1] || 1) cur = count end count = Ops.add(count, 1) end # put it into table UI.ChangeWidget(Id(:server), :Items, inc_items) UI.ChangeWidget(Id(:server), :CurrentItem, cur) if cur != 0 nil end |
- (Object) LUNDetailDialog(pos, items)
281 282 283 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 330 331 332 333 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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 281 def LUNDetailDialog(pos, items) items = deep_copy(items) Builtins.y2milestone("LUNDetailDialog pos:%1 items:%2", pos, items) other = Ops.greater_or_equal(pos, 0) ? Builtins.remove(items, pos) : items Builtins.y2milestone("LUNDetailDialog other:%1", other) previous = Ops.get(items, pos, Empty()) ret = Empty() lun_def = "99" if Ops.less_than(pos, 0) count = 0 while !CheckLun(count, other, true) count = Ops.add(count, 1) end lun_def = Builtins.tostring(count) end lun_dialog = VBox( Left( InputField( Id(:lun), Opt(:hstretch), _("LUN"), Ops.get_string(previous, 1, lun_def) ) ), VSpacing(1), HBox( InputField( Id(:path), Opt(:hstretch), _("Path:"), Ops.get_string(previous, 3, "") ), VBox(Label(""), PushButton(Id(:browse), _("Browse"))) ), InputField( Id(:name), Opt(:hstretch), "Name (autogenerated when empty):", Ops.get_string(previous, 2, "") ), VSpacing(1), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) UI.OpenDialog(lun_dialog) UI.ChangeWidget(Id(:lun), :ValidChars, "0123456789") sym = :nil while sym != :ok && sym != :cancel sym = Convert.to_symbol(UI.UserInput) if sym == :browse file = UI.AskForExistingFile("/", "", _("Select file or device")) if file != nil && CheckPath(file, other) UI.ChangeWidget(:path, :Value, file) end elsif sym == :path CheckPath(Convert.to_string(UI.QueryWidget(:path, :Value)), other) end if sym == :ok lun = Builtins.tointeger(UI.QueryWidget(:lun, :Value)) name = Convert.to_string(UI.QueryWidget(:name, :Value)) pth = Convert.to_string(UI.QueryWidget(:path, :Value)) Builtins.y2milestone( "LUNDetailDialog lun:%1 name:%2 path:%3", lun, name, pth ) if !CheckPath(pth, other) || !CheckLun(lun, other, false) || !CheckName(name, other) sym = :again end if sym == :ok if Builtins.isempty(name) used = Builtins.maplist(other) { |i| Ops.get_string(i, 2, "") } Builtins.y2milestone("LUNDetailDialog used:%1", used) name = IscsiLioData.CreateLunName(used, pth) end ret = Item( Id(Ops.greater_or_equal(pos, 0) ? pos : Builtins.size(other)), lun, name, pth ) Builtins.y2milestone("LUNDetailDialog ret:%1", ret) end end end UI.CloseDialog Builtins.y2milestone("LUNDetailDialog ret:%1", ret) deep_copy(ret) end |
- (Object) LUNMapDialog(clnt)
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 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 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 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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 398 def LUNMapDialog(clnt) Builtins.y2milestone("LUNMapDialog clnt:%1", clnt) lmap = {} Builtins.y2milestone("changed_lun: %1", @changed_lun) if Builtins.haskey(@changed_lun, clnt) lmap = Ops.get(@changed_lun, clnt, {}) else lmap = IscsiLioData.GetClntLun(@curr_target, @curr_tpg, clnt) end Builtins.y2milestone("LUNMapDialog map:%1", lmap) ll = Builtins.maplist(lmap) { |l, d| l } lt = Builtins.maplist(IscsiLioData.GetLun(@curr_target, @curr_tpg)) do |l, d| Item(Id(l), Builtins.tostring(l)) end lt = Builtins.add(lt, Item(Id(-1), "-")) mx = Ops.get(ll, Ops.subtract(Builtins.size(ll), 1), -1) i = 0 items = [] while Ops.less_or_equal(i, mx) items = Builtins.add( items, Item( Id(i), Builtins.tostring(i), Builtins.haskey(lmap, i) ? Builtins.tostring(Ops.get(lmap, i, 99)) : "-" ) ) i = Ops.add(i, 1) end Builtins.y2milestone("LUNMapDialog items:%1", items) lun_dialog = VBox( MinHeight( 10, Table( Id(:lun), Opt(:keepSorting, :immediate, :notify, :notifyContextMenu), Header(_("Initiator LUN"), _("Target LUN")), items ) ), Left( HBox( PushButton(Id(:add), _("Add")), PushButton(Id(:delete), _("Delete")), Label(_("Change:")), ComboBox(Id(:change), Opt(:notify), "", lt) ) ), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ) ) UI.OpenDialog(lun_dialog) if Builtins.size(items) == 0 UI.ChangeWidget(Id(:change), :Enabled, false) UI.ChangeWidget(Id(:delete), :Enabled, false) end UI.ChangeWidget( Id(:change), :Value, TpgIdFromTpgItem(Ops.get_string(items, [0, 2], "-")) ) sym = :nil while sym != :ok && sym != :cancel ev = UI.WaitForEvent sym = Event.IsWidgetActivatedOrSelectionChanged(ev) sym = Event.IsWidgetValueChanged(ev) if sym == nil sym = Event.IsWidgetContextMenuActivated(ev) if sym == nil Builtins.y2milestone("LUNMapDialog event:%1 sym:%2", ev, sym) if sym == :lun id = Convert.to_integer(UI.QueryWidget(:lun, :CurrentItem)) Builtins.y2milestone( "LUNMapDialog id:%1 item:%2", id, Ops.get(items, id) ) if Event.IsWidgetContextMenuActivated(ev) != nil UI.OpenContextMenu(term(:menu, lt)) value = Convert.to_integer(UI.UserInput) items_ref = arg_ref(items) ChangeTpgItems(id, value, items_ref) items = items_ref.value UI.ChangeWidget(Id(:change), :Value, value) else UI.ChangeWidget( Id(:change), :Value, TpgIdFromTpgItem(Ops.get_string(items, [id, 2], "-")) ) end elsif sym == :add n = Builtins.size(items) items = Builtins.add(items, Item(Id(n), Builtins.tostring(n), "-")) UI.ChangeWidget(Id(:lun), :Items, items) UI.ChangeWidget(Id(:lun), :CurrentItem, n) UI.ChangeWidget(Id(:change), :Value, -1) if Builtins.size(items) == 1 UI.ChangeWidget(Id(:change), :Enabled, true) UI.ChangeWidget(Id(:delete), :Enabled, true) end elsif sym == :delete id = Convert.to_integer(UI.QueryWidget(:lun, :CurrentItem)) if id != nil && Ops.less_than(id, Builtins.size(items)) items_ref = arg_ref(items) ChangeTpgItems(id, -1, items_ref) items = items_ref.value end elsif sym == :change id = Convert.to_integer(UI.QueryWidget(:lun, :CurrentItem)) value = Convert.to_integer(UI.QueryWidget(:change, :Value)) if id != nil && Ops.less_than(id, Builtins.size(items)) items_ref = arg_ref(items) ChangeTpgItems(id, value, items_ref) items = items_ref.value end elsif sym == :ok lmap = {} Builtins.foreach(items) do |it| s = Ops.get_string(it, 2, "-") i = nil i = Builtins.tointeger(Ops.get_string(it, 2, "")) if s != "-" if i != nil Ops.set(lmap, Builtins.tointeger(Ops.get_string(it, 1, "0")), i) end end Builtins.y2milestone("LUNMapDialog ret:%1", lmap) ok = true ll2 = Builtins.maplist(lmap) { |l, d| l } ld = Builtins.maplist(lmap) { |l, d| d } i = 0 while Ops.less_than(i, Builtins.size(ll2)) && ok ok = Ops.less_or_equal(Builtins.size(Builtins.filter(ld) do |j| j == Ops.get(ld, i, -1) end), 1) if !ok txt = Builtins.sformat( _("Target LUN %1 used more than once!"), Ops.get(ld, i, -1) ) j = Ops.add(i, 1) while Ops.get(ld, i, -1) != Ops.get(ld, j, -1) && Ops.less_than(j, Builtins.size(ll2)) j = Ops.add(j, 1) end if Ops.less_than(j, Builtins.size(items)) UI.ChangeWidget(Id(:lun), :CurrentItem, Ops.get(ll2, j, 0)) end Popup.Error(txt) end i = Ops.add(i, 1) end sym = :again if !ok elsif sym == :cancel lmap = nil end end UI.CloseDialog Ops.set(@changed_lun, clnt, lmap) if lmap != nil Builtins.y2milestone("LUNMapDialog ret:%1", lmap) deep_copy(lmap) end |
- (Object) RemoveById(it, id)
750 751 752 753 754 755 756 757 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 750 def RemoveById(it, id) it = deep_copy(it) id = deep_copy(id) Builtins.y2milestone("RemoveById id:%1 item:%2", id, Builtins.filter(it) do |i| Ops.get(i, [0, 0], 99) == id end) Builtins.filter(it) { |i| Ops.get(i, [0, 0], 99) != id } end |
- (Object) removeClntLun(tgt, tpg, clnt, lun)
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1462 def removeClntLun(tgt, tpg, clnt, lun) ret = IscsiLioData.DoRemoveClntLun(tgt, tpg, clnt, lun) if !ret txt = Builtins.sformat( _("Problem removing LUN %4 for initiator %3 in %1:%2"), tgt, tpg, clnt, lun ) Popup.Error(txt) end ret end |
- (Object) SetAuthIn(status)
set incoming authentication enabled/disabled status
50 51 52 53 54 55 56 57 58 59 60 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 50 def SetAuthIn(status) Builtins.y2milestone("Status of AuthIncoming %1", status) UI.ChangeWidget(Id(:user_in), :Enabled, status) UI.ChangeWidget(Id(:pass_in), :Enabled, status) UI.ChangeWidget(Id(:auth_in), :Value, status) if UI.WidgetExists(Id(:auth_none)) && status UI.ChangeWidget(Id(:auth_none), :Value, !status) end nil end |
- (Object) SetAuthOut(status)
set outgoing authentication enabled/disabled status
63 64 65 66 67 68 69 70 71 72 73 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 63 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) if UI.WidgetExists(Id(:auth_none)) && status UI.ChangeWidget(Id(:auth_none), :Value, !status) end nil end |
- (Object) storeAddTarget(option_id, option_map)
1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1181 def storeAddTarget(option_id, option_map) option_map = deep_copy(option_map) target = uiTarget Builtins.y2milestone("storeAddTarget %1", target) @curr_target = target.fetch(0,"") + (target.fetch(1,"") == "" ? "":":") + target.fetch(1,"") @curr_tpg = Ops.get_integer(target, 2, -1) storeModify(option_id, option_map) nil end |
- (Object) storeClient(option_id, option_map)
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1493 def storeClient(option_id, option_map) option_map = deep_copy(option_map) chg = false cl = IscsiLioData.GetClntList(@curr_target, @curr_tpg) Builtins.foreach(@del_clnt) do |c| if Builtins.contains(cl, c) chg = true if !IscsiLioData.DoRemoveClnt(@curr_target, @curr_tpg, c) txt = Builtins.sformat( _("Problem removing initiator %3 from %1:%2"), @curr_target, @curr_tpg, c ) Popup.Error(txt) end end end @del_clnt = [] new_clnt = Builtins.maplist(@changed_auth) { |c, m| c } new_clnt = Convert.convert( Builtins.union(new_clnt, Builtins.maplist(@changed_lun) { |c, m| c }), :from => "list", :to => "list <string>" ) new_clnt = Builtins.filter(new_clnt) { |c| !Builtins.contains(cl, c) } if !Builtins.isempty(new_clnt) Builtins.y2milestone("storeClient new clnt:%1", new_clnt) end Builtins.foreach(new_clnt) do |c| chg = true if !IscsiLioData.DoCreateClnt(@curr_target, @curr_tpg, c) txt = Builtins.sformat( _("Problem creating initiator %3 for %1:%2"), @curr_target, @curr_tpg, c ) Popup.Error(txt) else cl = Builtins.add(cl, c) end end Builtins.foreach(@changed_auth) do |c, m| if Builtins.contains(cl, c) ca = IscsiLioData.GetAuth(@curr_target, @curr_tpg, c) if Builtins.isempty(Ops.get_list(m, "incoming", [])) != Builtins.isempty(Ops.get_list(ca, "incoming", [])) || Builtins.isempty(Ops.get_list(m, "outgoing", [])) != Builtins.isempty(Ops.get_list(ca, "outgoing", [])) || Ops.get_string(m, ["incoming", 0], "") != Ops.get_string(ca, ["incoming", 0], "") || Ops.get_string(m, ["incoming", 1], "") != Ops.get_string(ca, ["incoming", 1], "") || Ops.get_string(m, ["outgoing", 0], "") != Ops.get_string(ca, ["outgoing", 0], "") || Ops.get_string(m, ["outgoing", 1], "") != Ops.get_string(ca, ["outgoing", 1], "") Builtins.y2milestone("storeClient set auth for client:%1", c) chg = true if !IscsiLioData.SetAuth( @curr_target, @curr_tpg, c, Ops.get_list(m, "incoming", []), Ops.get_list(m, "outgoing", []) ) txt = Builtins.sformat( _("Problem changing auth for initiator %3 in %1:%2"), @curr_target, @curr_tpg, c ) Popup.Error(txt) end end end end @changed_auth = {} Builtins.foreach(@changed_lun) do |c, m| if Builtins.contains(cl, c) cl2 = IscsiLioData.GetClntLun(@curr_target, @curr_tpg, c) Builtins.foreach(cl2) do |l, ol| if !Builtins.haskey(m, l) && removeClntLun(@curr_target, @curr_tpg, c, l) chg = true end end Builtins.foreach(m) do |l, ol| if !Builtins.haskey(cl2, l) chg = true if createClntLun(@curr_target, @curr_tpg, c, l, ol) elsif Ops.get(cl2, l, -1) != ol chg = true if removeClntLun(@curr_target, @curr_tpg, c, l) chg = true if createClntLun(@curr_target, @curr_tpg, c, l, ol) end end end end @changed_lun = {} Builtins.y2milestone("storeClient chg:%1", chg) IscsiLioData.UpdateConfig if chg nil end |
- (Object) storeGlobal(option_id, option_map)
save discovery authentication or authentication for given target
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 134 def storeGlobal(option_id, option_map) option_map = deep_copy(option_map) Builtins.y2milestone("storeGlobal id:%1 map:%2", option_id, option_map) ret = false ret = IscsiLioData.SetAuth( "", 0, "", GetIncomingValues(), GetOutgoingValues() ) Popup.Error(_("Problem changing authentication")) if !ret IscsiLioData.UpdateConfig nil end |
- (Object) storeModify(option_id, option_map)
997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 997 def storeModify(option_id, option_map) option_map = deep_copy(option_map) chg = false if !IscsiLioData.HasTarget(@curr_target, @curr_tpg) chg = true if !IscsiLioData.AddTarget(@curr_target, @curr_tpg) txt = Builtins.sformat( _("Problem creating target %1 with tpg %2"), @curr_target, @curr_tpg ) Popup.Error(txt) end end ipp = Ops.get( IscsiLioData.GetNetworkPortal(@curr_target, @curr_tpg), 0, "" ) ip = Convert.to_string(UI.QueryWidget(:ipaddr, :Value)) port = Builtins.tointeger(UI.QueryWidget(:port, :Value)) add_all = Convert.to_boolean(UI.QueryWidget(:add_ip, :Value)) Builtins.y2milestone("storeModify ip:%1 port:%2 ipp:%3", ip, port, ipp) np = IscsiLioData.FormatIpPort(ip, port) if (!ip.empty? && np != ipp) || add_all chg = true if !IscsiLioData.SetNetworkPortal(@curr_target, @curr_tpg, np, port, add_all) txt = Builtins.sformat(_("Problem setting network portal to %1"), np) Popup.Error(txt) end end it = Convert.convert( UI.QueryWidget(:lun_table, :Items), :from => "any", :to => "list <term>" ) nll = Builtins.maplist(it) do |t| Builtins.tointeger(Ops.get_string(t, 1, "-1")) end oll = Builtins.maplist(IscsiLioData.GetLunList(@curr_target, @curr_tpg)) do |lli| Ops.get_integer(lli, 0, -1) end Builtins.y2milestone("storeModify oll:%1", oll) Builtins.y2milestone("storeModify nll:%1", nll) Builtins.foreach(oll) do |l| if !Builtins.contains(nll, l) chg = true if !IscsiLioData.DoRemoveLun(@curr_target, @curr_tpg, l) txt = Builtins.sformat(_("Problem removing lun %1"), l) Popup.Error(txt) end end end Builtins.foreach(it) do |row| lun = { "lun" => Builtins.tointeger(Ops.get_string(row, 1, "-1")), "nm" => Ops.get_string(row, 2, ""), "path" => Ops.get_string(row, 3, "") } if ( lun_ref = arg_ref(lun); _NeedUpdateLun_result = IscsiLioData.NeedUpdateLun( @curr_target, @curr_tpg, lun_ref ); lun = lun_ref.value; _NeedUpdateLun_result ) Builtins.y2milestone("storeModify lun:%1", lun) chg = true if !IscsiLioData.DoUpdateLun(@curr_target, @curr_tpg, lun) txt = Builtins.sformat( _("Problem setting lun %1 (name:%2) to path %3"), Ops.get_integer(lun, "lun", -1), Ops.get_string(lun, "nm", ""), Ops.get_string(lun, "path", "") ) Popup.Error(txt) end end end val = Convert.to_boolean(UI.QueryWidget(:auth, :Value)) if val != IscsiLioData.GetTpgAuth(@curr_target, @curr_tpg) chg = true if !IscsiLioData.SetTpgAuth(@curr_target, @curr_tpg, val) txt = Builtins.sformat( _("Problem setting auth on %1:%2 to %3"), @curr_target, @curr_tpg, val ) Popup.Error(txt) end end if chg IscsiLioData.UpdateConfig initModify("") end nil end |
- (Object) TpgIdFromTpgItem(s)
375 376 377 378 379 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 375 def TpgIdFromTpgItem(s) val = s != "-" ? Builtins.tointeger(s) : -1 val = -1 if val == nil val end |
- (Object) TpgItemFromTpgId(i)
381 382 383 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 381 def TpgItemFromTpgId(i) Ops.greater_or_equal(i, 0) ? Builtins.tostring(i) : "-" end |
- (Object) uiTarget
1171 1172 1173 1174 1175 1176 1177 1178 1179 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1171 def uiTarget tpg = nil tpg = Builtins.tointeger(UI.QueryWidget(Id(:tpg), :Value)) [ Convert.to_string(UI.QueryWidget(Id(:target), :Value)), Convert.to_string(UI.QueryWidget(Id(:identifier), :Value)), tpg ] end |
- (Object) validateAddTarget(key, event)
validate function checks if target/tpg are unique and not empty
1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1194 def validateAddTarget(key, event) event = deep_copy(event) target = uiTarget Builtins.y2milestone("validateAddTarget %1", target) ret = true if Builtins.isempty(Ops.get_string(target, 0, "")) Popup.Error(_("The target cannot be empty.")) UI.SetFocus(Id(:target)) ret = false elsif Ops.get(target, 2) == nil Popup.Error(_("The target portal group cannot be empty.")) UI.SetFocus(Id(:tpg)) ret = false elsif IscsiLioData.HasTarget( Builtins.sformat( "%1:%2", Ops.get_string(target, 0, ""), Ops.get_string(target, 1, "") ), Ops.get_integer(target, 2, -1) ) Popup.Error(_("The target already exists.")) UI.SetFocus(Id(:target)) ret = false end ret end |
- (Object) validateClient(key, event)
1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 1445 def validateClient(key, event) event = deep_copy(event) clients = UI.QueryWidget(:clnt_table, :Items) continue = true if !clients.nil? && clients.empty? continue = Popup.YesNoHeadline( Label.WarningMsg, _("There isn't any initiator specified.\n" + "To allow an initiator login to the target, please\n" + "use the 'Add' button and enter the name\n" + "(see /etc/iscsi/initiatorname.iscsi on initiator).\n" + "Really want to continue without initiator access?" )) end continue end |
- (Object) validateGlobal(key, event)
validate functions checks the secret for incoming and outgoing cannot be same
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 |
# File '../../src/include/iscsi-lio-server/widgets.rb', line 152 def validateGlobal(key, event) event = deep_copy(event) Builtins.y2milestone("validateGlobal key:%1 ev:%2", key, event) ret = true _in = GetIncomingValues() if Ops.greater_than(Builtins.size(_in), 0) && (Builtins.size(Ops.get(_in, 0, "")) == 0 || Builtins.size(Ops.get(_in, 1, "")) == 0) user_fail = Builtins.size(Ops.get(_in, 0, "")) == 0 txt = user_fail ? _("Invalid Username") : _("Invalid Password.") UI.SetFocus(Id(user_fail ? :user_in : :pass_in)) Popup.Error(txt) ret = false end out = GetOutgoingValues() if Ops.greater_than(Builtins.size(out), 0) && (Builtins.size(Ops.get(out, 0, "")) == 0 || Builtins.size(Ops.get(out, 1, "")) == 0) user_fail = Builtins.size(Ops.get(out, 0, "")) == 0 txt = user_fail ? _("Invalid Username") : _("Invalid Password.") UI.SetFocus(Id(user_fail ? :user_out : :pass_out)) Popup.Error(txt) ret = false end ret end |