Update resource detail of ethernet port 80/9680/1
authorBin Yang <bin.yang@windriver.com>
Thu, 17 Nov 2022 08:09:21 +0000 (16:09 +0800)
committerBin Yang <bin.yang@windriver.com>
Thu, 17 Nov 2022 08:26:34 +0000 (16:26 +0800)
Issue-ID: INF-358

Signed-off-by: Bin Yang <bin.yang@windriver.com>
Change-Id: I24a5a2f49ad0a2df98ce9473cce25d631c2fedb6

o2ims/service/auditor/pserver_eth_handler.py

index 65e48a4..e373dbe 100644 (file)
@@ -15,7 +15,7 @@
 # pylint: disable=unused-argument
 from __future__ import annotations
 import uuid
-import json
+import json
 
 from o2ims.domain import commands, events
 from o2ims.domain.stx_object import StxGenericModel
@@ -99,11 +99,23 @@ def create_by(stxobj: StxGenericModel, parent: Resource, resourcetype_id: str)\
     resourcepool_id = parent.resourcePoolId
     parent_id = parent.resourceId
     gAssetId = ''  # TODO: global ID
-    description = "%s : An ethernet resource of the physical server"\
-        % stxobj.name
+    # description = "%s : An ethernet resource of the physical server"\
+    #     % stxobj.name
+    content = json.loads(stxobj.content)
+    selected_keys = [
+        "name", "namedisplay", "dev_id", "pdevice", "capabilities",
+        "type", "driver", "mac", "numa_node",
+        "pciaddr", "pclass", "psvendor", "psdevice",
+        "sriov_totalvfs", "sriov_numvfs", "dpdksupport",
+        "sriov_vf_driver", "sriov_vf_pdevice_id", "interface_uuid"
+        ]
+    filtered = dict(
+        filter(lambda item: item[0] in selected_keys, content.items()))
+    extensions = json.dumps(filtered)
+    description = ";".join([f"{k}:{v}" for k, v in filtered.items()])
     resource = Resource(stxobj.id, resourcetype_id, resourcepool_id,
                         stxobj.name, parent_id, gAssetId, stxobj.content,
-                        description)
+                        description, extensions)
     resource.createtime = stxobj.createtime
     resource.updatetime = stxobj.updatetime
     resource.hash = stxobj.hash