[edk2-devel] [staging/edk2-redfish-client Tools PATCH 5/6] RedfishClientPkg/Redfish-Profile-Simulator: Add ETAG on memory resource

Nickle Wang nickle.wang at hpe.com
Thu Jul 22 14:58:58 UTC 2021


Reviewed-by: Nickle Wang <nickle.wang at hpe.com>

Thanks,
Nickle
________________________________
From: Chang, Abner (HPS SW/FW Technologist) <abner.chang at hpe.com>
Sent: Thursday, July 22, 2021 14:08
To: devel at edk2.groups.io <devel at edk2.groups.io>
Cc: Wang, Nickle (HPS SW) <nickle.wang at hpe.com>; Liming Gao <gaoliming at byosoft.com.cn>
Subject: [staging/edk2-redfish-client Tools PATCH 5/6] RedfishClientPkg/Redfish-Profile-Simulator: Add ETAG on memory resource

Add ETAG support on Memory resource.

Signed-off-by: Abner Chang <abner.chang at hpe.com>
Cc: Nickle Wang <nickle.wang at hpe.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
---
 .../Redfish-Profile-Simulator/v1sim/systems.py      | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py
index 690101fb10..de4b839aeb 100644
--- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py
+++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py
@@ -18,6 +18,7 @@ from .resource import RfResource, RfCollection
 from .storage import RfSimpleStorageCollection, RfSmartStorage
 import flask
 import json
+import hashlib
 from collections import OrderedDict

 class RfSystemsCollection(RfCollection):
@@ -142,13 +143,25 @@ class RfMemoryCollection(RfCollection):
         self.res_data["Members"].append({"@odata.id":newMemoryUrl})

         post_data["@odata.id"] = newMemoryUrl
+
+        md5 = hashlib.md5()
+        md5.update(json.dumps(post_data).encode("utf-8"))
+        etag_str = 'W/"' + md5.hexdigest() + '"'
+        post_data["@odata.etag"] = etag_str
         self.elements[str(newMemoryIdx)] = post_data

         resp = flask.Response(json.dumps(post_data,indent=4))
         resp.headers["Location"] = newMemoryUrl
+        resp.headers["ETag"] = etag_str
+
         return 0, 200, None, resp

     def patch_memory(self, Idx, patch_data):
+        md5 = hashlib.md5()
+        md5.update(json.dumps(patch_data).encode("utf-8"))
+        etag_str = 'W/"' + md5.hexdigest() + '"'
+        patch_data["@odata.etag"] = etag_str
+
         self.elements[str(Idx)] = {**self.elements[str(Idx)], **patch_data}
         resp = flask.Response(json.dumps(self.elements[str(Idx)],indent=4))
         return 0, 200, None, resp
--
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78095): https://edk2.groups.io/g/devel/message/78095
Mute This Topic: https://groups.io/mt/84374368/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/edk2-devel-archive/attachments/20210722/af1493cb/attachment.htm>


More information about the edk2-devel-archive mailing list