Merge "Multi tenancy support - all tenants"

This commit is contained in:
Jenkins 2016-10-05 13:08:05 +00:00 committed by Gerrit Code Review
commit 706816e01f
6 changed files with 71 additions and 16 deletions

View File

@ -17,10 +17,11 @@ class Alarm(object):
def __init__(self, api):
self.api = api
def list(self, vitrage_id):
def list(self, vitrage_id, all_tenants):
"""Get a all alarms on 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()

View File

@ -26,11 +26,24 @@ class AlarmList(lister.Lister):
metavar="<vitrage id>",
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
def take_action(self, parsed_args):
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',
'name',
'resource_type',

View File

@ -19,7 +19,18 @@ class RcaShow(show.ShowOne):
def get_parser(self, 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
def formatter_default(self):
@ -27,5 +38,9 @@ class RcaShow(show.ShowOne):
def take_action(self, parsed_args):
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)

View File

@ -24,17 +24,31 @@ class TopologyShow(show.ShowOne):
metavar='<query>',
help='query for the graph)')
parser.add_argument('--limit', type=int,
parser.add_argument('--limit',
type=int,
metavar='<depth>',
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'],
default='graph', dest='type',
parser.add_argument('--graph-type',
choices=['tree', 'graph'],
default='graph',
dest='type',
help='graph type. '
'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
def formatter_default(self):
@ -45,6 +59,7 @@ class TopologyShow(show.ShowOne):
graph_type = parsed_args.type
query = parsed_args.filter
root = parsed_args.root
all_tenants = parsed_args.all_tenants
if graph_type == 'graph' and limit is not None and root is None:
raise exc.CommandException(
@ -53,5 +68,6 @@ class TopologyShow(show.ShowOne):
topology = self.app.client.topology.get(limit=limit,
graph_type=graph_type,
query=query,
root=root)
root=root,
all_tenants=all_tenants)
return self.dict2columns(topology)

View File

@ -17,10 +17,11 @@ class Rca(object):
def __init__(self, api):
self.api = api
def get(self, alarm_id):
def get(self, alarm_id, all_tenants):
"""Get RCA for an alarm
:param alarm_id: the id of the alarm
"""
url = self.url + alarm_id
return self.api.get(url).json()
params = dict(alarm_id=alarm_id,
all_tenants=all_tenants)
return self.api.get(self.url, params=params).json()

View File

@ -17,15 +17,24 @@ class Topology(object):
def __init__(self, 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
:param root: the root of the topology graph
:param query: the query filter for the topology
:param graph_type: graph can be tree or 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,
query=query, root=root)
params = dict(depth=limit,
graph_type=graph_type,
query=query,
root=root,
all_tenants=all_tenants)
return self.api.post(self.URL, json=params).json()