当前位置: 首页>>代码示例>>Python>>正文


Python YumProfiler._get_rpms_from_errata方法代码示例

本文整理汇总了Python中pulp_rpm.plugins.profilers.yum.YumProfiler._get_rpms_from_errata方法的典型用法代码示例。如果您正苦于以下问题:Python YumProfiler._get_rpms_from_errata方法的具体用法?Python YumProfiler._get_rpms_from_errata怎么用?Python YumProfiler._get_rpms_from_errata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulp_rpm.plugins.profilers.yum.YumProfiler的用法示例。


在下文中一共展示了YumProfiler._get_rpms_from_errata方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_install_units

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
 def test_install_units(self):
     repo_id = "test_repo_id"
     errata_obj = self.get_test_errata_object()
     errata_unit = Unit(TYPE_ID_ERRATA, {"id":errata_obj["id"]}, errata_obj, None)
     existing_units = [errata_unit]
     test_repo = profiler_mocks.get_repo(repo_id)
     conduit = profiler_mocks.get_profiler_conduit(existing_units=existing_units,
                                                   repo_bindings=[test_repo])
     example_errata = {"unit_key":errata_unit.unit_key, "type_id":TYPE_ID_ERRATA}
     prof = YumProfiler()
     translated_units  = prof.install_units(self.test_consumer, [example_errata], None, None,
                                            conduit)
     # check repo_id passed to the conduit get_units()
     self.assertEqual(conduit.get_units.call_args[0][0].id, repo_id)
     # check unit association criteria passed to the conduit get_units()
     self.assertEqual(conduit.get_units.call_args[0][1].type_ids, [TYPE_ID_ERRATA])
     self.assertEqual(conduit.get_units.call_args[0][1].unit_filters, errata_unit.unit_key)
     # validate translated units
     self.assertEqual(len(translated_units), 2)
     expected = []
     for r in prof._get_rpms_from_errata(errata_unit):
         expected_name = "%s-%s:%s-%s.%s" % (r["name"], r["epoch"], r["version"], r["release"],
                                             r["arch"])
         expected.append(expected_name)
     for u in translated_units:
         rpm_name = u["unit_key"]["name"]
         self.assertTrue(rpm_name in expected)
开发者ID:bechtoldt,项目名称:pulp_rpm,代码行数:29,代码来源:test_plugins_profilers_yum.py

示例2: test_unit_applicable_false

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_unit_applicable_false(self):
        # Errata refers to RPMs which are NOT part of our test consumer's profile
        errata_obj = self.get_test_errata_object_unrelated()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        test_repo = profiler_mocks.get_repo("test_repo_id")

        prof = YumProfiler()
        errata_rpms = prof._get_rpms_from_errata(errata_unit)
        conduit = profiler_mocks.get_profiler_conduit(repo_units=[errata_unit],
                                                      repo_bindings=[test_repo],
                                                      errata_rpms=errata_rpms)
        unit_profile = self.test_consumer.profiles[TYPE_ID_RPM]
        bound_repo_id = "test_repo_id"
        report_list = prof.calculate_applicable_units(unit_profile, bound_repo_id, None, conduit)
        self.assertEqual(report_list, {TYPE_ID_ERRATA: [], TYPE_ID_RPM: []})
开发者ID:BrnoPCmaniak,项目名称:pulp_rpm,代码行数:17,代码来源:test_yum.py

示例3: test_unit_applicable_updated_rpm_already_installed

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_unit_applicable_updated_rpm_already_installed(self):
        # Errata refers to RPMs already installed, i.e. the consumer has these exact NEVRA already
        errata_obj = self.get_test_errata_object()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        test_repo = profiler_mocks.get_repo("test_repo_id")

        prof = YumProfiler()
        errata_rpms = prof._get_rpms_from_errata(errata_unit)
        conduit = profiler_mocks.get_profiler_conduit(repo_units=[errata_unit],
                                                      repo_bindings=[test_repo],
                                                      errata_rpms=errata_rpms)
        unit_profile = self.test_consumer_been_updated.profiles[TYPE_ID_RPM]
        bound_repo_id = "test_repo_id"
        report_list = prof.calculate_applicable_units(unit_profile, bound_repo_id, None, conduit)
        self.assertEqual(report_list, {TYPE_ID_RPM: [], TYPE_ID_ERRATA: []})
开发者ID:BrnoPCmaniak,项目名称:pulp_rpm,代码行数:17,代码来源:test_yum.py

示例4: test_unit_applicable_same_name_diff_arch

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_unit_applicable_same_name_diff_arch(self):
        # Errata refers to RPMs that are x86_64, the test consumer is i386
        # the rpms installed share the same name as the errata, but the client arch is different
        # so this errata is marked as unapplicable
        errata_obj = self.get_test_errata_object()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        test_repo = profiler_mocks.get_repo("test_repo_id")

        prof = YumProfiler()
        errata_rpms = prof._get_rpms_from_errata(errata_unit)
        conduit = profiler_mocks.get_profiler_conduit(repo_units=[errata_unit],
                                                      repo_bindings=[test_repo],
                                                      errata_rpms=errata_rpms)
        unit_profile = self.test_consumer_i386.profiles[TYPE_ID_RPM]
        bound_repo_id = "test_repo_id"
        report_list = prof.calculate_applicable_units(unit_profile, bound_repo_id, None, conduit)
        self.assertEqual(report_list, {TYPE_ID_RPM: [], TYPE_ID_ERRATA: []})
开发者ID:BrnoPCmaniak,项目名称:pulp_rpm,代码行数:19,代码来源:test_yum.py

示例5: test_install_units

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_install_units(self):
        """
        Verify that all available packages in the erratum are installed

        In this test, there are two packages in the erratum, and both are
        available to the consumer. Thus, both should be installed.
        """
        repo_id = "test_repo_id"
        errata_obj = self.get_test_errata_object()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        existing_units = [errata_unit]
        test_repo = profiler_mocks.get_repo(repo_id)

        # create two RPM units that match what is in the erratum
        rpm_units = []
        rpm_unit_key_1 = self.create_profile_entry("emoticons", 0, "0.1", "2", "x86_64",
                                                   "Test Vendor")
        rpm_units.append(Unit(TYPE_ID_RPM, rpm_unit_key_1, {}, None))

        rpm_unit_key_2 = self.create_profile_entry("patb", 0, "0.1", "2", "x86_64", "Test Vendor")
        rpm_units.append(Unit(TYPE_ID_RPM, rpm_unit_key_2, {}, None))

        existing_units += rpm_units

        conduit = profiler_mocks.get_profiler_conduit(existing_units=existing_units,
                                                      repo_bindings=[test_repo],
                                                      repo_units=rpm_units)

        example_errata = {"unit_key": errata_unit.unit_key, "type_id": TYPE_ID_ERRATA}
        prof = YumProfiler()
        translated_units = prof.install_units(self.test_consumer, [example_errata], None, None,
                                              conduit)
        # check repo_id passed to the conduit get_units()
        self.assertEqual(conduit.get_units.call_args[0][0].id, repo_id)
        # check unit association criteria passed to the conduit get_units()
        self.assertEqual(conduit.get_units.call_args_list[0][0][1].type_ids, [TYPE_ID_ERRATA])
        self.assertEqual(conduit.get_units.call_args_list[0][0][1].unit_filters,
                         errata_unit.unit_key)
        # validate translated units
        self.assertEqual(len(translated_units), 2)
        expected = prof._get_rpms_from_errata(errata_unit)
        for u in translated_units:
            rpm_unit_key = u["unit_key"]
            self.assertTrue(rpm_unit_key in expected)
开发者ID:msutter,项目名称:pulp_rpm,代码行数:46,代码来源:test_yum.py

示例6: test_get_rpms_from_errata

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
 def test_get_rpms_from_errata(self):
     errata_obj = self.get_test_errata_object()
     errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
     prof = YumProfiler()
     rpms = prof._get_rpms_from_errata(errata_unit)
     # Expected data:
     # [{'src': 'xen-3.0.3-80.el5_3.3.src.rpm', 'name': 'emoticons',
     # 'sum': ('md5', '366bb5e73a5905eacb82c96e0578f92b'),
     #   'filename': 'emoticons-0.1-2.x86_64.rpm', 'epoch': '0',
     #   'version': '0.1', 'release': '2', 'arch': 'x86_64'},
     # {'src': 'xen-3.0.3-80.el5_3.3.src.rpm', 'name': 'patb',
     #   'sum': ('md5', 'f3c197a29d9b66c5b65c5d62b25db5b4'),
     #   'filename': 'patb-0.1-2.x86_64.rpm', 'epoch': '0'
     #   'version': '0.1', 'release': '2', 'arch': 'x86_64'}]
     self.assertEqual(len(rpms), 2)
     self.assertTrue(rpms[0]["name"] in ['emoticons', 'patb'])
     self.assertTrue(rpms[1]["name"] in ['emoticons', 'patb'])
     for r in rpms:
         for key in ["name", "filename", "epoch", "version", "release"]:
             self.assertTrue(key in r)
             self.assertTrue(r[key])
开发者ID:BrnoPCmaniak,项目名称:pulp_rpm,代码行数:23,代码来源:test_yum.py

示例7: test_rpms_applicable_to_consumer

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_rpms_applicable_to_consumer(self):
        errata_rpms = []
        prof = YumProfiler()
        applicable_rpms, old_rpms = prof._rpms_applicable_to_consumer(Consumer("test", {}), errata_rpms)
        self.assertEqual(applicable_rpms, [])
        self.assertEqual(old_rpms, {})

        # Get rpm dictionaries embedded in an errata
        errata_obj = self.get_test_errata_object()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        errata_rpms = prof._get_rpms_from_errata(errata_unit)
        # Test with 2 newer RPMs in the test errata
        # The consumer has already been configured with a profile containing 'emoticons' and
        # 'patb' rpms
        applicable_rpms, old_rpms = prof._rpms_applicable_to_consumer(self.test_consumer, errata_rpms)
        self.assertTrue(applicable_rpms)
        self.assertTrue(old_rpms)
        self.assertEqual(len(applicable_rpms), 2)
        self.assertTrue("emoticons x86_64" in old_rpms)
        self.assertEqual("emoticons", old_rpms["emoticons x86_64"]["installed"]["name"])
        self.assertEqual("0.1", old_rpms["emoticons x86_64"]["installed"]["version"])
开发者ID:,项目名称:,代码行数:23,代码来源:

示例8: test_get_rpms_from_errata_no_epoch

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
 def test_get_rpms_from_errata_no_epoch(self):
     """
     Test that we default to '0' for the epoch if one doesn't exist.
     """
     errata_obj = self.get_test_errata_object(eid='RHEA-2010:8888')
     errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
     prof = YumProfiler()
     rpms = prof._get_rpms_from_errata(errata_unit)
     # Expected data:
     # [{'src': 'xen-3.0.3-80.el5_3.3.src.rpm', 'name': 'emoticons',
     #   'sum': ('md5', '366bb5e73a5905eacb82c96e0578f92b'),
     #   'filename': 'emoticons-0.1-2.x86_64.rpm', 'epoch': '0',
     #   'version': '0.1', 'release': '2', 'arch': 'x86_64'},
     # {'src': 'xen-3.0.3-80.el5_3.3.src.rpm', 'name': 'patb',
     #   'sum': ('md5', 'f3c197a29d9b66c5b65c5d62b25db5b4'),
     #   'filename': 'patb-0.1-2.x86_64.rpm', 'epoch': '0',
     #   'version': '0.1', 'release': '2', 'arch': 'x86_64'}]
     self.assertEqual(len(rpms), 2)
     self.assertTrue(rpms[0]["name"] in ['emoticons', 'patb'])
     self.assertTrue(rpms[1]["name"] in ['emoticons', 'patb'])
     for r in rpms:
         self.assertTrue('epoch' in r)
         self.assertTrue(r['epoch'] == '0')
开发者ID:BrnoPCmaniak,项目名称:pulp_rpm,代码行数:25,代码来源:test_yum.py

示例9: test_unit_applicable

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_unit_applicable(self):
        # Errata refers to RPMs which ARE part of our test consumer's profile,
        # AND in the repo.
        errata_obj = self.get_test_errata_object()
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        errata_unit.id = "an_errata"

        rpm_unit_key = self.create_profile_entry("emoticons", 0, "0.1", "2", "x86_64", "Test Vendor")
        rpm_unit = Unit(TYPE_ID_RPM, rpm_unit_key, {}, None)
        # Let's give it an id, so we can assert for it later
        rpm_unit.id = "a_test_id"

        test_repo = profiler_mocks.get_repo("test_repo_id")

        prof = YumProfiler()
        errata_rpms = prof._get_rpms_from_errata(errata_unit)
        conduit = profiler_mocks.get_profiler_conduit(
            repo_units=[errata_unit, rpm_unit], repo_bindings=[test_repo], errata_rpms=errata_rpms
        )
        unit_profile = self.test_consumer.profiles[TYPE_ID_RPM]
        bound_repo_id = "test_repo_id"
        report_list = prof.calculate_applicable_units(unit_profile, bound_repo_id, None, conduit)
        self.assertEqual(report_list, {TYPE_ID_RPM: ["a_test_id"], TYPE_ID_ERRATA: ["an_errata"]})
开发者ID:,项目名称:,代码行数:25,代码来源:

示例10: test_install_units_unit_not_in_repo

# 需要导入模块: from pulp_rpm.plugins.profilers.yum import YumProfiler [as 别名]
# 或者: from pulp_rpm.plugins.profilers.yum.YumProfiler import _get_rpms_from_errata [as 别名]
    def test_install_units_unit_not_in_repo(self):
        """
        This tests that if an erratum unit is requested to be installed, we do
        not attempt to install any RPM units that are not available in repos.

        For example, if an erratum contains packages for RHEL6 and RHEL7, we do
        not want to ask a RHEL6 consumer to install RHEL7 packages that are
        unavailable on that host.

        This is a related issue to errata applicability but is slightly
        different since the API caller wants to install a particular erratum, and is
        not trying to determine which errata are applicable.

        Note also that RHEA-2014:9999 has emoticons-0.1 and patb-0.1 in
        different package collections; this is atypical and would likely not be
        seen in the wild. I set it up like this to ensure the package list from
        the erratum was being flattened during comparisons.

        More detail is available in https://pulp.plan.io/issues/770
        """
        repo_id = "test_repo_id"

        # this erratum has four RPMs but only two are available
        errata_obj = self.get_test_errata_object(eid='RHEA-2014:9999')
        errata_unit = Unit(TYPE_ID_ERRATA, {"id": errata_obj["id"]}, errata_obj, None)
        existing_units = [errata_unit]
        test_repo = profiler_mocks.get_repo(repo_id)

        # create two RPM units that match what is in the erratum. There are
        # higher versioned RPMs in the erratum that are not available; these
        # should not be installed.

        rpm_units = []
        rpm_unit_key_1 = self.create_profile_entry("emoticons", 0, "0.1", "2", "x86_64",
                                                   "Test Vendor")
        rpm_units.append(Unit(TYPE_ID_RPM, rpm_unit_key_1, {}, None))

        rpm_unit_key_2 = self.create_profile_entry("patb", 0, "0.1", "2", "x86_64", "Test Vendor")
        rpm_units.append(Unit(TYPE_ID_RPM, rpm_unit_key_2, {}, None))

        existing_units += rpm_units

        conduit = profiler_mocks.get_profiler_conduit(existing_units=existing_units,
                                                      repo_bindings=[test_repo],
                                                      repo_units=rpm_units)

        def mocked_get_units(repo_id, criteria=None):
            """
            Override the default get_units in profiler_mocks.

            This method is specific to this particular unit test. The default
            get_units() in profiler_mocks only checks the criteria's type_id and not any
            other fields.

            :param repo_id: repo ID (unused)
            :type  repo_id: not used
            :param criteria: unit association criteria
            :type  criteria: pulp.server.db.model.criteria.UnitAssociationCriteria

            """
            if TYPE_ID_ERRATA in criteria.type_ids:
                return [errata_unit]
            elif criteria['unit_filters']['name'] == 'emoticons' and \
                    criteria['unit_filters']['version'] == '0.1':
                    return [rpm_units[0]]
            elif criteria['unit_filters']['name'] == 'patb' and \
                    criteria['unit_filters']['version'] == '0.1':
                    return [rpm_units[1]]
            else:
                return []

        conduit.get_units.side_effect = mocked_get_units

        example_errata = {"unit_key": errata_unit.unit_key, "type_id": TYPE_ID_ERRATA}
        prof = YumProfiler()
        translated_units = prof.install_units(self.test_consumer, [example_errata], None, None,
                                              conduit)
        # check repo_id passed to the conduit get_units()
        self.assertEqual(conduit.get_units.call_args_list[0][0][0].id, repo_id)
        # validate translated units
        self.assertEqual(len(translated_units), 2)
        self.assertEqual(translated_units[0]['unit_key']['filename'], 'patb-0.1-2.x86_64.rpm')
        self.assertEqual(translated_units[1]['unit_key']['filename'], 'emoticons-0.1-2.x86_64.rpm')
        expected = prof._get_rpms_from_errata(errata_unit)
        for u in translated_units:
            rpm_unit_key = u["unit_key"]
            self.assertTrue(rpm_unit_key in expected)
开发者ID:msutter,项目名称:pulp_rpm,代码行数:89,代码来源:test_yum.py


注:本文中的pulp_rpm.plugins.profilers.yum.YumProfiler._get_rpms_from_errata方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。