From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web08.4638.1626937420443933563 for ; Thu, 22 Jul 2021 00:03:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=AD4c5Mx3; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=08370df290=abner.chang@hpe.com) Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16M73bC2025251; Thu, 22 Jul 2021 07:03:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=pps0720; bh=LzSdXZjyARQoUxn7UWS2w8u3QvjjTpVcjx+AEQBUziU=; b=AD4c5Mx398Fk229H3kP3WLngFmsbAprmjEjYdPho0/HEw7LTqEhZou38xaViDz/qlSmb AIqUxTA2uPx1dNRzJNnJfJEVJIfXWidsyUS+WSCC/7whjAsm1JjTphBNbk3drPDJ643A tRFbbE/SQDvf3tG5NTIblRDdO65tLor+wiPbVXz/zwysl+YF2WZeIFJNIsttBIkuj2wN 2jTLPyNMx9u4sAGpb0GweYS6mCnWcEW1InvBEyjLJAS+9pF07iaTfrh9s3i1OGWT8t8g /mzS3YMI9rY9+7vMnIKldG/aKkSwWDHzFSZ+7PanJXKn326C58mSqh0dnil+VwctNh0x gQ== Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 39y3rjg3h9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Jul 2021 07:03:37 +0000 Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id 2F0F057; Thu, 22 Jul 2021 07:03:29 +0000 (UTC) Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 4C5734D; Thu, 22 Jul 2021 07:03:28 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Nickle Wang , Liming Gao Subject: [staging/edk2-redfish-client Tools PATCH 5/6] RedfishClientPkg/Redfish-Profile-Simulator: Add ETAG on memory resource Date: Thu, 22 Jul 2021 14:08:16 +0800 Message-Id: <20210722060817.18564-6-abner.chang@hpe.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210722060817.18564-1-abner.chang@hpe.com> References: <20210722060817.18564-1-abner.chang@hpe.com> X-Proofpoint-ORIG-GUID: ywu1_Xm2bfMjGzDdxpWI291ZP1ScUeZq X-Proofpoint-GUID: ywu1_Xm2bfMjGzDdxpWI291ZP1ScUeZq X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-22_03:2021-07-22,2021-07-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 impostorscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=750 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107220043 Add ETAG support on Memory resource. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Liming Gao --- .../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