Skip to content

Commit

Permalink
Fix product and version detection in installation rules
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jan 26, 2016
1 parent 35c737f commit 01d3d4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
15 changes: 5 additions & 10 deletions src/modules/AutoInstallRules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def main
Yast.import "IP"
Yast.import "Product"
Yast.import "Hostname"
Yast.import "OSRelease"

Yast.include self, "autoinstall/io.rb"

Expand Down Expand Up @@ -340,19 +341,13 @@ def ProbeRules

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.ReleaseName
@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
Expand Down
21 changes: 4 additions & 17 deletions test/AutoInstallRules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,16 @@
expect(Yast::Storage).to receive(:GetForeignPrimary)
expect(Yast::Storage).to receive(:GetOtherLinuxPartitions)

expect(Yast::SCR).to receive(:Read).with(Yast::Path.new(".content.DISTRO")).
and_return("cpe:/o:suse:sles:12,SUSE Linux Enterprise Server 12")
expect(Yast::OSRelease).to receive(:ReleaseName).
and_return("SUSE Linux Enterprise Server 12")
expect(Yast::OSRelease).to receive(:ReleaseVersion).
and_return("12")

subject.ProbeRules

expect(Yast::AutoInstallRules.installed_product).to eq("SUSE Linux Enterprise Server 12")
expect(Yast::AutoInstallRules.installed_product_version).to eq("12")
end

context "when .content.DISTRO is not found" do
before(:each) do
subject.reset
allow(Yast::SCR).to receive(:Read).with(any_args)
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('')
end
end
end

describe "#getHostid" do
Expand Down

0 comments on commit 01d3d4a

Please sign in to comment.