[PATCH] Remove raid clone option and code (#587036)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove the raid clone option from the create-storage menu, and also
remove the underlying code. It is broken, and this has not been noticed
until very recently as no-one uses it. So as discussed on irc it is better
to just remove it, otherwise the next time we accidentally break it,
it will likely once more remain broken for a long time.

This also "fixes" RHEL-6 bug 589957.
---
 iw/partition_gui.py     |   35 +------
 iw/raid_dialog_gui.py   |  294 -----------------------------------------------
 ui/create-storage.glade |   43 +------
 3 files changed, 5 insertions(+), 367 deletions(-)

diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index 7ce4df2..9496e4e 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -1335,18 +1335,11 @@ class PartitionWindow(InstallWindow):
                 and availraidparts > 1):
             activate_create_raid_dev = True
 
-        # FIXME: Why do I need availraidparts to clone?
-        activate_create_raid_clone = False
-        if (len(self.storage.partitioned) > 1
-                and availraidparts > 0):
-            activate_create_raid_clone = True
-
         # Must check if all the possibilities are False.  In this case tell the
         # user that he can't create anything and the reasons.
         if (not activate_create_partition
                 and not activate_create_vg
-                and not activate_create_raid_dev
-                and not activate_create_raid_clone):
+                and not activate_create_raid_dev):
             self.intf.messageWindow(_("Cannot perform any creation action"),
                         _("Note that the creation action requires one of the "
                         "following:\n\n"
@@ -1433,12 +1426,6 @@ class PartitionWindow(InstallWindow):
         if activate_create_raid_dev:
             rd_rb.set_sensitive(True)
 
-        # Activate RAID clone if needed.
-        # rc_rb -> RAID clone
-        rc_rb = create_storage_xml.get_widget("create_storage_rb_raid_clone")
-        if activate_create_raid_clone:
-            rc_rb.set_sensitive(True)
-
         # Before drawing lets select the first radio button that is sensitive:
         # How can I get sensitivity from gtk.radiobutton?
         if activate_create_partition:
@@ -1450,9 +1437,6 @@ class PartitionWindow(InstallWindow):
         elif activate_create_raid_dev:
             rd_rb.set_active(True)
             rd_rb.grab_focus()
-        elif activate_create_raid_clone:
-            rc_rb.set_active(True)
-            rc_rb.grab_focus()
 
         gui.addFrame(self.dialog)
         self.dialog.show_all()
@@ -1525,23 +1509,6 @@ class PartitionWindow(InstallWindow):
             self.editPartition(member, isNew = True, restrictfs=["mdmember"])
             return
 
-        elif rc_rb.get_active():
-            # r_d_g -> raid_dialog_gui
-            cloneDialog = r_d_g.RaidCloneDialog(self.storage, self.intf,
-                    self.parent)
-            if cloneDialog is None:
-                self.intf.messageWindow(_("Couldn't Create Drive Clone Editor"),
-                                        _("The drive clone editor could not "
-                                          "be created for some reason."),
-                                        custom_icon="error")
-                return
-
-            if cloneDialog.run():
-                self.refresh()
-
-            cloneDialog.destroy()
-            return
-
         elif rd_rb.get_active():
             array = self.storage.newMDArray(fmt_type=self.storage.defaultFSType)
             self.editRaidArray(array, isNew = True)
diff --git a/iw/raid_dialog_gui.py b/iw/raid_dialog_gui.py
index 9b633d6..2255815 100644
--- a/iw/raid_dialog_gui.py
+++ b/iw/raid_dialog_gui.py
@@ -613,297 +613,3 @@ class RaidEditor:
         self.allow_ok_button(path)
         return 1
 
-class RaidCloneDialog:
-    def createDriveList(self, disks):
-
-	store = gtk.ListStore(gobject.TYPE_STRING)
-        view = gtk.TreeView(store)
-
-	sw = gtk.ScrolledWindow()
-	sw.add(view)
-	sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
-	sw.set_shadow_type(gtk.SHADOW_IN)
-
-        for disk in disks:
-            iter = store.append()
-            store.set_value(iter, 0, disk.name)
-            
-        view.set_property("headers-visible", False)
-
-        col = gtk.TreeViewColumn("", gtk.CellRendererText(), text=0)
-        view.append_column(col)
-        
-        return (sw, view)
-
-    def getInterestingRequestsForDrive(self, drive):
-        disk = self.storage.devicetree.getDeviceByName(drive)
-        allrequests = self.storage.devicetree.getDependentDevices(disk)
-
-	if not allrequests:
-	    return allrequests
-
-        # remove extended partitions
-        requests = []
-        for req in allrequests:
-            if req.type == "partition" and req.isExtended:
-                continue
-	    elif req.type != "partition":
-		continue
-
-            requests.append(req)
-
-        return requests
-
-    def sanityCheckSourceDrive(self):
-        # first see if it has any non-software RAID partitions
-        requests = self.getInterestingRequestsForDrive(self.sourceDrive)
-        
-        errmsg1 = _("The source drive has no partitions to be cloned.  "
-                    "You must first define partitions of type "
-                    "'software RAID' on this drive before it can be cloned.")
-        if requests is None or len(requests) == 0:
-            self.intf.messageWindow(_("Source Drive Error"), errmsg1,
-				    custom_icon="error")
-            return 1
-
-        for req in requests:
-            if req.format.type != "mdmember":
-                self.intf.messageWindow(_("Source Drive Error"),
-                                        _("The source drive you selected has "
-                                          "partitions which are not of "
-                                          "type 'software RAID'.\n\n"
-                                          "You must remove these "
-                                          "partitions "
-                                          "before this drive can be cloned. "),
-					custom_icon="error")
-                return 1
-
-        sourceDev = self.storage.devicetree.getDeviceByName(self.sourceDrive)
-        for req in requests:
-            if not req.req_disks or len(req.req_disks) > 1 or \
-               req.req_disks[0] != self.sourceDrive:
-                self.intf.messageWindow(_("Source Drive Error"),
-                                        _("The source drive you selected has "
-                                          "partitions which are not "
-                                          "constrained to the drive %s.\n\n"
-                                          "You must remove these partitions "
-                                          "or restrict them to this "
-                                          "drive "
-                                          "before this drive can be cloned. ")
-                                        %(sourceDev.path,), custom_icon="error")
-                return 1
-
-        for req in requests:
-            if req not in self.storage.unusedMDMembers():
-                self.intf.messageWindow(_("Source Drive Error"),
-                                        _("The source drive you selected has "
-                                          "software RAID partition(s) which "
-                                          "are members of an active "
-                                          "software RAID device.\n\n"
-                                          "You must remove these partitions "
-                                          "before this drive "
-                                          "can be cloned."), custom_icon="error")
-                return 1
-
-        return 0
-
-    def sanityCheckTargetDrives(self):
-        sourceDev = self.storage.devicetree.getDeviceByName(self.sourceDrive)
-        if self.targetDrives is None or len(self.targetDrives) < 1:
-                self.intf.messageWindow(_("Target Drive Error"),
-                                        _("Please select the target drives "
-                                          "for the clone operation."), custom_icon="error")
-                return 1
-
-        if self.sourceDrive in self.targetDrives:
-                self.intf.messageWindow(_("Target Drive Error"),
-                                        _("The source drive %s cannot be "
-                                          "selected as a target drive as well.")
-                                        % (sourceDev.path,),
-                                        custom_icon="error")
-                return 1
-
-        for drive in self.targetDrives:
-            requests = self.getInterestingRequestsForDrive(drive)
-	    if requests is None:
-		continue
-	    
-            targetDev = self.storage.devicetree.getDeviceByName(drive)
-            for req in requests:
-                rc = self.storage.deviceImmutable(req)
-                if rc:
-                    self.intf.messageWindow(_("Target Drive Error"),
-                                            _("The target drive %(path)s "
-                                              "has a partition which cannot "
-                                              "be removed for the following "
-                                              "reason:\n\n\"%(rc)s\"\n\n"
-                                              "You must remove this partition "
-                                              "before "
-                                              "this drive can be a target.") %
-                                            {'path': targetDev.path, 'rc': rc},
-                                            custom_icon="error")
-                    return 1
-
-        return 0
-
-
-    def cloneDrive(self):
-	# first create list of interesting partitions on the source drive
-        requests = self.getInterestingRequestsForDrive(self.sourceDrive)
-
-	# no requests to clone, bail out
-	if not requests:
-	    return 0
-
-	# now try to clear the target drives
-	for devname in self.targetDrives:
-            device = self.storage.devicetree.getDeviceByName(devname)
-            doClearPartitionedDevice(self.intf, self.storage,
-				     device, confirm=0, quiet=1)
-
-	# now clone!
-	for req in requests:
-	    for drive in self.targetDrives:
-                # this feels really dirty
-                device = self.storage.devicetree.getDeviceByName(drive)
-                newdev = copy.deepcopy(req)
-                newdev.req_disks = [device]
-                newdev.exists = False
-                newdev.format.exists = False
-                newdev.format.device = None
-                self.storage.createDevice(newdev)
-		
-	return
-	
-
-    def targetSelectFunc(self, model, path, iter):
-        self.targetDrives.append(model.get_value(iter,0))
-        
-    def run(self):
-	if self.dialog is None:
-	    return None
-	
-	while 1:
-	    rc = self.dialog.run()
-
-	    # user hit cancel, do nothing
-	    if rc in [gtk.RESPONSE_CANCEL, gtk.RESPONSE_DELETE_EVENT]:
-		self.destroy()
-		return None
-
-            # see what drive they selected as the source
-            selection = self.sourceView.get_selection()
-            (model, iter) = selection.get_selected()
-            if iter is None:
-                self.intf.messageWindow(_("Error"),
-                                        _("Please select a source drive."),
-					custom_icon="error")
-                continue
-
-            self.sourceDrive = model.get_value(iter, 0)
-
-            # sanity check it
-            if self.sanityCheckSourceDrive():
-                continue
-            
-            # now get target drive(s)
-            self.targetDrives = []
-            selection = self.targetView.get_selection()
-            selection.selected_foreach(self.targetSelectFunc)
-
-            # sanity check it
-            if self.sanityCheckTargetDrives():
-                continue
-
-	    # now give them last chance to bail
-	    msgtxt = _("The drive %s will now be cloned to the "
-		       "following drives:\n\n" % (self.sourceDrive,))
-	    for drive in self.targetDrives:
-		msgtxt = msgtxt + "\t" + "%s" % (drive,)
-
-	    msgtxt = msgtxt + _("\n\nWARNING! ALL DATA ON THE TARGET DRIVES "
-				"WILL BE DESTROYED.")
-	    
-	    rc = self.intf.messageWindow(_("Final Warning"),
-					 msgtxt, type="custom",
-					 custom_buttons = ["gtk-cancel", _("Clone Drives")], custom_icon="warning")
-	    if not rc:
-		return 0
-
-	    # try to clone now
-	    ret = self.cloneDrive()
-
-	    if ret:
-		self.intf.messageWindow(_("Error"),
-					_("There was an error clearing the "
-					  "target drives.  Cloning failed."),
-					custom_icon="error")
-		return 0
-
-	    # if everything ok, break out
-	    if not ret:
-		break
-
-	return 1
-
-    def destroy(self):
-	if self.dialog:
-	    self.dialog.destroy()
-
-	self.dialog = None
-	
-    def __init__(self, storage, intf, parent):
-	self.storage = storage
-	self.intf = intf
-	self.parent = parent
-
-	self.dialog = None
-	self.dialog = gtk.Dialog(_("Clone Drive Tool"), self.parent)
-        self.dialog.set_default_size(500, 200)
-	gui.addFrame(self.dialog)
-	self.dialog.add_button('gtk-cancel', gtk.RESPONSE_CANCEL)
-	self.dialog.add_button('gtk-ok', 1)
-	self.dialog.set_position(gtk.WIN_POS_CENTER)
-
-        # present list of drives as source
-        vbox = gtk.VBox()
-        clnmessage = _("This tool clones the layout from a partitioned source "
-                        "onto other similar sized drives. The source must have "
-                        "partitions which are restricted to that drive and must "
-                        "ONLY contain unused software RAID partitions.  "
-                        "EVERYTHING on the target drive(s) will be destroyed.\n")
-
-        lbl = gui.WrappingLabel(clnmessage)
-        vbox.pack_start(lbl)
-                                  
-        box = gtk.HBox()
-
-        lbl = gtk.Label(_("Source Drive:"))
-        lbl.set_alignment(0.0, 0.0)
-        box.pack_start(lbl, padding=5)
-        (sw, self.sourceView) = self.createDriveList(storage.partitioned)
-        selection = self.sourceView.get_selection()
-        selection.set_mode(gtk.SELECTION_SINGLE)
-        box.pack_start(sw, padding=5)
-
-        lbl = gtk.Label(_("Target Drive(s):"))
-        lbl.set_alignment(0.0, 0.0)
-        box.pack_start(lbl, padding=5)
-        (sw, self.targetView) = self.createDriveList(storage.partitioned)
-        selection = self.targetView.get_selection()
-        selection.set_mode(gtk.SELECTION_MULTIPLE)
-        box.pack_start(sw, padding=5)
-
-        frame = gtk.Frame(_("Drives"))
-        frame.add(box)
-        vbox.pack_start(frame)
-
-	# put contents into dialog
-	self.dialog.vbox.pack_start(vbox)
-
-	self.dialog.show_all()
-
-	return
-
-
-
diff --git a/ui/create-storage.glade b/ui/create-storage.glade
index b9e246c..98db7d7 100644
--- a/ui/create-storage.glade
+++ b/ui/create-storage.glade
@@ -179,41 +179,6 @@
               </packing>
             </child>
             <child>
-              <widget class="GtkVBox" id="vbox5">
-                <property name="visible">True</property>
-                <property name="orientation">vertical</property>
-                <child>
-                  <widget class="GtkRadioButton" id="create_storage_rb_raid_clone">
-                    <property name="label" translatable="yes">RAID Clone</property>
-                    <property name="visible">True</property>
-                    <property name="sensitive">False</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="draw_indicator">True</property>
-                    <property name="group">create_storage_rb_standard_part</property>
-                  </widget>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label7">
-                    <property name="visible">True</property>
-                    <property name="xalign">0</property>
-                    <property name="xpad">20</property>
-                    <property name="label" translatable="yes">&lt;span size="small" color="gray"&gt;Facilitates RAID device creation&lt;/span&gt;</property>
-                    <property name="use_markup">True</property>
-                  </widget>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </widget>
-              <packing>
-                <property name="position">5</property>
-              </packing>
-            </child>
-            <child>
               <widget class="GtkHBox" id="hbox3">
                 <property name="visible">True</property>
                 <child>
@@ -245,7 +210,7 @@
                 </child>
               </widget>
               <packing>
-                <property name="position">6</property>
+                <property name="position">5</property>
               </packing>
             </child>
             <child>
@@ -280,7 +245,7 @@
                 </child>
               </widget>
               <packing>
-                <property name="position">7</property>
+                <property name="position">6</property>
               </packing>
             </child>
             <child>
@@ -326,7 +291,7 @@
                 </child>
               </widget>
               <packing>
-                <property name="position">8</property>
+                <property name="position">7</property>
               </packing>
             </child>
             <child>
@@ -361,7 +326,7 @@
                 </child>
               </widget>
               <packing>
-                <property name="position">9</property>
+                <property name="position">8</property>
               </packing>
             </child>
           </widget>
-- 
1.7.0.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux