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