Make sure depth is an int in get topology

Change-Id: If0e2bc147a51137fbe1988f84b921ce2182bb75b
This commit is contained in:
Eyal 2020-05-08 10:02:39 +03:00
parent 1dc094a593
commit 2856f88fcf
2 changed files with 6 additions and 0 deletions

View File

@ -25,6 +25,7 @@ from pecan.core import abort
from vitrage.api.controllers.rest import RootRestController from vitrage.api.controllers.rest import RootRestController
from vitrage.api.policy import enforce from vitrage.api.policy import enforce
from vitrage.common.constants import VertexProperties as VProps from vitrage.common.constants import VertexProperties as VProps
from vitrage.common.utils import to_int
# noinspection PyProtectedMember # noinspection PyProtectedMember
from vitrage.common.utils import decompress_obj from vitrage.common.utils import decompress_obj
@ -44,6 +45,7 @@ class TopologyController(RootRestController):
def post(self, depth=None, graph_type='graph', query=None, root=None, def post(self, depth=None, graph_type='graph', query=None, root=None,
all_tenants=False): all_tenants=False):
all_tenants = bool_from_string(all_tenants) all_tenants = bool_from_string(all_tenants)
depth = to_int(depth)
if all_tenants: if all_tenants:
enforce('get topology:all_tenants', pecan.request.headers, enforce('get topology:all_tenants', pecan.request.headers,
pecan.request.enforcer, {}) pecan.request.enforcer, {})

View File

@ -155,3 +155,7 @@ def decompress_obj(blob):
del decoded_blob del decoded_blob
del str_data del str_data
return obj return obj
def to_int(i):
return int(i) if i is not None else i