1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 import sys
18 import logging
19
20 from yum.update_md import UpdateMetadata
21
22 from pulp.server.db.model import Errata
23
24 log = logging.getLogger(__name__)
25
26
28 """
29 path_to_updateinfo: path to updateinfo.xml
30
31 Returns a list of dictionaries
32 Dictionary is based on keys from yum.update_md.UpdateNotice
33 """
34 um = UpdateMetadata()
35 um.add(path_to_updateinfo)
36 notices = []
37 for info in um.get_notices():
38 notices.append(info.get_metadata())
39 return notices
40
42 """
43 @param path_to_updateinfo: path to updateinfo metadata xml file
44
45 Returns a list of pulp.model.Errata objects
46 Parses updateinfo xml file and converts yum.update_md.UpdateNotice
47 objects to pulp.model.Errata objects
48 """
49 errata = []
50 uinfos = get_update_notices(path_to_updateinfo)
51 for u in uinfos:
52 e = _translate_updatenotice_to_erratum(u)
53 errata.append(e)
54 return errata
55
57 id = unotice['update_id']
58 title = unotice['title']
59 description = unotice['description']
60 version = unotice['version']
61 release = unotice['release']
62 type = unotice['type']
63 status = unotice['status']
64 updated = unotice['updated']
65 issued = unotice['issued']
66 pushcount = unotice['pushcount']
67 from_str = unotice['from']
68 reboot_suggested = unotice['reboot_suggested']
69 references = unotice['references']
70 pkglist = unotice['pkglist']
71 erratum = Errata(id, title, description, version, release, type,
72 status, updated, issued, pushcount, from_str, reboot_suggested,
73 references, pkglist)
74 return erratum
75
76 if __name__ == "__main__":
77 if len(sys.argv) < 2:
78 print "Usage: %s <PATH_TO/updateinfo.xml>"
79 sys.exit(1)
80 updateinfo_path = sys.argv[1]
81 notices = get_update_notices(updateinfo_path)
82 if len(notices) < 1:
83 print "Error parsing %s" % (updateinfo_path)
84 print "Ensure you are specifying the path to updateinfo.xml"
85 sys.exit(1)
86 print "UpdateInfo has been parsed for %s notices." % (len(notices))
87 example = notices[0]
88 for key in example.keys():
89 print "%s: %s" % (key, example[key])
90 print "Available keys are: %s" % (example.keys())
91