Fix: the resource's parameter 'parentId' is resourcepool ID 11/7611/1
authorZhang Rong(Jon) <rong.zhang@windriver.com>
Tue, 25 Jan 2022 05:59:00 +0000 (13:59 +0800)
committerZhang Rong(Jon) <rong.zhang@windriver.com>
Tue, 25 Jan 2022 05:59:33 +0000 (13:59 +0800)
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) <rong.zhang@windriver.com>
Change-Id: I3eb2f9569d6655755cce25b4464b66c66e5faf51

o2ims/service/auditor/pserver_handler.py
o2ims/views/ocloud_route.py

index f5df381..d18d3c3 100644 (file)
@@ -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,
index 00fe520..d6913a9 100644 (file)
@@ -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)