diff options
author | Miruna Paun <Miruna.Paun@enea.com> | 2017-04-07 12:27:55 +0200 |
---|---|---|
committer | Miruna Paun <Miruna.Paun@enea.com> | 2017-04-07 12:27:55 +0200 |
commit | 74c97c90a9fa10ebad46ec00061da9e2578b33a7 (patch) | |
tree | 9a6169d87c2b9ff598e83ae218c54c8400cefb78 /gen_known_issues.py | |
download | doc-enea-nfv-74c97c90a9fa10ebad46ec00061da9e2578b33a7.tar.gz |
Updated ENFV (COSNOS) Installation Guide
COSNOSCR-318 seeking to complete first time push
Diffstat (limited to 'gen_known_issues.py')
-rw-r--r-- | gen_known_issues.py | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/gen_known_issues.py b/gen_known_issues.py new file mode 100644 index 0000000..6d3f6e2 --- /dev/null +++ b/gen_known_issues.py | |||
@@ -0,0 +1,120 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | #------------------------------------------------------------------------------ | ||
4 | # This script generates an XML file with a table with issues in Jira. See the | ||
5 | # variable 'conditions' for query details. It is used by the make system in | ||
6 | # the generation of the release notes. | ||
7 | # The result is printed to STDOUT. | ||
8 | # | ||
9 | # It is possible to override the generation. If there is a file named | ||
10 | # jiraissues_override.xml in the current directory, then that file will be | ||
11 | # printed instead. This mechanism can be used if the table needs manual | ||
12 | # modifications. | ||
13 | # | ||
14 | #------------------------------------------------------------------------------ | ||
15 | |||
16 | from subprocess import check_output | ||
17 | import json, re, datetime | ||
18 | import time | ||
19 | |||
20 | try: | ||
21 | with open("book-enea-linux-release-info/doc/jiraissues_override.xml") as f: | ||
22 | print f.read(), | ||
23 | |||
24 | exit(0) | ||
25 | |||
26 | except SystemExit: | ||
27 | # Printing the override file was successful. Exception raised by | ||
28 | # the exit() call in the try block. | ||
29 | exit(0) | ||
30 | |||
31 | except IOError: | ||
32 | # Accessing the override file failed. Assume that it does not exist | ||
33 | # and proceed with normal operation. | ||
34 | pass | ||
35 | |||
36 | jd = json.JSONDecoder() | ||
37 | |||
38 | def jira_query(query): | ||
39 | jira_url = "http://eneaissues.enea.com" | ||
40 | fields = "key,summary" | ||
41 | query = query.replace(" ", "+") | ||
42 | |||
43 | cmd = ["curl", | ||
44 | "-s", | ||
45 | "-D-", | ||
46 | "-u", "rest_reader:jira123", | ||
47 | "-X", "GET", | ||
48 | "-H", "Content-Type: application/json", | ||
49 | jira_url + "/rest/api/2/search?jql=" + query + "&fields=" + fields | ||
50 | ] | ||
51 | |||
52 | tmp = check_output(cmd).splitlines() | ||
53 | tmp = jd.decode(tmp[-1]) | ||
54 | return tmp["issues"] | ||
55 | |||
56 | conditions = ("project=LXCR", | ||
57 | "issueType=bug", | ||
58 | "resolution=Unresolved", | ||
59 | 'affectedversion="Enea Linux 6"' | ||
60 | ) | ||
61 | |||
62 | bugs = [] | ||
63 | |||
64 | time_str = time.strftime("%Y-%m-%d, %H:%M:%S (%Z)") | ||
65 | |||
66 | for issue in jira_query(" and ".join(conditions)): | ||
67 | bugs.append((issue["key"], issue["fields"]["summary"])) | ||
68 | |||
69 | print '<?xml version="1.0" encoding="ISO-8859-1"?>' | ||
70 | print '<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"' | ||
71 | print '"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">' | ||
72 | print '<section id="relinfo-extracted-from-jira">' | ||
73 | print ' <title>Extracted from Jira</title>' | ||
74 | |||
75 | print ' <para>' | ||
76 | print ' This section lists open bugs in Jira. Extracted at %s.' % time_str | ||
77 | print ' </para>' | ||
78 | |||
79 | print ' <remark>Jira query: (%s)</remark>' % "\n and ".join(conditions) | ||
80 | |||
81 | print ' <informaltable>' | ||
82 | print ' <tgroup cols="2">' | ||
83 | print ' <colspec colwidth="6*" colname="c1"/>' | ||
84 | |||
85 | print ' <colspec align="center" colwidth="1*" colname="c2"/>' | ||
86 | |||
87 | print ' <thead>' | ||
88 | print ' <row>' | ||
89 | print ' <entry align="center">Summary</entry>' | ||
90 | |||
91 | print ' <entry>Enea Ref</entry>' | ||
92 | print ' </row>' | ||
93 | print ' </thead>' | ||
94 | |||
95 | print ' <tbody>', | ||
96 | |||
97 | if bugs: | ||
98 | for bug in sorted(bugs): | ||
99 | |||
100 | print ' <row>' | ||
101 | print ' <entry>%s</entry>' % bug[1] | ||
102 | |||
103 | print ' <entry>%s</entry>' % bug[0] | ||
104 | print ' </row>' | ||
105 | |||
106 | else: | ||
107 | print ' <row>' | ||
108 | print ' <entry namest="c1" nameend="c2" align="center">' | ||
109 | print ' No issues found' | ||
110 | print ' </entry>' | ||
111 | print ' </row>' | ||
112 | |||
113 | print ' </tbody>' | ||
114 | print ' </tgroup>' | ||
115 | print ' </informaltable>' | ||
116 | |||
117 | if bugs: | ||
118 | print ' <para>Number of open bugs: %d</para>' % len(bugs) | ||
119 | |||
120 | print '</section>' \ No newline at end of file | ||