From nobody Mon Feb 9 14:03:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+78065+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78065+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1626937416; cv=none; d=zohomail.com; s=zohoarc; b=LSZAhljdwFABiXK/x5pZvw8BNZubr9UoqWoDm+vRZC2kc9CCoXIS1gkP44AHAI3eIoKCP2TjmXWKdtU0w3qdu/RlBDlOFdVbnN9WzozdQe9RXHZZZi+K65VeizgiR/ycVQhkr+CtHfEwgY0/4kg9DE3G1USjKJ4RsdPKq7eF4IM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626937416; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=udEZvYlGH15BdNIQlOua5ArViJYULYLLiJSujm0sTmY=; b=m8IkLWOQK9PXc/0Q9uCWqJ370fn9HntNwriMxhtSpKc4sDFExxEQVb/a/Z3IezD6vjMHO9NYvRGAxmyGxLxhgjI+Xn84BmxdwraXjoBOcSRKgTvubup59EfwbUo6+A2ZITHKEvYJgZWpty6Y5WoMzQyHog0AkIdP/InNQ7pzH3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+78065+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1626937416515198.50605187946258; Thu, 22 Jul 2021 00:03:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id n1J1YY1788612x54duXduiNt; Thu, 22 Jul 2021 00:03:36 -0700 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.4649.1626937414190099448 for ; Thu, 22 Jul 2021 00:03:34 -0700 X-Received: from pps.filterd (m0148664.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16M6vie8006483; Thu, 22 Jul 2021 07:03:28 GMT X-Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 39xysjsmpd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 22 Jul 2021 07:03:28 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3427.houston.hpe.com (Postfix) with ESMTP id F09DF6F; Thu, 22 Jul 2021 07:03:27 +0000 (UTC) X-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 0D5A467; Thu, 22 Jul 2021 07:03:26 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Nickle Wang , Liming Gao Subject: [edk2-devel] [staging/edk2-redfish-client Tools PATCH 4/6] RedfishClientPkg/Redfish-Profile-Simulator: HTTP methods on Memory Collection Date: Thu, 22 Jul 2021 14:08:15 +0800 Message-Id: <20210722060817.18564-5-abner.chang@hpe.com> In-Reply-To: <20210722060817.18564-1-abner.chang@hpe.com> References: <20210722060817.18564-1-abner.chang@hpe.com> X-Proofpoint-GUID: srBuJ5vRFI38XZB1ViBGcUQ_dnW1_RWH X-Proofpoint-ORIG-GUID: srBuJ5vRFI38XZB1ViBGcUQ_dnW1_RWH X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: AftZKJocmXfdARn2yj8v6pTAx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1626937416; bh=83sFnqxXDsi2fQv9Ml1Sh6ehWiBb9CRVfAksrUXZ+C4=; h=Cc:Date:From:Reply-To:Subject:To; b=DEQErr4kOkiSbDhjovNWkySvAlKIsrl0xP+Jbx6XBt8GThAOnGu/8TDSg9hAm4dQBeD L0QaFQdvoMSgBC5f4l0UqKseH6XEgM9SZ4eBmJN8ma7lALONbCcn8EzVYXLWFqvxR03V2 avn0BZnJZylT93WSiwvqfGYpScxSVUe8WEg= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1626937418321100012 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add POST and PATCH methods on Memory collection and resource. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Liming Gao Reviewed-by: Nickle Wang --- .../v1sim/redfishURIs.py | 25 +++++++++++ .../v1sim/systems.py | 43 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/redfish= URIs.py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/redfishURI= s.py index 3c912f7ce1..35d3794cc6 100644 --- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/redfishURIs.py +++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/redfishURIs.py @@ -1,6 +1,7 @@ # # Copyright Notice: # Copyright (c) 2019, Intel Corporation. All rights reserved.
+# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # # Copyright Notice: @@ -308,6 +309,30 @@ def rfApi_SimpleServer(root, versions, host=3D"127.0.0= .1", port=3D5000, cert=3D"", key else: return err_string, status_code =20 + @app.route("/redfish/v1/Systems//Memory", methods=3D= ['POST']) + @auth.rfAuthRequired + def rf_computer_memory_post(system_id): + print ("in POST memory collection") + rdata =3D json.loads(request.data,object_pairs_hook=3DOrderedDict) + print("rdata:{}".format(rdata)) + rc, status_code, err_string, resp =3D root.components['Systems'].g= et_element(system_id).components['Memory'].post_resource(rdata) + if rc =3D=3D 0: + return resp, status_code + else: + return err_string, status_code + + @app.route("/redfish/v1/Systems//Memory/", methods=3D['PATCH']) + @auth.rfAuthRequired + def rf_computer_memory_patch(system_id, MemoryIdx): + print ("in PATCH memory[%s] resource" % MemoryIdx) + rdata =3D json.loads(request.data,object_pairs_hook=3DOrderedDict) + print("rdata:{}".format(rdata)) + rc, status_code, err_string, resp =3D root.components['Systems'].g= et_element(system_id).components['Memory'].patch_memory(MemoryIdx, rdata) + if rc =3D=3D 0: + return resp, status_code + else: + return err_string, status_code + def resolve_path(service, path): parts =3D path.split('/') result =3D service diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems= .py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py index b8b3788054..690101fb10 100644 --- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py +++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py @@ -2,6 +2,7 @@ # Copyright Notice: # # Copyright (c) 2019, Intel Corporation. All rights reserved.
+# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # # Copyright Notice: @@ -123,9 +124,50 @@ class RfSystemObj(RfResource): =20 # subclass Logs Collection class RfMemoryCollection(RfCollection): + def final_init_processing(self, base_path, rel_path): + self.maxIdx =3D self.res_data["Members@odata.count"] + def element_type(self): return RfMemory =20 + def post_resource(self, post_data): + print("Members@odata.count:{}".format(self.res_data["Members@odata= .count"])) + print("Members:{}".format(self.res_data["Members"])) + print("post_data:{}".format(post_data)) + + self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] + 1 + self.maxIdx =3D self.maxIdx + 1 + newMemoryIdx =3D self.maxIdx + newMemoryUrl =3D self.res_data["@odata.id"] + "/" + str(newMemoryI= dx) + self.res_data["Members"].append({"@odata.id":newMemoryUrl}) + + post_data["@odata.id"] =3D newMemoryUrl + self.elements[str(newMemoryIdx)] =3D post_data + + resp =3D flask.Response(json.dumps(post_data,indent=3D4)) + resp.headers["Location"] =3D newMemoryUrl + return 0, 200, None, resp + + def patch_memory(self, Idx, patch_data): + self.elements[str(Idx)] =3D {**self.elements[str(Idx)], **patch_da= ta} + resp =3D flask.Response(json.dumps(self.elements[str(Idx)],indent= =3D4)) + return 0, 200, None, resp + + def get_memory(self, Idx): + return json.dumps(self.elements[Idx],indent=3D4) + + def delete_memory(self, Idx): + print("in delete_memory") + + resp =3D flask.Response(json.dumps(self.elements[Idx],indent=3D4)) + + self.elements.pop(Idx) + self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] - 1 + + newMemoryUrl =3D self.res_data["@odata.id"] + "/" + str(Idx) + self.res_data["Members"].remove({"@odata.id":newMemoryUrl}) + return 0, 200, None, resp + =20 class RfMemory(RfResource): pass @@ -267,3 +309,4 @@ class RfBootOptionCollection(RfCollection): return 0, 200, None, resp =20 class RfBootOption(RfResource): + pass --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#78065): https://edk2.groups.io/g/devel/message/78065 Mute This Topic: https://groups.io/mt/84374363/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-