<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;">Reviewed-by:
 Nickle Wang <nickle.wang@hpe.com></span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;">Thanks,</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="color: rgb(0, 0, 0); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 14.6667px; background-color: rgb(255, 255, 255); display: inline !important;">Nickle</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Chang, Abner (HPS SW/FW Technologist) <abner.chang@hpe.com><br>
<b>Sent:</b> Thursday, July 22, 2021 14:08<br>
<b>To:</b> devel@edk2.groups.io <devel@edk2.groups.io><br>
<b>Cc:</b> Wang, Nickle (HPS SW) <nickle.wang@hpe.com>; Liming Gao <gaoliming@byosoft.com.cn><br>
<b>Subject:</b> [staging/edk2-redfish-client Tools PATCH 5/6] RedfishClientPkg/Redfish-Profile-Simulator: Add ETAG on memory resource</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Add ETAG support on Memory resource.<br>
<br>
Signed-off-by: Abner Chang <abner.chang@hpe.com><br>
Cc: Nickle Wang <nickle.wang@hpe.com><br>
Cc: Liming Gao <gaoliming@byosoft.com.cn><br>
---<br>
 .../Redfish-Profile-Simulator/v1sim/systems.py      | 13 +++++++++++++<br>
 1 file changed, 13 insertions(+)<br>
<br>
diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py<br>
index 690101fb10..de4b839aeb 100644<br>
--- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py<br>
+++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py<br>
@@ -18,6 +18,7 @@ from .resource import RfResource, RfCollection<br>
 from .storage import RfSimpleStorageCollection, RfSmartStorage<br>
 import flask<br>
 import json<br>
+import hashlib<br>
 from collections import OrderedDict<br>
 <br>
 class RfSystemsCollection(RfCollection):<br>
@@ -142,13 +143,25 @@ class RfMemoryCollection(RfCollection):<br>
         self.res_data["Members"].append({"@odata.id":newMemoryUrl})<br>
 <br>
         post_data["@odata.id"] = newMemoryUrl<br>
+<br>
+        md5 = hashlib.md5()<br>
+        md5.update(json.dumps(post_data).encode("utf-8"))<br>
+        etag_str = 'W/"' + md5.hexdigest() + '"'<br>
+        post_data["@odata.etag"] = etag_str<br>
         self.elements[str(newMemoryIdx)] = post_data<br>
 <br>
         resp = flask.Response(json.dumps(post_data,indent=4))<br>
         resp.headers["Location"] = newMemoryUrl<br>
+        resp.headers["ETag"] = etag_str<br>
+<br>
         return 0, 200, None, resp<br>
 <br>
     def patch_memory(self, Idx, patch_data):<br>
+        md5 = hashlib.md5()<br>
+        md5.update(json.dumps(patch_data).encode("utf-8"))<br>
+        etag_str = 'W/"' + md5.hexdigest() + '"'<br>
+        patch_data["@odata.etag"] = etag_str<br>
+<br>
         self.elements[str(Idx)] = {**self.elements[str(Idx)], **patch_data}<br>
         resp = flask.Response(json.dumps(self.elements[str(Idx)],indent=4))<br>
         return 0, 200, None, resp<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</body>
</html>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/78095">View/Reply Online (#78095)</a> |    |  <a target="_blank" href="https://groups.io/mt/84374368/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>