Module: Yast::DhcpServerDialogs2Include
- Defined in:
- ../../src/include/dhcp-server/dialogs2.rb
Instance Method Summary (collapse)
- - (Object) CardSelectionHandle(key, event)
- - (Object) CardSelectionInit(key)
- - (Object) CardSelectionStore(key, event)
- - (Object) CardSelectionValidate(key, event)
- - (Object) CheckHostId(name)
- - (Object) CheckMacAddrFormat
- - (Object) CheckMacAddrUnique(original)
-
- (Yast::Term) Common_CardSelectionDialog
Common Config Dialog - Card Selection.
-
- (Yast::Term) Common_DynamicDHCPDialog
Common Config Dialog - Dynamic DHCP.
-
- (Yast::Term) Common_GlobalSettingsDialog
Common Config Dialog - Global Settings.
-
- (Yast::Term) Common_HostManagementDialog
Common Config Dialog - Host Management.
-
- (Symbol) CommonConfigDialog
Common Config Dialog.
- - (Object) CurrentDomainName
- - (Object) DynamicDHCPHandle(key, event)
- - (Object) DynamicDHCPInit(key)
- - (Object) DynamicDHCPStore(key, event)
- - (Object) DynamicDHCPValidate(key, event)
- - (Object) DynamicDHCPValidChars
- - (Object) ExpertSettingsTabInit(tab)
- - (Object) FirstRunDialog(current_tab, step_number)
- - (Object) GetStartService
- - (Object) GlobalSettingsHandle(key, event)
- - (Object) GlobalSettingsInit(key)
- - (Object) GlobalSettingsStore(key, event)
- - (Object) GlobalSettingsValidate(key, event)
- - (Object) GlobalSettingsValidChars
- - (Object) HostManagementHandle(key, event_descr)
- - (Object) HostManagementInit(key)
- - (Object) HostManagementStore(key, event)
- - (Object) HostManagementValidChars
- - (Object) initialize_dhcp_server_dialogs2(include_target)
- - (Object) OtherOptionsInit(key)
- - (Object) OtherOptionsStore(key, event)
- - (Object) OtherOptionsValidate(key, event)
- - (Object) PrepareDirectives
- - (Object) RedrawInterfacesTable
- - (Object) SaveAndRestart
- - (Object) seconds2time(seconds)
- - (Object) SelectItem(id)
- - (Object) SetInterfacesTableButtons
- - (Object) SetStartService(start)
- - (Object) time2seconds(count, unit)
- - (Object) TimeComboLabelLength
Instance Method Details
- (Object) CardSelectionHandle(key, event)
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 554 def CardSelectionHandle(key, event) event = deep_copy(event) item_id = Convert.to_string( UI.QueryWidget(Id("nic_selection"), :CurrentItem) ) SetInterfacesTableButtons() @current_item_iface = item_id if Ops.get(event, "ID") == "add" Ops.set(@ifaces, [item_id, "active"], true) elsif Ops.get(event, "ID") == "remove" Ops.set(@ifaces, [item_id, "active"], false) end RedrawInterfacesTable() nil end |
- (Object) CardSelectionInit(key)
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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 515 def CardSelectionInit(key) Wizard.DisableBackButton Builtins.foreach(NetworkInterfaces.List("")) do |iface| if iface != "" && !Builtins.issubstring(iface, "lo") && !Builtins.issubstring(iface, "sit") device_name = NetworkInterfaces.GetValue(iface, "NAME") if Ops.greater_than(Builtins.size(device_name), 40) device_name = Ops.add(Builtins.substring(device_name, 0, 37), "...") end Ops.set( @ifaces, iface, { "device" => device_name, "ipaddr" => NetworkInterfaces.GetValue(iface, "BOOTPROTO") == "dhcp" ? # TRANSLATORS: Table items; Informs that the IP is a DHCP Address _("DHCP address") : NetworkInterfaces.GetValue(iface, "IPADDR"), "active" => false } ) end end dhcp_ifaces = DhcpServer.GetAllowedInterfaces Builtins.foreach(@ifaces) do |iface, settings| if Builtins.contains(dhcp_ifaces, iface) Ops.set(@ifaces, [iface, "active"], true) end end RedrawInterfacesTable() nil end |
- (Object) CardSelectionStore(key, event)
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 575 def CardSelectionStore(key, event) event = deep_copy(event) # FIXME: subnet handling allowed_interfaces = [] Builtins.foreach(@ifaces) do |iface, settings| if Ops.get_boolean(@ifaces, [iface, "active"], false) == true allowed_interfaces = Builtins.add(allowed_interfaces, iface) end end DhcpServer.SetAllowedInterfaces(allowed_interfaces) DhcpServer.SetModified nil end |
- (Object) CardSelectionValidate(key, event)
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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 591 def CardSelectionValidate(key, event) event = deep_copy(event) return true if Ops.get(event, "ID") == :abort allowed_interfaces = [] configured_interfaces = [] Builtins.foreach(@ifaces) do |iface, settings| if Ops.get_boolean(@ifaces, [iface, "active"], false) == true allowed_interfaces = Builtins.add(allowed_interfaces, iface) if DhcpServer.GetInterfaceInformation(iface) != {} configured_interfaces = Builtins.add(configured_interfaces, iface) end raise Break end end if Ops.less_or_equal(Builtins.size(allowed_interfaces), 0) # TRANSLATORS: popup error, DHCP Server needs to run on one or more interfaces, # currently no one is selected Report.Error(_("At least one network interface must be selected.")) return false end if Ops.less_or_equal(Builtins.size(configured_interfaces), 0) # TRANSLATORS: popup error, DHCP Server requires selected interface to have # at least minimal configuration return Popup.ContinueCancel( _( "The selected network interface is not configured (no assigned IP address \n" + "and netmask). Using it in the DHCP server configuration may not work.\n" + "Really use this interface?\n" ) ) end true end |
- (Object) CheckHostId(name)
1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1938 def CheckHostId(name) if Builtins.size(name) == 0 UI.SetFocus(Id("hostname")) # error popup Popup.Error(_("The hostname cannot be empty.")) return false elsif !Hostname.Check(name) UI.SetFocus(Id("hostname")) Popup.Error(Hostname.ValidFQ) return false elsif Builtins.haskey(@hosts, name) UI.SetFocus(Id("hostname")) # error popup, %1 is host name Popup.Error( Builtins.sformat(_("A host named %1 already exists."), name) ) return false end true end |
- (Object) CheckMacAddrFormat
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1872 def CheckMacAddrFormat hosthwaddress = Convert.to_string( UI.QueryWidget(Id("hosthwaddress"), :Value) ) addr_type = Convert.to_string( UI.QueryWidget(Id("network_type"), :CurrentButton) ) if addr_type == "ethernet" || addr_type == "token-ring" if !Address.CheckMAC(hosthwaddress) UI.SetFocus(Id("hosthwaddress")) Report.Error( Ops.add( # error popup _("The hardware address is invalid.\n"), Address.ValidMAC ) ) return false end end true end |
- (Object) CheckMacAddrUnique(original)
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1896 def CheckMacAddrUnique(original) existing = DhcpServer.GetChildrenOfEntry("subnet", @hosts_parent_id) addresses = Builtins.maplist(existing) do |h| if Ops.get(h, "id", "") != original directives = DhcpServer.GetEntryDirectives( Ops.get(h, "type", ""), Ops.get(h, "id", "") ) addr = nil Builtins.find(directives) do |d| if Ops.get(d, "key", "") == "hardware" addr = Ops.get(d, "value", "") next true end false end next addr else next nil end end addresses = Builtins.filter(addresses) { |a| a != nil } address_unique = true Builtins.find(PrepareDirectives()) do |d| if Ops.get(d, "key", "") == "hardware" if Builtins.contains(addresses, Ops.get(d, "value", "")) address_unique = false end next true end false end if !address_unique UI.SetFocus(Id("hosthwaddress")) # error popup Popup.Error(_("The hardware address must be unique.")) return false end true end |
- (Yast::Term) Common_CardSelectionDialog
Common Config Dialog - Card Selection
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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 439 def Common_CardSelectionDialog dialog = VBox( VBox( # Table - listing available network cards Left(Label(_("Network Cards for DHCP Server"))), Table( Id("nic_selection"), Opt(:notify, :immediate), Header( # TRANSLATORS: table header item _("Selected"), # TRANSLATORS: table header item _("Interface Name"), # TRANSLATORS: table header item _("Device Name"), # TRANSLATORS: table header item _("IP") ), [] ) ), HBox( # TRANSLATORS: a push-button PushButton(Id("add"), _("&Select")), # TRANSLATORS: a push-button PushButton(Id("remove"), _("&Deselect")) ), VStretch() ) deep_copy(dialog) end |
- (Yast::Term) Common_DynamicDHCPDialog
Common Config Dialog - Dynamic DHCP
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 1101 1102 1103 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 1170 1171 1172 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1064 def Common_DynamicDHCPDialog dialog = VBox( # frame Frame( _("Subnet Information"), VBox( HBox( HWeight( 2, # TRANSLATORS: informative text entry (filled up, disabled) TextEntry(Id("current_network"), _("Current &Network")) ), HWeight( 2, # TRANSLATORS: informative text entry (filled up, disabled) TextEntry(Id("current_netmask"), _("Current Net&mask")) ), HWeight( 1, # TRANSLATORS: informative text entry (filled up, disabled) TextEntry(Id("current_bits"), _("Netmask Bi&ts")) ) ), HBox( HWeight( 2, # text entry TextEntry(Id("from_ip_min"), _("Min&imum IP Address")) ), HWeight( 2, # text entry TextEntry(Id("to_ip_max"), _("Ma&ximum IP Address")) ), HWeight(1, HStretch()) ) ) ), VSpacing(1), Frame( _("IP Address Range"), VBox( HBox( HWeight( 2, # text entry TextEntry(Id("from_ip"), _("&First IP Address")) ), HWeight( 2, # text entry TextEntry(Id("to_ip"), _("&Last IP Address")) ), HWeight(1, HStretch()) ), Left(CheckBox(Id("dyn_bootp"), _("Allow Dynamic &BOOTP"))) ) ), VSpacing(1), Frame( # frame label _("Lease Time"), HBox( Opt(:hstretch), HWeight( # Textentry label - lease time for IPs in the range 3, TextEntry(Id("defaultleasetime"), _("&Default")) ), HWeight( 2, MinWidth( TimeComboLabelLength(), # Combobox - type of units for lease time ComboBox( Id("defaultleasetimeunits"), _("&Units"), @time_combo_items ) ) ), HSpacing(1), HWeight( # TextEntryLabel - max. time for leasing of IPs from the range 3, TextEntry(Id("maxleasetime"), _("&Maximum")) ), HWeight( 2, MinWidth( TimeComboLabelLength(), # Combobox - type of units for max lease time HSquash( ComboBox( Id("maxleasetimeunits"), _("Uni&ts"), @time_combo_items ) ) ) ) ) ), VStretch(), ReplacePoint(Id(:dns_advanced), Empty()) ) deep_copy(dialog) end |
- (Yast::Term) Common_GlobalSettingsDialog
Common Config Dialog - Global Settings
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 629 def Common_GlobalSettingsDialog ldap = VBox( # configuration will be saved in ldap? HBox( Left(CheckBox(Id("ldap"), Opt(:notify), _("&LDAP Support"), true)), HSpacing(2), # FATE #227, comments #5 and #17 Left( HSquash( TextEntry( Id("ldap-dhcp-server-cn"), _("DHCP Server &Name (optional)") ) ) ) ), VSpacing(2) ) dialog = VBox( ldap, HBox( VBox( # Textentry with name of the domain Left(TextEntry(Id("domainname"), _("&Domain Name"))), # Textentry with IP address of primary name server Left(TextEntry(Id("primarydnsip"), _("&Primary Name Server IP"))), # Textentry with IP address of secondary name server Left( TextEntry(Id("secondarydnsip"), _("&Secondary Name Server IP")) ), # Textentry with IP address of default router Left(TextEntry(Id("defaultgw"), _("Default &Gateway (Router) "))) ), HSpacing(2), VBox( # Textentry with IP address of time server Left(TextEntry(Id("timeserver"), _("NTP &Time Server"))), # Textentry with IP address of print server Left(TextEntry(Id("printserver"), _("&Print Server"))), # Textentry with IP address of WINS (Windows Internet Naming Service) server Left(TextEntry(Id("winsserver"), _("&WINS Server"))), Left( HBox( # Textentry with default lease time of IP address from dhcp server HSquash( TextEntry(Id("defaultleasetime"), _("Default &Lease Time")) ), HSpacing(0.1), MinWidth( TimeComboLabelLength(), # Units for defaultleasetime HSquash( ComboBox( Id("defaultleasetimeunits"), _("&Units"), @time_combo_items ) ) ) ) ) ) ), VStretch() ) deep_copy(dialog) end |
- (Yast::Term) Common_HostManagementDialog
Common Config Dialog - Host Management
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1639 def Common_HostManagementDialog dialog = VBox( VBox( # Label of the registered hosts table Left(Label(_("Registered Host"))), Table( Id("registered_hosts_table"), Opt(:notify, :immediate, :vstretch), Header( # Table header item - Name of the host _("Name"), # Table header item - IP of the host _("IP"), # MAC address of the host _("Hardware Address"), # Network type of the host _("Type") ) ) ), # Frame label - configuration of particular host VSquash( Frame( _("List Setup"), VBox( Top( HBox( Top( VBox( HBox( # Textentry label - name of the host Left(TextEntry(Id("hostname"), _("&Name"))), # noneditable textentry Left(TextEntry(Id("domain"), Opt(:disabled), " ")) ), # Textentry label - IP address of the host Left(TextEntry(Id("hostip"), _("&IP Address"))) ) ), HSpacing(2), Top( VBox( # Textentry label - hardware (mac) address of the host Left( TextEntry(Id("hosthwaddress"), _("&Hardware Address")) ), # Radiobutton label - network type of the host RadioButtonGroup( Id("network_type"), HBox( Left( RadioButton(Id("ethernet"), _("&Ethernet"), true) ), Left(RadioButton(Id("token-ring"), _("&Token Ring"))) ) ) ) ) ) ), VSpacing(1), Top( Left( HBox( # Pushbutton label - add host into list Left(PushButton(Id("addhost"), Label.AddButton)), HSpacing(1), # Pushbutton label - change host in list Left(PushButton(Id("edithost"), _("C&hange in List"))), HSpacing(1), # Pushbutton label - delete host from list Left(PushButton(Id("deletehost"), _("Dele&te from List"))) ) ) ) ) ) ) ) deep_copy(dialog) end |
- (Symbol) CommonConfigDialog
Common Config Dialog
2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2206 def CommonConfigDialog ids_order = [ "start_up", "card_selection", "global_settings", "dynamic_dhcp", "host_management", "expert_settings" ] DialogTree.ShowAndRun( { "ids_order" => ids_order, "initial_screen" => "start_up", "screens" => @tabs, "widget_descr" => @widgets, "back_button" => "", "abort_button" => Label.CancelButton, "next_button" => Label.OKButton, "functions" => @functions } ) end |
- (Object) CurrentDomainName
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 714 def CurrentDomainName current_domain_name = "" Builtins.foreach(DhcpServer.GetEntryOptions("", "")) do |opt| if Ops.get(opt, "key") == "domain-name" current_domain_name = Ops.get(opt, "value", "") if Builtins.regexpmatch(current_domain_name, "^[ \t]*\".*\"[ \t]*$") current_domain_name = Builtins.regexpsub( current_domain_name, "^[ \t]*\"(.*)\"[ \t]*$", "\\1" ) end raise Break end end current_domain_name end |
- (Object) DynamicDHCPHandle(key, event)
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 1444 1445 1446 1447 1448 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1400 def DynamicDHCPHandle(key, event) event = deep_copy(event) return nil if key != "dynamic_dhcp" # Only these IDs are handled if Ops.get(event, "ID") != :dns_advanced_edit_current && Ops.get(event, "ID") != :dns_advanced_from_scratch && Ops.get(event, "ID") != :dns_advanced_zone_info return nil end # Show DNS Zone Information if Ops.get(event, "ID") == :dns_advanced_zone_info Report.Message( Builtins.sformat( _( "DNS zone %1 is not a master zone.\nTherefore, you cannot change it here.\n" ), Ops.get(@current_settings, "domain", "") ) ) # Run the DNS Wizard - Zone from Scratch elsif Ops.get(event, "ID") == :dns_advanced_from_scratch if !DynamicDHCPValidate(nil, nil) Builtins.y2milestone( "Dynamic DHCP Validation failed, Not managing DNS Server" ) return nil end Builtins.y2milestone("Running DNS wizard -- Creating zone from scratch") RunNewDNSServerWizard(@current_dynamic_dhcp) # Edit the current DNS Zone - for experts elsif Ops.get(event, "ID") == :dns_advanced_edit_current if !DynamicDHCPValidate(nil, nil) Builtins.y2milestone( "Dynamic DHCP Validation failed, Not managing DNS Server" ) return nil end Builtins.y2milestone("Managing DNS Server") ManageDNSServer(@current_dynamic_dhcp) end nil end |
- (Object) DynamicDHCPInit(key)
1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 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 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 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 1280 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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1184 def DynamicDHCPInit(key) # find out the our subnet identification ifaces_allowed = DhcpServer.GetAllowedInterfaces if Ops.greater_than(Builtins.size(ifaces_allowed), 1) Builtins.y2warning( "More than one interface allowed, using the first one only." ) end if Builtins.size(ifaces_allowed) == 0 Builtins.y2error("No interfaces set") return end interface = Ops.get(ifaces_allowed, 0) m = DhcpServer.GetInterfaceInformation(interface) id = Ops.add( Ops.add(Ops.get_string(m, "network", ""), " netmask "), Ops.get_string(m, "netmask", "") ) zone_name = CurrentDomainName() @current_dynamic_dhcp = { "network" => Ops.get_string(m, "network", ""), "netmask" => Ops.get_string(m, "netmask", ""), "domain" => zone_name } netmask_bits = Netmask.ToBits( Ops.get_string(m, "netmask", "255.255.255.255") ) Ops.set( @current_dynamic_dhcp, "netmask_bits", Builtins.tostring(netmask_bits) ) UI.ChangeWidget( Id("current_network"), :Value, Ops.get_string(m, "network", "") ) UI.ChangeWidget(Id("current_network"), :Enabled, false) UI.ChangeWidget( Id("current_netmask"), :Value, Ops.get_string(m, "netmask", "") ) UI.ChangeWidget(Id("current_netmask"), :Enabled, false) UI.ChangeWidget( Id("current_bits"), :Value, Builtins.tostring(netmask_bits) ) UI.ChangeWidget(Id("current_bits"), :Enabled, false) # Computing minimal and maximal IPs current_network = IP.ComputeNetwork( Ops.get_string(m, "network", ""), Ops.get_string(m, "netmask", "255.255.255.255") ) network_binary = IP.IPv4ToBits(current_network) Ops.set(@current_dynamic_dhcp, "current_network", current_network) Ops.set(@current_dynamic_dhcp, "network_binary", network_binary) # generating reverse zone if IP.Check(current_network) # 10.20.60.2 / 255.255.255.0 -> 60.20.10.in-addr.arpa # 135.14.80.2 / 255.255.240.0 -> 14.135.in-addr.arpa # 10.20.60.2 / 255.128.0.0 -> 10.in-addr.arpa reverse_zone = "" # only 255's are valid for a reverse zone network_bytes = Ops.divide(netmask_bits, 8) network_split = Builtins.splitstring(current_network, ".") while Ops.greater_than(network_bytes, 0) network_bytes = Ops.subtract(network_bytes, 1) reverse_zone = Ops.add( Ops.add(reverse_zone, Ops.get(network_split, network_bytes, "")), "." ) end reverse_zone = Ops.add(reverse_zone, "in-addr.arpa") Ops.set(@current_dynamic_dhcp, "reverse_domain", reverse_zone) end # Computing minimal IP ipv4_min = Builtins.regexpsub(network_binary, "^(.*).$", "\\11") ipv4_min = IP.BitsToIPv4(ipv4_min) # Computing maximal IP ipv4_max = Builtins.substring(network_binary, 0, netmask_bits) ipv4_max = Ops.add(ipv4_max, "11111111111111111111111111111111") ipv4_max = Builtins.substring(ipv4_max, 0, 32) # changing the last bit not to be >1< (reserved for broadcast) ipv4_max = Builtins.regexpsub(ipv4_max, "(.*)1$", "\\10") ipv4_max = IP.BitsToIPv4(ipv4_max) Builtins.y2milestone( "Network: %1, Min. IP: %2, Max. IP: %3", Ops.get_string(m, "network", ""), ipv4_min, ipv4_max ) UI.ChangeWidget(Id("from_ip_min"), :Enabled, false) UI.ChangeWidget(Id("to_ip_max"), :Enabled, false) if ipv4_min != nil && ipv4_max != nil UI.ChangeWidget(Id("from_ip_min"), :Value, ipv4_min) UI.ChangeWidget(Id("to_ip_max"), :Value, ipv4_max) Ops.set(@current_dynamic_dhcp, "ipv4_min", ipv4_min) Ops.set(@current_dynamic_dhcp, "ipv4_max", ipv4_max) end Builtins.y2milestone("Id to lookup: %1", id) if !DhcpServer.EntryExists("subnet", id) DhcpServer.CreateEntry("subnet", id, "", "") end # FIXME: it may not exist directives = DhcpServer.GetEntryDirectives("subnet", id) default_lease_time = 14400 max_lease_time = 172800 Builtins.foreach(directives) do |opt| if Ops.get(opt, "key") == "range" range = Builtins.splitstring(Ops.get(opt, "value", ""), " ") idx = 0 if Ops.get(range, 0, "") == "dynamic-bootp" UI.ChangeWidget(Id("dyn_bootp"), :Value, true) idx = 1 end UI.ChangeWidget(Id("from_ip"), :Value, Ops.get(range, idx, "")) UI.ChangeWidget( Id("to_ip"), :Value, Ops.get(range, Ops.add(idx, 1), "") ) elsif Ops.get(opt, "key") == "default-lease-time" default_lease_time = Builtins.tointeger(Ops.get(opt, "value", "0")) elsif Ops.get(opt, "key") == "max-lease-time" max_lease_time = Builtins.tointeger(Ops.get(opt, "value", "0")) end end if directives != nil vu = seconds2time(default_lease_time) value = Ops.get_integer(vu, "count", 0) unit = Ops.get_string(vu, "unit", "seconds") UI.ChangeWidget(Id("defaultleasetime"), :Value, Builtins.tostring(value)) UI.ChangeWidget(Id("defaultleasetimeunits"), :Value, unit) vu = seconds2time(max_lease_time) value = Ops.get_integer(vu, "count", 0) unit = Ops.get_string(vu, "unit", "seconds") UI.ChangeWidget(Id("maxleasetime"), :Value, Builtins.tostring(value)) UI.ChangeWidget(Id("maxleasetimeunits"), :Value, unit) DynamicDHCPValidChars() # Synchronize DNS Server -- init all_zones = DnsServerAPI.GetZones possible_dns_actions = [] # zone is not maintained by the DNS server if Ops.get(all_zones, zone_name) == nil possible_dns_actions = [ Item( Id(:dns_advanced_from_scratch), _("Create New DNS Zone from Scratch") ) ] # zone is maintained and it is a 'master' elsif Ops.get(all_zones, [zone_name, "type"]) == "master" possible_dns_actions = [ Item( Id(:dns_advanced_from_scratch), _("Create New DNS Zone from Scratch") ), Item(Id(:dns_advanced_edit_current), _("Edit Current DNS Zone")) ] # zone is maintained but it is not a 'master' else possible_dns_actions = [ Item(Id(:dns_advanced_zone_info), _("Get Current Zone Information")) ] end UI.ReplaceWidget( Id(:dns_advanced), MenuButton( Id(:dns_advanced_menu), _("&Synchronize DNS Server..."), possible_dns_actions ) ) UI.ChangeWidget( Id(:dns_advanced_menu), :Enabled, DhcpServer.IsDnsServerAvailable ) nil end |
- (Object) DynamicDHCPStore(key, event)
1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1450 def DynamicDHCPStore(key, event) event = deep_copy(event) ifaces_allowed = DhcpServer.GetAllowedInterfaces # we assume there is only a single interface at this stage interface = Ops.get(ifaces_allowed, 0) m = DhcpServer.GetInterfaceInformation(interface) id = Ops.add( Ops.add(Ops.get_string(m, "network", ""), " netmask "), Ops.get_string(m, "netmask", "") ) Builtins.y2milestone("Id to store: %1", id) directives = DhcpServer.GetEntryDirectives("subnet", id) directives = [] if directives == nil from_ip = Convert.to_string(UI.QueryWidget(Id("from_ip"), :Value)) to_ip = Convert.to_string(UI.QueryWidget(Id("to_ip"), :Value)) dyn_bootp = Convert.to_boolean(UI.QueryWidget(Id("dyn_bootp"), :Value)) # FIXME: validation # now update the directives # remove the old ones keys = ["max-lease-time", "range", "default-lease-time"] directives = Builtins.filter(directives) do |opt| !Builtins.contains(keys, Ops.get(opt, "key", "")) end if Builtins.size(from_ip) != 0 && Builtins.size(to_ip) != 0 directives = Builtins.add( directives, { "key" => "range", "value" => Ops.add( Ops.add(Ops.add(dyn_bootp ? "dynamic-bootp " : "", from_ip), " "), to_ip ) } ) end value = Convert.to_string(UI.QueryWidget(Id("defaultleasetime"), :Value)) if Ops.greater_than(Builtins.size(value), 0) val = Builtins.tointeger(value) units = Convert.to_string( UI.QueryWidget(Id("defaultleasetimeunits"), :Value) ) val = time2seconds(val, units) directives = Builtins.add( directives, { "key" => "default-lease-time", "value" => Builtins.tostring(val) } ) end value = Convert.to_string(UI.QueryWidget(Id("maxleasetime"), :Value)) if Ops.greater_than(Builtins.size(value), 0) val = Builtins.tointeger(value) units = Convert.to_string( UI.QueryWidget(Id("maxleasetimeunits"), :Value) ) val = time2seconds(val, units) directives = Builtins.add( directives, { "key" => "max-lease-time", "value" => Builtins.tostring(val) } ) end DhcpServer.SetEntryDirectives("subnet", id, directives) nil end |
- (Object) DynamicDHCPValidate(key, event)
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 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1528 def DynamicDHCPValidate(key, event) event = deep_copy(event) from_ip = Convert.to_string(UI.QueryWidget(Id("from_ip"), :Value)) to_ip = Convert.to_string(UI.QueryWidget(Id("to_ip"), :Value)) defaultleasetime = Convert.to_string( UI.QueryWidget(Id("defaultleasetime"), :Value) ) maxleasetime = Convert.to_string( UI.QueryWidget(Id("maxleasetime"), :Value) ) if from_ip == "" && to_ip == "" # disable dynamic IP assigning return true end # defined only one, both from and to must be defined if from_ip != "" && to_ip == "" UI.SetFocus(Id("to_ip")) # A popup error text Popup.Error(_("Enter values for both ends of the IP address range.")) return false end # defined only one, both from and to must be defined if from_ip == "" && to_ip != "" UI.SetFocus(Id("from_ip")) # A popup error text Popup.Error(_("Enter values for both ends of the IP address range.")) return false end # Checking from_ip for IPv4 if from_ip != "" && IP.Check4(from_ip) == false UI.SetFocus(Id("from_ip")) Popup.Error(IP.Valid4) return false end # Checking to_ip for IPv4 if to_ip != "" && IP.Check4(to_ip) == false UI.SetFocus(Id("to_ip")) Popup.Error(IP.Valid4) return false end # FIXME: Lease Time should NOT be zero or means zero NO expiration? # network of the current network interface current_network = IP.ComputeNetwork( Ops.get(@current_dynamic_dhcp, "network", ""), Ops.get(@current_dynamic_dhcp, "netmask", "") ) # checking from_ip network with the current network from_ip_network = IP.ComputeNetwork( from_ip, Ops.get(@current_dynamic_dhcp, "netmask", "") ) if from_ip_network != "" && current_network != nil && current_network != "" && current_network != from_ip_network UI.SetFocus(Id("from_ip")) Report.Error( # TRANSLATORS: popup error message # %1 is the tested IP which should match network %2 and netmask %3 Builtins.sformat( _( "The dynamic DHCP address range must be in the same network as the DHCP server.\nIP %1 does not match the network %2/%3." ), from_ip, Ops.get(@current_dynamic_dhcp, "network", ""), Ops.get(@current_dynamic_dhcp, "netmask", "") ) ) return false end # checking to_ip network with the current network to_ip_network = IP.ComputeNetwork( to_ip, Ops.get(@current_dynamic_dhcp, "netmask", "") ) if to_ip_network != "" && current_network != nil && current_network != "" && current_network != to_ip_network UI.SetFocus(Id("to_ip")) Report.Error( # TRANSLATORS: popup error message # %1 is the tested IP which should match network %2 and netmask %3 Builtins.sformat( _( "The dynamic DHCP address range must be in the same network as the DHCP server.\nIP %1 does not match the network %2/%3." ), to_ip, Ops.get(@current_dynamic_dhcp, "network", ""), Ops.get(@current_dynamic_dhcp, "netmask", "") ) ) return false end Ops.set(@current_dynamic_dhcp, "from_ip", from_ip) Ops.set(@current_dynamic_dhcp, "to_ip", to_ip) true end |
- (Object) DynamicDHCPValidChars
1174 1175 1176 1177 1178 1179 1180 1181 1182 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1174 def DynamicDHCPValidChars # ValidChars definition for DynamicDHCPDialog UI.ChangeWidget(Id("from_ip"), :ValidChars, IP.ValidChars4) UI.ChangeWidget(Id("to_ip"), :ValidChars, IP.ValidChars4) UI.ChangeWidget(Id("defaultleasetime"), :ValidChars, "0123456789") UI.ChangeWidget(Id("maxleasetime"), :ValidChars, "0123456789") nil end |
- (Object) ExpertSettingsTabInit(tab)
2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2082 def ExpertSettingsTabInit(tab) Builtins.y2warning("Tab: %1", tab) if tab == "expert_settings" # yes-no popup if !Popup.YesNo( _( "If you enter the expert settings, you cannot return \n" + "to this dialog. You may be able to display this dialog \n" + "by saving the changes and restarting the module. \n" + "If too complex a configuration is set, the expert \n" + "settings dialog is displayed when you\n" + "start the DHCP server module.\n" + "\n" + "Continue?" ) ) return :refuse_display else return :expert end end nil end |
- (Object) FirstRunDialog(current_tab, step_number)
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2231 def FirstRunDialog(current_tab, step_number) tab_descr = Ops.get(@tabs, current_tab, {}) # dialog caption, %1 is step number caption = Ops.add( Ops.add( Builtins.sformat(_("DHCP Server Wizard (%1 of 4)"), step_number), ": " ), Ops.get_string(tab_descr, "wizard", "") ) ret = CWM.ShowAndRun( { "widget_names" => Ops.get_list(tab_descr, "widget_names", []), "widget_descr" => @widgets, "contents" => Ops.get_term(tab_descr, "contents", VBox()), "caption" => caption, "back_button" => Label.BackButton, "next_button" => step_number == 4 ? Label.FinishButton : Label.NextButton, "fallback_functions" => { :abort => fun_ref(method(:confirmAbortIfChanged), "boolean ()") } } ) ret end |
- (Object) GetStartService
2185 2186 2187 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2185 def GetStartService DhcpServer.GetStartService end |
- (Object) GlobalSettingsHandle(key, event)
808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 808 def GlobalSettingsHandle(key, event) event = deep_copy(event) if Ops.get(event, "ID") == "ldap" && Ops.get(event, "EventReason") == "ValueChanged" ldap = Convert.to_boolean(UI.QueryWidget(Id("ldap"), :Value)) # LDAP switch SetUseLdap(ldap) ldap = DhcpServer.GetUseLdap UI.ChangeWidget(Id("ldap"), :Value, ldap) # ldap-dhcp-server-cn switch UI.ChangeWidget(Id("ldap-dhcp-server-cn"), :Enabled, ldap) end nil end |
- (Object) GlobalSettingsInit(key)
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 734 def GlobalSettingsInit(key) # get the global options = DhcpServer.GetEntryOptions("", "") = [] if == nil # setup the corresponding values Builtins.foreach() do |opt| if Ops.get(opt, "key") == "domain-name" value2 = Ops.get(opt, "value", "") if Builtins.regexpmatch(value2, "^[ \t]*\".*\"[ \t]*$") value2 = Builtins.regexpsub(value2, "^[ \t]*\"(.*)\"[ \t]*$", "\\1") end UI.ChangeWidget(Id("domainname"), :Value, value2) elsif Ops.get(opt, "key") == "domain-name-servers" vals = Builtins.splitstring(Ops.get(opt, "value", ""), " ,") vals = Builtins.filter(vals) { |v| v != "" } UI.ChangeWidget(Id("primarydnsip"), :Value, Ops.get(vals, 0, "")) UI.ChangeWidget(Id("secondarydnsip"), :Value, Ops.get(vals, 1, "")) elsif Ops.get(opt, "key") == "routers" vals = Builtins.splitstring(Ops.get(opt, "value", ""), ", ") vals = Builtins.filter(vals) { |v| v != "" } UI.ChangeWidget(Id("defaultgw"), :Value, Ops.get(vals, 0, "")) elsif Ops.get(opt, "key") == "ntp-servers" vals = Builtins.splitstring(Ops.get(opt, "value", ""), " ") UI.ChangeWidget(Id("timeserver"), :Value, Ops.get(vals, 0, "")) elsif Ops.get(opt, "key") == "lpr-servers" vals = Builtins.splitstring(Ops.get(opt, "value", ""), " ") UI.ChangeWidget(Id("printserver"), :Value, Ops.get(vals, 0, "")) elsif Ops.get(opt, "key") == "netbios-name-servers" vals = Builtins.splitstring(Ops.get(opt, "value", ""), " ") UI.ChangeWidget(Id("winsserver"), :Value, Ops.get(vals, 0, "")) end end # get the global directives directives = DhcpServer.GetEntryDirectives("", "") directives = [] if directives == nil default_lease_time = 14400 # setup the corresponding values Builtins.foreach(directives) do |opt| if Ops.get(opt, "key") == "default-lease-time" default_lease_time = Builtins.tointeger(Ops.get(opt, "value", "0")) end end vu = seconds2time(default_lease_time) value = Ops.get_integer(vu, "count", 0) unit = Ops.get_string(vu, "unit", "seconds") UI.ChangeWidget(Id("defaultleasetime"), :Value, Builtins.tostring(value)) UI.ChangeWidget(Id("defaultleasetimeunits"), :Value, unit) ldap_in_use = DhcpServer.GetUseLdap ldap_available = DhcpServer.GetLdapAvailable if ldap_available UI.ChangeWidget(Id("ldap"), :Value, ldap_in_use) UI.ChangeWidget( Id("ldap-dhcp-server-cn"), :Value, DhcpServer.GetLdapDHCPServerCN ) UI.ChangeWidget(Id("ldap-dhcp-server-cn"), :Enabled, ldap_in_use) else UI.ChangeWidget(Id("ldap"), :Enabled, ldap_available) end GlobalSettingsValidChars() nil end |
- (Object) GlobalSettingsStore(key, event)
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 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 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 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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 825 def GlobalSettingsStore(key, event) event = deep_copy(event) directives = [] # get the global options = DhcpServer.GetEntryOptions("", "") directives = [] if directives == nil # filter out those we know to change keys = [ "domain-name", "domain-name-servers", "routers", "ntp-servers", "lpr-servers", "netbios-name-servers" ] = Builtins.filter() do |opt| !Builtins.contains(keys, Ops.get(opt, "key", "")) end value = Convert.to_string(UI.QueryWidget(Id("domainname"), :Value)) if Ops.greater_than(Builtins.size(value), 0) = Builtins.add( , { "key" => "domain-name", "value" => Builtins.sformat("\"%1\"", value) } ) end value1 = Convert.to_string(UI.QueryWidget(Id("primarydnsip"), :Value)) value2 = Convert.to_string(UI.QueryWidget(Id("secondarydnsip"), :Value)) if Ops.greater_than(Builtins.size(value1), 0) || Ops.greater_than(Builtins.size(value2), 0) value1 = value1 == nil ? "" : value1 value2 = value2 == nil ? "" : value2 domain_servers = Ops.add( value1, Ops.greater_than(Builtins.size(value2), 0) ? Ops.add( Ops.greater_than(Builtins.size(value1), 0) ? ", " : "", value2 ) : "" ) = Builtins.add( , { "key" => "domain-name-servers", "value" => domain_servers } ) end value = Convert.to_string(UI.QueryWidget(Id("defaultgw"), :Value)) if Ops.greater_than(Builtins.size(value), 0) = Builtins.add( , { "key" => "routers", "value" => value } ) end value = Convert.to_string(UI.QueryWidget(Id("timeserver"), :Value)) if Ops.greater_than(Builtins.size(value), 0) = Builtins.add( , { "key" => "ntp-servers", "value" => value } ) end value = Convert.to_string(UI.QueryWidget(Id("printserver"), :Value)) if Ops.greater_than(Builtins.size(value), 0) = Builtins.add( , { "key" => "lpr-servers", "value" => value } ) end value = Convert.to_string(UI.QueryWidget(Id("winsserver"), :Value)) if Ops.greater_than(Builtins.size(value), 0) = Builtins.add( , { "key" => "netbios-name-servers", "value" => value } ) end DhcpServer.SetEntryOptions("", "", ) # get the global directives directives = DhcpServer.GetEntryDirectives("", "") directives = [] if directives == nil # filter out the known ones keys = ["default-lease-time"] directives = Builtins.filter(directives) do |opt| !Builtins.contains(keys, Ops.get(opt, "key", "")) end value = Convert.to_string(UI.QueryWidget(Id("defaultleasetime"), :Value)) if Ops.greater_than(Builtins.size(value), 0) val = Builtins.tointeger(value) units = Convert.to_string( UI.QueryWidget(Id("defaultleasetimeunits"), :Value) ) val = time2seconds(val, units) directives = Builtins.add( directives, { "key" => "default-lease-time", "value" => Builtins.tostring(val) } ) end if UI.WidgetExists(Id("ldap-dhcp-server-cn")) ldap_dhcp_server_cn = Convert.to_string( UI.QueryWidget(Id("ldap-dhcp-server-cn"), :Value) ) DhcpServer.SetLdapDHCPServerCN(ldap_dhcp_server_cn) # save ldap-dhcp-server-cn only when set if ldap_dhcp_server_cn != "" # backslash quotes in the ldap-dhcp-server-cn entry, just to be safe ldap_dhcp_server_cn = Builtins.mergestring( Builtins.splitstring(ldap_dhcp_server_cn, "\""), "\\\"" ) directives = Builtins.add( directives, { "key" => "ldap-dhcp-server-cn", "value" => Builtins.sformat("\"%1\"", ldap_dhcp_server_cn) } ) end end DhcpServer.SetEntryDirectives("", "", directives) DhcpServer.SetModified nil end |
- (Object) GlobalSettingsValidate(key, event)
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 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 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 970 def GlobalSettingsValidate(key, event) event = deep_copy(event) domainname = Convert.to_string(UI.QueryWidget(Id("domainname"), :Value)) primarydnsip = Convert.to_string( UI.QueryWidget(Id("primarydnsip"), :Value) ) secondarydnsip = Convert.to_string( UI.QueryWidget(Id("secondarydnsip"), :Value) ) defaultgw = Convert.to_string(UI.QueryWidget(Id("defaultgw"), :Value)) timeserver = Convert.to_string(UI.QueryWidget(Id("timeserver"), :Value)) printserver = Convert.to_string(UI.QueryWidget(Id("printserver"), :Value)) winsserver = Convert.to_string(UI.QueryWidget(Id("winsserver"), :Value)) defaultleasetime = Convert.to_string( UI.QueryWidget(Id("defaultleasetime"), :Value) ) # FIXME: it is not defined which of values must be filled (must be lease time defined?) # shouldn't be lease time controlled for too small or too big value? # checking domain name if domainname != "" && Hostname.CheckDomain(domainname) != true UI.SetFocus(Id("domainname")) Popup.Error(Hostname.ValidDomain) return false end # checking primary server if primarydnsip != "" && IP.Check4(primarydnsip) != true UI.SetFocus(Id("primarydnsip")) Popup.Error(IP.Valid4) return false end # checking secondary server if secondarydnsip != "" && IP.Check4(secondarydnsip) != true UI.SetFocus(Id("primarydnsip")) Popup.Error(IP.Valid4) return false end # checking default gateway server if defaultgw != "" && Hostname.Check(defaultgw) != true && Hostname.CheckFQ(defaultgw) != true && IP.Check4(defaultgw) != true UI.SetFocus(Id("defaultgw")) # error popup Popup.Error( _("The specified value is not a valid hostname or IP address.") ) return false end # checking time server if timeserver != "" && Hostname.Check(timeserver) != true && Hostname.CheckFQ(timeserver) != true && IP.Check4(timeserver) != true UI.SetFocus(Id("timeserver")) # error popup Popup.Error( _("The specified value is not a valid hostname or IP address.") ) return false end # checking print server if printserver != "" && Hostname.Check(printserver) != true && Hostname.CheckFQ(printserver) != true && IP.Check4(printserver) != true UI.SetFocus(Id("printserver")) # error popup Popup.Error( _("The specified value is not a valid hostname or IP address.") ) return false end # checking wins server if winsserver != "" && Hostname.Check(winsserver) != true && Hostname.CheckFQ(winsserver) != true && IP.Check4(winsserver) != true UI.SetFocus(Id("winsserver")) # error popup Popup.Error( _("The specified value is not a valid hostname or IP address.") ) return false end true end |
- (Object) GlobalSettingsValidChars
700 701 702 703 704 705 706 707 708 709 710 711 712 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 700 def GlobalSettingsValidChars # ValidChars definition for GlobalSettingsDialog UI.ChangeWidget(Id("domainname"), :ValidChars, Address.ValidChars4) UI.ChangeWidget(Id("primarydnsip"), :ValidChars, IP.ValidChars4) UI.ChangeWidget(Id("secondarydnsip"), :ValidChars, IP.ValidChars4) UI.ChangeWidget(Id("defaultgw"), :ValidChars, Address.ValidChars4) UI.ChangeWidget(Id("timeserver"), :ValidChars, Address.ValidChars4) UI.ChangeWidget(Id("printserver"), :ValidChars, Address.ValidChars4) UI.ChangeWidget(Id("winsserver"), :ValidChars, Address.ValidChars4) UI.ChangeWidget(Id("defaultleasetime"), :ValidChars, "0123456789") nil end |
- (Object) HostManagementHandle(key, event_descr)
1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1959 def HostManagementHandle(key, event_descr) event_descr = deep_copy(event_descr) if Ops.get_string(event_descr, "ID", "") == "addhost" name = Convert.to_string(UI.QueryWidget(Id("hostname"), :Value)) return nil if !CheckHostId(name) # checking new IP hostip = Convert.to_string(UI.QueryWidget(Id("hostip"), :Value)) if Builtins.size(hostip) == 0 UI.SetFocus(Id("hostip")) # error popup Popup.Error(_("Enter a host IP.")) return nil elsif IP.Check4(hostip) != true UI.SetFocus(Id("hostip")) Popup.Error(IP.Valid4) return nil end # checking new MAC hosthwaddress = Convert.to_string( UI.QueryWidget(Id("hosthwaddress"), :Value) ) if Builtins.size(hosthwaddress) == 0 UI.SetFocus(Id("hosthwaddress")) # error popup Report.Error(_("The hardware address must be defined.")) return nil end # check the syntax return nil if !CheckMacAddrFormat() # check if MAC address is unique return nil if !CheckMacAddrUnique(nil) # finally create the entry DhcpServer.CreateEntry("host", name, "subnet", @hosts_parent_id) DhcpServer.SetEntryDirectives("host", name, PrepareDirectives()) HostManagementInit(key) elsif Ops.get_string(event_descr, "ID", "") == "deletehost" id = Convert.to_string( UI.QueryWidget(Id("registered_hosts_table"), :CurrentItem) ) if id == nil # error popup Popup.Error(_("Select a host first.")) return nil end # yes-no popup return nil if !Confirm.Delete(id) DhcpServer.DeleteEntry("host", id) HostManagementInit(key) elsif Ops.get_string(event_descr, "ID", "") == "edithost" id = Convert.to_string( UI.QueryWidget(Id("registered_hosts_table"), :CurrentItem) ) if id == nil Popup.Error(_("Select a host first.")) return nil end # check the new ID new_id = Convert.to_string(UI.QueryWidget(Id("hostname"), :Value)) return nil if new_id != id && !CheckHostId(new_id) # checking new IP hostip = Convert.to_string(UI.QueryWidget(Id("hostip"), :Value)) if Builtins.size(hostip) == 0 # FIXME: text? UI.SetFocus(Id("hostip")) Popup.Error(_("Enter a host IP.")) return nil elsif IP.Check4(hostip) != true UI.SetFocus(Id("hostip")) Popup.Error(IP.Valid4) return nil end # checking new MAC hosthwaddress = Convert.to_string( UI.QueryWidget(Id("hosthwaddress"), :Value) ) if Builtins.size(hosthwaddress) == 0 UI.SetFocus(Id("hosthwaddress")) Popup.Error(_("The input value must be defined.")) return nil end # check the syntax return nil if !CheckMacAddrFormat() # check if MAC address is unique return nil if !CheckMacAddrUnique(id) if id != new_id DhcpServer.DeleteEntry("host", id) id = new_id DhcpServer.CreateEntry("host", id, "subnet", @hosts_parent_id) end DhcpServer.SetEntryDirectives("host", id, PrepareDirectives()) HostManagementInit(key) elsif Ops.get_string(event_descr, "ID", "") == "registered_hosts_table" && Ops.get_string(event_descr, "EventReason", "") == "SelectionChanged" id = Convert.to_string( UI.QueryWidget(Id("registered_hosts_table"), :CurrentItem) ) SelectItem(id) if id != nil end nil end |
- (Object) HostManagementInit(key)
1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1754 def HostManagementInit(key) @hosts = {} @hosts_parent_id = "" ifaces_allowed = DhcpServer.GetAllowedInterfaces # we assume there is only a single interface at this stage interface = Ops.get(ifaces_allowed, 0) m = DhcpServer.GetInterfaceInformation(interface) id = Ops.add( Ops.add(Ops.get_string(m, "network", ""), " netmask "), Ops.get_string(m, "netmask", "") ) @hosts_parent_id = id Builtins.y2milestone("Id to get hosts from: %1", id) if !DhcpServer.EntryExists("subnet", id) DhcpServer.CreateEntry("subnet", id, "", "") end # now, get the list of interesting children children = DhcpServer.GetChildrenOfEntry("subnet", id) Builtins.foreach(children) do |child| if Ops.get(child, "type") == "host" child_id = Ops.get(child, "id", "") # let's initialize our cache Ops.set(@hosts, child_id, {}) directives = DhcpServer.GetEntryDirectives( "host", Ops.get(child, "id", "") ) Builtins.foreach(directives) do |opt| if Ops.get(opt, "key") == "hardware" parts = Builtins.splitstring(Ops.get(opt, "value", ""), " ") Ops.set(@hosts, [child_id, "hardware"], Ops.get(parts, 1, "")) Ops.set(@hosts, [child_id, "type"], Ops.get(parts, 0, "ethernet")) elsif Ops.get(opt, "key") == "fixed-address" Ops.set(@hosts, [child_id, "ip"], Ops.get(opt, "value", "")) end end end end # now, fill the dialog items = Builtins.maplist(@hosts) do |id2, opts| Item( Id(id2), id2, Ops.get(opts, "ip", ""), Ops.get(opts, "hardware", ""), Ops.get(opts, "type", "ethernet") == "ethernet" ? _("Ethernet") : _("Token Ring") ) end UI.ChangeWidget(Id("registered_hosts_table"), :Items, items) if Ops.greater_than(Builtins.size(items), 0) # fill the corresponding fields SelectItem(Ops.get_string(items, [0, 1], "")) end # get the global options = DhcpServer.GetEntryOptions("", "") = [] if == nil # setup the corresponding values Builtins.foreach() do |opt| if Ops.get(opt, "key") == "domain-name" value = Ops.get(opt, "value", "") value = Builtins.regexpsub(value, "^[ \t]*\"(.*)\"[ \t]*$", "\\1") if Ops.greater_than(Builtins.size(value), 0) value = Ops.add(".", value) end UI.ChangeWidget(Id("domain"), :Value, value) raise Break end end HostManagementValidChars() nil end |
- (Object) HostManagementStore(key, event)
2077 2078 2079 2080 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2077 def HostManagementStore(key, event) event = deep_copy(event) nil end |
- (Object) HostManagementValidChars
1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1722 def HostManagementValidChars # ValidChars definition for HostManagementDialog UI.ChangeWidget(Id("hostname"), :ValidChars, Hostname.ValidChars) UI.ChangeWidget(Id("hostip"), :ValidChars, IP.ValidChars4) UI.ChangeWidget( Id("hosthwaddress"), :ValidChars, "ABCDEFabcdef0123456789:" ) nil end |
- (Object) initialize_dhcp_server_dialogs2(include_target)
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 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 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 15 def initialize_dhcp_server_dialogs2(include_target) textdomain "dhcp-server" Yast.import "Confirm" Yast.import "Label" Yast.import "Wizard" Yast.import "DhcpServer" Yast.import "Popup" Yast.import "Address" Yast.import "IP" Yast.import "Hostname" Yast.import "Progress" Yast.import "DialogTree" Yast.import "CWMServiceStart" #import "ProductFeatures"; Yast.import "NetworkInterfaces" Yast.import "Report" Yast.import "Mode" Yast.import "Netmask" Yast.include include_target, "dhcp-server/helps.rb" Yast.include include_target, "dhcp-server/widgets.rb" Yast.include include_target, "dhcp-server/dns-server-management.rb" Yast.include include_target, "dhcp-server/dns-server-wizard.rb" # Using expert UI #define boolean expert_ui = (ProductFeatures::GetFeature ("globals", "ui_mode") == "expert"); # Start of common configuration section @time_combo_items = [ # combo box item Item(Id("days"), _("Days")), # combo box item Item(Id("hours"), _("Hours")), # combo box item Item(Id("minutes"), _("Minutes")), # combo box item Item(Id("seconds"), _("Seconds")) ] @quit = false # Currently selected item in the interface table @current_item_iface = nil @current_dynamic_dhcp = {} @hosts_parent_id = "" @hosts = {} @valid_opts = { "p" => true, "f" => false, "d" => false, "q" => false, "t" => false, "T" => false, "cf" => true, "lf" => true, "tf" => true, "play" => true } @tabs = { "start_up" => { "contents" => VBox( "auto_start_up", # `VSpacing(), "use_ldap", VSpacing(), "start_stop", VSpacing(), HBox("other_options", HStretch()), VStretch() ), # dialog caption "caption" => _("DHCP Server: Start-Up"), # dialog caption "wizard" => _("Start-Up"), # tree item "tree_item_label" => _("Start-Up"), "widget_names" => [ "auto_start_up", "use_ldap", "start_stop", "expert_settings", "other_options" ] }, "card_selection" => { "contents" => VBox( VSpacing(1), Common_CardSelectionDialog(), VSpacing(1), Left("open_firewall"), VStretch() ), # dialog caption "caption" => _("DHCP Server: Card Selection"), # dialog caption "wizard" => _("Card Selection"), # tree item "tree_item_label" => _("Card Selection"), "widget_names" => [ "card_selection", "open_firewall", "expert_settings" ] }, "global_settings" => { "contents" => Common_GlobalSettingsDialog(), # dialog caption "caption" => _( "DHCP Server: Global Settings" ), # dialog caption "wizard" => _("Global Settings"), # tree item "tree_item_label" => _("Global Settings"), "widget_names" => ["global_settings", "expert_settings"] }, "dynamic_dhcp" => { "contents" => Common_DynamicDHCPDialog(), # dialog caption "caption" => _("DHCP Server: Dynamic DHCP"), # dialog caption "wizard" => _("Dynamic DHCP"), # tree item "tree_item_label" => _("Dynamic DHCP"), "widget_names" => ["dynamic_dhcp", "expert_settings"] }, "host_management" => { "contents" => Common_HostManagementDialog(), # dialog caption "caption" => _( "DHCP Server: Host Management" ), # tree item "tree_item_label" => _("Host Management"), "widget_names" => ["host_management", "expert_settings"] }, "expert_settings" => { # dialog caption "caption" => _( "DHCP Server: Expert Settings" ), # tree item "tree_item_label" => _("Expert Settings"), "init" => fun_ref( method(:ExpertSettingsTabInit), "symbol (string)" ) }, "inst_summary" => { "contents" => VBox( VSpacing(1), "auto_start_up", VSpacing(1), "config_summary", VSpacing(1), "all_settings_button", VSpacing(1) ), # dialog caption "wizard" => _("Start-Up"), "widget_names" => [ "auto_start_up", "config_summary", "all_settings_button" ] } } @new_widgets = Convert.convert( Builtins.union( @widgets, { "auto_start_up" => CWMServiceStart.CreateAutoStartWidget( { "get_service_auto_start" => fun_ref( method(:GetStartService), "boolean ()" ), "set_service_auto_start" => fun_ref( method(:SetStartService), "void (boolean)" ), # radio button "start_auto_button" => _("When &Booting"), # radio button "start_manual_button" => _("&Manually"), "help" => Builtins.sformat( CWMServiceStart.AutoStartHelpTemplate, # part of help text - radio button label, NO SHORTCUT!!! _("When Booting"), # part of help text - radio button label, NO SHORTCUT!!! _("Manually") ) } ), "start_stop" => CWMServiceStart.CreateStartStopWidget( { "service_id" => "dhcpd", # label - service status "service_running_label" => _( "DHCP server is running" ), # label - service status "service_not_running_label" => _( "DHCP server is not running" ), # push button "start_now_button" => _( "&Start DHCP Server Now" ), # push button "stop_now_button" => _( "S&top DHCP Server Now" ), "save_now_action" => fun_ref( method(:SaveAndRestart), "void ()" ), # push button "save_now_button" => _( "Save Settings and Restart DHCP Server &Now" ), "help" => Builtins.sformat( CWMServiceStart.StartStopHelpTemplate(true), # part of help text - push button label, NO SHORTCUT!!! _("Start DHCP Server Now"), # part of help text - push button label, NO SHORTCUT!!! _("Stop DHCP Server Now"), # part of help text - push button label, NO SHORTCUT!!! _("Save Settings and Restart DHCP Server Now") ) } ), "use_ldap" => CWMServiceStart.CreateLdapWidget( { "get_use_ldap" => fun_ref( DhcpServer.method(:GetUseLdap), "boolean ()" ), "set_use_ldap" => fun_ref(method(:SetUseLdap), "void (boolean)") } ), "card_selection" => { "widget" => :custom, "custom_widget" => VBox(), "init" => fun_ref( method(:CardSelectionInit), "void (string)" ), "handle" => fun_ref( method(:CardSelectionHandle), "symbol (string, map)" ), "store" => fun_ref( method(:CardSelectionStore), "void (string, map)" ), "validate_type" => :function, "validate_function" => fun_ref( method(:CardSelectionValidate), "boolean (string, map)" ), "help" => Ops.get( @HELPS, "card_selection_expert", "" ) }, "global_settings" => { "widget" => :custom, "custom_widget" => VBox(), "init" => fun_ref( method(:GlobalSettingsInit), "void (string)" ), "handle" => fun_ref( method(:GlobalSettingsHandle), "symbol (string, map)" ), "validate_type" => :function, "validate_function" => fun_ref( method(:GlobalSettingsValidate), "boolean (string, map)" ), "store" => fun_ref( method(:GlobalSettingsStore), "void (string, map)" ), "help" => Ops.add( Ops.add( Ops.get(@HELPS, "ldap_support", ""), Ops.get(@HELPS, "ldap_server_name", "") ), Ops.get(@HELPS, "global_settings", "") ) }, "dynamic_dhcp" => { "widget" => :custom, "custom_widget" => VBox(), "init" => fun_ref( method(:DynamicDHCPInit), "void (string)" ), "validate_type" => :function, "validate_function" => fun_ref( method(:DynamicDHCPValidate), "boolean (string, map)" ), "handle" => fun_ref( method(:DynamicDHCPHandle), "symbol (string, map)" ), "store" => fun_ref( method(:DynamicDHCPStore), "void (string, map)" ), "help" => Ops.get(@HELPS, "dynamic_dhcp", "") }, "host_management" => { "widget" => :custom, "custom_widget" => VBox(), "init" => fun_ref( method(:HostManagementInit), "void (string)" ), "handle" => fun_ref( method(:HostManagementHandle), "symbol (string, map)" ), "store" => fun_ref( method(:HostManagementStore), "void (string, map)" ), "help" => Ops.get(@HELPS, "host_management", "") }, "expert_settings" => { "widget" => :custom, "custom_widget" => VBox(), "help" => Ops.get(@HELPS, "expert_settings", " ") }, "config_summary" => { "widget" => :custom, "custom_widget" => Empty(), "help" => Ops.get(@HELPS, "config_summary", " ") }, "other_options" => { "widget" => :custom, "custom_widget" => TextEntry( Id("other_opts"), _("DHCP Server Start-up Arguments") ), "init" => fun_ref( method(:OtherOptionsInit), "void (string)" ), "validate_type" => :function, "validate_function" => fun_ref( method(:OtherOptionsValidate), "boolean (string, map)" ), "store" => fun_ref( method(:OtherOptionsStore), "void (string, map)" ), "help" => Ops.get(@HELPS, "other_options", " ") } } ), :from => "map", :to => "map <string, map <string, any>>" ) end |
- (Object) OtherOptionsInit(key)
2106 2107 2108 2109 2110 2111 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2106 def OtherOptionsInit(key) params = DhcpServer.GetOtherOptions UI.ChangeWidget(Id("other_opts"), :Value, params) nil end |
- (Object) OtherOptionsStore(key, event)
2176 2177 2178 2179 2180 2181 2182 2183 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2176 def OtherOptionsStore(key, event) event = deep_copy(event) params = Convert.to_string(UI.QueryWidget(Id("other_opts"), :Value)) DhcpServer.SetOtherOptions(params) nil end |
- (Object) OtherOptionsValidate(key, event)
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2113 def OtherOptionsValidate(key, event) event = deep_copy(event) cmdline = Convert.to_string(UI.QueryWidget(Id("other_opts"), :Value)) #remove leading '-' if Ops.greater_than(Builtins.size(cmdline), 0) cmdline = Builtins.substring(cmdline, 1) end correct = true = Builtins.listmap(Builtins.splitstring(cmdline, "-")) do |s| wrk = Builtins.splitstring(s, " ") { Ops.get(wrk, 0, "") => Ops.get(wrk, 1, "") } end Builtins.y2milestone("Cmdline options: %1", ) Builtins.foreach() do |k, v| if !Builtins.haskey(@valid_opts, k) UI.SetFocus(Id("other_opts")) Popup.Error( Builtins.sformat( _("\"-%1\" is not a valid DHCP server commandline option"), k ) ) correct = false raise Break else if v == "" && Ops.get(@valid_opts, k, false) UI.SetFocus(Id("other_opts")) Popup.Error( Builtins.sformat( _("DHCP server commandline option \"-%1\" requires an argument"), k ) ) correct = false raise Break end if k == "cf" UI.SetFocus(Id("other_opts")) correct = Popup.ContinueCancel( Builtins.sformat( _( "You have specified an alternate configuration file for the DHCP server.\n" + "\n" + "YaST does not supported this. The DHCP server module can only read and write\n" + "/etc/dhcpd.conf. The new configuration from %1 will not be imported. All\n" + "changes will be saved to the default configuration file.\n" + " \n" + "Really continue?\n" ), v ) ) raise Break end end end # y2milestone("Commandline options parsed"); correct end |
- (Object) PrepareDirectives
1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1845 def PrepareDirectives directives = [] value = Convert.to_string(UI.QueryWidget(Id("hostip"), :Value)) if Ops.greater_than(Builtins.size(value), 0) # FIXME: validation directives = Builtins.add( directives, { "key" => "fixed-address", "value" => value } ) end value = Convert.to_string(UI.QueryWidget(Id("hosthwaddress"), :Value)) if Ops.greater_than(Builtins.size(value), 0) # FIXME: validation type = Convert.to_string( UI.QueryWidget(Id("network_type"), :CurrentButton) ) directives = Builtins.add( directives, { "key" => "hardware", "value" => Ops.add(Ops.add(type, " "), value) } ) end deep_copy(directives) end |
- (Object) RedrawInterfacesTable
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 490 def RedrawInterfacesTable table_items = [] Builtins.foreach(@ifaces) do |iface, settings| table_items = Builtins.add( table_items, Item( Id(iface), Ops.get_boolean(settings, "active", false) ? "x" : "", iface, Ops.get_string(settings, "device", ""), Ops.get_string(settings, "ipaddr", "") ) ) end UI.ChangeWidget(Id("nic_selection"), :Items, table_items) if @current_item_iface != nil UI.ChangeWidget(Id("nic_selection"), :CurrentItem, @current_item_iface) end SetInterfacesTableButtons() nil end |
- (Object) SaveAndRestart
2195 2196 2197 2198 2199 2200 2201 2202 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2195 def SaveAndRestart Wizard.CreateDialog Wizard.RestoreHelp(Ops.get(@HELPS, "write", "")) DhcpServer.Write UI.CloseDialog nil end |
- (Object) seconds2time(seconds)
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 419 def seconds2time(seconds) unit = "seconds" count = seconds if Ops.modulo(seconds, 60 * 60 * 24) == 0 return { "unit" => "days", "count" => Ops.divide(seconds, 60 * 60 * 24) } end if Ops.modulo(seconds, 60 * 60) == 0 return { "unit" => "hours", "count" => Ops.divide(seconds, 60 * 60) } end if Ops.modulo(seconds, 60) == 0 return { "unit" => "minutes", "count" => Ops.divide(seconds, 60) } end { "unit" => "seconds", "count" => seconds } end |
- (Object) SelectItem(id)
1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 1735 def SelectItem(id) opts = Ops.get(@hosts, id, {}) UI.ChangeWidget(Id("hostname"), :Value, id) UI.ChangeWidget(Id("hostip"), :Value, Ops.get(opts, "ip", "")) UI.ChangeWidget( Id("hosthwaddress"), :Value, Ops.get(opts, "hardware", "") ) UI.ChangeWidget( Id("network_type"), :CurrentButton, Ops.get(opts, "type", "ethernet") ) nil end |
- (Object) SetInterfacesTableButtons
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 472 def SetInterfacesTableButtons current_item = Convert.to_string( UI.QueryWidget(Id("nic_selection"), :CurrentItem) ) # The currently selected item is active, can be deactivated if Ops.get_boolean(@ifaces, [current_item, "active"]) == true UI.ChangeWidget(Id("add"), :Enabled, false) UI.ChangeWidget(Id("remove"), :Enabled, true) # and vice versa else UI.ChangeWidget(Id("add"), :Enabled, true) UI.ChangeWidget(Id("remove"), :Enabled, false) end nil end |
- (Object) SetStartService(start)
2189 2190 2191 2192 2193 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 2189 def SetStartService(start) DhcpServer.SetStartService(start) nil end |
- (Object) time2seconds(count, unit)
408 409 410 411 412 413 414 415 416 417 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 408 def time2seconds(count, unit) if unit == "days" return Ops.multiply(Ops.multiply(Ops.multiply(count, 60), 60), 24) elsif unit == "hours" return Ops.multiply(Ops.multiply(count, 60), 60) elsif unit == "minutes" return Ops.multiply(count, 60) end count end |
- (Object) TimeComboLabelLength
395 396 397 398 399 400 401 402 403 404 405 406 |
# File '../../src/include/dhcp-server/dialogs2.rb', line 395 def TimeComboLabelLength max_length = 0 Builtins.foreach(@time_combo_items) do |combo_item| combo_label = Ops.get_string(combo_item, 1, " ") current_length = Builtins.size(combo_label) if Ops.greater_than(current_length, max_length) max_length = current_length end end max_length end |