Log resources
Log resources let you prepare, download, and monitor the download of the HCP internal logs.
Data type |
Method |
Use |
Access |
Notes |
---|---|---|---|---|
.../logs |
||||
LogDownloadStatus |
GET |
Retrieve the status of the log download in progress |
System-level user with the administrator, service, or monitor role. |
|
N/A | POST | Marks the logs with a supplied message |
System-level user with the administrator or service role. |
You supply the message at the end of the command. Use the plus (+) sign or %20 to make spaces between words. |
N/A | POST | Clears the log download so that it can be reinitiated. |
System-level user with the administrator or service role. |
|
.../logs/prepare |
||||
LogPrepare | POST | Post a system request to package logs for download |
System-level user with the administrator or service role. |
Packages all logs, regardless of log type. If prepared logs are not downloaded withing twenty four hours, the package is deleted. |
.../logs/download |
||||
LogDownload | POST | Starts the log download |
System-level user with the administrator or service role. |
Downloaded logs come as .zip files. For HCP nodes, you have control over which log types are downloaded. |
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.
Example: Start log packaging
Here’s a sample POST request that packages system logs for download. The command requests to package logs between the dates of 8/19/2017 and 8/21/2017. The dates are specified in an XML file named logPrepare.xml. The request is made using a system-level user account that includes the administrator role.
Request body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<logPrepare>
<startDate>08/19/2017</startDate>
<endDate>08/21/2017</endDate>
</logPrepare>
Request with cURL command line
curl -iX POST -d @logPrepare.xml -k -i -H "Content-type: application/xml"
-H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
"https://admin.hcp.example.com:9090/mapi/logs/prepare"
Request in Python using PycURL
import pycurl
import os
filename = "logPrepare.xml"
filehandle = open(filename, "rb")
filesize = os.path.getsize(filename)
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "POST")
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml", \
"Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/mapi/logs/prepare")
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, filesize)
curl.perform()
filehandle.close()
curl.close()
Request headers
POST /mapi/logs/prepare HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Content-Type: application/xml
Content-Length: 56
Response headers
HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 8.2.0.2
Content-Length: 0
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.
Example: Download the logs
Here’s a sample POST request that downloads the system logs prepared in the previous example to your current directory in a zip file. The request downloads the Service logs for General Node 17. The log type and selected General Node are specified in an XML file named logDownload.xml. The request is made using a system-level user account that includes the administrator role.
Request body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<logDownload>
<nodes>17</nodes>
<content>SERVICE</content>
</logDownload>
Request with cURL command line
curl -X POST -T @logDownload.xml -k -H "Content-type: application/xml"
-H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
"https://admin.hcp.example.com:9090/mapi/logs/download"
-o logDownload.zip
Request in Python using PycURL
import pycurl
import os
filename = "logDownload.xml"
filehandle = open(filename, "rb")
filesize = os.path.getsize(filename)
output = open("downloadedLogs.zip", "wb")
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "POST")
curl.setopt(pycurl.READFUNCTION, filehandle.read)
curl.setopt(pycurl.HTTPHEADER, ["Content-Type: application/xml", \
"Authorization: HCP \
YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/mapi/logs/download")
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.setopt(pycurl.UPLOAD, 1)
curl.setopt(pycurl.INFILESIZE, filesize)
curl.setopt(pycurl.WRITEFUNCTION, output.write)
curl.perform()
print(curl.getinfo(pycurl.RESPONSE_CODE))
filehandle.close()
curl.close()
Request headers
POST /mapi/logs/download HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Response headers
HTTP/1.1 200 OK
Content-Type: application/zip
Content-Disposition: attachment; filename=HCPLogs-admin.hcp.example.com-n17-sp20170321-1225.zip
Accept-Ranges: none
Transfer-Encoding: chunked
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.
Example: Retrieving the log download status
Here’s a sample GET request that retrieves the log download status. The request is made using a system-level user account that includes the administrator role.
Request with cURL command line
curl -k -i
-H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
"https://admin.hcp.example.com:9090/mapi/logs"
Request in Python using PycURL
import pycurl
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "GET")
curl.setopt(pycurl.HTTPHEADER, ["Accept: application/xml", \
"Authorization: HCP \
YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/m...gs?prettyprint")
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.perform()
curl.close()
Request headers
GET /mapi/logs HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Response headers
HTTP/1.1 200 OK
Content-Type: application/xml
X-HCP-SoftwareVersion: 8.2.0.2
Content-Length: 282
Response body in XML
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<logDownloadStatus>
<readyForStreaming>true</readyForStreaming>
<streamingInProgress>false</streamingInProgress>
<started>true</started>
<error>false</error>
<content>SERVICE</content>
</logDownloadStatus>
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.
Example: Canceling a log download
Here’s a sample POST request that clears the log download status. The request is made using a system-level user account that includes the administrator role.
Request with cURL command line
curl -X POST -k -i
-H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
"https://admin.hcp.example.com:9090/mapi/logs?cancel"
Request in Python using PycURL
import pycurl
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "POST")
curl.setopt(pycurl.HTTPHEADER, ["Authorization: HCP \
YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, "https://admin.hcp.example.com:9090/mapi/logs?cancel")
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.perform()
curl.close()
Request headers
POST /mapi/logs?cancel HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Response headers
HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 8.2.0.2
Content-Length: 0
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.
Example: Marking the download log
Here’s a sample POST request that marks the system logs with the message "Mark the log." The request is made using a system-level user account that includes the administrator role.
Request with cURL command line
curl -X POST -k -i
-H "Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"
"https://admin.hcp.example.com:9090/m...k=Mark+the+log"
Request in Python using PycURL
import pycurl
markMessage = "Mark+the+log"
curl = pycurl.Curl()
curl.setopt(pycurl.VERBOSE, True)
curl.setopt(pycurl.CUSTOMREQUEST, "POST")
curl.setopt(pycurl.HTTPHEADER, ["Authorization: HCP \
YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382"])
curl.setopt(pycurl.URL, ("https://admin.hcp.example.com:9090/mapi/logs/?" +
"mark="Mark+the+log"))
curl.setopt(pycurl.SSL_VERIFYPEER, False)
curl.setopt(pycurl.SSL_VERIFYHOST, False)
curl.perform()
curl.close()
Request headers
POST /mapi/logs?mark=Mark+the+log HTTP/1.1
Host: admin.hcp.example.com:9090
Authorization: HCP YWxscm9sZXM=:04EC9F614D89FF5C7126D32ACB448382
Response headers
HTTP/1.1 200 OK
X-HCP-SoftwareVersion: 8.2.0.2
Content-Length: 0
Trademarks and Legal Disclaimer
© 2015, 2019 Hitachi Vantara Corporation. All rights reserved.