Skip to content
Snippets Groups Projects

[LOS-1020] Not create updateinfo.xml from updateinfo.db in advisories directory

Merged [LOS-1020] Not create updateinfo.xml from updateinfo.db in advisories directory
Merged Marta Vila Fernandes requested to merge los1020 into master
2 files
+ 0
92
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 0
88
@@ -2,94 +2,10 @@
@@ -2,94 +2,10 @@
"""Update advisories info"""
"""Update advisories info"""
import re
import re
import gzip
from argparse import ArgumentParser
from argparse import ArgumentParser
import xml.etree.cElementTree as ET
from updatesqlite import SQLiteQueries
from updatesqlite import SQLiteQueries
import createrepo_c as cr
import createrepo_c as cr
def generate_xmlfile(pargs, advisory_db):
"""
Generating xml file.
"""
m_encoding = 'UTF-8'
updateinfofile = pargs.updinfofile
# updates
root = ET.Element("updates")
erratarows = advisory_db.select(table='errata')
for erratarow in erratarows:
advisory, type_ad = erratarow
xml_update_type = "bugfix"
if type_ad == "bug fix":
xml_update_type = "bugfix"
else:
xml_update_type = type_ad
# update
doc_update = ET.SubElement(
root, "update", {'from': 'security@redhat.com', 'status': 'final',
'type': xml_update_type, 'version': '1'})
ET.SubElement(doc_update, "id").text = advisory
channelerratarows = advisory_db.select(table='channelerrata',
advisory=advisory)
for channelerratarow in channelerratarows:
synopsis, issue_date, update_date = channelerratarow
ET.SubElement(doc_update, "title").text = synopsis
ET.SubElement(doc_update, "issued", {'date': issue_date})
ET.SubElement(doc_update, "updated", {'date': update_date})
erratarows_ad = advisory_db.select(table='errata', advisory=advisory)
for description_ad in erratarows_ad:
ET.SubElement(doc_update, "description").text = description_ad[0]
erratabugzillafixesrows = advisory_db.select(table='erratabugzilla',
advisory=advisory)
erratabugzillacount = len(erratabugzillafixesrows)
erratacvesrows = advisory_db.select(table='erratacves',
advisory=advisory)
erratacvescount = len(erratacvesrows)
doc_references = ET.SubElement(doc_update, "references")
if erratabugzillacount > 0 or erratacvescount > 0:
# references
for erratabugzillafixesrow in erratabugzillafixesrows:
bugzilla_id, summary = erratabugzillafixesrow
ET.SubElement(doc_references, 'reference',
{'href': "http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=%s" % (bugzilla_id),
'id': bugzilla_id, 'type': 'bugzilla'}).text = summary
for erratacvesrow in erratacvesrows:
ET.SubElement(doc_references, 'reference',
{'href': "http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=%s" % (erratacvesrow),
'id': erratacvesrow[0], 'type': 'cve'})
xmlchannelnamevalue = advisory_db.select(table='misc')
# pkglist
doc_pkglist = ET.SubElement(doc_update, "pkglist")
# collection
rhchannel = "RHEL"
doc_collection = ET.SubElement(doc_pkglist, "collection", {'short': rhchannel})
ET.SubElement(doc_collection, 'name').text = xmlchannelnamevalue[0][0]
erratapackagesrows = advisory_db.select(table='erratapackages',
advisory=advisory)
for erratapackagesrow in erratapackagesrows:
name, version, release, epoch, arch_label, file, md5sum = erratapackagesrow
md5sum = ""
epoch = "0" if not epoch else epoch
doc_pkg = ET.SubElement(
doc_collection, "package",
{'name': name, 'version': version, 'release': release,
'epoch': epoch, 'arch': arch_label, 'src': ""})
ET.SubElement(doc_pkg, "filename").text = file
ET.SubElement(doc_pkg, 'sum', {'type': "md5"}).text = md5sum
tree = ET.ElementTree(root)
with open(updateinfofile, 'w') as xfile:
tree.write(xfile, encoding='utf-8', xml_declaration=True)
def updatedbinfo(pargs, advisory_db):
def updatedbinfo(pargs, advisory_db):
"""Update advisories info"""
"""Update advisories info"""
uinfo = cr.UpdateInfo(pargs.updinfofile)
uinfo = cr.UpdateInfo(pargs.updinfofile)
@@ -170,8 +86,6 @@ def main():
@@ -170,8 +86,6 @@ def main():
help="Database file")
help="Database file")
parser.add_argument('--arch', dest='archlabel',
parser.add_argument('--arch', dest='archlabel',
help="Arch")
help="Arch")
parser.add_argument('--updatexml', action="store_true", default=False, dest='updatexml',
help="Update the xml file with the data in the database")
parser.add_argument('--updatedb', action="store_true", default=False, dest='updatedb',
parser.add_argument('--updatedb', action="store_true", default=False, dest='updatedb',
help="Update the database with the xml data")
help="Update the database with the xml data")
pargs = parser.parse_args()
pargs = parser.parse_args()
@@ -186,8 +100,6 @@ def main():
@@ -186,8 +100,6 @@ def main():
if pargs.updatedb:
if pargs.updatedb:
updatedbinfo(pargs, db)
updatedbinfo(pargs, db)
if pargs.updatexml:
generate_xmlfile(pargs, db)
db.close_connection()
db.close_connection()
Loading