Skip to content

Commit

Permalink
more adaptions to storage-ng
Browse files Browse the repository at this point in the history
  • Loading branch information
schubi2 committed Nov 15, 2017
1 parent 8df8bf2 commit 345baa2
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 59 deletions.
6 changes: 3 additions & 3 deletions src/clients/inst_autosetup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#
# $Id$
require "autoinstall/module_config_builder"
require "y2storage"

module Yast
import "AutoinstConfig"

Expand Down Expand Up @@ -265,9 +267,7 @@ def main
Progress.NextStage
# if one modifies the partition table in a pre script, we will
# recognize this now
# storage-ng
log.error("FIXME : Missing storage call")
# Storage.ReReadTargetMap
Y2Storage::StorageManager.instance.probe

if Profile.current["partitioning_advanced"] && !Profile.current["partitioning_advanced"].empty?
write_storage = AutoinstStorage.ImportAdvanced(Profile.current["partitioning_advanced"])
Expand Down
7 changes: 4 additions & 3 deletions src/clients/inst_autosetup_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Uwe Gansert <ug@suse.de>
#
# $Id: inst_autosetup.ycp 61521 2010-03-29 09:10:07Z ug $
require "y2storage"

module Yast
class InstAutosetupUpgradeClient < Client
include Yast::Logger
Expand Down Expand Up @@ -202,9 +204,8 @@ def main

if !(Mode.autoupgrade && AutoinstConfig.ProfileInRootPart)
# reread only if target system is not yet initialized (bnc#673033)
log.error("FIXME : Missing storage call")
# storage-ng
# Storage.ReReadTargetMap
Y2Storage::StorageManager.instance.probe

if :abort == WFM.CallFunction("inst_update_partition_auto", [])
return :abort
end
Expand Down
4 changes: 0 additions & 4 deletions src/include/autoinstall/AdvancedPartitionDialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ def initialize_autoinstall_AdvancedPartitionDialog(include_target)
textdomain "autoinst"

Yast.include include_target, "autoinstall/common.rb"
# storage-ng
=begin
Yast.include include_target, "partitioning/custom_part_dialogs.rb"
=end

Yast.import "AutoinstPartPlan"
Yast.import "AutoinstDrive"
Expand Down
43 changes: 12 additions & 31 deletions src/modules/AutoInstallRules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
# $Id$
require "yast"
require "y2storage"

module Yast
class AutoInstallRulesClass < Module
Expand All @@ -22,11 +23,6 @@ def main
Yast.import "Installation"
Yast.import "AutoinstConfig"
Yast.import "XML"
# storage-ng
=begin
# Yast.import "Storage"
# Yast.import "StorageControllers"
=end
Yast.import "Kernel"
Yast.import "Mode"
Yast.import "Profile"
Expand Down Expand Up @@ -276,21 +272,14 @@ def ProbeRules
#
# Disk sizes
#

# storage-ng
=begin
StorageControllers.Initialize # ugly hack, Storage.GetTargetMap should simply work without it
storage = Storage.GetTargetMap
_PhysicalTargetMap = Builtins.filter(storage) do |k, v|
Storage.IsRealDisk(v)
end
@totaldisk = 0
@disksize = Builtins.maplist(_PhysicalTargetMap) do |k, v|
size_in_mb = Ops.divide(Ops.get_integer(v, "size_k", 0), 1024)
@totaldisk = Ops.add(@totaldisk, size_in_mb)
{ "device" => k, "size" => size_in_mb }
@disksize = []
one_mega = Y2Storage::DiskSize.MiB(1)
Y2Storage::StorageManager.instance.probed.disks.each do |disk|
size = disk.size.ceil(one_mega).to_i / one_mega.to_i
@totaldisk += size
@disksize << { "device" => disk.name, "size" => size }
end
=end
Builtins.y2milestone("disksize: %1", @disksize)
Ops.set(@ATTR, "totaldisk", @totaldisk)
#
Expand All @@ -316,20 +305,12 @@ def ProbeRules
@xserver = Convert.to_string(SCR.Read(path(".etc.install_inf.XServer")))
Ops.set(@ATTR, "xserver", @xserver)

# storage-ng
=begin
@NonLinuxPartitions = Storage.GetForeignPrimary
=end
@others = Builtins.size(@NonLinuxPartitions)

probed_disks = Y2Storage::StorageManager.instance.probed_disk_analyzer
@NonLinuxPartitions = probed_disks.windows_partitions()
@others = @NonLinuxPartitions.size
Builtins.y2milestone("Other primaries: %1", @NonLinuxPartitions)

# storage-ng
=begin
@LinuxPartitions = Storage.GetOtherLinuxPartitions
=end
@linux = Builtins.size(@LinuxPartitions)

@LinuxPartitions = probed_disks.linux_partitions()
@linux = @LinuxPartitions.size
Builtins.y2milestone("Other linux parts: %1", @LinuxPartitions)

@installed_product = Yast::OSRelease.ReleaseInformation
Expand Down
6 changes: 2 additions & 4 deletions src/modules/AutoinstClone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#
#
require "yast"
require "y2storage"

module Yast
class AutoinstCloneClass < Module
Expand Down Expand Up @@ -48,10 +49,7 @@ def main
# Detects whether the current system uses multipath
# @return [Boolean] if in use
def multipath_in_use?
# storage-ng
log.error("FIXME : Missing storage call")
# Storage.GetTargetMap.detect{|k,e| e.fetch("type",:X)==:CT_DMMULTIPATH} ? true:false
false
!Y2Storage::StorageManager.instance.probed.multipaths.empty?
end

# General options
Expand Down
5 changes: 0 additions & 5 deletions src/modules/AutoinstGeneral.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ def main
Yast.import "Profile"
Yast.import "ProductFeatures"

# storage-ng
=begin
Yast.import "Storage"
=end

Yast.import "SignatureCheckCallbacks"
Yast.import "Report"
Yast.import "Arch"
Expand Down
8 changes: 0 additions & 8 deletions src/modules/ProfileLocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@ def main

Yast.import "AutoinstConfig"
Yast.import "AutoInstallRules"

# storage-ng
=begin
Yast.import "StorageDevices"
Yast.import "StorageControllers"
=end

Yast.import "Mode"
Yast.import "Installation"
Yast.import "Report"
Yast.import "Label"
Yast.import "URL"


Yast.include self, "autoinstall/autoinst_dialogs.rb"
Yast.include self, "autoinstall/io.rb"
ProfileLocation()
Expand Down
14 changes: 13 additions & 1 deletion test/AutoInstallRules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@

describe "#ProbeRules" do
before { subject.main }
let(:devicegraph) { instance_double(Y2Storage::Devicegraph, disk_devices: disk_devices) }
let(:disk_devices) { [disk] }
let(:disk) {
instance_double(Y2Storage::Disk, name: "/dev/sda", size: Y2Storage::DiskSize.MiB(1)) }

it "detect system properties" do
allow(Y2Storage::StorageManager.instance).to receive(:probed)
.and_return(devicegraph)
allow(Y2Storage::StorageManager.instance.probed).to receive(:disks)
.and_return([disk])
allow_any_instance_of(Y2Storage::DiskAnalyzer).to receive(:linux_partitions)
.and_return([])
expect_any_instance_of(Y2Storage::DiskAnalyzer).to receive(:windows_partitions)
.and_return([])
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")
allow(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")
Expand Down

0 comments on commit 345baa2

Please sign in to comment.