Hello community, here is the log from the commit of package yast2-network for openSUSE:Factory checked in at 2014-03-01 14:38:26 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-network (Old) and /work/SRC/openSUSE:Factory/.yast2-network.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "yast2-network" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-network/yast2-network.changes 2014-02-21 13:48:27.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-network.new/yast2-network.changes 2014-03-01 14:38:29.000000000 +0100 @@ -1,0 +2,45 @@ +Fri Feb 28 15:30:41 UTC 2014 - jreidinger@suse.com + +- fix installation crash - do not mess ruby global namespace +- 3.1.29 + +------------------------------------------------------------------- +Fri Feb 28 11:21:19 UTC 2014 - mfilka@suse.com + +- bnc#864614 + - exclude already configured devices from dhcp candidates when + attempting to do an autoconfiguration at the begining of + installation +- 3.1.28 + +------------------------------------------------------------------- +Fri Feb 28 08:25:53 UTC 2014 - mfilka@suse.com + +- bnc#866224 + - inst_install_inf.rb is present in instsys +- 3.1.27 + +------------------------------------------------------------------- +Thu Feb 27 10:44:09 UTC 2014 - mfilka@suse.com + +- bnc#865199 + - netmask generated corectly when handling static net + configuration provided by install.inf +- 3.1.26 + +------------------------------------------------------------------- +Wed Feb 26 23:00:17 UTC 2014 - mfilka@suse.com + +- fixed internal error in save_network client +- 3.1.25 + +------------------------------------------------------------------- +Wed Feb 26 13:19:08 UTC 2014 - mfilka@suse.com + +- bnc#859213 + - generate install.inf based netconfig at the begining of + installation. Generated configuration is copied to target at the + end of installation +- 3.1.24 + +------------------------------------------------------------------- Old: ---- yast2-network-3.1.23.tar.bz2 New: ---- yast2-network-3.1.29.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-network.spec ++++++ --- /var/tmp/diff_new_pack.0Y8IHl/_old 2014-03-01 14:38:30.000000000 +0100 +++ /var/tmp/diff_new_pack.0Y8IHl/_new 2014-03-01 14:38:30.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.23 +Version: 3.1.29 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ yast2-network-3.1.23.tar.bz2 -> yast2-network-3.1.29.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/package/yast2-network.changes new/yast2-network-3.1.29/package/yast2-network.changes --- old/yast2-network-3.1.23/package/yast2-network.changes 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/package/yast2-network.changes 2014-02-28 17:03:50.000000000 +0100 @@ -1,4 +1,49 @@ ------------------------------------------------------------------- +Fri Feb 28 15:30:41 UTC 2014 - jreidinger@suse.com + +- fix installation crash - do not mess ruby global namespace +- 3.1.29 + +------------------------------------------------------------------- +Fri Feb 28 11:21:19 UTC 2014 - mfilka@suse.com + +- bnc#864614 + - exclude already configured devices from dhcp candidates when + attempting to do an autoconfiguration at the begining of + installation +- 3.1.28 + +------------------------------------------------------------------- +Fri Feb 28 08:25:53 UTC 2014 - mfilka@suse.com + +- bnc#866224 + - inst_install_inf.rb is present in instsys +- 3.1.27 + +------------------------------------------------------------------- +Thu Feb 27 10:44:09 UTC 2014 - mfilka@suse.com + +- bnc#865199 + - netmask generated corectly when handling static net + configuration provided by install.inf +- 3.1.26 + +------------------------------------------------------------------- +Wed Feb 26 23:00:17 UTC 2014 - mfilka@suse.com + +- fixed internal error in save_network client +- 3.1.25 + +------------------------------------------------------------------- +Wed Feb 26 13:19:08 UTC 2014 - mfilka@suse.com + +- bnc#859213 + - generate install.inf based netconfig at the begining of + installation. Generated configuration is copied to target at the + end of installation +- 3.1.24 + +------------------------------------------------------------------- Wed Feb 19 16:30:43 CET 2014 - snwint@suse.de - copy also ifroute-* files into installed system diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/package/yast2-network.spec new/yast2-network-3.1.29/package/yast2-network.spec --- old/yast2-network-3.1.23/package/yast2-network.spec 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/package/yast2-network.spec 2014-02-28 17:03:50.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-network -Version: 3.1.23 +Version: 3.1.29 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/src/Makefile.am new/yast2-network-3.1.29/src/Makefile.am --- old/yast2-network-3.1.23/src/Makefile.am 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/src/Makefile.am 2014-02-28 17:03:50.000000000 +0100 @@ -40,7 +40,8 @@ clients/remote.rb \ clients/dns.rb \ clients/lan_proposal.rb \ - clients/host.rb + clients/host.rb \ + clients/inst_install_inf.rb yncludedir = @yncludedir@/network/installation ynclude_DATA = \ @@ -109,7 +110,8 @@ ylibdir = @ylibdir@/network ylib_DATA = \ lib/network/edit_nic_name.rb \ - lib/network/confirm_virt_proposal.rb + lib/network/confirm_virt_proposal.rb \ + lib/network/install_inf_convertor.rb EXTRA_DIST = \ $(module_DATA) \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/src/clients/inst_install_inf.rb new/yast2-network-3.1.29/src/clients/inst_install_inf.rb --- old/yast2-network-3.1.23/src/clients/inst_install_inf.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.29/src/clients/inst_install_inf.rb 2014-02-28 17:03:50.000000000 +0100 @@ -0,0 +1,16 @@ +require "yast" +require "network/install_inf_convertor" + +module Yast + + class InstInstallInfClient < Client + def main + InstallInfConvertor.instance.write_netconfig + + :next + end + end + +end + +Yast::InstInstallInfClient.new.main diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/src/clients/inst_setup_dhcp.rb new/yast2-network-3.1.29/src/clients/inst_setup_dhcp.rb --- old/yast2-network-3.1.23/src/clients/inst_setup_dhcp.rb 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/src/clients/inst_setup_dhcp.rb 2014-02-28 17:03:50.000000000 +0100 @@ -48,9 +48,21 @@ NetworkInterfaces.Write("") end + def self.configured?(devname) + # TODO: + # one day there should be LanItems.IsItemConfigured, but we currently + # miss index -> devname translation. As this LanItems internal structure + # will be subject of refactoring, we will use NetworkInterfaces directly. + # It currently doesn't hurt as it currently writes configuration for both + # wicked even sysconfig. + NetworkInterfaces.Check(devname) + end + + include Logger # TODO time consuming, some progress would be nice - dhcp_cards = network_cards.select { |c| get_lease?(c) } + dhcp_cards = network_cards.select { |c| !configured?(c) && get_lease?(c) } + log.info "Candidates for enabling DHCP: #{dhcp_cards}" dhcp_cards.each do |dcard| setup_dhcp(dcard) # make DHCP setup persistent diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/src/clients/save_network.rb new/yast2-network-3.1.29/src/clients/save_network.rb --- old/yast2-network-3.1.23/src/clients/save_network.rb 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/src/clients/save_network.rb 2014-02-28 17:03:50.000000000 +0100 @@ -28,7 +28,11 @@ # # module Yast + require "network/install_inf_convertor" + class SaveNetworkClient < Client + include Logger + def main Yast.import "UI" @@ -50,646 +54,38 @@ Yast.include self, "network/routines.rb" Yast.include self, "network/complex.rb" - @InstallInf = {} - - # global variable because chrooted environment - @network_disk = :no # `nfs `iscsi `fcoe - @netdevice = "" - - @hardware = ReadHardware("netcard") - Builtins.y2milestone("hardware %1", @hardware) - # for update system don't copy network from inst_sys (#325738) if !Mode.update save_network else Builtins.y2milestone("update - skip save_network") - end - # EOF - - nil - end - - # Read one install.inf item - # @param [String] item InstallInf map key - # @param [String] var install.inf SCR variable - # @return true on success - def ReadInstallInfItem(install_inf, item, var) - return false if item == nil || item == "" || var == nil || var == "" - - val = Convert.to_string(SCR.Read(Builtins.add(install_inf, var))) - return false if val == nil - - Ops.set(@InstallInf, item, val) if val != "" - - true - end - - def DeleteFirstWord(s) - ret = Builtins.regexpsub(s, "^[^ ]* +(.*)", "\\1") - ret == nil ? s : ret - end - - # Read install.inf from the correct location - # @return true on success - def ReadInstallInf - Builtins.y2milestone("ReadInstallInf()") - - # Detect install.inf location - install_inf = nil - if Ops.greater_than(SCR.Read(path(".target.size"), "/etc/install.inf"), 0) - install_inf = path(".etc.install_inf") - Ops.set(@InstallInf, "installation", "yes") - else - # FIXME - # else if(SCR::Read(.target.size,"/var/lib/YaST2/install.inf") > 0) - # install_inf = .var.lib.YaST2.install_inf; - return false - end - - # Read install.inf items - ReadInstallInfItem(install_inf, "firststage_network", "ConfigureNetwork") - ReadInstallInfItem(install_inf, "ipaddr", "IP") - ReadInstallInfItem(install_inf, "ipaddr6", "IP6") - ReadInstallInfItem(install_inf, "netmask", "Netmask") - ReadInstallInfItem(install_inf, "bcast", "Broadcast") - ReadInstallInfItem(install_inf, "remote_ip", "Pointopoint") - ReadInstallInfItem(install_inf, "mtu", "IP_MTU") - ReadInstallInfItem(install_inf, "bootproto", "NetConfig") - ReadInstallInfItem(install_inf, "netdevice", "Netdevice") - ReadInstallInfItem(install_inf, "gateway", "Gateway") - ReadInstallInfItem(install_inf, "nameserver", "Nameserver") - ReadInstallInfItem(install_inf, "nameserver2", "Nameserver2") - ReadInstallInfItem(install_inf, "nameserver3", "Nameserver3") - ReadInstallInfItem(install_inf, "domain", "Domain") - ReadInstallInfItem(install_inf, "nisdomain", "NISDomain") - ReadInstallInfItem(install_inf, "hostname", "Hostname") - ReadInstallInfItem(install_inf, "module", "Alias") - ReadInstallInfItem(install_inf, "proxyUrl", "ProxyUrl") - ReadInstallInfItem(install_inf, "proxyProto", "ProxyProto") - # ReadInstallInfItem(install_inf, "options", "Options"); - # OSAHwAddr parameter s390 - ReadInstallInfItem(install_inf, "hwaddr", "HWAddr") - ReadInstallInfItem(install_inf, "ethtool_options", "ethtool") - ReadInstallInfItem(install_inf, "unique", "NetUniqueID") - ReadInstallInfItem(install_inf, "connect_wait", "ConnectWait") - - ReadInstallInfItem(install_inf, "QETH_LAYER2_SUPPORT", "Layer2") - # ReadInstallInfItem(install_inf, "LLADDR", "OSAHWAddr"); - ReadInstallInfItem(install_inf, "dhcptimeout", "DHCPTimeout") - - ReadInstallInfItem(install_inf, "WESSID", "WlanESSID") - ReadInstallInfItem(install_inf, "WAuth", "WlanAuth") - ReadInstallInfItem(install_inf, "WKey", "WlanKey") - ReadInstallInfItem(install_inf, "WkeyType", "WlanKeyType") - ReadInstallInfItem(install_inf, "WkeyLen", "WlanKeyLen") - - - # Split network device - @netdevice = Ops.get_string(@InstallInf, "netdevice", "") - Builtins.y2milestone("InstallInf::netdevice:%1", @netdevice) - if Mode.autoinst - # if possible, for temporary installation network use same device - # with same MAC address (even if devicename changed) (bnc#648270) - new_devname = LanUdevAuto.GetDevnameByMAC( - Ops.get_string(@InstallInf, "hwaddr", "") - ) - Builtins.y2milestone("LanUdevAuto::netdevice:%1", new_devname) - if Ops.greater_than(Builtins.size(new_devname), 0) - Builtins.y2milestone( - "old devname: %1, new devname: %2", - @netdevice, - new_devname - ) - @netdevice = new_devname - end - end - if @netdevice != "" - devtype = NetworkInterfaces.device_type(@netdevice) - Ops.set(@InstallInf, "type", devtype) if devtype != nil && devtype != "" - # InstallInf = remove(InstallInf, "netdevice"); - end - - if Arch.s390 - Builtins.y2milestone( - "Interface type: %1", - Ops.get_string(@InstallInf, "type", "") - ) - # only some card types need a persistent MAC (bnc#658708) - sysfs_id = dev_name_to_sysfs_id(@netdevice, @hardware) - if !s390_device_needs_persistent_mac(sysfs_id, @hardware) - @InstallInf = Builtins.remove(@InstallInf, "hwaddr") - end - # hsi devices do not support setting hwaddr (bnc #479481) - if Ops.get_string(@InstallInf, "type", "") == "hsi" && - Builtins.haskey(@InstallInf, "hwaddr") - @InstallInf = Builtins.remove(@InstallInf, "hwaddr") - end - # set HW address only for qeth set to Layer 2 (bnc #479481) - if Ops.get_string(@InstallInf, "type", "") == "eth" && - Ops.get_string(@InstallInf, "QETH_LAYER2_SUPPORT", "0") != "1" - @InstallInf = Builtins.remove(@InstallInf, "hwaddr") - end - end - - # Split FQ hostname - hostname = Ops.get_string(@InstallInf, "hostname", "") - if hostname != "" && !IP.Check(hostname) - split = Hostname.SplitFQ(hostname) - - # hostname is supposed to be FQDN (http://en.opensuse.org/Linuxrc) - # so we should not cut off domain name ... anyway remember domain, - # use it as fallback below, if there is no DNS search domain (#476208) - if Ops.greater_than(Builtins.size(split), 1) - Ops.set(@InstallInf, "fqdomain", Ops.get_string(split, 1, "")) - end - else - # do not have numeric hostname, #152218 - Ops.set(@InstallInf, "hostname", "") end - - # #180821, todo cleanup - if @netdevice != "" - mod = Convert.to_string( - SCR.Read(Builtins.add(path(".etc.install_inf_alias"), @netdevice)) - ) - if mod != "" && mod != nil - Ops.set(@InstallInf, "module", mod) - options = Convert.to_string( - SCR.Read(Builtins.add(path(".etc.install_inf_options"), mod)) - ) - if options != "" && options != nil - Ops.set(@InstallInf, "options", options) - end - end - else - # FIXME: alias = eth0 tulip - # FIXME: options = ne io=0x200 - - # #42203: correctly parse module and options for proposal - # "eth0 qeth" -> "qeth" - # FIXME: this only works for a single module - mod = Ops.get_string(@InstallInf, "module", "") - Ops.set(@InstallInf, "module", DeleteFirstWord(mod)) if mod != "" - - options = Ops.get_string(@InstallInf, "options", "") - if options != "" - Ops.set(@InstallInf, "options", DeleteFirstWord(options)) - end - end - - Builtins.y2milestone("InstallInf(%1)", @InstallInf) - true - end - - - # Read module options from /etc/install.inf - # @param [String] module_name Module name - # @return module options, empty string if none - def InstallModuleOptions(module_name) - if Ops.greater_than(SCR.Read(path(".target.size"), "/etc/install.inf"), 0) - modules = SCR.Dir(path(".etc.install_inf_options")) - Builtins.y2milestone( - "Module with options in /etc/install.inf: %1", - modules - ) - if Builtins.contains(modules, module_name) - options = SCR.Read( - Builtins.add(path(".etc.install_inf_options"), module_name) - ) - return Convert.to_string(options) if options != nil && options != "" - end - end - "" - end - - def StdoutOf(command) - out = Convert.to_map(SCR.Execute(path(".target.bash_output"), command)) - Ops.get_string(out, "stdout", "") - end - - def CreateIfcfg - ifcfg = "" - - if @network_disk == :iscsi && - Builtins.contains( - NetworkStorage.getiBFTDevices, - Ops.get_string(@InstallInf, "netdevice", "") - ) - ifcfg = Builtins.sformat( - "%1STARTMODE='nfsroot'\nBOOTPROTO='ibft'\n", - ifcfg - ) - else - # set BOOTPROTO=[ static | dhcp ] - if Ops.get_string(@InstallInf, "bootproto", "dhcp") == "static" - # add broadcast interface #suse49131 - ifcfg = Builtins.sformat( - "BOOTPROTO='static'\n" + - "IPADDR='%1/%2'\n" + - "BROADCAST='%3'\n", - Ops.get_string(@InstallInf, "ipaddr", ""), - Netmask.ToBits(Ops.get_string(@InstallInf, "netmask", "")), - Ops.get_string(@InstallInf, "bcast", "") - ) - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "ipaddr6", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1\n%2", - ifcfg, - Builtins.sformat( - "LABEL_ipv6='ipv6'\nIPADDR_ipv6='%1'\n", - Ops.get_string(@InstallInf, "ipaddr6", "") - ) - ) - end - else - #DHCP (also for IPv6) setup - if Ops.get_string(@InstallInf, "bootproto", "") == "dhcp" - ifcfg = "BOOTPROTO='dhcp4'\n" - elsif Ops.get_string(@InstallInf, "bootproto", "") == "dhcp6" - ifcfg = "BOOTPROTO='dhcp6'\n" - elsif Ops.get_string(@InstallInf, "bootproto", "") == "dhcp,dhcp6" - ifcfg = "BOOTPROTO='dhcp'\n" - end - - # set DHCP_SET_HOSTNAME=yes #suse30528 - Builtins.y2milestone( - "set DHCLIENT_SET_HOSTNAME=yes on installed system" - ) - SCR.Execute( - path(".target.bash_output"), - "sed -i s/\"DHCLIENT_SET_HOSTNAME=.*\"/'DHCLIENT_SET_HOSTNAME=\"yes\"'/g /etc/sysconfig/network/dhcp" - ) - end - - if @network_disk == :no - ifcfg = Builtins.sformat("%1STARTMODE='onboot'\n", ifcfg) - else - ifcfg = Builtins.sformat("%1STARTMODE='nfsroot'\n", ifcfg) - end - end - - # wireless devices (bnc#223570) - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "WESSID", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1WIRELESS_ESSID='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "WESSID", "") - ) - - case Ops.get_string(@InstallInf, "WAuth", "") - when "", "psk" - ifcfg = Builtins.sformat( - "%1WIRELESS_WPA_PSK='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "WKey", "") - ) - ifcfg = Builtins.sformat("%1WIRELESS_AUTH_MODE='psk'\n", ifcfg) - when "open" - ifcfg = Builtins.sformat( - "%1WIRELESS_AUTH_MODE='no-encryption'\n", - ifcfg - ) - when "wep_open", "wep_restricted" - @type = "" - if Ops.get_string(@InstallInf, "WkeyType", "") == "password" - @type = "h:" - elsif Ops.get_string(@InstallInf, "WkeyType", "") == "ascii" - @type = "s:" - end - ifcfg = Builtins.sformat( - "%1WIRELESS_AUTH_MODE='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "WAuth", "") == "wep-open" ? "open" : "sharedkey" - ) - ifcfg = Builtins.sformat("%1WIRELESS_DEFAULT_KEY='0'\n", ifcfg) - ifcfg = Builtins.sformat( - "%1WIRELESS_KEY_0='%2%3'\n", - ifcfg, - @type, - Ops.get_string(@InstallInf, "WKey", "") - ) - ifcfg = Builtins.sformat( - "%1WIRELESS_KEY_LENGTH='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "WKeyLen", "") - ) - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "WKeyType", "")), - 0 - ) && - Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "WKey", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1WIRELESS_KEY_0='%2:%3'\n", - ifcfg, - Builtins.substring( - Ops.get_string(@InstallInf, "WKeyType", ""), - 0, - 1 - ), - Ops.get_string(@InstallInf, "WKey", "") - ) - end - end - end - - # if available, write MTU - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "mtu", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1MTU='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "mtu", "") - ) - end - - # for queth devices (s390) - # bnc#578689 - YaST2 should not write the MAC address into ifcfg file - if Arch.s390 && - Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "hwaddr", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1LLADDR='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "hwaddr", "") - ) - end - - # point to point interface - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "remote_ip", "")), - 0 - ) - ifcfg = Builtins.sformat( - "%1REMOTE_IPADDR='%2'\n", - ifcfg, - Ops.get_string(@InstallInf, "remote_ip", "") - ) - end - - new_netdevice = @netdevice - if !LanUdevAuto.AllowUdevModify - # bnc#821427: use same options as in /lib/udev/rules.d/71-biosdevname.rules - cmd = Builtins.sformat( - "biosdevname --policy physical --smbios 2.6 --nopirq -i %1", - @netdevice - ) - out = String.FirstChunk(StdoutOf(cmd), "\n") - if out != "" - Builtins.y2milestone("biosdevname renames %1 to %2", @netdevice, out) - new_netdevice = out - end - end - - ifcfg_name = Builtins.sformat("ifcfg-%1", new_netdevice) - - hw_name = BuildDescription( - NetworkInterfaces.device_type(@netdevice), - NetworkInterfaces.device_num(ifcfg_name), - { "dev_name" => @netdevice }, - @hardware - ) - # protect special characters, #305343 - if Ops.greater_than(Builtins.size(hw_name), 0) - ifcfg = Builtins.sformat("%1NAME='%2'\n", ifcfg, String.Quote(hw_name)) - end - - Builtins.y2milestone( - "Network Configuration:\n%1\nifcfg file: %2", - ifcfg, - ifcfg_name - ) - - # write only if file doesn't exists - dev_file = Builtins.sformat("/etc/sysconfig/network/%1", ifcfg_name) - - SCR.Write(path(".target.string"), dev_file, ifcfg) - Builtins.y2milestone("ifcfg file: %1", dev_file) + # EOF nil end - # create all network files except ifcfg and hwcfg - # directly to installed system - - def CreateOtherNetworkFiles - # create hostname - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "hostname", "")), - 0 - ) - Builtins.y2milestone( - "Write HOSTNAME: %1", - Ops.get_string(@InstallInf, "hostname", "") - ) - SCR.Write( - path(".target.string"), - "/etc/HOSTNAME", - Ops.get_string(@InstallInf, "hostname", "") - ) - end - - if Ops.get_string(@InstallInf, "bootproto", "dhcp") == "static" - # create routes file - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "gateway", "")), - 0 - ) - Builtins.y2milestone( - "Writing route : %1", - Ops.get_string(@InstallInf, "gateway", "") - ) - SCR.Write( - path(".target.string"), - "/etc/sysconfig/network/routes", - Builtins.sformat( - "default %1 - -\n", - Ops.get_string(@InstallInf, "gateway", "") - ) - ) - elsif Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "remote_ip", "")), - 0 - ) - Builtins.y2milestone( - "Writing Peer-to-Peer route: %1", - Ops.get_string(@InstallInf, "remote_ip", "") - ) - SCR.Write( - path(".target.string"), - "/etc/sysconfig/network/routes", - Builtins.sformat( - "default %1 - -\n", - Ops.get_string(@InstallInf, "remote_ip", "") - ) - ) - else - Builtins.y2warning("No routing information in install.inf") - end - - # write DHCPTimeout linuxrc parameter as /etc/sysconfig/network/config.WAIT_FOR_INTERFACES (bnc#396824) - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "dhcptimeout", "")), - 0 - ) - SCR.Write( - path(".sysconfig.network.config.WAIT_FOR_INTERFACES"), - Ops.get_string(@InstallInf, "dhcptimeout", "") - ) - Builtins.y2milestone( - "Writing WAIT_FOR_INTERFACES=%1", - Ops.get_string(@InstallInf, "dhcptimeout", "") - ) - end - - - # create resolv.conf only for static configuration - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "nameserver", "")), - 0 - ) - serverlist = Ops.get_string(@InstallInf, "nameserver", "") - # write also secondary and third nameserver when available (bnc#446101) - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "nameserver2", "")), - 0 - ) - serverlist = Builtins.sformat( - "%1 %2", - serverlist, - Ops.get_string(@InstallInf, "nameserver2", "") - ) - end - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "nameserver3", "")), - 0 - ) - serverlist = Builtins.sformat( - "%1 %2", - serverlist, - Ops.get_string(@InstallInf, "nameserver3", "") - ) - end - #Do not write /etc/resolv.conf directly, feed the data to sysconfig instead, - #'netconfig' will do the job later on network startup (FaTE #303618) - SCR.Write( - path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS"), - serverlist - ) - Builtins.y2milestone( - "Writing static nameserver entry: %1", - Ops.get_string(@InstallInf, "nameserver", "") - ) - - #Enter search domain data only if present - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "domain", "")), - 0 - ) - SCR.Write( - path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST"), - Ops.get_string(@InstallInf, "domain", "") - ) - Builtins.y2milestone( - "Writing static searchlist entry: %1", - Ops.get_string(@InstallInf, "domain", "") - ) - elsif Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "fqdomain", "")), - 0 - ) - SCR.Write( - path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST"), - Ops.get_string(@InstallInf, "fqdomain", "") - ) - Builtins.y2milestone( - "No DNS search domain defined, using FQ domain name %1 as a fallback", - Ops.get_string(@InstallInf, "fqdomain", "") - ) - end - - #We're done. It is OK not to touch NETCONFIG_DNS_POLICY now as it is set to 'auto' by default - #and user did not have a chance to modify it up to now - SCR.Write(path(".sysconfig.network.config"), nil) - end - end - - # create proxy sysconfig file - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "proxyProto", "")), - 0 - ) && - Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "proxyUrl", "")), - 0 - ) - Builtins.y2milestone( - "Writing proxy settings: %1", - Ops.get_string(@InstallInf, "proxyUrl", "") - ) - - Proxy.Read - ex = Proxy.Export - - # bnc#693640 - update Proxy module's configuration - # username and password is stored in url because it is handled by linuxrc this way and it is impossible - # to distinguish how the user inserted it (separate or as a part of url?) - Ops.set( - ex, - Ops.add(Ops.get_string(@InstallInf, "proxyProto", ""), "_proxy"), - Ops.get_string(@InstallInf, "proxyUrl", "") - ) + def adjust_for_network_disks(file) + # known net devices: `nfs `iscsi `fcoe + device = NetworkStorage.getDevice(Installation.destdir) + network_disk = NetworkStorage.isDiskOnNetwork(device) - Proxy.Import(ex) - Proxy.Write + log.info("Network based device: #{network_disk}") - Builtins.y2debug("Written proxy settings: %1", ex) - end - # create defaultdomain - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "nisdomain", "")), - 0 - ) && - FileUtils.Exists("/etc/defaultdomain") - Builtins.y2milestone( - "Write defaultdomain: %1", - Ops.get_string(@InstallInf, "nisdomain", "") - ) - SCR.Write( - path(".target.string"), - "/etc/defaultdomain", - Ops.get_string(@InstallInf, "nisdomain", "") + # overwrite configuration created during network setup e.g. in InstInstallInfClient + if network_disk == :iscsi && + NetworkStorage.getiBFTDevices.include?( + InstallInfConvertor::InstallInf["Netdevice"] ) - end - - # write wait_for_interfaces if needed - if Ops.greater_than( - Builtins.size(Ops.get_string(@InstallInf, "connect_wait", "")), - 0 + SCR.Execute( + path(".target.bash"), + "sed -i s/STARTMODE.*/STARTMODE='nfsroot'/ #{file}" ) SCR.Execute( - path(".target.bash_output"), - Builtins.sformat( - "sed -i s/^WAIT_FOR_INTERFACES=.*/WAIT_FOR_INTERFACES=%1/g /etc/sysconfig/network/config", - Ops.get_string(@InstallInf, "connect_wait", "") - ) + path(".target.bash"), + "sed -i s/BOOTPROTO.*/BOOTPROTO='ibft'/ #{file}" ) end - - nil end def CopyConfiguredNetworkFiles @@ -703,6 +99,10 @@ # just copy files Builtins.foreach(["ifcfg-*", "ifroute-*", "routes"]) do |file| + if file.include?("ifcfg-") + adjust_for_network_disks("#{sysconfig}/#{file}") + end + copy_from = String.Quote(Builtins.sformat("%1%2", sysconfig, file)) Builtins.y2milestone("Copy %1 into %2", copy_from, copy_to) cmd = Builtins.sformat("cp %1 %2", copy_from, copy_to) @@ -765,9 +165,6 @@ Installation.destdir, device ) - @network_disk = NetworkStorage.isDiskOnNetwork(device) - Builtins.y2milestone("Network based device: %1", @network_disk) - if Arch.s390 Builtins.y2milestone( @@ -854,11 +251,7 @@ Builtins.y2milestone("Not copying file %1 - it already exists", net_destfile) end - if ReadInstallInf() - CopyConfiguredNetworkFiles() - else - Builtins.y2error("Error while reading install.inf!") - end + CopyConfiguredNetworkFiles() # close and chroot back WFM.SCRSetDefault(old_SCR) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/src/lib/network/install_inf_convertor.rb new/yast2-network-3.1.29/src/lib/network/install_inf_convertor.rb --- old/yast2-network-3.1.23/src/lib/network/install_inf_convertor.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.29/src/lib/network/install_inf_convertor.rb 2014-02-28 17:03:50.000000000 +0100 @@ -0,0 +1,403 @@ +require "yast" + + +module Yast + + class InstallInfConvertor + include Singleton + include Logger + include Yast # for path shortcuts + include I18n # for textdomain + + BASH_PATH = Path.new(".target.bash") + + class InstallInf + INSTALL_INF = Path.new(".etc.install_inf") + + def self.[](item) + SCR.Read(INSTALL_INF + Path.new(".#{item}")).to_s + end + end + + def initialize + Yast.import "Hostname" + Yast.import "IP" + Yast.import "NetworkInterfaces" + Yast.import "FileUtils" + Yast.import "Netmask" + Yast.import "NetworkStorage" + Yast.import "Proxy" + Yast.import "Installation" + Yast.import "String" + Yast.import "Mode" + Yast.import "Arch" + Yast.import "LanUdevAuto" + + Yast.include self, "network/routines.rb" + Yast.include self, "network/complex.rb" + end + + def write_netconfig + write_ifcfg(create_ifcfg) + write_global_netconfig + end + + private + + def create_ifcfg + ifcfg = "" + + # set BOOTPROTO=[ static | dhcp ], linuxrc names it "NetConfig" + bootproto = InstallInf["NetConfig"] + case bootproto + when "static" + # add broadcast interface #suse49131 + ifcfg << "BOOTPROTO='static'\n" + ifcfg << "IPADDR='%s/%s'\n" % [ + InstallInf["IP"], + Netmask.ToBits(InstallInf["Netmask"]) + ] + ifcfg << "BROADCAST='%s'\n" % InstallInf["Broadcast"] + + ip6_addr = InstallInf["IP6"] + if !ip6_addr.empty? + ifcfg << "LABEL_ipv6='ipv6'\n" + ifcfg << "IPADDR_ipv6='#{ip6_addr}'\n" + end + + when "dhcp" + ifcfg << "BOOTPROTO='dhcp4'\n" + + when "dhcp6" + ifcfg << "BOOTPROTO='dhcp6'\n" + + when "dhcp,dhcp6" + ifcfg << "BOOTPROTO='dhcp'\n" + end + + # set DHCP_SET_HOSTNAME=yes #suse30528 + if bootproto =~ /dhcp/ + log.info("set DHCLIENT_SET_HOSTNAME=yes on installed system") + SCR.Execute( + BASH_PATH, + "sed -i s/\"DHCLIENT_SET_HOSTNAME=.*\"/'DHCLIENT_SET_HOSTNAME=\"yes\"'/g /etc/sysconfig/network/dhcp" + ) + end + + ifcfg << "STARTMODE='onboot'\n" + + # wireless devices (bnc#223570) + ifcfg << create_wlan_ifcfg + + # if available, write MTU + mtu = InstallInf["IP_MTU"] + ifcfg << "MTU='#{mtu}'\n" if !mtu.empty? + + # for qeth devices (s390) + # bnc#578689 - YaST2 should not write the MAC address into ifcfg file + hardware = ReadHardware("netcard") + log.info("hardware: #{hardware}") + + ifcfg << create_s390_ifcfg(hardware) if Arch.s390 + + # point to point interface + remote_ip = InstallInf["Pointopoint"] + ifcfg << "REMOTE_IPADDR='#{remote_ip}'\n" if !remote_ip.empty? + + ifcfg << create_device_name_ifcfg(hardware) + + log.info("Network Configuration:\n#{ifcfg}") + + ifcfg + end + + # create all network files except ifcfg and hwcfg + # directly to installed system + def write_global_netconfig + # create hostname + write_hostname + + if InstallInf["NetConfig"] == "static" + write_gateway + + # write DHCPTimeout linuxrc parameter as /etc/sysconfig/network/config.WAIT_FOR_INTERFACES (bnc#396824) + write_dhcp_timeout + + # create resolv.conf only for static configuration + write_dns + end + + # create proxy sysconfig file + write_proxy + + # create defaultdomain + write_nis_domain + + # write wait_for_interfaces if needed + write_connect_wait + + nil + end + + def write_dhcp_timeout + dhcp_timeout = InstallInf["DHCPTimeout"].to_s + + return false if dhcp_timeout.empty? + + log.info("Writing WAIT_FOR_INTERFACES=#{dhcp_timeout}") + SCR.Write(path(".sysconfig.network.config.WAIT_FOR_INTERFACES"), dhcp_timeout) + end + + def write_gateway + gateway = InstallInf["Gateway"].to_s + ptp = InstallInf["Pointopoint"].to_s + + # create routes file + if !gateway.empty? + log.info("Writing route : #{gateway}") + return SCR.Write( + path(".target.string"), + "/etc/sysconfig/network/routes", + "default #{gateway} - -\n") + elsif !ptp.empty? + log.info("Writing Peer-to-Peer route: #{ptp}") + return SCR.Write( + path(".target.string"), + "/etc/sysconfig/network/routes", + "default #{ptp} - -\n" + ) + else + log.warn("No routing information in install.inf") + return false + end + end + + def hostname + hostname = InstallInf["Hostname"].to_s + + # do not have numeric hostname, #152218 + return "" if hostname.empty? || IP.Check(hostname) + return hostname + end + + def write_hostname + return false if hostname.empty? + + log.info("Write HOSTNAME: #{hostname}") + SCR.Write(path(".target.string"), "/etc/HOSTNAME", hostname) + end + + def write_dns + nameserver = InstallInf["Nameserver"].to_s + + return false if nameserver.empty? + + # hostname is supposed to be FQDN (http://en.opensuse.org/Linuxrc) + # remember domain, use it as fallback below, if there is no DNS search + # domain (#476208) + split = Hostname.SplitFQ(hostname) if !hostname.empty? && !IP.Check(hostname) + fqdomain = "" + fqdomain = split[1].to_s if split + + serverlist = nameserver + # write also secondary and third nameserver when available (bnc#446101) + nameserver2 = InstallInf["Nameserver2"].to_s + serverlist << " " << nameserver2 if !nameserver2.empty? + + nameserver3 = InstallInf["Nameserver3"].to_s + serverlist << " " << nameserver3 if !nameserver3.empty? + + # Do not write /etc/resolv.conf directly, feed the data to sysconfig instead, + # 'netconfig' will do the job later on network startup (FaTE #303618) + SCR.Write( + path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS"), + serverlist + ) + log.info("Writing static nameserver entry: #{nameserver}") + + # Enter search domain data only if present + domain = InstallInf["Domain"].to_s + if !domain.empty? + SCR.Write( + path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST"), + domain + ) + log.info("Writing static searchlist entry: #{domain}") + elsif !fqdomain.empty? + SCR.Write( + path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SEARCHLIST"), + fqdomain + ) + log.info("No DNS search domain defined, using FQ domain name #{fqdomain} as a fallback") + end + + #We're done. It is OK not to touch NETCONFIG_DNS_POLICY now as it is set to 'auto' by default + #and user did not have a chance to modify it up to now + SCR.Write(path(".sysconfig.network.config"), nil) + end + + def write_proxy + proxyUrl = InstallInf["ProxyUrl"].to_s + proxyProto = InstallInf["ProxyProto"].to_s + + return false if proxyProto.empty? || proxyUrl.empty? + + log.info("Writing proxy settings: #{proxyProto}_proxy = '#{proxyUrl}'") + + Proxy.Read + ex = Proxy.Export + + # bnc#693640 - update Proxy module's configuration + # username and password is stored in url because it is handled by linuxrc this way and it is impossible + # to distinguish how the user inserted it (separate or as a part of url?) + ex["#{proxyProto}_proxy"] = proxyUrl if ex + log.debug("Written proxy settings: #{ex}") + + Proxy.Import(ex) + Proxy.Write + end + + def write_nis_domain + nisdomain = InstallInf["NISDomain"].to_s + + return false if nisdomain.empty? || !FileUtils.Exists("/etc/defaultdomain") + + log.info("Write defaultdomain: #{nisdomain}") + SCR.Write(path(".target.string"), "/etc/defaultdomain", nisdomain) + end + + def write_connect_wait + connect_wait = InstallInf["ConnectWait"].to_s + + return false if connect_wait.empty? + + ret = SCR.Execute( + BASH_PATH, + "sed -i s/^WAIT_FOR_INTERFACES=.*/WAIT_FOR_INTERFACES=%s/g /etc/sysconfig/network/config" % connect_wait + ) + + return ret == 0 + end + + def dev_name + netdevice = InstallInf["Netdevice"].to_s + + if Mode.autoinst + # if possible, for temporary installation network use same device + # with same MAC address (even if devicename changed) (bnc#648270) + new_devname = LanUdevAuto.GetDevnameByMAC(InstallInf["HWAddr"]) + + netdevice = new_devname if !new_devname.empty? + end + + log.info("InstInstallInfClient#dev_name:#{netdevice}") + return netdevice + end + + def stdout_of(command) + SCR.Execute(path(".target.bash_output"), command)["stdout"].to_s + end + + def create_wlan_ifcfg + wlan_key = InstallInf["WlanKey"] + wlan_essid = InstallInf["WlanESSID"] + wlan_key_type = InstallInf["WlanKeyType"] + wlan_auth = InstallInf["WlanAuth"] + wlan_key_len = InstallInf["WlanKeyLen"] + + return "" if wlan_essid.empty? + + ifcfg = "WIRELESS_ESSID='#{wlan_essid}'\n" + + case wlan_auth + when "", "psk" + ifcfg << "WIRELESS_WPA_PSK='#{wlan_key}'\n" + ifcfg << "WIRELESS_AUTH_MODE='psk'\n" + + when "open" + ifcfg << "WIRELESS_AUTH_MODE='no-encryption'\n" + + when "wep_open", "wep_restricted" + if wlan_key_type == "password" + type = "h:" + elsif wlan_key_type == "ascii" + type = "s:" + else + type = wlan_key_type[0] + ":" + end + + auth_mode = wlan_auth == "wep-open" ? "open" : "sharedkey" + + ifcfg << "WIRELESS_AUTH_MODE='%s'\n" % wlan_auth_mode + ifcfg << "WIRELESS_DEFAULT_KEY='0'\n" + ifcfg << "WIRELESS_KEY_0='#{type}#{wlan_key}'\n" + ifcfg << "WIRELESS_KEY_LENGTH='#{wlan_key_len}'\n" + end + + return ifcfg + end + + def create_s390_ifcfg(hardware) + hwaddr = InstallInf["HWAddr"] + return "" if hwaddr.empty? + + netdevice = dev_name + return "" if netdevice.empty? + + devtype = NetworkInterfaces.GetType(netdevice) + + log.info("Interface type: #{devtype}") + + # only some card types need a persistent MAC (bnc#658708) + sysfs_id = dev_name_to_sysfs_id(netdevice, hardware) + return "" if !s390_device_needs_persistent_mac(sysfs_id, hardware) + + # hsi devices do not support setting hwaddr (bnc #479481) + return "" if devtype == "hsi" + + # set HW address only for qeth set to Layer 2 (bnc #479481) + return "" if devtype == "eth" && InstallInf["QETH_LAYER2_SUPPORT"] != "1" + + return "LLADDR='#{hwaddr}'\n" + end + + def create_device_name_ifcfg(hardware) + device_name = dev_name + + hw_name = BuildDescription( + NetworkInterfaces.device_type(device_name), + NetworkInterfaces.device_num(device_name), + { "dev_name" => device_name }, + hardware + ) + + return "" if hw_name.empty? + + # protect special characters, #305343 + return "NAME='%s'\n" % String.Quote(hw_name) + end + + def write_ifcfg(ifcfg) + device_name = dev_name + + return false if device_name.empty? + + if !LanUdevAuto.AllowUdevModify + # bnc#821427: use same options as in /lib/udev/rules.d/71-biosdevname.rules + cmd = "biosdevname --policy physical --smbios 2.6 --nopirq -i %s" % dev_name + out = String.FirstChunk(stdout_of(cmd), "\n") + if !out.empty? + device_name = out + log.info("biosdevname renames #{dev_name} to #{device_name}") + end + end + + dev_file = "/etc/sysconfig/network/ifcfg-#{device_name}" + + log.info("ifcfg file: #{dev_file}") + SCR.Write(path(".target.string"), dev_file, ifcfg) + end + + end + +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/test/Makefile.am new/yast2-network-3.1.29/test/Makefile.am --- old/yast2-network-3.1.23/test/Makefile.am 2014-02-19 16:33:34.000000000 +0100 +++ new/yast2-network-3.1.29/test/Makefile.am 2014-02-28 17:03:50.000000000 +0100 @@ -5,7 +5,8 @@ bridge_test.rb \ routing_test.rb \ new_device_startmode_test.rb \ - widgets_test.rb + widgets_test.rb \ + install_inf_convertor_test.rb TEST_EXTENSIONS = .rb RB_LOG_COMPILER = rspec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-network-3.1.23/test/install_inf_convertor_test.rb new/yast2-network-3.1.29/test/install_inf_convertor_test.rb --- old/yast2-network-3.1.23/test/install_inf_convertor_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-network-3.1.29/test/install_inf_convertor_test.rb 2014-02-28 17:03:50.000000000 +0100 @@ -0,0 +1,199 @@ +#!/usr/bin/env rspec + +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +require "yast" +require "network/install_inf_convertor" +include Yast # for path shortcut and avoid namespace + +describe "InstallInfConvertor" do + + context "in case of no network config in /etc/install.inf" do + + before(:each) do + @install_inf_convertor = Yast::InstallInfConvertor.instance + + expect(Yast::InstallInfConvertor::InstallInf) + .to receive(:[]) + .at_least(:once) { nil } + end + + describe "#write_dhcp_timeout" do + it "returns false" do + expect(@install_inf_convertor.send(:write_dhcp_timeout)).to be_false + end + end + + describe "#hostname" do + it "returns empty string" do + expect(@install_inf_convertor.send(:hostname)).to be_empty + end + end + + describe "#write_hostname" do + it "returns false" do + expect(@install_inf_convertor.send(:write_hostname)).to be_false + end + end + + describe "#write_dns" do + it "returns false" do + expect(@install_inf_convertor.send(:write_dns)).to be_false + end + end + + describe "#write_proxy" do + it "returns false" do + expect(@install_inf_convertor.send(:write_proxy)).to be_false + end + end + + describe "#write_nis_domain" do + it "returns false" do + expect(@install_inf_convertor.send(:write_nis_domain)).to be_false + end + end + + describe "#write_connect_wait" do + it "returns false" do + expect(@install_inf_convertor.send(:write_connect_wait)).to be_false + end + end + + describe "#dev_name" do + it "returns empty string" do + expect(@install_inf_convertor.send(:dev_name)).to be_empty + end + + it "returns empty string even in autoinst mode" do + Yast.import "Mode" + Mode.stub(:autoinst) { true } + + expect(@install_inf_convertor.send(:dev_name)).to be_empty + end + end + + describe "#write_ifcfg" do + it "returns false when attempting to write nil content" do + expect(@install_inf_convertor.send(:write_ifcfg, nil)).to eql false + end + + it "returns false even when written content is not nil" do + expect(@install_inf_convertor.send(:write_ifcfg, "STARTMODE='onboot'\n")).to eql false + end + end + end + + context "linuxrc provides dhcp configuration" do + + before(:each) do + @device = "enp0s3" + @netconfig = "dhcp" + + @install_inf_convertor = Yast::InstallInfConvertor.instance + + Yast::InstallInfConvertor::InstallInf + .stub(:[]) { "" } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("Netdevice") { @device } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("NetConfig") { @netconfig } + end + + describe "#dev_name" do + it "returns expected device name" do + expect(@install_inf_convertor.send(:dev_name)).to eql @device + end + end + + describe "#write_ifcfg" do + it "creates ifcfg file for #{@device}" do + expect(SCR) + .to receive(:Write) + .with(path(".target.string"), /.*-#{@device}/, "") { true } + expect(@install_inf_convertor.send(:write_ifcfg, "")).to eql true + end + end + + describe "#create_ifcfg" do + it "creates a valid ifcfg for netconfig" do + expect(ifcfg = @install_inf_convertor.send(:create_ifcfg)).not_to be_empty + expect(ifcfg).to match /BOOTPROTO='dhcp4'/ + expect(ifcfg).to match /STARTMODE='onboot'/ + expect(ifcfg).to match /NAME='.*'/ + end + end + end + + context "linuxrc provides static configuration" do + + before(:each) do + Yast.import "Netmask" + + @device = "enp0s3" + @ip = "10.121.157.133" + @netmask = "255.255.240.0" + @netconfig = "static" + @nameserver = "10.120.0.1" + + @install_inf_convertor = Yast::InstallInfConvertor.instance + + Yast::InstallInfConvertor::InstallInf + .stub(:[]) { "" } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("Netdevice") { @device } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("NetConfig") { @netconfig } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("IP") { @ip } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("Netmask") { @netmask } + Yast::InstallInfConvertor::InstallInf + .stub(:[]) + .with("Nameserver") { @nameserver } + end + + describe "#create_ifcfg" do + it "creates a valid ifcfg for netconfig" do + expect(ifcfg = @install_inf_convertor.send(:create_ifcfg)).not_to be_empty + expect(ifcfg).to match /BOOTPROTO='static'/ + expect(ifcfg).to match /IPADDR='#{@ip}\/#{Netmask.ToBits(@netmask)}'/ + end + end + + describe "#write_global_netconfig" do + it "writes all expected configuration" do + expect(@install_inf_convertor) + .to receive(:write_dns) + expect(@install_inf_convertor.send(:write_global_netconfig)) + .to eql nil + end + end + + describe "#write_dns" do + it "updates global netconfig file" do + expect(Yast::SCR) + .to receive(:Write) + .with( + path(".sysconfig.network.config"), + nil + ) { true } + expect(Yast::SCR) + .to receive(:Write) + .with( + path(".sysconfig.network.config.NETCONFIG_DNS_STATIC_SERVERS"), + @nameserver + ).once { true } + expect(@install_inf_convertor.send(:write_dns)).to eql true + end + end + + end + +end -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org