본문 바로가기
HW Knowledge/Hewlett-Packard Enterprise

OneView/How remove Alert Logs from Oneview via RESTful API

by 스쳐가는인연 2019. 4. 27.

HPE Oneview 환경에서, Alert 관련 로그를 일부 또는 전체 삭제하고자 할 때,

 

삭제 전 Oneview Data backup (언제나 백업은 소중함~)
Oneview > Setting > Backup > Create Backup > Download Backup(생성된 후)

 

Firefox - RESTClient (POSTMAN등을 이용할 수도 있음)
- Firefox Brower에서, 확장기능으로, RESTClient 설치 및 실행

- 헤더 추가 (Headers > Custom header > check favorite header and add)
---------------------------------
Name: Content-Type / Value: application/json
---------------------------------
Name: X-API-Version / Value: 1000
---------------------------------

 

cf. OneView version에 따른 X-API-Version
---------------------------------------------------------
1.20             120
2.00             200
2.00.06          201
3.00              300
3.10              500
4.00              600
4.10              800
4.20              1000
---------------------------------------------------------

 

- Session Mgmt
------------------------------------------------
POST https://{appl}/rest/login-sessions

 

Body:
{"userName":"Administrator","password":"password"}
------------------------------------------------

curl -k -X POST https://{appl}/rest/login-sessions -H "Content-type: application/json" -d "{\"userName\":\"Administrator\",\"password\":\"password\"}"
------------------------------------------------

 

결과로, session ID 취득 후,

Response
{"sessionID":"LTQ3OTk3MzY1Njk22WQSyc9HZZbvwECWjPWmeM6_GVbaSzGU"}

 

- 헤더 추가 (Headers > Custom header
------------------------------------------------
Name: Auth / Value: LTQ3OTk3MzY1Njk22WQSyc9HZZbvwECWjPWmeM6_GVbaSzGU
------------------------------------------------

 

- Alert 항목 일괄 조회
GET https://{appl}/rest/alerts/
"start": 0,
"count": 25,
"total": 418,

 

- 특정 일자 이전 생성된 내용 조회 및 삭제
GET https://{appl}/rest/alerts/?query="created <= '2019-02-28'"
"start": 0,
"count": 19,
"total": 19,

 

DELETE https://{appl}/rest/alerts/?query="created <= '2019-02-28'"

 

GET https://{appl}/rest/alerts/?query="created <= '2019-02-28'"
"start": 0,
"count": 1,
"total": 1,

 

NOTE: Locked 상태를 제외하고 삭제됨

GET https://{appl}/rest/alerts/
"start": 0,
"count": 25,
"total": 400,

 

DELETE https://{appl}/rest/alerts/?query="created <= '2019-02-28'"&force=true

 

NOTE: Locked 상태를 포함하여 삭제됨

 

- 전체 로그 삭제

DELETE https://{appl}/rest/alerts?force=true

 

- 특정 로그 삭제

e.g.) Alert 652 항목 존재 여부 확인
GET https://{appl}/rest/alerts/652
------------------------------------------------
curl -k -H "Auth:LTQ3OTk3MzY1Njk22WQSyc9HZZbvwECWjPWmeM6_GVbaSzGU" https://{appl}/rest/alerts/652
------------------------------------------------


DELETE https://{appl}/rest/alerts/652?force=true

 

- 특정 상태 로그 삭제 (예시, Active 상태인 로그 삭제)
GET https://{appl}/rest/alerts?start=0&count=-1&filter="alertState EQ 'Active'"
DELETE https://{appl}/rest/alerts?filter="alertState EQ 'Active'"

 

DELETE 작업 후 결과는 별도로 확인되지 않기에, GET을 통해 추가 확인하면, 삭제 여부 확인에 도움이 됨

반응형