Unsolved
This post is more than 5 years old
6 Posts
0
5241
Is there a SRM REST API resource for reports
I am looking a way to directly pull reports from SRM using REST API. is there a report resource to allow this? If not, is there any ways to do so?
isakats
141 Posts
0
February 27th, 2018 06:00
Hi shi.jia@gm.com,
You can only pull data points from the REST API, the API overview should be a good starting point.
In order to actual pull reports you should be using the ReportManager in the SOAP API, you can find more details on it in APG-Web-Service-Tutorial.pdf (APG/Doc/)
regards,
Isaka
Flo_csI
2 Intern
2 Intern
•
166 Posts
0
March 5th, 2018 06:00
Hello,
There is no RESTful API to manage the reports, but, if you are looking to pull the report in a dynamic way you can use the lookup endpoint.
It allows you to query directly a report or search for certain reports.
The URL is construct like this : http:// :: /lookup/ { } /<SEARCH FOR A REPORT USING *>/report.jsp?refine= &autologin=api:happy
The URL call relies on 3 main concepts :
Here is a dumb script to get a report:
The usage is like this : ./get_report.sh localhost admin changeme W4N-HOST-INVENTORY pdf myresult.pdf
jiashi2
6 Posts
0
March 5th, 2018 07:00
Nice! I will try that to update.
Shi Jia
Storage Tools Engineer
Automation & Performance Management
shi.jia@gm.com
T 586.208.1023
jiashi2
6 Posts
0
March 5th, 2018 10:00
I am trying to pull a standard report with report UID "EXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY", but nothing returned. Following is the command
curl -v -k --basic --user admin:changeme -G "https://localhost:58443//lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/report.csv"
Output:
> GET //lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/report.csv HTTP/1.1
> Authorization: Basic YWRtaW46Y2hhbmdlbWU=
> User-Agent: curl/7.19.7 (x86_64-suse-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8j zlib/1.2.7 libidn/1.10
> Host: localhost:58443
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Mon, 05 Mar 2018 18:54:33 GMT
<
* Connection #0 to host localhost left intact
* Closing connection #0
* TLSv1.0, TLS alert, Client hello (1):
Flo_csI
2 Intern
2 Intern
•
166 Posts
0
March 6th, 2018 01:00
As you can see in the script I shared there is a first authentication to get a session id, then the query.
Can you give it a try with the script & let me know if that works.
Rgds.
jiashi2
6 Posts
0
March 6th, 2018 05:00
Please see following, still couldn't get the report.
dcwipvmste025:~ # curl -s -k --basic --user admin:changeme -G "https://localhost:58443/APG-REST/metrics/aggregates"|python -m json.tool {
"periods": [
"0",
"3600",
"86400",
"604800"
],
"types": [
"average",
"min",
"max",
"sum",
"last",
"nbvalues",
"lasttimestamp"
]
}
dcwipvmste025:~ # curl -k -c - "https://localhost:58443/APG/" -o /dev/null % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
104 1769 104 1769 0 0 8289 0 --:--:-- --:--:-- --:--:-- 9071
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE /APG TRUE 0 JSESSIONID 6CFB1FB49A242CCA4F75395F78816074
dcwipvmste025:~ # curl -k -L --max-redirs 1 -c - -b "JSESSIONID='57562CEEB232D4400DC0666CD72925C0'" --data "j_username='admin'&j_password='changeme'" "https://localhost:58443/APG/j_security_check" -o /dev/null
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 42 0 42 0 40 648 617 --:--:-- --:--:-- --:--:-- 40
# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE /APG TRUE 0 JSESSIONID 9BC60DB4116F2C4C319B032BFA80B9E1
dcwipvmste025:~ # curl -v -k -L -b "JSESSIONIDSSO='9BC60DB4116F2C4C319B032BFA80B9E1'" "https://localhost:58443/lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/MXN5411WXM.csv"
* About to connect() to localhost port 58443 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 58443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs/
* TLSv1.0, TLS handshake, Client hello (1):
* TLSv1.0, TLS handshake, Server hello (2):
* TLSv1.0, TLS handshake, CERT (11):
* TLSv1.0, TLS handshake, Server key exchange (12):
* TLSv1.0, TLS handshake, Server finished (14):
* TLSv1.0, TLS handshake, Client key exchange (16):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES128-SHA
* Server certificate:
* subject: C=US; ST=MI; L=Warren; O=GM; OU=Hosting; CN=dcwipvmste025.edc.nam.gm.com
* start date: 2018-02-15 18:08:10 GMT
* expire date: 2021-02-14 18:08:10 GMT
* issuer: DC=com; DC=gm; DC=corp; CN=GM SHA2 Infrastructure Issuing CA2
* SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
> GET /lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/MXN5411WXM.csv HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-suse-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8j zlib/1.2.7 libidn/1.10
> Host: localhost:58443
> Accept: */*
> Cookie: JSESSIONIDSSO='9BC60DB4116F2C4C319B032BFA80B9E1'
>
< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Tue, 06 Mar 2018 13:49:52 GMT
<
* Connection #0 to host localhost left intact
* Closing connection #0
* TLSv1.0, TLS alert, Client hello (1):
dcwipvmste025:~ # curl -v -k -L -b "JSESSIONIDSSO='9BC60DB4116F2C4C319B032BFA80B9E1'" "https://localhost:58443/lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/report.csv"
* About to connect() to localhost port 58443 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 58443 (#0)
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs/
* TLSv1.0, TLS handshake, Client hello (1):
* TLSv1.0, TLS handshake, Server hello (2):
* TLSv1.0, TLS handshake, CERT (11):
* TLSv1.0, TLS handshake, Server key exchange (12):
* TLSv1.0, TLS handshake, Server finished (14):
* TLSv1.0, TLS handshake, Client key exchange (16):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* TLSv1.0, TLS change cipher, Client hello (1):
* TLSv1.0, TLS handshake, Finished (20):
* SSL connection using ECDHE-RSA-AES128-SHA
... ...
> GET /lookup/%7BEXPLORE-BRANCH-HOSTS-CONNECTED-TO-ARRAY%7D/*/report.csv HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-suse-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8j zlib/1.2.7 libidn/1.10
> Host: localhost:58443
> Accept: */*
> Cookie: JSESSIONIDSSO='9BC60DB4116F2C4C319B032BFA80B9E1'
>
< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< Content-Length: 0
< Date: Tue, 06 Mar 2018 13:50:05 GMT
<
* Connection #0 to host localhost left intact
* Closing connection #0
* TLSv1.0, TLS alert, Client hello (1):
dcwipvmste025:~ #
jiashi2
6 Posts
0
March 6th, 2018 06:00
I am able to pull the first line in standard report "EXPLORE-BRANCH-STORAGE-SYSTEMS". As you stated that SRM will stop on the first matching report, do you know how to loop through a report to get all lines in it?
Flo_csI
2 Intern
2 Intern
•
166 Posts
0
March 7th, 2018 02:00
Actually, you have to chain the requests like you would do with real REST API.
1st you get a list of elements, then, you request each report.
For example, if you want to get all the sub-elements from a table.
request_report.sh localhost admin changeme EXPLORE-BRANCH-STORAGE-SYSTEMS 4 csv ./
PS: There is a small trick in the position argument. It gives the column to be used as a key. In my example the second column. But for ease of parsing with awk the field seperator is " so the position for the key has to be 4.