summaryrefslogtreecommitdiffstats
path: root/gen_known_issues.py
diff options
context:
space:
mode:
authorMiruna Paun <Miruna.Paun@enea.com>2017-04-07 12:27:55 +0200
committerMiruna Paun <Miruna.Paun@enea.com>2017-04-07 12:27:55 +0200
commit74c97c90a9fa10ebad46ec00061da9e2578b33a7 (patch)
tree9a6169d87c2b9ff598e83ae218c54c8400cefb78 /gen_known_issues.py
downloaddoc-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.py120
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
16from subprocess import check_output
17import json, re, datetime
18import time
19
20try:
21 with open("book-enea-linux-release-info/doc/jiraissues_override.xml") as f:
22 print f.read(),
23
24 exit(0)
25
26except SystemExit:
27 # Printing the override file was successful. Exception raised by
28 # the exit() call in the try block.
29 exit(0)
30
31except IOError:
32 # Accessing the override file failed. Assume that it does not exist
33 # and proceed with normal operation.
34 pass
35
36jd = json.JSONDecoder()
37
38def 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
56conditions = ("project=LXCR",
57 "issueType=bug",
58 "resolution=Unresolved",
59 'affectedversion="Enea Linux 6"'
60 )
61
62bugs = []
63
64time_str = time.strftime("%Y-%m-%d, %H:%M:%S (%Z)")
65
66for issue in jira_query(" and ".join(conditions)):
67 bugs.append((issue["key"], issue["fields"]["summary"]))
68
69print '<?xml version="1.0" encoding="ISO-8859-1"?>'
70print '<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"'
71print '"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">'
72print '<section id="relinfo-extracted-from-jira">'
73print ' <title>Extracted from Jira</title>'
74print
75print ' <para>'
76print ' This section lists open bugs in Jira. Extracted at %s.' % time_str
77print ' </para>'
78print
79print ' <remark>Jira query: (%s)</remark>' % "\n and ".join(conditions)
80print
81print ' <informaltable>'
82print ' <tgroup cols="2">'
83print ' <colspec colwidth="6*" colname="c1"/>'
84print
85print ' <colspec align="center" colwidth="1*" colname="c2"/>'
86print
87print ' <thead>'
88print ' <row>'
89print ' <entry align="center">Summary</entry>'
90print
91print ' <entry>Enea Ref</entry>'
92print ' </row>'
93print ' </thead>'
94print
95print ' <tbody>',
96
97if bugs:
98 for bug in sorted(bugs):
99 print
100 print ' <row>'
101 print ' <entry>%s</entry>' % bug[1]
102 print
103 print ' <entry>%s</entry>' % bug[0]
104 print ' </row>'
105
106else:
107 print ' <row>'
108 print ' <entry namest="c1" nameend="c2" align="center">'
109 print ' No issues found'
110 print ' </entry>'
111 print ' </row>'
112
113print ' </tbody>'
114print ' </tgroup>'
115print ' </informaltable>'
116
117if bugs:
118 print ' <para>Number of open bugs: %d</para>' % len(bugs)
119
120print '</section>' \ No newline at end of file