add rca api
Change-Id: I58c29e3fd99b5e9f5d686c3cbb57c19302dc0947
This commit is contained in:
parent
f227ca890d
commit
d5f4cf07fe
@ -30,6 +30,7 @@ import client
|
||||
import noauth
|
||||
|
||||
from v1.cli import alarms
|
||||
from v1.cli import rca
|
||||
from v1.cli import resource
|
||||
from v1.cli import topology
|
||||
from vitrageclient import __version__
|
||||
@ -41,6 +42,7 @@ class VitrageCommandManager(commandmanager.CommandManager):
|
||||
"resource show": resource.ResourceShow,
|
||||
"resource list": resource.ResourceList,
|
||||
"alarms list": alarms.AlarmsList,
|
||||
"rca show": rca.RcaShow,
|
||||
}
|
||||
|
||||
def load_commands(self, namespace):
|
||||
|
28
vitrageclient/v1/cli/rca.py
Normal file
28
vitrageclient/v1/cli/rca.py
Normal file
@ -0,0 +1,28 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from cliff import show
|
||||
|
||||
|
||||
# noinspection PyAbstractClass
|
||||
class RcaShow(show.ShowOne):
|
||||
"""Show an RCA"""
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RcaShow, self).get_parser(prog_name)
|
||||
parser.add_argument("alarm_id", help="ID of an alarm")
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
alarm_id = parsed_args.alarm_id
|
||||
alarm = self.app.client.rca.get(alarm_id=alarm_id)
|
||||
return self.dict2columns(alarm)
|
@ -9,9 +9,11 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from vitrageclient import client
|
||||
|
||||
from vitrageclient.v1 import alarms
|
||||
from vitrageclient.v1 import rca
|
||||
from vitrageclient.v1 import resource
|
||||
from vitrageclient.v1 import topology
|
||||
|
||||
@ -24,3 +26,4 @@ class Client(object):
|
||||
self.topology = topology.Topology(self._api)
|
||||
self.resource = resource.Resource(self._api)
|
||||
self.alarms = alarms.Alarm(self._api)
|
||||
self.rca = rca.Rca(self._api)
|
||||
|
26
vitrageclient/v1/rca.py
Normal file
26
vitrageclient/v1/rca.py
Normal file
@ -0,0 +1,26 @@
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class Rca(object):
|
||||
url = "v1/rca/"
|
||||
|
||||
def __init__(self, api):
|
||||
self.api = api
|
||||
|
||||
def get(self, alarm_id):
|
||||
"""Get RCA for an alarm
|
||||
|
||||
:param alarm_id: the id of the alarm
|
||||
"""
|
||||
url = self.url + alarm_id
|
||||
return self.api.get(url).json()
|
Loading…
x
Reference in New Issue
Block a user