Blame SOURCES/0225-workflows-add-workflow-for-adding-data-to-existing-c.patch

28bab8
From 08cde7d66147769cd160630e0bac4fae93db3ada Mon Sep 17 00:00:00 2001
28bab8
From: Matej Habrnal <mhabrnal@redhat.com>
28bab8
Date: Thu, 31 Aug 2017 12:56:36 +0200
28bab8
Subject: [PATCH] workflows: add workflow for adding data to existing case
28bab8
28bab8
Change behavior of -t parameter in reporter-rhtsupport.
28bab8
28bab8
If option -t without support case ID is used and problem data in DIR was never
28bab8
reported to RHTSupport, you will ask to enter case ID to which you want to
28bab8
upload the FILEs. If the data in DIR was reported, the case ID is obtained from
28bab8
'reported_to' element in problem dir. In this case, you will be asked if you
28bab8
want to attach the data to the support case or you want to change the support
28bab8
case ID.
28bab8
28bab8
Related to #1395285
28bab8
28bab8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
28bab8
28bab8
Conflicts:
28bab8
	po/POTFILES.in
28bab8
	src/plugins/rhtsupport_event.conf
28bab8
	src/workflows/Makefile.am
28bab8
---
28bab8
 doc/reporter-rhtsupport.txt                        |  3 +-
28bab8
 po/POTFILES.in                                     |  8 +++
28bab8
 src/plugins/Makefile.am                            |  2 +
28bab8
 src/plugins/report_RHTSupport_AddData.xml.in       | 18 ++++++
28bab8
 src/plugins/reporter-rhtsupport.c                  | 67 +++++++++++++++++-----
28bab8
 src/plugins/rhtsupport_event.conf                  |  4 ++
28bab8
 src/workflows/Makefile.am                          | 16 ++++++
28bab8
 src/workflows/report_rhel_add_data.conf            | 27 +++++++++
28bab8
 src/workflows/workflow_RHELAddDataCCpp.xml.in      | 11 ++++
28bab8
 src/workflows/workflow_RHELAddDataJava.xml.in      | 11 ++++
28bab8
 .../workflow_RHELAddDataKerneloops.xml.in          | 11 ++++
28bab8
 src/workflows/workflow_RHELAddDataLibreport.xml.in | 10 ++++
28bab8
 src/workflows/workflow_RHELAddDataPython.xml.in    | 11 ++++
28bab8
 src/workflows/workflow_RHELAddDatavmcore.xml.in    | 12 ++++
28bab8
 src/workflows/workflow_RHELAddDataxorg.xml.in      | 10 ++++
28bab8
 15 files changed, 205 insertions(+), 16 deletions(-)
28bab8
 create mode 100644 src/plugins/report_RHTSupport_AddData.xml.in
28bab8
 create mode 100644 src/workflows/report_rhel_add_data.conf
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataCCpp.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataJava.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataKerneloops.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataLibreport.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataPython.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDatavmcore.xml.in
28bab8
 create mode 100644 src/workflows/workflow_RHELAddDataxorg.xml.in
28bab8
28bab8
diff --git a/doc/reporter-rhtsupport.txt b/doc/reporter-rhtsupport.txt
28bab8
index 66e5bed..2e779bc 100644
28bab8
--- a/doc/reporter-rhtsupport.txt
28bab8
+++ b/doc/reporter-rhtsupport.txt
28bab8
@@ -28,7 +28,8 @@ If not specified, CONFFILE defaults to /etc/libreport/plugins/rhtsupport.conf.
28bab8
 
28bab8
 Option -t uploads FILEs to the already created case on RHTSupport site.
28bab8
 The case ID is retrieved from directory specified by -d DIR.
28bab8
-If problem data in DIR was never reported to RHTSupport, upload will fail.
28bab8
+If problem data in DIR was never reported to RHTSupport, you will be asked
28bab8
+to enter case ID to which you want to upload the FILEs.
28bab8
 
28bab8
 Option -tCASE uploads FILEs to the case CASE on RHTSupport site.
28bab8
 -d DIR is ignored.
28bab8
diff --git a/po/POTFILES.in b/po/POTFILES.in
28bab8
index 4246e06..9f972ae 100644
28bab8
--- a/po/POTFILES.in
28bab8
+++ b/po/POTFILES.in
28bab8
@@ -42,6 +42,7 @@ src/plugins/report_Kerneloops.xml.in
28bab8
 src/plugins/report_Logger.xml.in
28bab8
 src/plugins/report_Mailx.xml.in
28bab8
 src/plugins/report_RHTSupport.xml.in
28bab8
+src/plugins/report_RHTSupport_AddData.xml.in
28bab8
 src/plugins/report_Uploader.xml.in
28bab8
 src/plugins/report_uReport.xml.in
28bab8
 src/plugins/report_EmergencyAnalysis.xml.in
28bab8
@@ -73,6 +74,13 @@ src/workflows/workflow_RHELvmcore.xml.in
28bab8
 src/workflows/workflow_RHELxorg.xml.in
28bab8
 src/workflows/workflow_RHELLibreport.xml.in
28bab8
 src/workflows/workflow_RHELJava.xml.in
28bab8
+src/workflows/workflow_RHELAddDataCCpp.xml.in
28bab8
+src/workflows/workflow_RHELAddDataJava.xml.in
28bab8
+src/workflows/workflow_RHELAddDataKerneloops.xml.in
28bab8
+src/workflows/workflow_RHELAddDataLibreport.xml.in
28bab8
+src/workflows/workflow_RHELAddDataPython.xml.in
28bab8
+src/workflows/workflow_RHELAddDatavmcore.xml.in
28bab8
+src/workflows/workflow_RHELAddDataxorg.xml.in
28bab8
 src/workflows/workflow_RHELBugzillaCCpp.xml.in
28bab8
 src/workflows/workflow_RHELBugzillaKerneloops.xml.in
28bab8
 src/workflows/workflow_RHELBugzillaPython.xml.in
28bab8
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
28bab8
index 8e1a166..c5e8ec1 100644
28bab8
--- a/src/plugins/Makefile.am
28bab8
+++ b/src/plugins/Makefile.am
28bab8
@@ -62,6 +62,7 @@ dist_events_DATA = $(reporters_events) \
28bab8
     report_Logger.xml \
28bab8
     report_Mailx.xml \
28bab8
     report_RHTSupport.xml \
28bab8
+    report_RHTSupport_AddData.xml \
28bab8
     report_Kerneloops.xml \
28bab8
     report_Uploader.xml \
28bab8
     report_EmergencyAnalysis.xml
28bab8
@@ -96,6 +97,7 @@ EXTRA_DIST = $(reporters_extra_dist) \
28bab8
     report_Logger.xml.in \
28bab8
     report_Mailx.xml.in \
28bab8
     report_RHTSupport.xml.in \
28bab8
+    report_RHTSupport_AddData.xml.in \
28bab8
     report_Kerneloops.xml.in \
28bab8
     report_Uploader.xml.in \
28bab8
     report_EmergencyAnalysis.xml.in
28bab8
diff --git a/src/plugins/report_RHTSupport_AddData.xml.in b/src/plugins/report_RHTSupport_AddData.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..b4aa7e1
28bab8
--- /dev/null
28bab8
+++ b/src/plugins/report_RHTSupport_AddData.xml.in
28bab8
@@ -0,0 +1,18 @@
28bab8
+
28bab8
+<event>
28bab8
+    <_name>Red Hat Customer Support</_name>
28bab8
+    <_description>Attach the data to existing Red Hat support case</_description>
28bab8
+
28bab8
+    <requires-items>package</requires-items>
28bab8
+    <requires-details>yes</requires-details>
28bab8
+    <exclude-items-by-default>event_log</exclude-items-by-default>
28bab8
+    <exclude-items-always></exclude-items-always>
28bab8
+    <exclude-binary-items>no</exclude-binary-items>
28bab8
+    <include-items-by-default></include-items-by-default>
28bab8
+    <minimal-rating>0</minimal-rating>
28bab8
+    <gui-review-elements>yes</gui-review-elements>
28bab8
+
28bab8
+    <options>
28bab8
+        <import-event-options event="report_RHTSupport"/>
28bab8
+    </options>
28bab8
+</event>
28bab8
diff --git a/src/plugins/reporter-rhtsupport.c b/src/plugins/reporter-rhtsupport.c
28bab8
index 14b3864..dc0d04e 100644
28bab8
--- a/src/plugins/reporter-rhtsupport.c
28bab8
+++ b/src/plugins/reporter-rhtsupport.c
28bab8
@@ -44,6 +44,8 @@
28bab8
 
28bab8
 #define ABRT_ELEMENTS_KB_ARTICLE "https://access.redhat.com/articles/2134281"
28bab8
 
28bab8
+#define RHTSUPPORT_CASE_URL_PATH "cases"
28bab8
+
28bab8
 #define QUERY_HINTS_IF_SMALLER_THAN  (8*1024*1024)
28bab8
 
28bab8
 static void ask_rh_credentials(char **login, char **password);
28bab8
@@ -449,6 +451,32 @@ void prepare_ureport_configuration(const char *urcfile,
28bab8
     }
28bab8
 }
28bab8
 
28bab8
+static char *create_case_url(char *url, const char *case_no)
28bab8
+{
28bab8
+    char *url1 = concat_path_file(url, RHTSUPPORT_CASE_URL_PATH);
28bab8
+    free(url);
28bab8
+    url = concat_path_file(url1, case_no);
28bab8
+    free(url1);
28bab8
+
28bab8
+    return url;
28bab8
+}
28bab8
+
28bab8
+static char *ask_case_no_create_url(char *url)
28bab8
+{
28bab8
+    char *msg = xasprintf(_("Please enter customer case number to which you want to attach the data:"));
28bab8
+    char *case_no = ask(msg);
28bab8
+    free(msg);
28bab8
+    if (case_no == NULL || case_no[0] == '\0')
28bab8
+    {
28bab8
+        set_xfunc_error_retval(EXIT_CANCEL_BY_USER);
28bab8
+        error_msg_and_die(_("Can't continue without RHTSupport case number"));
28bab8
+    }
28bab8
+    char *new_url = create_case_url(url, (const char *)case_no);
28bab8
+    free(case_no);
28bab8
+
28bab8
+    return new_url;
28bab8
+}
28bab8
+
28bab8
 int main(int argc, char **argv)
28bab8
 {
28bab8
     abrt_init(argv);
28bab8
@@ -484,7 +512,8 @@ int main(int argc, char **argv)
28bab8
         "\n"
28bab8
         "Option -t uploads FILEs to the already created case on RHTSupport site.\n"
28bab8
         "The case ID is retrieved from directory specified by -d DIR.\n"
28bab8
-        "If problem data in DIR was never reported to RHTSupport, upload will fail.\n"
28bab8
+        "If problem data in DIR was never reported to Red Hat Support, you will be asked\n"
28bab8
+        "to enter case ID to which you want to upload the FILEs.\n"
28bab8
         "\n"
28bab8
         "Option -tCASE uploads FILEs to the case CASE on RHTSupport site.\n"
28bab8
         "-d DIR is ignored."
28bab8
@@ -586,24 +615,32 @@ int main(int argc, char **argv)
28bab8
         {
28bab8
             /* -t: extract URL where we previously reported it */
28bab8
             report_result_t *reported_to = get_reported_to(dump_dir_name);
28bab8
-            if (!reported_to || !reported_to->url)
28bab8
-                error_msg_and_die("Can't attach: problem data in '%s' "
28bab8
-                        "was not reported to RHTSupport and therefore has no URL",
28bab8
-                        dump_dir_name);
28bab8
-            //log("URL:'%s'", reported_to->url);
28bab8
-            //log("MSG:'%s'", reported_to->msg);
28bab8
-            free(url);
28bab8
-            url = reported_to->url;
28bab8
-            reported_to->url = NULL;
28bab8
-            free_report_result(reported_to);
28bab8
+            if (reported_to && reported_to->url)
28bab8
+            {
28bab8
+                free(url);
28bab8
+                url = reported_to->url;
28bab8
+                reported_to->url = NULL;
28bab8
+                free_report_result(reported_to);
28bab8
+                char *msg = xasprintf(
28bab8
+                    _("We found a similar Red Hat support case %s. "
28bab8
+                      "Do you want to attach the data to the case? "
28bab8
+                      "Otherwise, you will have to enter the existing "
28bab8
+                      "Red Hat support case number."), url);
28bab8
+                int yes = ask_yes_no(msg);
28bab8
+                free(msg);
28bab8
+                if (!yes)
28bab8
+                    url = ask_case_no_create_url(url);
28bab8
+            }
28bab8
+            else
28bab8
+            {
28bab8
+                log("Problem was not reported to RHTSupport.");
28bab8
+                url = ask_case_no_create_url(url);
28bab8
+            }
28bab8
         }
28bab8
         else
28bab8
         {
28bab8
             /* -tCASE */
28bab8
-            char *url1 = concat_path_file(url, "cases");
28bab8
-            free(url);
28bab8
-            url = concat_path_file(url1, case_no);
28bab8
-            free(url1);
28bab8
+            url = create_case_url(url, case_no);
28bab8
         }
28bab8
 
28bab8
         if (*argv)
28bab8
diff --git a/src/plugins/rhtsupport_event.conf b/src/plugins/rhtsupport_event.conf
28bab8
index f6a9d47..cc2f05d 100644
28bab8
--- a/src/plugins/rhtsupport_event.conf
28bab8
+++ b/src/plugins/rhtsupport_event.conf
28bab8
@@ -1,3 +1,7 @@
28bab8
 EVENT=report_RHTSupport
28bab8
     # Submit an uReport and create a case in Red Hat Customer Portal
28bab8
     reporter-rhtsupport -u
28bab8
+
28bab8
+EVENT=report_RHTSupport_AddData
28bab8
+    # Attach data to a case in Red Hat Customer Portal
28bab8
+    reporter-rhtsupport -t
28bab8
diff --git a/src/workflows/Makefile.am b/src/workflows/Makefile.am
28bab8
index 72502ca..e853030 100644
28bab8
--- a/src/workflows/Makefile.am
28bab8
+++ b/src/workflows/Makefile.am
28bab8
@@ -15,6 +15,13 @@ dist_workflows_DATA = \
28bab8
     workflow_RHELxorg.xml \
28bab8
     workflow_RHELLibreport.xml \
28bab8
     workflow_RHELJava.xml \
28bab8
+    workflow_RHELAddDataCCpp.xml \
28bab8
+    workflow_RHELAddDataJava.xml \
28bab8
+    workflow_RHELAddDataKerneloops.xml \
28bab8
+    workflow_RHELAddDataLibreport.xml \
28bab8
+    workflow_RHELAddDataPython.xml \
28bab8
+    workflow_RHELAddDatavmcore.xml \
28bab8
+    workflow_RHELAddDataxorg.xml \
28bab8
     workflow_uReport.xml \
28bab8
     workflow_Mailx.xml \
28bab8
     workflow_MailxCCpp.xml \
28bab8
@@ -43,6 +50,7 @@ workflowsdefdir = $(WORKFLOWS_DEFINITION_DIR)
28bab8
 dist_workflowsdef_DATA =\
28bab8
     report_fedora.conf \
28bab8
     report_rhel.conf \
28bab8
+    report_rhel_add_data.conf \
28bab8
     report_uReport.conf \
28bab8
     report_mailx.conf \
28bab8
     report_logger.conf \
28bab8
@@ -72,6 +80,14 @@ EXTRA_DIST = \
28bab8
     workflow_RHELxorg.xml.in \
28bab8
     workflow_RHELLibreport.xml.in \
28bab8
     workflow_RHELJava.xml.in \
28bab8
+    workflow_RHELAddDataCCpp.xml.in \
28bab8
+    workflow_RHELAddDataJava.xml.in \
28bab8
+    workflow_RHELAddDataKerneloops.xml.in \
28bab8
+    workflow_RHELAddDataLibreport.xml.in \
28bab8
+    workflow_RHELAddDataPython.xml.in \
28bab8
+    workflow_RHELAddDatavmcore.xml.in \
28bab8
+    workflow_RHELAddDataxorg.xml.in \
28bab8
+    workflow_uReport.xml.in \
28bab8
     workflow_Mailx.xml.in \
28bab8
     workflow_MailxCCpp.xml.in \
28bab8
     workflow_Upload.xml.in \
28bab8
diff --git a/src/workflows/report_rhel_add_data.conf b/src/workflows/report_rhel_add_data.conf
28bab8
new file mode 100644
28bab8
index 0000000..be8251e
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/report_rhel_add_data.conf
28bab8
@@ -0,0 +1,27 @@
28bab8
+EVENT=workflow_RHELAddDataLibreport analyzer=libreport
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDataCCpp type=CCpp
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDataPython type=Python component!=anaconda
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDataKerneloops type=Kerneloops
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDatavmcore type=vmcore
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDataxorg type=xorg
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
+
28bab8
+EVENT=workflow_RHELAddDataJava type=Java
28bab8
+# this is just a meta event which consists of other events
28bab8
+# the list is defined in the xml file
28bab8
diff --git a/src/workflows/workflow_RHELAddDataCCpp.xml.in b/src/workflows/workflow_RHELAddDataCCpp.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..6d0f5e0
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataCCpp.xml.in
28bab8
@@ -0,0 +1,11 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>collect_*</event>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDataJava.xml.in b/src/workflows/workflow_RHELAddDataJava.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..6d0f5e0
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataJava.xml.in
28bab8
@@ -0,0 +1,11 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>collect_*</event>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDataKerneloops.xml.in b/src/workflows/workflow_RHELAddDataKerneloops.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..6d0f5e0
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataKerneloops.xml.in
28bab8
@@ -0,0 +1,11 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>collect_*</event>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDataLibreport.xml.in b/src/workflows/workflow_RHELAddDataLibreport.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..26dc4c9
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataLibreport.xml.in
28bab8
@@ -0,0 +1,10 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDataPython.xml.in b/src/workflows/workflow_RHELAddDataPython.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..6d0f5e0
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataPython.xml.in
28bab8
@@ -0,0 +1,11 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>collect_*</event>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDatavmcore.xml.in b/src/workflows/workflow_RHELAddDatavmcore.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..79af822
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDatavmcore.xml.in
28bab8
@@ -0,0 +1,12 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>collect_*</event>
28bab8
+        <event>analyze_VMcore</event>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
diff --git a/src/workflows/workflow_RHELAddDataxorg.xml.in b/src/workflows/workflow_RHELAddDataxorg.xml.in
28bab8
new file mode 100644
28bab8
index 0000000..26dc4c9
28bab8
--- /dev/null
28bab8
+++ b/src/workflows/workflow_RHELAddDataxorg.xml.in
28bab8
@@ -0,0 +1,10 @@
28bab8
+
28bab8
+<workflow>
28bab8
+    <_name>Attach crash data to an existing Red Hat support case</_name>
28bab8
+    <_description>Provide Red Hat Support with crash details</_description>
28bab8
+    <priority>99</priority>
28bab8
+
28bab8
+    <events>
28bab8
+        <event>report_RHTSupport_AddData</event>
28bab8
+    </events>
28bab8
+</workflow>
28bab8
-- 
28bab8
1.8.3.1
28bab8