Example #1
0
 def get_test_errata_object(self, eid='RHEA-2010:9999'):
     errata_from_xml = updateinfo.get_errata(self.updateinfo_xml_path)
     self.assertTrue(len(errata_from_xml) > 0)
     errata = {}
     for e in errata_from_xml:
         errata[e['id']] = e
     self.assertTrue(eid in errata)
     return errata[eid]
Example #2
0
 def get_test_errata_object(self, eid='RHEA-2010:9999'):
     errata_from_xml = updateinfo.get_errata(self.updateinfo_xml_path)
     self.assertTrue(len(errata_from_xml) > 0)
     errata = {}
     for e in errata_from_xml:
         errata[e['id']] = e
     self.assertTrue(eid in errata)
     return errata[eid]
Example #3
0
def get_available_errata(repo_dir):
    """
        Check and Parses the updateinfo.xml and extract errata items to sync

        @param repo_dir repo directory where the metadata can be found
        @type repo_dir str

        @return a dict of errata items with errata id as key
        @rtype {'':{}}
    """
    repomd_xml = os.path.join(repo_dir, "repodata/repomd.xml")
    ftypes = util.get_repomd_filetypes(repomd_xml)
    errata_from_xml = {}
    if "updateinfo" not in ftypes:
        return errata_from_xml
    updateinfo_xml_path = os.path.join(repo_dir, util.get_repomd_filetype_path(repomd_xml, "updateinfo"))
    if not os.path.exists(updateinfo_xml_path):
        return {}
    try:
        errata_from_xml = updateinfo.get_errata(updateinfo_xml_path)
    except yum.Errors.YumBaseError, e:
        _LOG.error("Error parsing updateinfo file [%s]; Error: %s" % (updateinfo_xml_path, e))
Example #4
0
 def get_test_errata_object_unrelated(self):
     errata_from_xml = updateinfo.get_errata(self.updateinfo_unrelated_xml_path)
     self.assertTrue(len(errata_from_xml) > 0)
     return errata_from_xml[0]
Example #5
0
    def test_iso_export_by_date_range(self):
        feed_url = "file://%s/test_errata_local_sync/" % self.data_dir
        repo = mock.Mock(spec=Repository)
        repo.working_dir = self.repo_working_dir
        repo.id = "test_errata_local_sync"
        repo.checksumtype = 'sha'
        sync_conduit = importer_mocks.get_sync_conduit(type_id=TYPE_ID_RPM, existing_units=[], pkg_dir=self.pkg_dir)
        config = importer_mocks.get_basic_config(feed_url=feed_url)
        importerRPM = importer_rpm.ImporterRPM()
        status, summary, details = importerRPM.sync(repo, sync_conduit, config)
        metadata = {'updated' : '2010-03-30 08:07:30'}
        existing_units = []
        unit_key_a = {'id' : '','name' :'patb', 'version' :'0.1', 'release' : '2', 'epoch':'0', 'arch' : 'x86_64', 'checksumtype' : 'sha',
                      'checksum': '017c12050a97cf6095892498750c2a39d2bf535e'}
        rpm_unit_a = Unit(TYPE_ID_RPM, unit_key_a, metadata, '')
        rpm_unit_a.storage_path = "%s/patb/0.1/2/noarch/017c12050a97cf6095892498750c2a39d2bf535e/patb-0.1-2.noarch.rpm" % self.pkg_dir
        existing_units.append(rpm_unit_a)
        unit_key_b = {'id' : '', 'name' :'emoticons', 'version' :'0.1', 'release' :'2', 'epoch':'0','arch' : 'x86_64', 'checksumtype' :'sha',
                      'checksum' : '663c89b0d29bfd5479d8736b716d50eed9495dbb'}
        rpm_unit_b = Unit(TYPE_ID_RPM, unit_key_b, metadata, '')
        rpm_unit_b.storage_path = "%s/emoticons/0.1/2/noarch/663c89b0d29bfd5479d8736b716d50eed9495dbb/emoticons-0.1-2.noarch.rpm" % self.pkg_dir
        existing_units.append(rpm_unit_b)
        sync_conduit = importer_mocks.get_sync_conduit(type_id=TYPE_ID_RPM, existing_units=existing_units, pkg_dir=self.pkg_dir)
        importerErrata = errata.ImporterErrata()
        status, summary, details = importerErrata.sync(repo, sync_conduit, config)
        unit_key = dict()
        unit_key['id'] = "RHEA-2010:9999"
        mdata = { 'description'  : "test",
                     'from_str': '*****@*****.**',
                    'issued': '2010-03-30 08:07:30',
                    'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
                            'packages': [{'arch': 'x86_64',
                                        'epoch': '0',
                                        'filename': 'patb-0.1-2.x86_64.rpm',
                                        'name': 'patb',
                                        'release': '2',
                                        'src': '',
                                        'sum': ('sha',
                                                '017c12050a97cf6095892498750c2a39d2bf535e'),
                                        'version': '0.1'},
                                        {'arch': 'x86_64',
                                        'epoch': '0',
                                        'filename': 'emoticons-0.1-2.x86_64.rpm',
                                        'name': 'emoticons',
                                        'release': '2',
                                        'src': '',
                                        'sum': ('sha',
                                                '663c89b0d29bfd5479d8736b716d50eed9495dbb'),
                                        'version': '0.1'}],
                            'short': 'rhel-i386-server-vt-5'}],
                    'pushcount': 1,
                    'reboot_suggested': False,
                    'references': [],
                    'release': '',
                    'rights': '',
                     'status': 'final',
                    'summary': '',
                    'title': 'emoticons enhancement fix and enhancement update',
                     'updated': '2010-03-30 08:07:30',
        'version': '1',
        'type' : 'enhancement',
        'severity' : 'Low',
        'solution' : ''}
        unit_key_2 = dict()
        unit_key_2['id'] = "RHEA-2008:9999"
        mdata_2 = { 'description'  : "test",
                     'from_str': '*****@*****.**',
                    'issued': '2008-03-30 00:00:00',
                    'pkglist': [{'name': 'RHEL Virtualization (v. 5 for 32-bit x86)',
                            'packages': [{'arch': 'x86_64',
                                        'epoch': '0',
                                        'filename': 'patb-0.1-2.x86_64.rpm',
                                        'name': 'patb',
                                        'release': '2',
                                        'src': '',
                                        'sum': ('sha',
                                                '017c12050a97cf6095892498750c2a39d2bf535e'),
                                        'version': '0.1'},
                                        {'arch': 'x86_64',
                                        'epoch': '0',
                                        'filename': 'emoticons-0.1-2.x86_64.rpm',
                                        'name': 'emoticons',
                                        'release': '2',
                                        'src': '',
                                        'sum': ('sha',
                                                '663c89b0d29bfd5479d8736b716d50eed9495dbb'),
                                        'version': '0.1'}],
                            'short': 'rhel-i386-server-vt-5'}],
                    'pushcount': 1,
                    'reboot_suggested': False,
                    'references': [],
                    'release': '',
                    'rights': '',
                     'status': 'final',
                    'summary': '',
                    'title': 'emoticons enhancement fix and enhancement update',
                     'updated': '2008-03-30 00:00:00',
        'version': '1',
        'type' : 'enhancement',
        'severity' : 'Low',
        'solution' : ''}
        errata_unit = [Unit(TYPE_ID_ERRATA, unit_key, mdata, ''), Unit(TYPE_ID_ERRATA, unit_key_2,  mdata_2, '')]
        existing_units += errata_unit
        print existing_units
        repo.working_dir = "%s/%s" % (self.repo_working_dir, "export")
        iso_distributor = ISODistributor()
        publish_conduit = distributor_mocks.get_publish_conduit(existing_units=existing_units, pkg_dir=self.pkg_dir)

        # test http publish
        config = distributor_mocks.get_basic_config(http_publish_dir=self.http_publish_dir, https_publish_dir=self.https_publish_dir, http=True, https=False,
            start_date="2009-03-30 08:07:30", end_date="2012-03-30 08:07:30", generate_metadata=True)
        def cleanup(rpm_working_dir):
            return
        iso_util.cleanup_working_dir = mock.Mock()
        iso_util.cleanup_working_dir.side_effect = cleanup
        report = iso_distributor.publish_repo(repo, publish_conduit, config)
        ftypes = util.get_repomd_filetypes("%s/%s" % (repo.working_dir, "repodata/repomd.xml"))
        self.assertTrue("updateinfo" in ftypes)
        updateinfo_path = util.get_repomd_filetype_path("%s/%s" % (repo.working_dir, "repodata/repomd.xml"), "updateinfo")
        updateinfo_path = os.path.join(repo.working_dir, updateinfo_path)
        self.assertTrue(os.path.exists(updateinfo_path))
        elist = updateinfo.get_errata(updateinfo_path)
        self.assertEquals(len(elist), 1)
        self.assertTrue(unit_key_2['id'] not in elist[0])
        self.assertEquals(elist[0]['id'], unit_key['id'])
        self.assertEquals(elist[0]['issued'], mdata['issued'])
        self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
        self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
        isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
        self.assertEqual(len(isos_list), 1)
Example #6
0
 def get_test_errata_object_unrelated(self):
     errata_from_xml = updateinfo.get_errata(
         self.updateinfo_unrelated_xml_path)
     self.assertTrue(len(errata_from_xml) > 0)
     return errata_from_xml[0]
Example #7
0
    def test_iso_export_by_date_range(self):
        feed_url = "file://%s/test_errata_local_sync/" % self.data_dir
        repo = mock.Mock(spec=Repository)
        repo.working_dir = self.repo_working_dir
        repo.id = "test_errata_local_sync"
        repo.checksumtype = "sha"
        sync_conduit = importer_mocks.get_sync_conduit(type_id=TYPE_ID_RPM, existing_units=[], pkg_dir=self.pkg_dir)
        config = importer_mocks.get_basic_config(feed_url=feed_url)
        importerRPM = importer_rpm.ImporterRPM()
        status, summary, details = importerRPM.sync(repo, sync_conduit, config)
        metadata = {}
        existing_units = []
        unit_key_a = {
            "id": "",
            "name": "patb",
            "version": "0.1",
            "release": "2",
            "epoch": "0",
            "arch": "x86_64",
            "checksumtype": "sha",
            "checksum": "017c12050a97cf6095892498750c2a39d2bf535e",
        }
        rpm_unit_a = Unit(TYPE_ID_RPM, unit_key_a, metadata, "")
        rpm_unit_a.storage_path = (
            "%s/patb/0.1/2/noarch/017c12050a97cf6095892498750c2a39d2bf535e/patb-0.1-2.noarch.rpm" % self.pkg_dir
        )
        existing_units.append(rpm_unit_a)
        unit_key_b = {
            "id": "",
            "name": "emoticons",
            "version": "0.1",
            "release": "2",
            "epoch": "0",
            "arch": "x86_64",
            "checksumtype": "sha",
            "checksum": "663c89b0d29bfd5479d8736b716d50eed9495dbb",
        }
        rpm_unit_b = Unit(TYPE_ID_RPM, unit_key_b, metadata, "")
        rpm_unit_b.storage_path = (
            "%s/emoticons/0.1/2/noarch/663c89b0d29bfd5479d8736b716d50eed9495dbb/emoticons-0.1-2.noarch.rpm"
            % self.pkg_dir
        )
        existing_units.append(rpm_unit_b)
        sync_conduit = importer_mocks.get_sync_conduit(
            type_id=TYPE_ID_RPM, existing_units=existing_units, pkg_dir=self.pkg_dir
        )
        importerErrata = errata.ImporterErrata()
        status, summary, details = importerErrata.sync(repo, sync_conduit, config)
        unit_key = dict()
        unit_key["id"] = "RHEA-2010:9999"
        mdata = {
            "description": "test",
            "from_str": "*****@*****.**",
            "issued": "2010-03-30 08:07:30",
            "pkglist": [
                {
                    "name": "RHEL Virtualization (v. 5 for 32-bit x86)",
                    "packages": [
                        {
                            "arch": "x86_64",
                            "epoch": "0",
                            "filename": "patb-0.1-2.x86_64.rpm",
                            "name": "patb",
                            "release": "2",
                            "src": "",
                            "sum": ("sha", "017c12050a97cf6095892498750c2a39d2bf535e"),
                            "version": "0.1",
                        },
                        {
                            "arch": "x86_64",
                            "epoch": "0",
                            "filename": "emoticons-0.1-2.x86_64.rpm",
                            "name": "emoticons",
                            "release": "2",
                            "src": "",
                            "sum": ("sha", "663c89b0d29bfd5479d8736b716d50eed9495dbb"),
                            "version": "0.1",
                        },
                    ],
                    "short": "rhel-i386-server-vt-5",
                }
            ],
            "pushcount": 1,
            "reboot_suggested": False,
            "references": [],
            "release": "",
            "rights": "",
            "status": "final",
            "summary": "",
            "title": "emoticons enhancement fix and enhancement update",
            "updated": "2010-03-30 08:07:30",
            "version": "1",
            "type": "enhancement",
            "severity": "Low",
            "solution": "",
        }
        unit_key_2 = dict()
        unit_key_2["id"] = "RHEA-2008:9999"
        mdata_2 = {
            "description": "test",
            "from_str": "*****@*****.**",
            "issued": "2008-03-30 00:00:00",
            "pkglist": [
                {
                    "name": "RHEL Virtualization (v. 5 for 32-bit x86)",
                    "packages": [
                        {
                            "arch": "x86_64",
                            "epoch": "0",
                            "filename": "patb-0.1-2.x86_64.rpm",
                            "name": "patb",
                            "release": "2",
                            "src": "",
                            "sum": ("sha", "017c12050a97cf6095892498750c2a39d2bf535e"),
                            "version": "0.1",
                        },
                        {
                            "arch": "x86_64",
                            "epoch": "0",
                            "filename": "emoticons-0.1-2.x86_64.rpm",
                            "name": "emoticons",
                            "release": "2",
                            "src": "",
                            "sum": ("sha", "663c89b0d29bfd5479d8736b716d50eed9495dbb"),
                            "version": "0.1",
                        },
                    ],
                    "short": "rhel-i386-server-vt-5",
                }
            ],
            "pushcount": 1,
            "reboot_suggested": False,
            "references": [],
            "release": "",
            "rights": "",
            "status": "final",
            "summary": "",
            "title": "emoticons enhancement fix and enhancement update",
            "updated": "2008-03-30 00:00:00",
            "version": "1",
            "type": "enhancement",
            "severity": "Low",
            "solution": "",
        }
        errata_unit = [Unit(TYPE_ID_ERRATA, unit_key, mdata, ""), Unit(TYPE_ID_ERRATA, unit_key_2, mdata_2, "")]
        existing_units += errata_unit
        print existing_units
        repo.working_dir = "%s/%s" % (self.repo_working_dir, "export")
        iso_distributor = ISODistributor()
        publish_conduit = distributor_mocks.get_publish_conduit(existing_units=existing_units, pkg_dir=self.pkg_dir)

        # test http publish
        config = distributor_mocks.get_basic_config(
            http_publish_dir=self.http_publish_dir,
            https_publish_dir=self.https_publish_dir,
            http=True,
            https=False,
            start_date="2009-03-30 08:07:30",
            end_date="2012-03-30 08:07:30",
            generate_metadata=True,
        )

        def cleanup(rpm_working_dir):
            return

        iso_util.cleanup_working_dir = mock.Mock()
        iso_util.cleanup_working_dir.side_effect = cleanup
        report = iso_distributor.publish_repo(repo, publish_conduit, config)
        ftypes = util.get_repomd_filetypes("%s/%s" % (repo.working_dir, "repodata/repomd.xml"))
        self.assertTrue("updateinfo" in ftypes)
        updateinfo_path = "%s/%s" % (repo.working_dir, "updateinfo.xml")
        self.assertTrue(os.path.exists(updateinfo_path))
        elist = updateinfo.get_errata(updateinfo_path)
        self.assertEquals(len(elist), 1)
        self.assertTrue(unit_key_2["id"] not in elist[0])
        self.assertEquals(elist[0]["id"], unit_key["id"])
        self.assertEquals(elist[0]["issued"], mdata["issued"])
        self.assertTrue(os.path.exists("%s/%s" % (self.http_publish_dir, repo.id)))
        self.assertEquals(len(os.listdir(self.https_publish_dir)), 0)
        isos_list = os.listdir("%s/%s" % (self.http_publish_dir, repo.id))
        self.assertEqual(len(isos_list), 1)