Пример #1
0
    def formToKickstart(self):
        if not self.y.packagesEnabled:
            return

        # Don't clear the lists out until now.  This means that if we failed
        # to start yum up, we can still write out the initial %packages
        # section.
        self.ks.packages.groupList = []
        self.ks.packages.packageList = []
        self.ks.packages.excludedList = []

        # Faster to grab all the package names up front rather than call
        # searchNevra in the loop below.
        allPkgNames = map(lambda pkg: pkg.name,
                          self.y.pkgSack.returnPackages())
        allPkgNames.sort()

        self.y.tsInfo.makelists()

        txmbrNames = map(lambda x: x.name, self.y.tsInfo.getMembers())

        for grp in filter(lambda x: x.selected, self.y.comps.groups):
            self.ks.packages.groupList.append(Group(name=grp.groupid))

            defaults = grp.default_packages.keys()
            optionals = grp.optional_packages.keys()

            for pkg in filter(
                    lambda x: x in defaults and
                (not x in txmbrNames and x in allPkgNames), grp.packages):
                self.ks.packages.excludedList.append(pkg)

            for pkg in filter(lambda x: x in txmbrNames, optionals):
                self.ks.packages.packageList.append(pkg)
Пример #2
0
    def create_group(self, name, include=GROUP_DEFAULT):
        """Create a new instance of a group.

        :param name: a name of the group
        :param include: a level of inclusion
        :return: a group object
        """
        return Group(name=name, include=include)
Пример #3
0
    def _convert_to_kickstart_groups(self):
        ks_groups = []
        for group_name in self.groups:
            ks_groups.append(
                Group(name=group_name,
                      include=self._groups_flags.get(group_name,
                                                     GROUP_DEFAULT)))

        return ks_groups
Пример #4
0
    def deselectGroup(self, groupid):
        grp = Group(groupid)

        if grp in self.data.packages.excludedGroupList:
            return

        if grp in self.data.packages.groupList:
            self.data.packages.groupList.remove(grp)

        self.data.packages.excludedGroupList.append(grp)
Пример #5
0
    def selectGroup(self, groupid, default=True, optional=False):
        if optional:
            include = GROUP_ALL
        elif default:
            include = GROUP_DEFAULT
        else:
            include = GROUP_REQUIRED

        grp = Group(groupid, include=include)

        if grp in self.data.packages.groupList:
            # I'm not sure this would ever happen, but ensure that re-selecting
            # a group with a different types set works as expected.
            if grp.include != include:
                grp.include = include

            return

        if grp in self.data.packages.excludedGroupList:
            self.data.packages.excludedGroupList.remove(grp)

        self.data.packages.groupList.append(grp)
Пример #6
0
    def selectGroup(self, groupid, default=True, optional=False):
        if optional:
            include = GROUP_ALL
        elif default:
            include = GROUP_DEFAULT
        else:
            include = GROUP_REQUIRED

        grp = Group(groupid, include=include)

        if grp in self.data.packages.groupList:
            # I'm not sure this would ever happen, but ensure that re-selecting
            # a group with a different types set works as expected.
            if grp.include != include:
                grp.include = include

            return

        if grp in self.data.packages.excludedGroupList:
            self.data.packages.excludedGroupList.remove(grp)

        self.data.packages.groupList.append(grp)
Пример #7
0
    def payload_group_test(self):
        import pykickstart.constants
        from pykickstart.parser import Group

        # verify that ksdata group lists are initially empty
        self.assertEqual(self.payload.data.packages.groupList, [])
        self.assertEqual(self.payload.data.packages.excludedGroupList, [])

        self.payload.deselectGroup("core")
        self.assertEqual(self.payload.groupSelected("core"), False)

        # select a group and verify the selection is reflected afterward
        self.payload.selectGroup("core", optional=True)
        self.assertTrue(self.payload.groupSelected("core"))

        # verify the group is not in the excluded group list
        self.assertTrue(
            Group("core") not in self.payload.data.packages.excludedGroupList)

        # verify the include (optional/all) is recorded
        groups = self.payload.data.packages.groupList
        group = groups[[g.name for g in groups].index("core")]
        self.assertEqual(group.include, pykickstart.constants.GROUP_ALL)

        # select more groups
        self.payload.selectGroup("base")
        self.payload.selectGroup("development", default=False)

        # verify include types for newly selected groups
        group = groups[[g.name for g in groups].index("development")]
        self.assertEqual(group.include, pykickstart.constants.GROUP_REQUIRED)

        group = groups[[g.name for g in groups].index("base")]
        self.assertEqual(group.include, pykickstart.constants.GROUP_DEFAULT)

        # deselect a group and verify the set of groups is correct afterward
        self.payload.deselectGroup("base")
        self.assertFalse(self.payload.groupSelected("base"))
        self.assertTrue(self.payload.groupSelected("core"))
        self.assertTrue(self.payload.groupSelected("development"))
Пример #8
0
 def groupSelected(self, groupid):
     return Group(groupid) in self.data.packages.groupList
Пример #9
0
 def runTest(self):
     hash(Group(name="groupA"))
Пример #10
0
 def runTest(self):
     self.assertLess(Group("A"), Group("B"))
     self.assertLessEqual(Group("A"), Group("B"))
     self.assertLessEqual(Group("A"), Group("A"))
     self.assertEqual(Group("A"), Group("A"))
     self.assertNotEqual(Group("A"), Group("B"))
     self.assertGreater(Group("B"), Group("A"))
     self.assertGreaterEqual(Group("B"), Group("A"))
     self.assertGreaterEqual(Group("B"), Group("B"))
Пример #11
0
 def _convert_to_excluded_kickstart_groups(self):
     """Create KS excluded groups from an excluded_groups"""
     return [
         Group(name=group, include=GROUP_DEFAULT)
         for group in self.excluded_groups
     ]