Esempio n. 1
0
    def newFormat(*args, **kwargs):
        """ Return a new DeviceFormat instance suitable for testing.

            Keyword Arguments:

                device_instance - StorageDevice instance this format will be
                                  created on. This is needed for setup of
                                  resizable formats.

            All other arguments are passed directly to
            pyanaconda.storage.formats.getFormat.
        """
        args = args[1:]  # drop self arg
        exists = kwargs.pop("exists", False)
        device_instance = kwargs.pop("device_instance", None)
        format = getFormat(*args, **kwargs)
        if isinstance(format, storage.formats.disklabel.DiskLabel):
            format._partedDevice = Mock()
            format._partedDisk = Mock()

        format.exists = exists

        if format.resizable and device_instance:
            format._size = device_instance.currentSize

        return format
    def newFormat(*args, **kwargs):
        """ Return a new DeviceFormat instance suitable for testing.

            Keyword Arguments:

                device_instance - StorageDevice instance this format will be
                                  created on. This is needed for setup of
                                  resizable formats.

            All other arguments are passed directly to
            pyanaconda.storage.formats.getFormat.
        """
        args = args[1:] # drop self arg
        exists = kwargs.pop("exists", False)
        device_instance = kwargs.pop("device_instance", None)
        format = getFormat(*args, **kwargs)
        if isinstance(format, storage.formats.disklabel.DiskLabel):
            format._partedDevice = Mock()
            format._partedDisk = Mock()

        format.exists = exists

        if format.resizable and device_instance:
            format._size = device_instance.currentSize

        return format
Esempio n. 3
0
    def getNext (self):
        # I don't like this but I also don't see a better way right now
        for (cb, entry) in self.cbs:
            action = self.devicetree.findActions(device=entry,
                                                 type="migrate")
            if cb.get_active():
                if action:
                    # the migrate action has already been scheduled
                    continue

                newfs = getFormat(entry.format.migrationTarget)
                if not newfs:
                    log.warning("failed to get new filesystem type (%s)"
                                % entry.format.migrationTarget)
                    continue
                action = ActionMigrateFormat(entry)
                self.devicetree.registerAction(action)
            elif action:
                self.devicetree.cancelAction(action)

        return None
Esempio n. 4
0
    def __call__(self, screen, anaconda):

        migent = anaconda.storage.migratableDevices

        g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4)

        text = (_("This release of %(productName)s supports "
                  "an updated file system, which has several "
                  "benefits over the file system traditionally shipped "
                  "in %(productName)s.  This installation program can migrate "
                  "formatted partitions without data loss.\n\n"
                  "Which of these partitions would you like to migrate?") % {
                      'productName': productName
                  })

        tb = TextboxReflowed(60, text)
        g.add(tb, 0, 0, anchorLeft=1, padding=(0, 0, 0, 1))

        partlist = CheckboxTree(height=4, scroll=1)
        for device in migent:
            if not device.format.exists:
                migrating = True
            else:
                migrating = False

            # FIXME: the fstype at least will be wrong here
            partlist.append(
                "%s - %s - %s" %
                (device.path, device.format.type, device.format.mountpoint),
                device, migrating)

        g.add(partlist, 0, 1, padding=(0, 0, 0, 1))

        buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON])
        g.add(buttons, 0, 3, anchorLeft=1, growx=1)

        while 1:
            result = g.run()

            if (buttons.buttonPressed(result)):
                result = buttons.buttonPressed(result)

            if result == TEXT_BACK_CHECK:
                screen.popWindow()
                return INSTALL_BACK

        # reset
        # XXX the way to do this is by scheduling and cancelling actions
        #for entry in migent:
        #    entry.setFormat(0)
        #    entry.setMigrate(0)
        #    entry.fsystem = entry.origfsystem

            for entry in partlist.getSelection():
                try:
                    newfs = getFormat(entry.format.migratetofs[0])
                except Exception, e:
                    log.info(
                        "failed to get new filesystem type, defaulting to ext3: %s"
                        % (e, ))
                    newfs = getFormat("ext3")
                    anaconda.storage.migrateFormat(entry, newfs)

            screen.popWindow()
            return INSTALL_OK
    def __call__ (self, screen, anaconda):
      
        migent = anaconda.storage.migratableDevices

	g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4)

	text = (_("This release of %(productName)s supports "
                 "an updated file system, which has several "
                 "benefits over the file system traditionally shipped "
                 "in %(productName)s.  This installation program can migrate "
                 "formatted partitions without data loss.\n\n"
                 "Which of these partitions would you like to migrate?") %
                  {'productName': productName})

	tb = TextboxReflowed(60, text)
	g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1))

        partlist = CheckboxTree(height=4, scroll=1)
        for device in migent:
            if not device.format.exists:
                migrating = True
            else:
                migrating = False

            # FIXME: the fstype at least will be wrong here
            partlist.append("%s - %s - %s" % (device.path,
                                              device.format.type,
                                              device.format.mountpoint),
                                              device, migrating)
            
	g.add(partlist, 0, 1, padding = (0, 0, 0, 1))
        
	buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] )
	g.add(buttons, 0, 3, anchorLeft = 1, growx = 1)

	while 1:
	    result = g.run()
        
	    if (buttons.buttonPressed(result)):
		result = buttons.buttonPressed(result)

	    if result == TEXT_BACK_CHECK:
		screen.popWindow()
		return INSTALL_BACK

            # reset
            # XXX the way to do this is by scheduling and cancelling actions
            #for entry in migent:
            #    entry.setFormat(0)
            #    entry.setMigrate(0)
            #    entry.fsystem = entry.origfsystem

            for entry in partlist.getSelection():
                try:
                    newfs = getFormat(entry.format.migratetofs[0])
                except Exception, e:
                    log.info("failed to get new filesystem type, defaulting to ext3: %s" %(e,))
                    newfs = getFormat("ext3")
                    anaconda.storage.migrateFormat(entry, newfs)

            screen.popWindow()
            return INSTALL_OK
Esempio n. 6
0
    def __call__ (self, screen, anaconda):
        migent = anaconda.storage.migratableDevices

	g = GridFormHelp(screen, _("Migrate File Systems"), "upmigfs", 1, 4)

	text = (_("This release of %(productName)s supports "
                 "an updated file system, which has several "
                 "benefits over the file system traditionally shipped "
                 "in %(productName)s.  This installation program can migrate "
                 "formatted partitions without data loss.\n\n"
                 "Which of these partitions would you like to migrate?") %
                  {'productName': productName})

	tb = TextboxReflowed(60, text)
	g.add(tb, 0, 0, anchorLeft = 1, padding = (0, 0, 0, 1))

        partlist = CheckboxTree(height=4, scroll=1)
        for device in migent:
            if not device.format.exists:
                migrating = True
            else:
                migrating = False

            # FIXME: the fstype at least will be wrong here
            partlist.append("%s - %s - %s" % (device.path,
                                              device.format.type,
                                              device.format.mountpoint),
                                              device, migrating)

	g.add(partlist, 0, 1, padding = (0, 0, 0, 1))

	buttons = ButtonBar(screen, [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] )
	g.add(buttons, 0, 3, anchorLeft = 1, growx = 1)

	while True:
	    result = g.run()

	    if (buttons.buttonPressed(result)):
		result = buttons.buttonPressed(result)

	    if result == TEXT_BACK_CHECK:
		screen.popWindow()
		return INSTALL_BACK

            # Cancel any previously scheduled migrate actions first.
            for entry in partlist.getSelection():
                actions = anaconda.storage.devicetree.findActions(device=entry[1],
                                                                  type="migrate")
                if not actions:
                    continue

                for action in actions:
                    anaconda.storage.devicetree.cancelAction(action)

            # Then schedule an action for whatever rows were selected.
            for entry in partlist.getSelection():
                newfs = getFormat(entry[1].format.migrationTarget)
                if not newfs:
                    log.warning("failed to get new filesystem type (%s)"
                                % entry[1].format.migrationTarget)
                    continue

                action = ActionMigrateFormat(entry[1])
                anaconda.storage.devicetree.registerAction(action)

            screen.popWindow()
            return INSTALL_OK
    def testActionCreation(self, *args, **kwargs):
        """ Verify correct operation of action class constructors. """
        # instantiation of device resize action for non-existent device should
        # fail
        # XXX resizable depends on existence, so this is covered implicitly
        sdd = self.storage.devicetree.getDeviceByName("sdd")
        p = self.newDevice(device_class=PartitionDevice,
                           name="sdd1", size=32768, parents=[sdd])
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionResizeDevice,
                              p,
                              p.size + 7232)

        # instantiation of device resize action for non-resizable device
        # should fail
        vg = self.storage.devicetree.getDeviceByName("VolGroup")
        self.assertNotEqual(vg, None)
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionResizeDevice,
                              vg,
                              vg.size + 32)

        # instantiation of format resize action for non-resizable format type
        # should fail
        lv_swap = self.storage.devicetree.getDeviceByName("VolGroup-lv_swap")
        self.assertNotEqual(lv_swap, None)
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionResizeFormat,
                              lv_swap,
                              lv_swap.size + 32)

        # instantiation of format resize action for non-existent format
        # should fail
        lv_root = self.storage.devicetree.getDeviceByName("VolGroup-lv_root")
        self.assertNotEqual(lv_root, None)
        lv_root.format.exists = False
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionResizeFormat,
                              lv_root,
                              lv_root.size - 1000)
        lv_root.format.exists = True

        # instantiation of format migrate action for non-migratable format
        # type should fail
        lv_swap = self.storage.devicetree.getDeviceByName("VolGroup-lv_swap")
        self.assertNotEqual(lv_swap, None)
        self.assertEqual(lv_swap.exists, True)
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionMigrateFormat,
                              lv_swap)

        # instantiation of format migrate for non-existent format should fail
        lv_root = self.storage.devicetree.getDeviceByName("VolGroup-lv_root")
        self.assertNotEqual(lv_root, None)
        orig_format = lv_root.format
        lv_root.format = getFormat("ext3", device=lv_root.path)
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionMigrateFormat,
                              lv_root)
        lv_root.format = orig_format

        # instantiation of device create action for existing device should
        # fail
        lv_swap = self.storage.devicetree.getDeviceByName("VolGroup-lv_swap")
        self.assertNotEqual(lv_swap, None)
        self.assertEqual(lv_swap.exists, True)
        self.failUnlessRaises(ValueError,
                              storage.deviceaction.ActionCreateDevice,
                              lv_swap)

        # instantiation of format destroy action for device causes device's
        # format attribute to be a DeviceFormat instance
        lv_swap = self.storage.devicetree.getDeviceByName("VolGroup-lv_swap")
        self.assertNotEqual(lv_swap, None)
        orig_format = lv_swap.format
        self.assertEqual(lv_swap.format.type, "swap")
        a = storage.deviceaction.ActionDestroyFormat(lv_swap)
        self.assertEqual(lv_swap.format.type, None)

        # instantiation of format create action for device causes new format
        # to be accessible via device's format attribute
        new_format = getFormat("vfat", device=lv_swap.path)
        a = storage.deviceaction.ActionCreateFormat(lv_swap, new_format)
        self.assertEqual(lv_swap.format, new_format)
        lv_swap.format = orig_format