Hello community,

here is the log from the commit of package autoyast2 for openSUSE:Factory 
checked in at 2016-03-29 09:54:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/autoyast2 (Old)
 and      /work/SRC/openSUSE:Factory/.autoyast2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "autoyast2"

Changes:
--------
--- /work/SRC/openSUSE:Factory/autoyast2/autoyast2.changes      2016-03-16 
10:25:11.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.autoyast2.new/autoyast2.changes 2016-03-29 
09:54:34.000000000 +0200
@@ -1,0 +2,7 @@
+Thu Mar 10 08:33:33 UTC 2016 - [email protected]
+
+- Evaluate the correct domain, network, product and product version
+  when applying rules (bnc#963137).
+- 3.1.119
+
+-------------------------------------------------------------------

Old:
----
  autoyast2-3.1.118.tar.bz2

New:
----
  autoyast2-3.1.119.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ autoyast2.spec ++++++
--- /var/tmp/diff_new_pack.l5YBQZ/_old  2016-03-29 09:54:35.000000000 +0200
+++ /var/tmp/diff_new_pack.l5YBQZ/_new  2016-03-29 09:54:35.000000000 +0200
@@ -18,7 +18,7 @@
 
 Name:           autoyast2
 
-Version:        3.1.118
+Version:        3.1.119
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build

++++++ autoyast2-3.1.118.tar.bz2 -> autoyast2-3.1.119.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/package/autoyast2.changes 
new/autoyast2-3.1.119/package/autoyast2.changes
--- old/autoyast2-3.1.118/package/autoyast2.changes     2016-03-09 
10:33:25.000000000 +0100
+++ new/autoyast2-3.1.119/package/autoyast2.changes     2016-03-16 
13:05:06.000000000 +0100
@@ -1,4 +1,11 @@
 -------------------------------------------------------------------
+Thu Mar 10 08:33:33 UTC 2016 - [email protected]
+
+- Evaluate the correct domain, network, product and product version
+  when applying rules (bnc#963137).
+- 3.1.119
+
+-------------------------------------------------------------------
 Wed Mar  9 08:39:49 UTC 2016 - [email protected]
 
 - Check uptime instead of system time while waiting for systemd
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/package/autoyast2.spec 
new/autoyast2-3.1.119/package/autoyast2.spec
--- old/autoyast2-3.1.118/package/autoyast2.spec        2016-03-09 
10:33:25.000000000 +0100
+++ new/autoyast2-3.1.119/package/autoyast2.spec        2016-03-16 
13:05:06.000000000 +0100
@@ -18,7 +18,7 @@
 
 Name:           autoyast2
 
-Version:        3.1.118
+Version:        3.1.119
 Release:        0
 
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/src/modules/AutoInstallRules.rb 
new/autoyast2-3.1.119/src/modules/AutoInstallRules.rb
--- old/autoyast2-3.1.118/src/modules/AutoInstallRules.rb       2016-03-09 
10:33:25.000000000 +0100
+++ new/autoyast2-3.1.119/src/modules/AutoInstallRules.rb       2016-03-16 
13:05:06.000000000 +0100
@@ -33,6 +33,8 @@
       Yast.import "URL"
       Yast.import "IP"
       Yast.import "Product"
+      Yast.import "Hostname"
+      Yast.import "OSRelease"
 
       Yast.include self, "autoinstall/io.rb"
 
@@ -61,7 +63,7 @@
       @installed_product = ""
       @installed_product_version = ""
       @hostname = ""
-      @hostaddress = ""
+      @hostaddress = nil
       @network = ""
       @domain = ""
       @arch = ""
@@ -144,8 +146,8 @@
       if Stage.initial
         cmd = 'ip link show | grep link/ether | head -1 | sed -e 
"s:^.*link/ether.::" -e "s: .*::"'
         ret = SCR.Execute(path(".target.bash_output"), cmd )
-       Builtins.y2milestone("mac Addr ret:%1", ret)
-       tmpmac = ret.fetch("stdout","")
+      Builtins.y2milestone("mac Addr ret:%1", ret)
+      tmpmac = ret.fetch("stdout","")
       end
       Builtins.y2milestone("mac Addr tmp:%1", tmpmac)
       cleanmac = Builtins.deletechars(tmpmac != nil ? tmpmac : "", ":\n")
@@ -153,23 +155,32 @@
       cleanmac
     end
 
+    # Return the network part of the hostaddress
+    #
+    # @example
+    #   AutoInstallRules.getNetwork #=> "192.168.122.0"
+    #
+    # @return [String] Network part of the hostaddress
+    #
+    # @see hostaddress
+    def getNetwork
+      ip_route = SCR.Execute(path(".target.bash_output"), "/usr/sbin/ip route")
+
+      # Regexp to fetch match the network address.
+      regexp = /([\h:\.]+)\/\d+ .+src #{hostaddress}/
+      if ret = ip_route["stdout"][regexp, 1]
+        ret
+      else
+        log.warn "Cannot find network address through 'ip': #{ip_route}"
+        nil
+      end
+    end
 
-    # Return host id (hex ip )
+    # Return host id (hex ip)
+    #
     # @return [String] host ID
     def getHostid
-      if Stage.initial
-        wicked_ret = SCR.Execute(path(".target.bash_output"), 
"/usr/sbin/wicked show --verbose all|grep pref-src")
-        if wicked_ret["exit"] == 0
-          stdout = wicked_ret["stdout"].split
-          @hostaddress = stdout[stdout.index("pref-src")+1]
-        else
-          log.warn "Cannot evaluate IP address with wicked: 
#{wicked_ret["stderr"]}"
-          @hostaddress = nil
-        end
-      else
-        @hostaddress = "192.168.1.1" # FIXME
-      end
-      IP.ToHex(@hostaddress)
+      IP.ToHex(hostaddress)
     end
 
     # Return host name
@@ -284,7 +295,7 @@
       #
       # Network
       #
-      Ops.set(@ATTR, "hostaddress", @hostaddress)
+      Ops.set(@ATTR, "hostaddress", hostaddress)
 
       #
       # Hostid (i.e. a8c00101);
@@ -292,9 +303,9 @@
       Ops.set(@ATTR, "hostid", @hostid)
 
       Ops.set(@ATTR, "hostname", getHostname)
-      @domain = Convert.to_string(SCR.Read(path(".etc.install_inf.Domain")))
+      @domain = Hostname.CurrentDomain
       Ops.set(@ATTR, "domain", @domain)
-      @network = Convert.to_string(SCR.Read(path(".etc.install_inf.Network")))
+      @network = getNetwork
       Ops.set(@ATTR, "network", @network)
       @xserver = Convert.to_string(SCR.Read(path(".etc.install_inf.XServer")))
       Ops.set(@ATTR, "xserver", @xserver)
@@ -309,19 +320,13 @@
 
       Builtins.y2milestone("Other linux parts: %1", @LinuxPartitions)
 
-      distro_str = SCR.Read(path(".content.DISTRO"))
-      log.info "DISTRO: #{distro_str}"
-
-      distro = distro_map(distro_str) || {}
-      cpe = cpeid_map(distro["cpeid"]) || {}
-
-      @installed_product = distro["name"] || ""
-      @installed_product_version = cpe["version"] || ""
+      @installed_product = Yast::OSRelease.ReleaseInformation
+      @installed_product_version = Yast::OSRelease.ReleaseVersion
       Ops.set(@ATTR, "installed_product", @installed_product)
       Ops.set(@ATTR, "installed_product_version", @installed_product_version)
 
-      log.info "Installing #{@installed_product.inspect}, " \
-        "version: #{@installed_product_version.inspect}"
+      log.info "Installing #{@installed_product}, " \
+        "version: #{@installed_product_version}"
       log.info "ATTR=#{@ATTR}"
 
       nil
@@ -456,16 +461,16 @@
       AutoInstallRules.ProbeRules if !rulelist.empty?
       Builtins.foreach(rulelist) do |ruleset|
         Builtins.y2milestone("Ruleset: %1", ruleset)
-       rls = ruleset.keys
-       if( rls.include?("result"))
-         rls.reject! {|r| r=="result"}
-         rls.push("result")
-       end
+        rls = ruleset.keys
+        if rls.include?("result")
+          rls.reject! {|r| r=="result"}
+          rls.push("result")
+        end
         op = Ops.get_string(ruleset, "operator", "and")
         rls.reject! {|r| r=="op"}
-       Builtins.y2milestone("Orderes Rules: %1", rls)
+        Builtins.y2milestone("Orderes Rules: %1", rls)
         Builtins.foreach(rls) do |rule|
-         ruledef = ruleset.fetch( rule, {} )
+          ruledef = ruleset.fetch( rule, {} )
           Builtins.y2milestone("Rule: %1", rule)
           Builtins.y2milestone("Ruledef: %1", ruledef)
           match = Ops.get_string(ruledef, "match", "undefined")
@@ -1106,6 +1111,20 @@
       nil
     end
 
+    # Return the IP through iproute2 tools
+    #
+    # @return [String] IP address
+    def hostaddress
+      return @hostaddress unless @hostaddress.nil?
+      ip_route = SCR.Execute(path(".target.bash_output"), "/usr/sbin/ip route")
+      regexp = /src ([\w.]+) \n/
+      if ret = ip_route["stdout"][regexp, 1]
+        ret
+      else
+        log.warn "Cannot evaluate IP address: #{ip_route}"
+        nil
+      end
+    end
 
     publish :variable => :userrules, :type => "boolean"
     publish :variable => :dontmergeIsDefault, :type => "boolean"
@@ -1114,7 +1133,6 @@
     publish :variable => :installed_product, :type => "string"
     publish :variable => :installed_product_version, :type => "string"
     publish :variable => :hostname, :type => "string"
-    publish :variable => :hostaddress, :type => "string"
     publish :variable => :network, :type => "string"
     publish :variable => :domain, :type => "string"
     publish :variable => :arch, :type => "string"
@@ -1135,6 +1153,7 @@
     publish :variable => :LinuxPartitions, :type => "list"
     publish :variable => :UserRules, :type => "map <string, any>"
     publish :variable => :tomerge, :type => "list <string>"
+    publish :function => :hostaddress, :type => "string ()"
     publish :function => :XML_cleanup, :type => "boolean (string, string)"
     publish :function => :StdErrLog, :type => "void (string)"
     publish :function => :getMAC, :type => "string ()"
@@ -1149,56 +1168,6 @@
     publish :function => :CreateDefault, :type => "void ()"
     publish :function => :CreateFile, :type => "void (string)"
     publish :function => :AutoInstallRules, :type => "void ()"
-
-    private
-
-    # TODO FIXME: share these functions (move to yast2?)
-
-    # Split CPE ID and distro label (separated by comma)
-    # @param distro [String] "DISTRO" value from content file
-    # @return [Hash<String,String>,nil] parsed value, map:
-    #    {"name" => <string>, "cpeid" => <string> }
-    #    or nil if the input value is invalid
-    def distro_map(distro)
-      if !distro
-        log.warn "Received nil distro value"
-        return nil
-      end
-
-      # split at the first comma, resulting in 2 parts at max.
-      cpeid, name = distro.split(",", 2)
-
-      if !name
-        log.warn "Cannot parse DISTRO value: #{distro}"
-        return nil
-      end
-
-      {"cpeid" => cpeid, "name" => name}
-    end
-
-    # parse CPE ID in URI syntax
-    # @see 
http://csrc.nist.gov/publications/nistir/ir7695/NISTIR-7695-CPE-Naming.pdf
-    # @param cpeid [String] e.g. "cpe:/o:suse:sles:12"
-    # @return [Hash<String,String>] parsed values, the keys are "part", 
"vendor", "product",
-    #   "version", "update", "edition", "lang", nil is returned for missing 
values
-    def cpeid_map(cpeid)
-      return nil unless cpeid && cpeid.start_with?("cpe:/")
-
-      # remove the "cpe:/" prefix
-      raw_cpe = cpeid.sub(/^cpe:\//, "")
-
-      parts = raw_cpe.split(":")
-
-      {
-        "part"    => parts[0],
-        "vendor"  => parts[1],
-        "product" => parts[2],
-        "version" => parts[3],
-        "update"  => parts[4],
-        "edition" => parts[5],
-        "lang"    => parts[6]
-      }
-    end
   end
 
   AutoInstallRules = AutoInstallRulesClass.new
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/test/AutoInstallRules_test.rb 
new/autoyast2-3.1.119/test/AutoInstallRules_test.rb
--- old/autoyast2-3.1.118/test/AutoInstallRules_test.rb 2016-03-09 
10:33:25.000000000 +0100
+++ new/autoyast2-3.1.119/test/AutoInstallRules_test.rb 2016-03-16 
13:05:06.000000000 +0100
@@ -9,109 +9,93 @@
 
   let(:root_path) { File.expand_path('../..', __FILE__) }
 
-  describe "#cpeid_map" do
-    it "parses SLES12 CPE ID" do
-      expect(subject.send(:cpeid_map, "cpe:/o:suse:sles:12")).to eq(
-        "part" => "o",
-        "vendor" => "suse",
-        "product" => "sles",
-        "version" => "12",
-        "update" => nil,
-        "edition" => nil,
-        "lang" => nil
-      )
-    end
+  describe "#ProbeRules" do
+    it "detect system properties" do
+      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".probe.bios")).and_return([])
+      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".probe.memory")).and_return([])
+      expect(Yast::Arch).to receive(:architecture).and_return("x86_64")
+      expect(Yast::Kernel).to receive(:GetPackages).and_return([])
+      expect(subject).to receive(:getNetwork).and_return("192.168.1.0")
+      expect(subject).to receive(:getHostname).and_return("myhost")
+      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.XServer"))
+      expect(Yast::Hostname).to 
receive(:CurrentDomain).and_return("mydomain.lan")
 
-    it "parses Adv. mgmt module CPE ID" do
-      machinery_cpeid = "cpe:/o:suse:sle-module-adv-systems-management:12"
-      expect(subject.send(:cpeid_map, machinery_cpeid)).to eq(
-        "part" => "o",
-        "vendor" => "suse",
-        "product" => "sle-module-adv-systems-management",
-        "version" => "12",
-        "update" => nil,
-        "edition" => nil,
-        "lang" => nil
-      )
-    end
+      expect(Yast::StorageControllers).to receive(:Initialize)
+      expect(Yast::Storage).to receive(:GetTargetMap).and_return({})
+      expect(Yast::Storage).to receive(:GetForeignPrimary)
+      expect(Yast::Storage).to receive(:GetOtherLinuxPartitions)
+
+      expect(Yast::OSRelease).to receive(:ReleaseInformation).
+        and_return("SUSE Linux Enterprise Server 12")
+      expect(Yast::OSRelease).to receive(:ReleaseVersion).
+        and_return("12")
+
+      subject.ProbeRules
 
-    it "return nil when CPE ID is does not start with 'cpe:/'" do
-      expect(subject.send(:cpeid_map, "invalid")).to be_nil
+      expect(Yast::AutoInstallRules.installed_product).to eq("SUSE Linux 
Enterprise Server 12")
+      expect(Yast::AutoInstallRules.installed_product_version).to eq("12")
     end
   end
 
-  describe "#distro_map" do
-    it "returns CPEID and product name" do
-      param = "cpe:/o:suse:sles:12,SUSE Linux Enterprise Server 12"
-      expected = {
-        "cpeid" => "cpe:/o:suse:sles:12",
-        "name" => "SUSE Linux Enterprise Server 12"
-      }
-
-      expect(subject.send(:distro_map, param)).to eq(expected)
+  describe "#getHostid" do
+    let(:ip_route_output_path) do
+      File.join(root_path, "test", "fixtures", "output", "ip_route.out")
     end
 
-    it "returns product name with comma" do
-      param = "cpe:/o:suse:sles:12,SLES12, Mini edition"
-      expected = {
-        "cpeid" => "cpe:/o:suse:sles:12",
-        "name" => "SLES12, Mini edition"
-      }
+    it "returns host IP in hex format (initial Stage)" do
+      expect(Yast::SCR).to receive(:Execute).
+        with(Yast::Path.new(".target.bash_output"), /ip route/).
+        and_return("stdout" => File.read(ip_route_output_path), "exit" => 0)
 
-      expect(subject.send(:distro_map, param)).to eq(expected)
+      expect(subject.getHostid).to eq(Yast::IP.ToHex("10.13.32.195"))
     end
 
-    it "returns nil if input is nil" do
-      expect(subject.send(:distro_map, nil)).to be_nil
-    end
+    it "returns nil if an error occurs finding the IP address" do
+      expect(Yast::SCR).to receive(:Execute).
+        with(Yast::Path.new(".target.bash_output"), /ip route/).
+        and_return("stdout" => "", "stderr" => "error from iputils", "exit" => 
1)
 
-    it "returns nil if the input does not contain comma" do
-      expect(subject.send(:distro_map, "foo")).to be_nil
+      expect(subject.getHostid).to eq(nil)
     end
   end
 
-  describe "#ProbeRules" do
-    before(:each) do
-      subject.reset
+  describe "#getHostname" do
+    before do
+      allow(Yast::SCR).to receive(:Execute).
+        with(Yast::Path.new(".target.bash_output"), "/bin/hostname").
+        and_return(hostname_output)
     end
 
-    it "reads installed product properties from content file" do
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".probe.bios")).and_return([])
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".probe.memory")).and_return([])
-      expect(Yast::Arch).to receive(:architecture).and_return("x86_64")
-      expect(Yast::Kernel).to receive(:GetPackages).and_return([])
-      expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"), "/bin/hostname")
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.Domain"))
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.Hostname"))
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.Network"))
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.XServer"))
+    context "/bin/hostname returns the hostname properly" do
+      let(:hostname_output) { { "stdout" => "myhost", "exit" => 0 } }
 
-      expect(Yast::StorageControllers).to receive(:Initialize)
-      expect(Yast::Storage).to receive(:GetTargetMap).and_return({})
-      expect(Yast::Storage).to receive(:GetForeignPrimary)
-      expect(Yast::Storage).to receive(:GetOtherLinuxPartitions)
+      it "returns that hostname" do
+        expect(subject.getHostname).to eq("myhost")
+      end
+    end
 
-      expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".content.DISTRO")).
-        and_return("cpe:/o:suse:sles:12,SUSE Linux Enterprise Server 12")
+    context "/bin/hostname fails" do
+      let(:hostname_output) { { "stderr" => "error from hostname", "stdout" => 
"", "exit" => 1 } }
 
-      subject.ProbeRules
+      before do
+        allow(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".etc.install_inf.Hostname"))
+          .and_return(inf_hostname)
+      end
 
-      expect(Yast::AutoInstallRules.installed_product).to eq("SUSE Linux 
Enterprise Server 12")
-      expect(Yast::AutoInstallRules.installed_product_version).to eq("12")
-    end
+      context "and install.inf contains a Hostname" do
+        let(:inf_hostname) { "myhost" }
 
-    context "when .content.DISTRO is not found" do
-      before(:each) do
-        allow(Yast::SCR).to receive(:Read).with(any_args)
-        allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
+        it "returns the name stored in install.inf" do
+          expect(subject.getHostname).to eq("myhost")
+        end
       end
 
-      it 'set installed_product and installed_product_version to blank string' 
do
-        expect(Yast::SCR).to 
receive(:Read).with(Yast::Path.new(".content.DISTRO")).
-          and_return(nil)
-        subject.ProbeRules
-        expect(Yast::AutoInstallRules.installed_product).to eq('')
-        expect(Yast::AutoInstallRules.installed_product_version).to eq('')
+      context "and install.inf does not contain a Hostname" do
+        let(:inf_hostname) { nil }
+
+        it "returns nil" do
+          expect(subject.getHostname).to eq(nil)
+        end
       end
     end
   end
@@ -130,7 +114,7 @@
       )
       expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"),
        "if  ( [ \"$hostaddress\" = \"10.69.57.43\" ] )   ||   ( [ \"$mac\" = 
\"000c2903d288\" ] ); then exit 0; else exit 1; fi",
-       {"hostaddress"=>"192.168.1.1", "mac"=>""}
+       {"hostaddress" => subject.hostaddress, "mac"=>""}
        )
       .and_return({"stdout"=>"", "exit"=>0, "stderr"=>""})
 
@@ -150,7 +134,7 @@
       )
       expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"),
        "if  ( [ \"$hostaddress\" = \"10.69.57.43\" ] )   &&   ( [ \"$mac\" = 
\"000c2903d288\" ] ); then exit 0; else exit 1; fi",
-       {"hostaddress"=>"192.168.1.1", "mac"=>""}
+       {"hostaddress" => subject.hostaddress, "mac"=>""}
        )
       .and_return({"stdout"=>"", "exit"=>0, "stderr"=>""})
 
@@ -169,7 +153,7 @@
       )
       expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"),
        "if  ( [ \"$hostaddress\" = \"10.69.57.43\" ] )   &&   ( [ \"$mac\" = 
\"000c2903d288\" ] ); then exit 0; else exit 1; fi",
-       {"hostaddress"=>"192.168.1.1", "mac"=>""}
+       {"hostaddress" => subject.hostaddress, "mac"=>""}
        )
       .and_return({"stdout"=>"", "exit"=>0, "stderr"=>""})
 
@@ -177,26 +161,41 @@
     end
   end
 
-  describe "#Host ID" do
-    let(:wicked_output_path) { File.join(root_path, 'test', 'fixtures', 
'output', 'wicked_output')  }
-    it "returns host IP in hex format (initial Stage)" do
-      expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"), "/usr/sbin/wicked 
show --verbose all|grep 
pref-src").and_return({"stdout"=>File.read(wicked_output_path), "exit"=>0})
-      expect(Yast::Stage).to receive(:initial).and_return(true)
-      expect(subject.getHostid).to eq("C0A864DA")
+  describe "#getNetwork" do
+    let(:hostaddress) { "10.13.32.195" }
+    let(:initial) { true }
+    let(:ip_route_output) { { "stdout" => ip_route_content, "exit" => 0 } }
+    let(:ip_route_content) do
+      File.read(File.join(root_path, "test", "fixtures", "output", 
"ip_route.out"))
+    end
+
+    before do
+      allow(subject).to receive(:hostaddress).and_return(hostaddress)
+      allow(Yast::SCR).to receive(:Execute).
+        with(Yast::Path.new(".target.bash_output"), /ip route/).
+        and_return(ip_route_output)
+    end
+
+    context "the host address is known to wicked" do
+      it "returns the network for the system's hostaddress" do
+        expect(subject.getNetwork).to eq("10.13.32.0")
+      end
     end
 
-    it "returns fix 192.168.1.1 in hex format (normal Stage)" do
-      expect(Yast::Stage).to receive(:initial).and_return(false)
-      expect(subject.getHostid).to eq("C0A80101")
-    end
+    context "the host address is unknown" do
+      let(:hostaddress) { "10.163.2.9" }
 
-    it "returns nil if wicked does not find IP address" do
-      expect(Yast::Stage).to receive(:initial).and_return(true)
-      expect(Yast::SCR).to 
receive(:Execute).with(Yast::Path.new(".target.bash_output"), "/usr/sbin/wicked 
show --verbose all|grep pref-src").and_return({"stderr"=>"error from wicked", 
"exit"=>1})
-      expect(subject.getHostid).to eq(nil)
+      it "returns nil" do
+        expect(subject.getNetwork).to be_nil
+      end
     end
 
-  end
-
+    context "an error occurs finding the IP" do
+      let(:ip_route_output) { { "stderr" => "some error", "stdout" => "", 
"exit" => 1 } }
 
+      it "returns nil" do
+        expect(subject.getNetwork).to be_nil
+      end
+    end
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/test/fixtures/network/wicked.out 
new/autoyast2-3.1.119/test/fixtures/network/wicked.out
--- old/autoyast2-3.1.118/test/fixtures/network/wicked.out      1970-01-01 
01:00:00.000000000 +0100
+++ new/autoyast2-3.1.119/test/fixtures/network/wicked.out      2016-03-16 
13:05:07.000000000 +0100
@@ -0,0 +1,25 @@
+lo              up
+      link:     #1, state up
+      type:     loopback
+      control:  persistent
+      config:   compat:suse:/etc/sysconfig/network/ifcfg-lo,
+                uuid: 1040df49-3c8f-515e-abe4-0aa3134b1a21
+      leases:   ipv4 static granted
+      leases:   ipv6 static granted
+      addr:     ipv4 127.0.0.1/8 [static]
+      addr:     ipv6 ::1/128 [static]
+      route:    ipv6 ::1/128 dev #0 type local table main scope universe 
protocol kernel priority 256
+
+em1             up
+      link:     #2, state up, mtu 1500
+      type:     ethernet, hwaddr 99:99:99:99:99:99
+      control:  none
+      config:   compat:suse:/etc/sysconfig/network/ifcfg-em1,
+                uuid: 2c1933h4-e982-50f4-96ae-929556183dd3
+      leases:   ipv4 dhcp granted [group]
+      leases:   ipv6 dhcp requesting [group]
+      addr:     ipv6 fe80::9a90:96ff:fed1:f2b2/64
+      addr:     ipv4 10.163.2.8/28 [dhcp]
+      route:    ipv4 0.0.0.0/0 via 10.163.2.1 dev #0 type unicast table main 
scope universe protocol dhcp
+      route:    ipv4 10.163.2.0/28 dev #0 type unicast table main scope link 
protocol kernel pref-src 10.163.2.8
+      route:    ipv6 fe80::/64 dev #0 type unicast table main scope universe 
protocol kernel priority 256
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/autoyast2-3.1.118/test/fixtures/network/wicked_partial.out 
new/autoyast2-3.1.119/test/fixtures/network/wicked_partial.out
--- old/autoyast2-3.1.118/test/fixtures/network/wicked_partial.out      
1970-01-01 01:00:00.000000000 +0100
+++ new/autoyast2-3.1.119/test/fixtures/network/wicked_partial.out      
2016-03-16 13:05:07.000000000 +0100
@@ -0,0 +1 @@
+route:    ipv4 192.168.100.0/24 dev #0 type unicast table main scope link 
protocol kernel pref-src 192.168.100.218
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/autoyast2-3.1.118/test/fixtures/output/ip_route.out 
new/autoyast2-3.1.119/test/fixtures/output/ip_route.out
--- old/autoyast2-3.1.118/test/fixtures/output/ip_route.out     1970-01-01 
01:00:00.000000000 +0100
+++ new/autoyast2-3.1.119/test/fixtures/output/ip_route.out     2016-03-16 
13:05:07.000000000 +0100
@@ -0,0 +1,3 @@
+10.13.32.0/24 dev eth0  proto kernel  scope link  src 10.13.32.195 
+10.163.0.1 dev tun0  proto kernel  scope link  src 10.163.0.6 
+10.163.2.0/28 dev eth1  proto kernel  scope link  src 10.163.2.1 


Reply via email to