From: Ondrej Lichtner <olichtne(a)redhat.com>
The method follows the example of other create methods that we already
have. One speciality is the addition of the set_user call, since the
user attribute is only required for Report objects.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/PerfRepo.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/PerfRepo.py b/lnst/Controller/PerfRepo.py
index 902820d..5c3b905 100644
--- a/lnst/Controller/PerfRepo.py
+++ b/lnst/Controller/PerfRepo.py
@@ -854,10 +854,18 @@ class PerfRepoRESTAPI(object):
return PerfRepoReport(response.content)
def report_create(self, report):
- #TODO not needed yet and therefore not tested
post_url = self._url + '/rest/report/create'
- self._session.post(post_url, data=report)
- return None
+
+ report.set_user(self._user)
+
+ response = self._session.post(post_url, data=report.to_xml_string())
+ if response.status_code != 201:
+ logging.debug(response.text)
+ return None
+ else:
+ new_id = response.headers["Location"].split('/')[-1]
+ report.set_id(new_id)
+ return report
def report_delete(self, report_id):
#TODO not needed yet and therefore not tested
--
2.5.2