Merge "Multi tenancy support - all tenants"
This commit is contained in:
commit
706816e01f
@ -17,10 +17,11 @@ class Alarm(object):
|
|||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
def list(self, vitrage_id):
|
def list(self, vitrage_id, all_tenants):
|
||||||
"""Get a all alarms on entity
|
"""Get a all alarms on entity
|
||||||
|
|
||||||
:param vitrage_id: the id for the entity
|
:param vitrage_id: the id for the entity
|
||||||
"""
|
"""
|
||||||
params = dict(vitrage_id=vitrage_id)
|
params = dict(vitrage_id=vitrage_id,
|
||||||
|
all_tenants=all_tenants)
|
||||||
return self.api.get(self.url, params=params).json()
|
return self.api.get(self.url, params=params).json()
|
||||||
|
@ -26,11 +26,24 @@ class AlarmList(lister.Lister):
|
|||||||
metavar="<vitrage id>",
|
metavar="<vitrage id>",
|
||||||
help="Vitrage id of the affected resource")
|
help="Vitrage id of the affected resource")
|
||||||
|
|
||||||
|
parser.add_argument('--all-tenants',
|
||||||
|
metavar='<0|1>',
|
||||||
|
nargs='?',
|
||||||
|
type=int,
|
||||||
|
const=1,
|
||||||
|
default=0,
|
||||||
|
dest='all_tenants',
|
||||||
|
help='Shows alarms of all the tenants in the '
|
||||||
|
'entity graph')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
vitrage_id = parsed_args.vitrage_id
|
vitrage_id = parsed_args.vitrage_id
|
||||||
alarms = self.app.client.alarm.list(vitrage_id=vitrage_id)
|
all_tenants = parsed_args.all_tenants
|
||||||
|
|
||||||
|
alarms = self.app.client.alarm.list(vitrage_id=vitrage_id,
|
||||||
|
all_tenants=all_tenants)
|
||||||
return utils.list2cols(('type',
|
return utils.list2cols(('type',
|
||||||
'name',
|
'name',
|
||||||
'resource_type',
|
'resource_type',
|
||||||
|
@ -19,7 +19,18 @@ class RcaShow(show.ShowOne):
|
|||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(RcaShow, self).get_parser(prog_name)
|
parser = super(RcaShow, self).get_parser(prog_name)
|
||||||
parser.add_argument('alarm_id', help='ID of an alarm')
|
parser.add_argument('alarm_id',
|
||||||
|
help='ID of an alarm')
|
||||||
|
|
||||||
|
parser.add_argument('--all-tenants',
|
||||||
|
metavar='<0|1>',
|
||||||
|
nargs='?',
|
||||||
|
type=int,
|
||||||
|
const=1,
|
||||||
|
default=0,
|
||||||
|
dest='all_tenants',
|
||||||
|
help='Shows alarms of all the tenants for the RCA')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def formatter_default(self):
|
def formatter_default(self):
|
||||||
@ -27,5 +38,9 @@ class RcaShow(show.ShowOne):
|
|||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
alarm_id = parsed_args.alarm_id
|
alarm_id = parsed_args.alarm_id
|
||||||
alarm = self.app.client.rca.get(alarm_id=alarm_id)
|
all_tenants = parsed_args.all_tenants
|
||||||
|
|
||||||
|
alarm = self.app.client.rca.get(alarm_id=alarm_id,
|
||||||
|
all_tenants=all_tenants)
|
||||||
|
|
||||||
return self.dict2columns(alarm)
|
return self.dict2columns(alarm)
|
||||||
|
@ -24,17 +24,31 @@ class TopologyShow(show.ShowOne):
|
|||||||
metavar='<query>',
|
metavar='<query>',
|
||||||
help='query for the graph)')
|
help='query for the graph)')
|
||||||
|
|
||||||
parser.add_argument('--limit', type=int,
|
parser.add_argument('--limit',
|
||||||
|
type=int,
|
||||||
metavar='<depth>',
|
metavar='<depth>',
|
||||||
help='the depth of the topology graph')
|
help='the depth of the topology graph')
|
||||||
|
|
||||||
parser.add_argument('--root', help='the root of the topology graph')
|
parser.add_argument('--root',
|
||||||
|
help='the root of the topology graph')
|
||||||
|
|
||||||
parser.add_argument('--graph-type', choices=['tree', 'graph'],
|
parser.add_argument('--graph-type',
|
||||||
default='graph', dest='type',
|
choices=['tree', 'graph'],
|
||||||
|
default='graph',
|
||||||
|
dest='type',
|
||||||
help='graph type. '
|
help='graph type. '
|
||||||
'Valid graph types: [tree, graph]')
|
'Valid graph types: [tree, graph]')
|
||||||
|
|
||||||
|
parser.add_argument('--all-tenants',
|
||||||
|
metavar='<0|1>',
|
||||||
|
nargs='?',
|
||||||
|
type=int,
|
||||||
|
const=1,
|
||||||
|
default=0,
|
||||||
|
dest='all_tenants',
|
||||||
|
help='Shows entities of all the tenants in the '
|
||||||
|
'entity graph')
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def formatter_default(self):
|
def formatter_default(self):
|
||||||
@ -45,6 +59,7 @@ class TopologyShow(show.ShowOne):
|
|||||||
graph_type = parsed_args.type
|
graph_type = parsed_args.type
|
||||||
query = parsed_args.filter
|
query = parsed_args.filter
|
||||||
root = parsed_args.root
|
root = parsed_args.root
|
||||||
|
all_tenants = parsed_args.all_tenants
|
||||||
|
|
||||||
if graph_type == 'graph' and limit is not None and root is None:
|
if graph_type == 'graph' and limit is not None and root is None:
|
||||||
raise exc.CommandException(
|
raise exc.CommandException(
|
||||||
@ -53,5 +68,6 @@ class TopologyShow(show.ShowOne):
|
|||||||
topology = self.app.client.topology.get(limit=limit,
|
topology = self.app.client.topology.get(limit=limit,
|
||||||
graph_type=graph_type,
|
graph_type=graph_type,
|
||||||
query=query,
|
query=query,
|
||||||
root=root)
|
root=root,
|
||||||
|
all_tenants=all_tenants)
|
||||||
return self.dict2columns(topology)
|
return self.dict2columns(topology)
|
||||||
|
@ -17,10 +17,11 @@ class Rca(object):
|
|||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
def get(self, alarm_id):
|
def get(self, alarm_id, all_tenants):
|
||||||
"""Get RCA for an alarm
|
"""Get RCA for an alarm
|
||||||
|
|
||||||
:param alarm_id: the id of the alarm
|
:param alarm_id: the id of the alarm
|
||||||
"""
|
"""
|
||||||
url = self.url + alarm_id
|
params = dict(alarm_id=alarm_id,
|
||||||
return self.api.get(url).json()
|
all_tenants=all_tenants)
|
||||||
|
return self.api.get(self.url, params=params).json()
|
||||||
|
@ -17,15 +17,24 @@ class Topology(object):
|
|||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
self.api = api
|
self.api = api
|
||||||
|
|
||||||
def get(self, limit=None, graph_type='graph', query=None, root=None):
|
def get(self,
|
||||||
|
limit=None,
|
||||||
|
graph_type='graph',
|
||||||
|
query=None,
|
||||||
|
root=None,
|
||||||
|
all_tenants=0):
|
||||||
"""Get a topology
|
"""Get a topology
|
||||||
|
|
||||||
:param root: the root of the topology graph
|
:param root: the root of the topology graph
|
||||||
:param query: the query filter for the topology
|
:param query: the query filter for the topology
|
||||||
:param graph_type: graph can be tree or graph
|
:param graph_type: graph can be tree or graph
|
||||||
:param limit: the depth of the topology graph
|
:param limit: the depth of the topology graph
|
||||||
|
:param all_tenants: show entities in graph of all tenants
|
||||||
"""
|
"""
|
||||||
|
|
||||||
params = dict(depth=limit, graph_type=graph_type,
|
params = dict(depth=limit,
|
||||||
query=query, root=root)
|
graph_type=graph_type,
|
||||||
|
query=query,
|
||||||
|
root=root,
|
||||||
|
all_tenants=all_tenants)
|
||||||
return self.api.post(self.URL, json=params).json()
|
return self.api.post(self.URL, json=params).json()
|
||||||
|
Loading…
Reference in New Issue
Block a user