e547b8c136
Adding support to the VIM for containerized keystone. The VIM will now support two keystone instances: - platform: bare metal keystone used to authenticate with platform services (e.g. sysinv, patching) - openstack: containerized keystone used to authenticate with openstack services (e.g. nova, neutron, cinder) For now, the VIM will use the same baremetal keystone for both the platform and openstack, because we still only deploy with the baremetal keystone. Story: 2002876 Task: 26872 Depends-On: If4bd46a4c14cc65978774001cb2887e5d3e3607b Change-Id: Id1ec639aa347e0c4e4019576d3c36c8c72aefedf
85 lines
2.6 KiB
Python
Executable File
85 lines
2.6 KiB
Python
Executable File
#
|
|
# Copyright (c) 2018 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
from nfv_common import debug
|
|
|
|
from nfv_plugins.nfvi_plugins.openstack.objects import PLATFORM_SERVICE
|
|
from nfv_plugins.nfvi_plugins.openstack.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(PLATFORM_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(PLATFORM_SERVICE.FM)
|
|
if url is None:
|
|
raise ValueError("OpenStack FM 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(PLATFORM_SERVICE.FM)
|
|
if url is None:
|
|
raise ValueError("OpenStack FM 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
|