From 7b80a6162b616d1cd33d3af4367abfb8d56622d8 Mon Sep 17 00:00:00 2001 From: "Zhang Rong(Jon)" Date: Tue, 25 Jan 2022 13:59:00 +0800 Subject: [PATCH] Fix: the resource's parameter 'parentId' is resourcepool ID 1. The resource's parameter 'parentId' should be resource ID, now it uses resourcepool ID, fix it to resource ID, and the root resource set to None. 2. Make the query with parentId=null can search the root resources. Signed-off-by: Zhang Rong(Jon) Change-Id: I3eb2f9569d6655755cce25b4464b66c66e5faf51 --- o2ims/service/auditor/pserver_handler.py | 2 +- o2ims/views/ocloud_route.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/o2ims/service/auditor/pserver_handler.py b/o2ims/service/auditor/pserver_handler.py index f5df381..d18d3c3 100644 --- a/o2ims/service/auditor/pserver_handler.py +++ b/o2ims/service/auditor/pserver_handler.py @@ -97,7 +97,7 @@ def create_by(stxobj: StxGenericModel, parentid: str, resourcetype_id: str) \ # content = json.loads(stxobj.content) resourcetype_id = resourcetype_id resourcepool_id = parentid - parent_id = parentid + parent_id = None # the root of the resource has no parent id gAssetId = '' # TODO: global ID description = "A physical server resource" resource = Resource(stxobj.id, resourcetype_id, resourcepool_id, diff --git a/o2ims/views/ocloud_route.py b/o2ims/views/ocloud_route.py index 00fe520..d6913a9 100644 --- a/o2ims/views/ocloud_route.py +++ b/o2ims/views/ocloud_route.py @@ -128,6 +128,9 @@ class ResourcesListRouter(Resource): kwargs['resourceTypeName'] = args.resourceTypeName if args.parentId is not None: kwargs['parentId'] = args.parentId + if args.parentId.lower() == 'null': + kwargs['parentId'] = None + return ocloud_view.resources(resourcePoolID, bus.uow, **kwargs) -- 2.16.6