From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.73]) by mx.groups.io with SMTP id smtpd.web11.122820.1683013866013083378 for ; Tue, 02 May 2023 00:51:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=OSMO7kW9; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: nvidia.com, ip: 40.107.94.73, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vue22Eg7KeCAyj0e1fmAlnxFErvs8ENb2WozT+VapN3YwJc79zlS+TkU/YFkQUF7HjEDaS3YKsltWN2ZdwoYx6nQqM9NtzbE4RiQA0v0+EtBp7olE/g3Tl87YAJGL7Av8wwCwiD9hfuy+qsgRxG4TRxAMflN8q1EX7KJyUJFidoAYcYul2r7cDVAiQwFKOfZ8BN2tvMprxaQrlMFmVYT6tXjfWTHIodexL0Os9v8sUKnx+GpmvbVTt4hDin0bkVlffEhPe1+5Wwq466+tcK60ap1v1oxPLPq6NMi8KyRV1r9TRu4FSrZ5cEMUgM0QEOVPbsD05FCfz5M+J5EsI95vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=4JMdylxKMduIKarGLHK48dyYwJaZNVS5QR7PnKsagic=; b=M89TA8SKF3jViWulmC1rPDYanclOVBq6yM6jICyktcAaPqMRFulH24HUkFMPxefZzwwHsESIcogOw5R5T4CZel5FyYvYpPjyxH4FJ7bB+tYF0zOJ1o35gFA1ijKoYowWKGP5OCqHZq0mfN2jiD7QHyzOWcavDUtRACR5/OwIdE41LssQGR26iRW9rPCJnMogKVrI2wGBqwWyF5nzjum3cutSYgGVjVrzO5Fxz2SjpzbPzTgtoy9sMMu7LD0/kwntehTQzBXZ9YYADYqKrpmu61lpMHlqBmYUM4Tu7He7mcE3ZEh9T0ASVhFMgJas0WtrnKMmzGr1VAAvIW8/ElQPAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4JMdylxKMduIKarGLHK48dyYwJaZNVS5QR7PnKsagic=; b=OSMO7kW9py7SooumXon8HYs1KG+S5zFx1GRU3aAyrmMXdcl2+bv+s8jgauWfsR2m1LeV3P5ITmqN+OYJExPf2L2I5l26dANXf+cdIYs/4CkkEOu2NtGKQl0sUulqSWmfzPJOTlHBk3eJEjoYAO0Wamr+s826ktecCAZ6fD7v8iTx6mA36hDliLqwUJ3EvoR28mNLuXMzhwFrPl1l3OHQHE57ppnqQXYfMX7KW5o93SYcX4ZbjBBCkAtYVFP8npf09ZbLVAD385YfOySQ157DKx6dSWKKdznbzYrIwdH6Uj1ZgyA51rqjD5KPPu9N1YUMwVF0G3PIkn2SCYLuKf4Tfg== Received: from DS7PR03CA0026.namprd03.prod.outlook.com (2603:10b6:5:3b8::31) by MN2PR12MB4221.namprd12.prod.outlook.com (2603:10b6:208:1d2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.31; Tue, 2 May 2023 07:51:03 +0000 Received: from DS1PEPF0000E647.namprd02.prod.outlook.com (2603:10b6:5:3b8:cafe::9a) by DS7PR03CA0026.outlook.office365.com (2603:10b6:5:3b8::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.30 via Frontend Transport; Tue, 2 May 2023 07:51:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DS1PEPF0000E647.mail.protection.outlook.com (10.167.18.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.16 via Frontend Transport; Tue, 2 May 2023 07:51:03 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 2 May 2023 00:50:57 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 2 May 2023 00:50:57 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 2 May 2023 00:50:56 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy Subject: [edk2-redfish-client][PATCH 2/4] Redfish-Profile-Simulator: HTTP methods on Memory Collection Date: Tue, 2 May 2023 15:50:56 +0800 Message-ID: <20230502075056.16613-1-nicklew@nvidia.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Return-Path: nicklew@nvidia.com X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E647:EE_|MN2PR12MB4221:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c9ea687-ee89-4586-bd2c-08db4ae1fa7d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XkyQmfSrJsU3CXItGmNgK+T8qguK6TZT7HidWXBEDm+FPRcQWoW99lINY/vTDHdbsyNI56zP9+PSN+NrErNKLBDSMw3YWmvwhWVAfitZcFDcd01YggRyWWXEwQIAvKRCufyp0vki3EfgYzemPqNmsqkq0OXjwK8CcsFYKFKHLKCxH2yaGH6IhaIolJuYthFhM6+yzcsE162O9EhkqsoW5PvlahTS4PgDeMdP+CA+jDuhBX46q9nafXv/L63S9r/PiHNV4nhtcV9fAW26NdY/C1qbv9fuZEyNylJNaAJnt2EUj9dvEF7IhMfc0Ww3JKLaFSBBN5VB5DFHgUOL1CJwgN8agBXAnAXSOoV9SfBw/klVczwQdplVFIa+fIDNeoM9Did25wxKX10ff7liMFE97cbGwrUs2+KCmMQ5+miDQOZITCigHCdRCxnHOqYU5Lb7OvnK+A+cdsz8+aIbUZNCTlJPZv1jWgTL25seTj1+N3IhW3KulZcjH+P2daI4/8+9fd9LQLSa76gIwUDV3FWm52hfSkAX6HTIBwTRVgz1YqT2RouX0vWmWipc+iYhfWiENsmrqI9a+LQ9Nma8BOhUQ7RePOyBm007L5XZ9VojHf5t85GsfYTrTLCqvkPe5goCD3nYjcDcEb4WFkvcDI14X4aGunB6N/QL3TxRYAExAeRRpVaJ8bvhEMkFpuov5oMzV6E6o4dBu4gH76kPzySTYg== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199021)(36840700001)(40470700004)(46966006)(86362001)(40460700003)(8676002)(8936002)(5660300002)(4326008)(6916009)(82740400003)(70206006)(70586007)(41300700001)(316002)(356005)(7636003)(40480700001)(2906002)(186003)(1076003)(26005)(7696005)(47076005)(36860700001)(336012)(83380400001)(426003)(36756003)(82310400005)(2616005)(19627235002)(478600001)(54906003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 May 2023 07:51:03.2292 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c9ea687-ee89-4586-bd2c-08db4ae1fa7d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E647.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4221 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Add POST and PATCH methods on Memory collection and resource. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy --- .../v1sim/redfishURIs.py | 25 +++++++++++ .../v1sim/systems.py | 43 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/Tools/Redfish-Profile-Simulator/v1sim/redfishURIs.py b/Tools/R= edfish-Profile-Simulator/v1sim/redfishURIs.py index 3c912f7..35d3794 100644 --- a/Tools/Redfish-Profile-Simulator/v1sim/redfishURIs.py +++ b/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/Tools/Redfish-Profile-Simulator/v1sim/systems.py b/Tools/Redfi= sh-Profile-Simulator/v1sim/systems.py index b8b3788..690101f 100644 --- a/Tools/Redfish-Profile-Simulator/v1sim/systems.py +++ b/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