Exemplo n.º 1
0
    def add(self, obj, mdtype='updateinfo', all=False):
        """ Parse a metadata from a given YumRepository, file, or filename. """
        if not obj:
            raise UpdateNoticeException
        if type(obj) in (type(''), type(u'')):
            infile = fileutils.decompress_open(obj)
        elif isinstance(obj, YumRepository):
            if obj.id not in self._repos:
                self._repos.append(obj.id)
                md = obj.retrieveMD(mdtype)
                if not md:
                    raise UpdateNoticeException()
                infile = fileutils.decompress_open(md)
        else:  # obj is a file object
            infile = obj

        for _event, elem in iterparse(infile):
            if elem.tag == 'update':
                un = UpdateNotice(elem)
                key = un['update_id']
                if all:
                    key = "%s-%s" % (un['update_id'], un['version'])
                if not self._notices.has_key(key):
                    self._notices[key] = un
                    for pkg in un['pkglist']:
                        for pkgfile in pkg['packages']:
                            self._cache['%s-%s-%s' %
                                        (pkgfile['name'], pkgfile['version'],
                                         pkgfile['release'])] = un
                            no = self._no_cache.setdefault(
                                pkgfile['name'], set())
                            no.add(un)
Exemplo n.º 2
0
def updateinfo(errata_units, save_location):
    um = UpdateMetadata()
    for e in errata_units:
        encode_epoch(e)
        un = UpdateNotice()

        _md = {
            'from': e.metadata['from'],
            'type': e.metadata['type'],
            'title': e.metadata['title'],
            'release': e.metadata.get('release', ''),
            'status': e.metadata['status'],
            'version': e.metadata['version'],
            'pushcount': e.metadata.get('pushcount', ''),
            'update_id': e.unit_key['id'],
            'issued': e.metadata['issued'],
            'updated': e.metadata.get('updated', ''),
            'description': e.metadata['description'],
            'references': e.metadata['references'],
            'pkglist': e.metadata['pkglist'],
            'reboot_suggested': e.metadata.get('reboot_suggested', False),
            'severity': e.metadata.get('severity', ''),
            'rights': e.metadata.get('rights', ''),
            'summary': e.metadata.get('summary', ''),
            'solution': e.metadata.get('solution', ''),
        }
        un._md = _md
        um.add_notice(un)

    if not um._notices:
        # nothing to do return
        return
    updateinfo_path = None
    try:
        updateinfo_path = "%s/%s" % (save_location, "updateinfo.xml")
        f = open(updateinfo_path, 'wt')
        try:
            um.xml(fileobj=f)
            log.info("updateinfo.xml generated and written to file %s" %
                     updateinfo_path)
        finally:
            f.close()
    except Exception, e:
        log.error("Error writing updateinfo.xml to path %s: %s" %
                  (updateinfo_path, e))
Exemplo n.º 3
0
def updateinfo(errata_units, save_location):
    um = UpdateMetadata()
    for e in errata_units:
        encode_epoch(e)
        un = UpdateNotice()

        _md = {
            'from'             : e.metadata['from'],
            'type'             : e.metadata['type'],
            'title'            : e.metadata['title'],
            'release'          : e.metadata.get('release', ''),
            'status'           : e.metadata['status'],
            'version'          : e.metadata['version'],
            'pushcount'        : e.metadata.get('pushcount', ''),
            'update_id'        : e.unit_key['id'],
            'issued'           : e.metadata['issued'],
            'updated'          : e.metadata.get('updated', ''),
            'description'      : e.metadata['description'],
            'references'       : e.metadata['references'],
            'pkglist'          : e.metadata['pkglist'],
            'reboot_suggested' : e.metadata.get('reboot_suggested', False),
            'severity'         : e.metadata.get('severity', ''),
            'rights'           : e.metadata.get('rights', ''),
            'summary'          : e.metadata.get('summary', ''),
            'solution'         : e.metadata.get('solution', ''),
            }
        un._md = _md
        um.add_notice(un)

    if not um._notices:
        # nothing to do return
        return
    updateinfo_path = None
    try:
        updateinfo_path = "%s/%s" % (save_location, "updateinfo.xml")
        f = open(updateinfo_path, 'wt')
        try:
            updateinfo_xml = um.xml(fileobj=f)
            log.info("updateinfo.xml generated and written to file %s" % updateinfo_path)
        finally:
            f.close()
    except Exception, e:
        log.error("Error writing updateinfo.xml to path %s: %s" % (updateinfo_path, e))
Exemplo n.º 4
0
def updateinfo(errata_units, save_location):
    um = UpdateMetadata()
    for e in errata_units:
        un = UpdateNotice()

        _md = {
            'from'             : e.metadata['from_str'],
            'type'             : e.metadata['type'],
            'title'            : e.metadata['title'],
            'release'          : e.metadata['release'],
            'status'           : e.metadata['status'],
            'version'          : e.metadata['version'],
            'pushcount'        : e.metadata['pushcount'],
            'update_id'        : e.unit_key['id'],
            'issued'           : e.metadata['issued'],
            'updated'          : e.metadata['updated'],
            'description'      : e.metadata['description'],
            'references'       : e.metadata['references'],
            'pkglist'          : e.metadata['pkglist'],
            'reboot_suggested' : e.metadata['reboot_suggested'],
            'severity'         : e.metadata['severity'],
            'rights'           : e.metadata['rights'],
            'summary'          : e.metadata['summary'],
            'solution'         : e.metadata['solution'],
            }
        un._md = _md
        um.add_notice(un)

    if not um._notices:
        # nothing to do return
        return
    updateinfo_path = None
    try:
        updateinfo_path = "%s/%s" % (save_location, "updateinfo.xml")
        updateinfo_xml = um.xml(fileobj=open(updateinfo_path, 'wt'))
        log.info("updateinfo.xml generated and written to file %s" % updateinfo_path)
    except:
        log.error("Error writing updateinfo.xml to path %s" % updateinfo_path)
    return updateinfo_path