[PATCH 3/6] Migrate FS user interface plumbing.

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

 



Hook up the migrate fs UI components with the new storage backend.
Highlights:
    - If user selects Migrate filesystem to, the Format checkbox is
      disabled.  Same for the reverse, selecting Format disables
      the Migrate options.
    - Mount point entry box is not disabled for migrate selections.
    - Wrap the return value in storage.formats.fs.FS.migratable
      in bool().  If the filter() operation returns a list, that's
      what we get in the return value rather than True.
    - Other minor typo and syntax fixes.
---
 iw/partition_dialog_gui.py     |    5 +--
 iw/partition_ui_helpers_gui.py |   53 +++++++++++++++++++---------------------
 storage/deviceaction.py        |    1 +
 storage/formats/__init__.py    |    6 ++--
 storage/formats/fs.py          |   18 +++++++------
 5 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/iw/partition_dialog_gui.py b/iw/partition_dialog_gui.py
index bdaaacd..4f428e6 100644
--- a/iw/partition_dialog_gui.py
+++ b/iw/partition_dialog_gui.py
@@ -27,7 +27,7 @@ import gtk
 
 import gui
 from storage.devices import PartitionDevice
-from storage.deviceaction import ActionCreateFormat
+from storage.deviceaction import *
 from partition_ui_helpers_gui import *
 from constants import *
 
@@ -203,8 +203,7 @@ class PartitionEditor:
                 if self.fsoptionsDict.has_key("migratecb") and \
                    self.fsoptionsDict["migratecb"].get_active():
                     format = getFormat(self.fsoptionsDict["migfstypeCombo"].get_active_value(), mountpoint=mountpoint)
-                    # TODO: implement ActionMigrateFormat
-                    #actions.append(ActionMigrateFormat(request, format))
+                    actions.append(ActionMigrateFormat(request))
 
                 if self.fsoptionsDict.has_key("resizecb") and \
                    self.fsoptionsDict["resizecb"].get_active():
diff --git a/iw/partition_ui_helpers_gui.py b/iw/partition_ui_helpers_gui.py
index 8fd455b..f868fbf 100644
--- a/iw/partition_ui_helpers_gui.py
+++ b/iw/partition_ui_helpers_gui.py
@@ -30,7 +30,7 @@ import iutil
 from constants import *
 from partIntfHelpers import *
 from partedUtils import *
-from storage.formats import device_formats, getFormat, get_default_filesystem_type
+from storage.formats import *
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -89,17 +89,18 @@ def createMountPointCombo(request, excludeMountPoints=[]):
     if request.exists and label and label.startswith("/"):
         mntptlist.append(label)
         idx = 0
-    
+
     for p in defaultMountPoints:
-	if p in excludeMountPoints:
-	    continue
-	
-	if not p in mntptlist and (p[0] == "/"):
-	    mntptlist.append(p)
+        if p in excludeMountPoints:
+            continue
+
+        if not p in mntptlist and (p[0] == "/"):
+            mntptlist.append(p)
 
     map(mountCombo.append_text, mntptlist)
 
-    if request.format.type and request.format.mountable:
+    if (request.format.type or request.format.migrate) and \
+       request.format.mountable:
         mountpoint = request.format.mountpoint
         mountCombo.set_sensitive(1)
         if mountpoint:
@@ -247,9 +248,13 @@ def formatOptionResizeCB(widget, resizesb):
     if resizesb.get_value_as_int() < lower:
         resizesb.set_value(adj.lower)
 
-def formatOptionCB(widget, data):
-    (combowidget, mntptcombo, ofstype, lukscb) = data
+def formatMigrateOptionCB(widget, data):
+    (combowidget, mntptcombo, ofstype, lukscb, othercombo, othercb) = data
+
     combowidget.set_sensitive(widget.get_active())
+    othercb.set_sensitive(not widget.get_active())
+    othercombo.set_sensitive(not widget.get_active())
+
     if lukscb is not None:
         lukscb.set_data("formatstate", widget.get_active())
         if not widget.get_active():
@@ -261,19 +266,11 @@ def formatOptionCB(widget, data):
 
     # inject event for fstype menu
     if widget.get_active():
-	fstype = combowidget.get_active_value()
-	setMntPtComboStateFromType(fstype, mntptcombo)
+        fstype = combowidget.get_active_value()
+        setMntPtComboStateFromType(fstype, mntptcombo)
         combowidget.grab_focus()
     else:
-	setMntPtComboStateFromType(ofstype, mntptcombo)
-
-def noformatCB(widget, data):
-    (combowidget, mntptcombo, ofstype) = data
-    combowidget.set_sensitive(not widget.get_active())
-
-    # inject event for fstype menu
-    if widget.get_active():
-	setMntPtComboStateFromType(ofstype, mntptcombo)
+        setMntPtComboStateFromType(ofstype, mntptcombo)
 
 
 """ createPreExistFSOptionSection: given inputs for a preexisting partition,
@@ -314,15 +311,10 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,
     # this gets added to the table a bit later on
     lukscb = gtk.CheckButton(_("_Encrypt"))
 
-    formatcb.connect("toggled", formatOptionCB,
-                    (fstypeCombo, mountCombo, ofstype, lukscb))
-
-
     if origrequest.format.migratable:
 	migratecb = gtk.CheckButton(label=_("Mi_grate filesystem to:"))
         migratecb.set_active(istruefalse(origrequest.format.migrate))
 
-        # TODO: unimplemented
 	migtypes = origrequest.format.migrationTarget
 
 	maintable.attach(migratecb, 0, 1, row, row + 1)
@@ -333,12 +325,17 @@ def createPreExistFSOptionSection(origrequest, maintable, row, mountCombo,
 	row = row + 1
         rc["migratecb"] = migratecb
         rc["migfstypeCombo"] = migfstypeCombo
-	migratecb.connect("toggled", formatOptionCB,
-                          (migfstypeCombo, mountCombo, ofstype, None))
+	migratecb.connect("toggled", formatMigrateOptionCB,
+                      (migfstypeCombo, mountCombo, ofstype, lukscb,
+	                   fstypeCombo, formatcb))
     else:
 	migratecb = None
 	migfstypeCombo = None
 
+    formatcb.connect("toggled", formatMigrateOptionCB,
+                     (fstypeCombo, mountCombo, ofstype, lukscb,
+                      migfstypeCombo, migratecb))
+
     if origrequest.resizable:
         resizecb = gtk.CheckButton(label=_("_Resize"))
         resizecb.set_active(origrequest.targetSize is not None)
diff --git a/storage/deviceaction.py b/storage/deviceaction.py
index 2f14a32..91aced4 100644
--- a/storage/deviceaction.py
+++ b/storage/deviceaction.py
@@ -140,6 +140,7 @@ class DeviceAction(object):
             raise ValueError("arg 1 must be a StorageDevice instance")
         self.device = device
         #self._backup = deepcopy(device)
+        self.format = self.device.format
 
     def execute(self, intf=None):
         """ perform the action """
diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index 8602923..04e7b98 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -80,8 +80,8 @@ def getFormat(fmt_type, *args, **kwargs):
 
             device -- path to the device on which the format resides
             uuid -- the UUID of the (preexisting) formatted device
-            exists -- whether or not the format exists on the device            
-            
+            exists -- whether or not the format exists on the device 
+
     """
     fmt_class = get_device_format_class(fmt_type)
     fmt = None
@@ -118,7 +118,7 @@ def get_device_format_class(fmt_type):
     fmt = device_formats.get(fmt_type)
     if not fmt:
         for fmt_class in device_formats.values():
-            if fmt_type == fmt_class.name:
+            if fmt_type == fmt_class:
                 fmt = fmt_class
                 break
             elif fmt_type in fmt_class._udevTypes:
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index f80a877..758ce68 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -140,7 +140,7 @@ class FS(DeviceFormat):
                 mountopts -- mount options for the filesystem
                 size -- the filesystem's size in MiB
                 exists -- indicates whether this is an existing filesystem
-                
+
         """
         if self.__class__ is FS:
             raise TypeError("FS is an abstract class.")
@@ -201,7 +201,7 @@ class FS(DeviceFormat):
         argv.extend(self.defaultFormatOptions)
         argv.append(self.device)
         return argv
-    
+
     def doFormat(self, *args, **kwargs):
         """ Create the filesystem.
 
@@ -259,7 +259,7 @@ class FS(DeviceFormat):
 
         if rc:
             raise FormatCreateError("format failed: %s" % rc, self.device)
-                                                                  
+
         self.exists = True
         self.notifyKernel()
 
@@ -599,11 +599,13 @@ class FS(DeviceFormat):
     @property
     def migratable(self):
         """ Can filesystems of this type be migrated? """
-        return (self._migratable and self.migratefsProg and
-                filter(lambda d: os.access("%s/%s" % (d, self.migratefsProg),
-                                           os.X_OK),
-                       os.environ["PATH"].split(":")) and
-                self.migrationTarget)
+
+        return bool(self._migratable and self.migratefsProg and
+                    filter(lambda d: os.access("%s/%s"
+                                               % (d, self.migratefsProg,),
+                                               os.X_OK),
+                           os.environ["PATH"].split(":")) and
+                    self.migrationTarget)
 
     def _setMigrate(self, migrate):
         if not migrate:
-- 
1.6.1.3

_______________________________________________
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