Update NFV to use FM rest API service: Add a NFVI open stack plugin for FM Update the NFV infrastructure and web server to use FM plugin Update sysinv plugin and remove get alarms and logs calls Story: 2002828 Task: 22747 Depends-On: https://review.openstack.org/#/c/591452/ Change-Id: I60ff74ccfb2ec2eaad427a23fe4d58d4fc49ab79 Signed-off-by: Tao Liu <tao.liu@windriver.com>changes/62/592562/2
parent
483a94531f
commit
935aa906ba
@ -0,0 +1,84 @@
|
||||
#
|
||||
# Copyright (c) 2018 Wind River Systems, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
from nfv_common import debug
|
||||
|
||||
from objects import OPENSTACK_SERVICE
|
||||
from rest_api import rest_api_request
|
||||
|
||||
DLOG = debug.debug_get_logger('nfv_plugins.nfvi_plugins.openstack.fm')
|
||||
|
||||
|
||||
def get_alarms(token):
|
||||
"""
|
||||
Asks Fault Management for customer alarms
|
||||
"""
|
||||
url = token.get_service_url(OPENSTACK_SERVICE.FM)
|
||||
if url is None:
|
||||
raise ValueError("OpenStack FM URL is invalid")
|
||||
|
||||
api_cmd = url + "/alarms?include_suppress=True"
|
||||
|
||||
response = rest_api_request(token, "GET", api_cmd)
|
||||
return response
|
||||
|
||||
|
||||
def get_logs(token, start=None, end=None):
|
||||
"""
|
||||
Asks Fault Management for customer logs
|
||||
"""
|
||||
url = token.get_service_url(OPENSTACK_SERVICE.FM)
|
||||
if url is None:
|
||||
raise ValueError("OpenStack SysInv URL is invalid")
|
||||
|
||||
api_cmd = url + "/event_log?logs=True"
|
||||
|
||||
if start is not None and end is not None:
|
||||
api_cmd += ("&q.field=start&q.field=end&q.op=eq&q.op=eq"
|
||||
"&q.value=%s&q.value=%s"
|
||||
% (str(start).replace(' ', 'T').replace(':', '%3A'),
|
||||
str(end).replace(' ', 'T').replace(':', '%3A')))
|
||||
|
||||
elif start is not None:
|
||||
api_cmd += ("&q.field=start;q.op=eq;q.value=%s"
|
||||
% str(start).replace(' ', 'T').replace(':', '%3A'))
|
||||
elif end is not None:
|
||||
api_cmd += ("&q.field=end;q.op=eq;q.value=%s"
|
||||
% str(end).replace(' ', 'T').replace(':', '%3A'))
|
||||
|
||||
api_cmd += '&limit=100'
|
||||
|
||||
response = rest_api_request(token, "GET", api_cmd)
|
||||
return response
|
||||
|
||||
|
||||
def get_alarm_history(token, start=None, end=None):
|
||||
"""
|
||||
Asks Fault Management for customer alarm history
|
||||
"""
|
||||
url = token.get_service_url(OPENSTACK_SERVICE.FM)
|
||||
if url is None:
|
||||
raise ValueError("OpenStack SysInv URL is invalid")
|
||||
|
||||
api_cmd = url + "/event_log?alarms=True"
|
||||
|
||||
if start is not None and end is not None:
|
||||
api_cmd += ("&q.field=start&q.field=end&q.op=eq&q.op=eq"
|
||||
"&q.value=%s&q.value=%s"
|
||||
% (str(start).replace(' ', 'T').replace(':', '%3A'),
|
||||
str(end).replace(' ', 'T').replace(':', '%3A')))
|
||||
|
||||
elif start is not None:
|
||||
api_cmd += ("&q.field=start;q.op=eq;q.value='%s'"
|
||||
% str(start).replace(' ', 'T').replace(':', '%3A'))
|
||||
elif end is not None:
|
||||
api_cmd += ("&q.field=end;q.op=eq;q.value='%s'"
|
||||
% str(end).replace(' ', 'T').replace(':', '%3A'))
|
||||
|
||||
api_cmd += '&limit=100'
|
||||
|
||||
response = rest_api_request(token, "GET", api_cmd)
|
||||
return response
|
Loading…
Reference in new issue