Hello community, here is the log from the commit of package yast2-storage-ng for openSUSE:Factory checked in at 2018-08-13 10:29:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-storage-ng (Old) and /work/SRC/openSUSE:Factory/.yast2-storage-ng.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-storage-ng" Mon Aug 13 10:29:30 2018 rev:28 rq:628658 version:4.1.4 Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-storage-ng/yast2-storage-ng.changes 2018-08-04 21:50:51.948992066 +0200 +++ /work/SRC/openSUSE:Factory/.yast2-storage-ng.new/yast2-storage-ng.changes 2018-08-13 10:29:32.163105295 +0200 @@ -1,0 +2,14 @@ +Fri Aug 10 11:56:40 UTC 2018 - [email protected] + +- Fixed the warning about overwriting a manually edited partition + layout. Now it works even after going back and forth in the + installer steps (bsc#1055756). +- 4.1.4 + +------------------------------------------------------------------- +Thu Aug 9 15:43:17 UTC 2018 - [email protected] + +- Partitioner: display Xen virtual partitions and allow to format + and mount them (bsc#1085134). + +------------------------------------------------------------------- Old: ---- yast2-storage-ng-4.1.3.tar.bz2 New: ---- yast2-storage-ng-4.1.4.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-storage-ng.spec ++++++ --- /var/tmp/diff_new_pack.G00HM0/_old 2018-08-13 10:29:32.539106057 +0200 +++ /var/tmp/diff_new_pack.G00HM0/_new 2018-08-13 10:29:32.539106057 +0200 @@ -17,7 +17,7 @@ Name: yast2-storage-ng -Version: 4.1.3 +Version: 4.1.4 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -27,8 +27,8 @@ Requires: yast2 >= 4.0.73 # for AbortException and handle direct abort Requires: yast2-ruby-bindings >= 4.0.6 -# BlkDevice#active? -Requires: libstorage-ng-ruby >= 3.3.310 +# Storage::StrayBlkDevice (in the SLE15-SP1 branch) +Requires: libstorage-ng-ruby >= 4.1.5 # communicate with udisks Requires: rubygem(ruby-dbus) # Y2Packager::Repository @@ -37,8 +37,8 @@ Requires: findutils BuildRequires: update-desktop-files -# BlkDevice#active? -BuildRequires: libstorage-ng-ruby >= 3.3.310 +# Storage::StrayBlkDevice (in the SLE15-SP1 branch) +BuildRequires: libstorage-ng-ruby >= 4.1.5 BuildRequires: yast2-devtools BuildRequires: yast2-ruby-bindings # yast2-xml dependency is added by yast2 but ignored in the ++++++ yast2-storage-ng-4.1.3.tar.bz2 -> yast2-storage-ng-4.1.4.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/package/yast2-storage-ng.changes new/yast2-storage-ng-4.1.4/package/yast2-storage-ng.changes --- old/yast2-storage-ng-4.1.3/package/yast2-storage-ng.changes 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/package/yast2-storage-ng.changes 2018-08-10 17:51:03.000000000 +0200 @@ -1,4 +1,18 @@ ------------------------------------------------------------------- +Fri Aug 10 11:56:40 UTC 2018 - [email protected] + +- Fixed the warning about overwriting a manually edited partition + layout. Now it works even after going back and forth in the + installer steps (bsc#1055756). +- 4.1.4 + +------------------------------------------------------------------- +Thu Aug 9 15:43:17 UTC 2018 - [email protected] + +- Partitioner: display Xen virtual partitions and allow to format + and mount them (bsc#1085134). + +------------------------------------------------------------------- Tue Jul 31 15:03:42 UTC 2018 - [email protected] - Warning if overwriting manually edited settings (bsc#1055756) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/package/yast2-storage-ng.spec new/yast2-storage-ng-4.1.4/package/yast2-storage-ng.spec --- old/yast2-storage-ng-4.1.3/package/yast2-storage-ng.spec 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/package/yast2-storage-ng.spec 2018-08-10 17:51:03.000000000 +0200 @@ -16,7 +16,7 @@ # Name: yast2-storage-ng -Version: 4.1.3 +Version: 4.1.4 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -26,8 +26,8 @@ Requires: yast2 >= 4.0.73 # for AbortException and handle direct abort Requires: yast2-ruby-bindings >= 4.0.6 -# BlkDevice#active? -Requires: libstorage-ng-ruby >= 3.3.310 +# Storage::StrayBlkDevice (in the SLE15-SP1 branch) +Requires: libstorage-ng-ruby >= 4.1.5 # communicate with udisks Requires: rubygem(ruby-dbus) # Y2Packager::Repository @@ -36,8 +36,8 @@ Requires: findutils BuildRequires: update-desktop-files -# BlkDevice#active? -BuildRequires: libstorage-ng-ruby >= 3.3.310 +# Storage::StrayBlkDevice (in the SLE15-SP1 branch) +BuildRequires: libstorage-ng-ruby >= 4.1.5 BuildRequires: yast2-ruby-bindings BuildRequires: yast2-devtools # yast2-xml dependency is added by yast2 but ignored in the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/actions/add_partition.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/actions/add_partition.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/actions/add_partition.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/actions/add_partition.rb 2018-08-10 17:51:03.000000000 +0200 @@ -94,7 +94,21 @@ # # @return [Boolean] def run? - not_used_validation && not_formatted_validation && available_space_validation + partitionable_validation && not_used_validation && + not_formatted_validation && available_space_validation + end + + # Checks whether the device can contain partitions, which is not true + # for StrayBlkDevice objects (they are listed as disks but they are not). + # + # @return [Boolean] true if device can be partitioned, false otherwise + def partitionable_validation + if part_controller.disk.respond_to?(:partitions) + true + else + impossible_partition_popup + false + end end # Checks whether the device is not used @@ -146,6 +160,13 @@ return true if part_controller.disk_formatted? return true if part_controller.new_partition_possible? + impossible_partition_popup + false + end + + # Displays a popup telling the user it's not possible to create a + # partition + def impossible_partition_popup Yast::Popup.Error( format( # TRANSLATORS: %{name} is a device name (e.g. "/dev/sda") @@ -153,8 +174,6 @@ name: disk_name ) ) - - false end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/blk_device_edit_button.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/blk_device_edit_button.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/blk_device_edit_button.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/blk_device_edit_button.rb 2018-08-10 17:51:03.000000000 +0200 @@ -52,11 +52,12 @@ partition? || software_raid? ? super : go_to_disk_page end - # Whether the device is a partition + # Whether the device is a partition or an equivalent device (in terms of + # editing/formatting it). # # @return [Booelan] def partition? - device.is?(:partition) + device.is?(:partition) || device.is?(:stray_blk_device) end # Whether the device is a software raid diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/blk_devices_table.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/blk_devices_table.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/blk_devices_table.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/blk_devices_table.rb 2018-08-10 17:51:03.000000000 +0200 @@ -251,6 +251,7 @@ lvm_pv: N_("PV"), lvm_vg: N_("LVM"), lvm_lv: N_("LV"), + stray: N_("Xen"), thin_pool: N_("Thin Pool"), thin: N_("Thin LV") } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/overview.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/overview.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/overview.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/overview.rb 2018-08-10 17:51:03.000000000 +0200 @@ -192,9 +192,12 @@ # @return [CWM::PagerTreeItem] def disks_items - devices = device_graph.disk_devices + devices = device_graph.disk_devices + device_graph.stray_blk_devices + page = Pages::Disks.new(devices, self) - children = devices.map { |d| disk_items(d) } + children = devices.map do |dev| + dev.is?(:stray_blk_device) ? stray_blk_device_item(dev) : disk_items(dev) + end CWM::PagerTreeItem.new(page, children: children, icon: Icons::HD) end @@ -211,6 +214,12 @@ CWM::PagerTreeItem.new(page) end + # @return [CWM::PagerTreeItem] + def stray_blk_device_item(device) + page = Pages::StrayBlkDevice.new(device) + CWM::PagerTreeItem.new(page) + end + # @return [CWM::PagerTreeItem] def raids_items devices = device_graph.software_raids diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/disks.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/disks.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/disks.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/disks.rb 2018-08-10 17:51:03.000000000 +0200 @@ -69,7 +69,6 @@ table, Left( HBox( - # TODO: Add move button ? PartitionAddButton.new(pager: pager, table: table), BlkDeviceEditButton.new(pager: pager, table: table), PartitionMoveButton.new(pager: pager, table: table), @@ -92,9 +91,9 @@ # # @return [Array<Y2Storage::BlkDevice>] def devices - disks.reduce([]) do |devices, disk| + disks.each_with_object([]) do |disk, devices| devices << disk - devices.concat(disk.partitions) + devices.concat(disk.partitions) if disk.respond_to?(:partitions) end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/stray_blk_device.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/stray_blk_device.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/stray_blk_device.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/stray_blk_device.rb 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,74 @@ +# encoding: utf-8 + +# Copyright (c) [2017-2018] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "cwm/pager" +require "y2partitioner/icons" +require "y2partitioner/widgets/blk_device_edit_button" +require "y2partitioner/widgets/blk_device_description" +require "y2partitioner/dialogs" + +module Y2Partitioner + module Widgets + module Pages + # A Page for a StrayBlkDevice (basically a XEN virtual partition) + class StrayBlkDevice < CWM::Page + # @return [Y2Storage::StrayBlkDevice] device the page is about + attr_reader :device + + # Constructor + # + # @param [Y2Storage::StrayBlkDevice] device + def initialize(device) + textdomain "storage" + + @device = device + self.widget_id = "stray_blk_device:" + device.name + end + + # @macro seeAbstractWidget + def label + device.basename + end + + # @macro seeCustomWidget + def contents + return @contents if @contents + + icon = Icons.small_icon(Icons::DEFAULT_DEVICE) + @contents = VBox( + Left( + HBox( + Image(icon, ""), + Heading(device.name) + ) + ), + BlkDeviceDescription.new(device), + Left( + HBox( + BlkDeviceEditButton.new(device: device) + ) + ) + ) + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/system.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/system.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages/system.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages/system.rb 2018-08-10 17:51:03.000000000 +0200 @@ -140,9 +140,12 @@ # @return [Array<Y2Storage::Device>] def disk_devices - device_graph.disk_devices.reduce([]) do |devices, disk| + # Since XEN virtual partitions are listed at the end of the "Hard + # Disks" section, let's do the same in the general storage table + all = device_graph.disk_devices + device_graph.stray_blk_devices + all.each_with_object([]) do |disk, devices| devices << disk - devices.concat(disk.partitions) + devices.concat(disk.partitions) if disk.respond_to?(:partitions) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages.rb new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2partitioner/widgets/pages.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2partitioner/widgets/pages.rb 2018-08-10 17:51:03.000000000 +0200 @@ -35,6 +35,7 @@ require "y2partitioner/widgets/pages/disk.rb" require "y2partitioner/widgets/pages/system.rb" require "y2partitioner/widgets/pages/disks.rb" +require "y2partitioner/widgets/pages/stray_blk_device.rb" require "y2partitioner/widgets/pages/lvm_lv.rb" require "y2partitioner/widgets/pages/lvm_vg.rb" require "y2partitioner/widgets/pages/partition.rb" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2storage/blk_device.rb new/yast2-storage-ng-4.1.4/src/lib/y2storage/blk_device.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2storage/blk_device.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2storage/blk_device.rb 2018-08-10 17:51:03.000000000 +0200 @@ -31,7 +31,7 @@ # This is a wrapper for Storage::BlkDevice class BlkDevice < Device wrap_class Storage::BlkDevice, - downcast_to: ["Partitionable", "Partition", "Encryption", "LvmLv"] + downcast_to: ["Partitionable", "Partition", "Encryption", "LvmLv", "StrayBlkDevice"] include ComparableByName include MatchVolumeSpec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2storage/clients/inst_disk_proposal.rb new/yast2-storage-ng-4.1.4/src/lib/y2storage/clients/inst_disk_proposal.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2storage/clients/inst_disk_proposal.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2storage/clients/inst_disk_proposal.rb 2018-08-10 17:51:03.000000000 +0200 @@ -45,8 +45,6 @@ include InstDialogMixin include PartitioningFeatures - attr_reader :manual_changed # Settings has been changed by user - def initialize textdomain "storage" @@ -62,7 +60,6 @@ def run log.info("BEGIN of inst_disk_proposal") - @manual_changed = false until [:back, :next, :abort].include?(@result) dialog = Dialogs::Proposal.new(@proposal, @devicegraph, excluded_buttons: excluded_buttons) @@ -91,16 +88,14 @@ # @return [Integer] attr_reader :initial_staging_revision - # The user has changed partition settings. + # The user has changed partition settings using the Expert Partitioner. # Asking if these changes can be overwritten. def overwrite_manual_settings? - return true unless manual_changed ret = Popup.YesNo(_( "Computing this proposal will overwrite manual changes \n"\ "done so far. Continue with computing proposal?" )) log.info "overwrite_manual_settings? return #{ret}" - @manual_changed = false if ret # reset for next change ret end @@ -116,7 +111,8 @@ end def guided_setup - return unless overwrite_manual_settings? + return if manual_partitioning? && !overwrite_manual_settings? + settings = @proposal ? @proposal.settings : new_settings dialog = Dialogs::GuidedSetup.new(settings, probed_analyzer) case dialog.run @@ -134,7 +130,6 @@ dialog_result = without_title_on_left { dialog.run } actions_after_partitioner(dialog.device_graph, dialog_result) - @manual_changed = true if @result != :abort end # Actions to perform after running the Partitioner @@ -266,6 +261,13 @@ Yast2::Popup.show(message, headline: :warning, buttons: :continue_cancel, focus: :cancel) end + + # Whether the current devicegraph was configured using the Expert Partitioner + # + # @return [Boolean] false if staging was calculated using a proposal + def manual_partitioning? + @proposal.nil? + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2storage/devicegraph.rb new/yast2-storage-ng-4.1.4/src/lib/y2storage/devicegraph.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2storage/devicegraph.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2storage/devicegraph.rb 2018-08-10 17:51:03.000000000 +0200 @@ -176,6 +176,14 @@ Disk.sorted_by_name(self) end + # All the stray block devices (basically XEN virtual partitions) in the + # devicegraph, sorted by name + # + # @return [Array<StrayBlkDevice>] + def stray_blk_devices + StrayBlkDevice.sorted_by_name(self) + end + # All the multipath devices in the devicegraph, sorted by name # # @return [Array<Multipath>] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2storage/stray_blk_device.rb new/yast2-storage-ng-4.1.4/src/lib/y2storage/stray_blk_device.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2storage/stray_blk_device.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/src/lib/y2storage/stray_blk_device.rb 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,73 @@ +# encoding: utf-8 + +# Copyright (c) [2017] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require "y2storage/storage_class_wrapper" +require "y2storage/blk_device" + +module Y2Storage + # Class representing devices that have no parent in the devicegraph but cannot + # be partitioned (they are not real disks or DASDs). + # + # Currently only Xen Virtual Partitions (e.g. /dev/xvda1) are represented as + # stray block devices. Note that partitionable devices in Xen (e.g. /dev/xvda) + # are represented as Disk objects and partitions on them as normal + # Partition objects (e.g. also /dev/xvda1). + # + # @note: This class may dissapear in the future if the functionality is merged + # into the Disk class (adding non-partitionable disks was considered too risky + # in the development phase in which StrayBlkDevice was introduced). Don't + # rely too much on this class. + class StrayBlkDevice < BlkDevice + wrap_class Storage::StrayBlkDevice + + # @!method self.create(devicegraph, name, region_or_size = nil) + # @param devicegraph [Devicegraph] + # @param name [String] + # @param region_or_size [Region, DiskSize] + # @return [StrayBlkDevice] + storage_class_forward :create, as: "StrayBlkDevice" + + # @!method self.all(devicegraph) + # @param devicegraph [Devicegraph] + # @return [Array<StrayBlkDevice>] all the stray devices in the given + # devicegraph, in no particular order + storage_class_forward :all, as: "StrayBlkDevice" + + # @!method self.find_by_name(devicegraph, name) + # @param devicegraph [Devicegraph] + # @param name [String] + # @return [StrayBlkDevice] nil if there is no such stray device + storage_class_forward :find_by_name, as: "Dasd" + + def inspect + "<StrayBlkDevice #{name} #{size}>" + end + + protected + + def types_for_is + types = super + types << :stray_blk_device + types << :stray + types + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/src/lib/y2storage.rb new/yast2-storage-ng-4.1.4/src/lib/y2storage.rb --- old/yast2-storage-ng-4.1.3/src/lib/y2storage.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/src/lib/y2storage.rb 2018-08-10 17:51:03.000000000 +0200 @@ -26,6 +26,7 @@ require "y2storage/resize_info" require "y2storage/device" require "y2storage/blk_device" +require "y2storage/stray_blk_device" require "y2storage/multi_disk_device" require "y2storage/disk" require "y2storage/dasd" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/data/devicegraphs/xen-disks-and-partitions.xml new/yast2-storage-ng-4.1.4/test/data/devicegraphs/xen-disks-and-partitions.xml --- old/yast2-storage-ng-4.1.3/test/data/devicegraphs/xen-disks-and-partitions.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/test/data/devicegraphs/xen-disks-and-partitions.xml 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,105 @@ +<?xml version="1.0"?> +<Devicegraph> + <Devices> + <StrayBlkDevice> + <sid>42</sid> + <name>/dev/xvda2</name> + <sysfs-name>xvda2</sysfs-name> + <sysfs-path>/devices/vbd-51728/block/xvda2</sysfs-path> + <region> + <length>62914560</length> + <block-size>512</block-size> + </region> + <range>16</range> + </StrayBlkDevice> + <StrayBlkDevice> + <sid>43</sid> + <name>/dev/xvda1</name> + <sysfs-name>xvda1</sysfs-name> + <sysfs-path>/devices/vbd-51745/block/xvda1</sysfs-path> + <region> + <length>125829120</length> + <block-size>512</block-size> + </region> + </StrayBlkDevice> + <Disk> + <sid>44</sid> + <name>/dev/xvdc</name> + <sysfs-name>xvdc</sysfs-name> + <sysfs-path>/devices/vbd-51712/block/xvdc</sysfs-path> + <region> + <length>125829120</length> + <block-size>512</block-size> + </region> + <topology/> + <range>16</range> + </Disk> + <Gpt> + <sid>48</sid> + </Gpt> + <Partition> + <sid>49</sid> + <name>/dev/xvdc1</name> + <sysfs-name>xvdc1</sysfs-name> + <sysfs-path>/devices/vbd-51728/block/xvdc/xvdc1</sysfs-path> + <region> + <start>2048</start> + <length>12580864</length> + <block-size>512</block-size> + </region> + <type>primary</type> + <id>131</id> + </Partition> + <Partition> + <sid>50</sid> + <name>/dev/xvdc2</name> + <sysfs-name>xvdc2</sysfs-name> + <sysfs-path>/devices/vbd-51728/block/xvdc/xvdc2</sysfs-path> + <region> + <start>12582912</start> + <length>12582912</length> + <block-size>512</block-size> + </region> + <type>primary</type> + <id>131</id> + </Partition> + <Xfs> + <sid>51</sid> + <uuid>7608bc33-8dfd-4ae0-8f38-e5923deb9631</uuid> + </Xfs> + <Ext4> + <sid>55</sid> + <uuid>c27cd058-8c30-45b4-a8e5-ca07a5b7efab</uuid> + </Ext4> + <Ext4> + <sid>56</sid> + <uuid>303df7e6-bdf1-4553-acf8-207a0dfc9fff</uuid> + </Ext4> + </Devices> + <Holders> + <User> + <source-sid>44</source-sid> + <target-sid>48</target-sid> + </User> + <Subdevice> + <source-sid>48</source-sid> + <target-sid>49</target-sid> + </Subdevice> + <Subdevice> + <source-sid>48</source-sid> + <target-sid>50</target-sid> + </Subdevice> + <FilesystemUser> + <source-sid>42</source-sid> + <target-sid>51</target-sid> + </FilesystemUser> + <FilesystemUser> + <source-sid>49</source-sid> + <target-sid>55</target-sid> + </FilesystemUser> + <FilesystemUser> + <source-sid>50</source-sid> + <target-sid>56</target-sid> + </FilesystemUser> + </Holders> +</Devicegraph> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/data/devicegraphs/xen-partitions.xml new/yast2-storage-ng-4.1.4/test/data/devicegraphs/xen-partitions.xml --- old/yast2-storage-ng-4.1.3/test/data/devicegraphs/xen-partitions.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/test/data/devicegraphs/xen-partitions.xml 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<Devicegraph> + <Devices> + <StrayBlkDevice> + <sid>42</sid> + <name>/dev/xvda2</name> + <sysfs-name>xvda2</sysfs-name> + <sysfs-path>/devices/vbd-51728/block/xvda2</sysfs-path> + <region> + <length>62914560</length> + <block-size>512</block-size> + </region> + <range>16</range> + </StrayBlkDevice> + <StrayBlkDevice> + <sid>43</sid> + <name>/dev/xvda1</name> + <sysfs-name>xvda1</sysfs-name> + <sysfs-path>/devices/vbd-51745/block/xvda1</sysfs-path> + <region> + <length>125829120</length> + <block-size>512</block-size> + </region> + </StrayBlkDevice> + <Xfs> + <sid>51</sid> + <uuid>7608bc33-8dfd-4ae0-8f38-e5923deb9631</uuid> + </Xfs> + </Devices> + <Holders> + <FilesystemUser> + <source-sid>42</source-sid> + <target-sid>51</target-sid> + </FilesystemUser> + </Holders> +</Devicegraph> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/actions/add_partition_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/actions/add_partition_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/actions/add_partition_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/actions/add_partition_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -92,6 +92,28 @@ end end + context "if called for a StrayBlkDevice (Xen virtual partition)" do + let(:scenario) { "xen-partitions.xml" } + + let(:disk) { Y2Storage::BlkDevice.find_by_name(current_graph, "/dev/xvda1") } + + it "shows an error popup" do + expect(Yast::Popup).to receive(:Error) + action.run + end + + it "quits returning :back" do + expect(action.run).to eq(:back) + end + + it "does not create any partition" do + partitions_before = current_graph.partitions + action.run + partitions_after = current_graph.partitions + expect(partitions_after).to eq(partitions_before) + end + end + context "if the disk is in use" do let(:scenario) { "empty_hard_disk_50GiB.yml" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/device_delete_button_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/device_delete_button_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/device_delete_button_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/device_delete_button_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -137,6 +137,19 @@ subject.handle end end + + context "and the device is a stray device (Xen virtual partition)" do + let(:device_type) { :stray_blk_device } + + it "shows a warning message" do + expect(Yast::Popup).to receive(:Warning) + subject.handle + end + + it "returns nil" do + expect(subject.handle).to be(nil) + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/device_resize_button_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/device_resize_button_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/device_resize_button_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/device_resize_button_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -204,13 +204,28 @@ end end - context "and resize action is not supported for the device" do + context "and resize action is not supported for the device (disk)" do let(:scenario) { "mixed_disks.yml" } let(:device_name) { "/dev/sda" } it "shows an error popup" do expect(Yast::Popup).to receive(:Error) + subject.handle + end + + it "returns nil" do + expect(subject.handle).to be_nil + end + end + + context "and resize action is not supported for the device (Xen virtual partition)" do + let(:scenario) { "xen-partitions.xml" } + + let(:device_name) { "/dev/xvda2" } + + it "shows an error popup" do + expect(Yast::Popup).to receive(:Error) subject.handle end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/overview_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/overview_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/overview_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/overview_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -165,6 +165,28 @@ end end + context "when there Xen devices representing disks and virtual partitions" do + let(:scenario) { "xen-disks-and-partitions.xml" } + + it "disks pager has a page for each Xen disk" do + page = disks_pages.find { |p| p.device.name == "/dev/xvdc" } + expect(page).to_not be_nil + end + + it "disks pager has a page for each Xen virtual partition" do + page = disks_pages.find { |p| p.device.name == "/dev/xvda1" } + expect(page).to_not be_nil + + page = disks_pages.find { |p| p.device.name == "/dev/xvda2" } + expect(page).to_not be_nil + end + + it "disks pager does not include an extra device to group Xen virtual partitions" do + page = disks_pages.find { |p| p.device.name == "/dev/xvda" } + expect(page).to be_nil + end + end + context "when there are BIOS RAIDs" do let(:scenario) { "md-imsm1-devicegraph.xml" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/pages/disks_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/pages/disks_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/pages/disks_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/pages/disks_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -26,14 +26,11 @@ require "y2partitioner/widgets/pages" describe Y2Partitioner::Widgets::Pages::Disks do - before do - devicegraph_stub("mixed_disks_btrfs.yml") - end + before { devicegraph_stub(scenario) } + let(:scenario) { "mixed_disks_btrfs.yml" } let(:device_graph) { Y2Partitioner::DeviceGraphs.instance.current } - let(:devices) { (device_graph.disks + device_graph.disks.map(&:partitions)).flatten.compact } - subject { described_class.new(disks, pager) } let(:disks) { device_graph.disks } @@ -44,18 +41,35 @@ describe "#contents" do let(:widgets) { Yast::CWM.widgets_in_contents([subject]) } + let(:table) { widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::BlkDevicesTable) } } + let(:disks_and_parts) do + (device_graph.disks + device_graph.disks.map(&:partitions)).flatten.compact + end it "shows a table with the disk devices and their partitions" do - table = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::BlkDevicesTable) } - expect(table).to_not be_nil - devices_name = devices.map(&:name) + devices_name = disks_and_parts.map(&:name) items_name = table.items.map { |i| i[1] } expect(items_name.sort).to eq(devices_name.sort) end + # This test is here to ensure we don't try to access the partitions within a + # StrayBlkDevice or something similar + context "when some of the devices to show are Xen virtual partitions" do + let(:scenario) { "xen-disks-and-partitions.xml" } + let(:disks) { device_graph.disks + device_graph.stray_blk_devices } + + it "shows a table with the disk devices, their partitions and the Xen virtual partitions" do + devices = disks_and_parts + device_graph.stray_blk_devices + devices_name = devices.map(&:name) + items_name = table.items.map { |i| i[1] } + + expect(items_name.sort).to eq(devices_name.sort) + end + end + it "shows a partition add button" do button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::PartitionAddButton) } expect(button).to_not be_nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/pages/stray_blk_device_test.rb new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/pages/stray_blk_device_test.rb --- old/yast2-storage-ng-4.1.3/test/y2partitioner/widgets/pages/stray_blk_device_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/test/y2partitioner/widgets/pages/stray_blk_device_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,67 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# Copyright (c) [2018] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "../../test_helper" + +require "cwm/rspec" +require "y2partitioner/widgets/pages" + +describe Y2Partitioner::Widgets::Pages::StrayBlkDevice do + before { devicegraph_stub("xen-partitions.xml") } + + let(:current_graph) { Y2Partitioner::DeviceGraphs.instance.current } + + let(:device) { current_graph.stray_blk_devices.first } + + subject { described_class.new(device) } + + include_examples "CWM::Page" + + describe "#contents" do + let(:widgets) { Yast::CWM.widgets_in_contents([subject]) } + + it "shows the description of the device" do + description = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::BlkDeviceDescription) } + expect(description).to_not be_nil + end + + it "shows a button for editing the device" do + button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::BlkDeviceEditButton) } + expect(button).to_not be_nil + end + + it "does not display a button for moving the device" do + button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::PartitionMoveButton) } + expect(button).to be_nil + end + + it "does not display a button for resizing the device" do + button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::DeviceResizeButton) } + expect(button).to be_nil + end + + it "does not display a button for deleting the device" do + button = widgets.detect { |i| i.is_a?(Y2Partitioner::Widgets::DeviceDeleteButton) } + expect(button).to be_nil + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2storage/clients/inst_disk_proposal_test.rb new/yast2-storage-ng-4.1.4/test/y2storage/clients/inst_disk_proposal_test.rb --- old/yast2-storage-ng-4.1.3/test/y2storage/clients/inst_disk_proposal_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2storage/clients/inst_disk_proposal_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -28,6 +28,7 @@ describe "#run" do let(:proposal_dialog) { double("Y2Storage::Dialogs::Proposal") } + let(:guided_dialog) { double("Y2Storage::Dialogs::GuidedSetup") } let(:storage_manager) { Y2Storage::StorageManager.instance } before do @@ -253,6 +254,70 @@ end end + describe "if the guided setup button is pressed in the proposal dialog" do + before do + allow(Y2Storage::Dialogs::Proposal).to receive(:new).and_return(proposal_dialog) + # First try to open the guided setup, then force quit to end the test + allow(proposal_dialog).to receive(:run).and_return(:guided, :abort) + + allow(initial_proposal).to receive(:settings).and_return proposal_settings + end + + let(:proposal_settings) { double("Y2Storage::ProposalSettings") } + + context "when the staging devicegraph has been manually set" do + before { allow(proposal_dialog).to receive(:proposal).and_return nil } + + it "ask the user for confirmation" do + expect(Yast::Popup).to receive(:YesNo) + client.run + end + + context "and the user confirms to continue" do + before { allow(Yast::Popup).to receive(:YesNo).and_return true } + + it "opens the guided setup dialog" do + expect(Y2Storage::Dialogs::GuidedSetup).to receive(:new).and_return(guided_dialog) + expect(guided_dialog).to receive(:run) + + client.run + end + end + + context "and the user denies the confirmation" do + before { allow(Yast::Popup).to receive(:YesNo).and_return false } + + it "does not open the guided setup dialog" do + expect(Y2Storage::Dialogs::GuidedSetup).to_not receive(:new) + + client.run + end + end + end + + context "when the staging devicegraph has been set by a proposal" do + before do + allow(proposal_dialog).to receive(:proposal).and_return initial_proposal + + allow(Y2Storage::Dialogs::GuidedSetup).to receive(:new).and_return(guided_dialog) + end + + it "does not ask the user for confirmation" do + allow(guided_dialog).to receive(:run) + + expect(Yast::Popup).to_not receive(:YesNo) + client.run + end + + it "opens the guided setup dialog" do + expect(Y2Storage::Dialogs::GuidedSetup).to receive(:new) + expect(guided_dialog).to receive(:run) + + client.run + end + end + end + describe "calling the expert partitioner" do let(:partitioner) { double("Y2Partitioner::Dialogs::Main") } @@ -418,7 +483,6 @@ end context "processing the guided setup result" do - let(:guided_dialog) { double("Y2Storage::Dialogs::GuidedSetup") } let(:devicegraph) { double("Y2Storage::Devicegraph") } let(:settings) { double("Storage::ProposalSettings") } let(:proposal) { double("Y2Storage::GuidedProposal", devices: devicegraph, settings: settings) } @@ -429,6 +493,9 @@ allow(Y2Storage::Dialogs::GuidedSetup).to receive(:new).and_return(guided_dialog) # Just to quit allow(second_proposal_dialog).to receive(:run).and_return :abort + + # Just to make sure the popup about overwriting a manual setup is not raised + allow(proposal_dialog).to receive(:proposal).and_return(proposal) end context "if the guided setup returns :abort" do @@ -444,7 +511,6 @@ context "if the guided setup returns :back" do before do - allow(proposal_dialog).to receive(:proposal).and_return(proposal) allow(proposal_dialog).to receive(:devicegraph).and_return(devicegraph) allow(guided_dialog).to receive(:run).and_return :back end @@ -510,10 +576,6 @@ it "aborts" do expect(client.run).to eq :abort end - it "recognizes that the user has NOT changed settings" do - client.run - expect(client.manual_changed).to eq(false) - end end context "if the expert partitioner returns :back" do @@ -568,15 +630,6 @@ .and_return(second_proposal_dialog) client.run end - it "recognizes that the user has changed settings" do - allow(Y2Storage::Dialogs::Proposal).to receive(:new).once - .and_return(proposal_dialog) - allow(Y2Storage::Dialogs::Proposal).to receive(:new).once - .with(nil, new_devicegraph, anything) - .and_return(second_proposal_dialog) - client.run - expect(client.manual_changed).to eq(true) - end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2storage/devicegraph_test.rb new/yast2-storage-ng-4.1.4/test/y2storage/devicegraph_test.rb --- old/yast2-storage-ng-4.1.3/test/y2storage/devicegraph_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2storage/devicegraph_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -810,7 +810,11 @@ end describe "#blk_devices" do - before { fake_scenario("complex-lvm-encrypt") } + before do + fake_scenario("complex-lvm-encrypt") + Y2Storage::StrayBlkDevice.create(fake_devicegraph, "/dev/xvda3") + end + subject(:list) { fake_devicegraph.blk_devices } it "returns a sorted array of block devices" do @@ -820,7 +824,7 @@ end it "finds all the devices" do - expect(list.size).to eq 24 + expect(list.size).to eq 25 end it "does not include other devices like volume groups" do @@ -830,6 +834,31 @@ end end + describe "#stray_blk_devices" do + before do + fake_scenario("mixed_disks") + end + + subject(:devicegraph) { fake_devicegraph } + + context "when there are virtual partitions" do + before do + Y2Storage::StrayBlkDevice.create(devicegraph, "/dev/xvda3") + Y2Storage::StrayBlkDevice.create(devicegraph, "/dev/xvda1") + end + + it "returns all virtual partitions sorted by name" do + expect(devicegraph.stray_blk_devices.map(&:name)).to eq ["/dev/xvda1", "/dev/xvda3"] + end + end + + context "when there are no virtual partitions" do + it "does not include any device" do + expect(devicegraph.stray_blk_devices).to be_empty + end + end + end + describe "#inspect" do context "when some devices are not supported by YamlWriter" do before do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2storage/disk_analyzer_test.rb new/yast2-storage-ng-4.1.4/test/y2storage/disk_analyzer_test.rb --- old/yast2-storage-ng-4.1.3/test/y2storage/disk_analyzer_test.rb 2018-08-01 10:42:52.000000000 +0200 +++ new/yast2-storage-ng-4.1.4/test/y2storage/disk_analyzer_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -219,6 +219,19 @@ end end + context "when there are some stray block devices (Xen virtual partitions)" do + let(:scenario) { "xen-disks-and-partitions.xml" } + + it "includes the Xen devices representing disks" do + expect(candidate_disks).to include("/dev/xvdc") + end + + it "does not include the Xen devices representing partitions" do + expect(candidate_disks).to_not include("/dev/xvda1") + expect(candidate_disks).to_not include("/dev/xvda2") + end + end + context "when a disk device is directly formatted" do before do format_device(sdb) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-storage-ng-4.1.3/test/y2storage/proposal_xen_devices_test.rb new/yast2-storage-ng-4.1.4/test/y2storage/proposal_xen_devices_test.rb --- old/yast2-storage-ng-4.1.3/test/y2storage/proposal_xen_devices_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-storage-ng-4.1.4/test/y2storage/proposal_xen_devices_test.rb 2018-08-10 17:51:03.000000000 +0200 @@ -0,0 +1,55 @@ +#!/usr/bin/env rspec +# encoding: utf-8 + +# Copyright (c) [2018] SUSE LLC +# +# All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of version 2 of the GNU General Public License as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, contact SUSE LLC. +# +# To contact SUSE LLC about this file by physical or electronic mail, you may +# find current contact information at www.suse.com. + +require_relative "spec_helper" +require "y2storage" +require_relative "#{TEST_PATH}/support/proposal_examples" +require_relative "#{TEST_PATH}/support/proposal_context" + +describe Y2Storage::GuidedProposal do + describe ".initial" do + include_context "proposal" + + context "with Xen devices representing virtual disks and partitions" do + let(:scenario) { "xen-disks-and-partitions.xml" } + + it "makes a proposal that doesn't use the virtual partitions (stray devices)" do + proposal = described_class.initial + used_devices = proposal.devices.actiongraph.compound_actions.map(&:target_device) + # Leave the Btrfs subvolumes out, they are noise for our purposes + device_names = used_devices.reject { |dev| dev.is?(:btrfs_subvolume) }.map(&:name) + + used_stray_device = device_names.find { |name| name.start_with?("/dev/xvda") } + expect(used_stray_device).to be_nil + end + end + + context "if there are only Xen virtual partitions (no disks)" do + let(:scenario) { "xen-partitions.xml" } + + it "fails to make a successful proposal" do + proposal = described_class.initial + expect(proposal.failed?).to eq true + end + end + end +end
