From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (NAM04-DM6-obe.outbound.protection.outlook.com [40.107.102.68]) by mx.groups.io with SMTP id smtpd.web10.109631.1683557522452273775 for ; Mon, 08 May 2023 07:52:02 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@nvidia.com header.s=selector2 header.b=Qtd+qnMo; 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.102.68, mailfrom: nicklew@nvidia.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOEfKuTPuYq0UtWCKE1VeMFh5Kh+Ve0qsbkJO2zXk9jt/clttWaNhjJ2idRN0uIlvyG260dje9C1SRCQ/o38IcyxtGIVc8kYaJYZIiHI5l3T67ZhC5oqnwIVvk4VgHyud3F1ELPlCKhWrGVqz/J/ISGtvBGv0EzgQ6TTNoqLa80HfuWlyKFJ1+XxXe9WFcUyCNEPvTWa639gLPwg7nUH3uFH0UT6aL+lR1jfQe2vkwEATVuABOvCOWd8Kqpz7J90qGinzo70H9T0QxBVQF+8bohg3ZflQe+ikYhioK+Mv4dlEaepDIHVvaA4LzYP3MWWdKkc1EdZL2DpKjdgAakjqQ== 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=tmjxg/VH7ShKKNMS1orQ7X1x9lOMuM0AKzFYpv39gxc=; b=QAJKXLpXdcJ4fW/0nOnWgGmh+axc+59Pw4DtqRUwLS61Z/LeE9mQlCMHmhExB8iNc8RQc6NsXb8VJxwda4BGa0/I8TtryYreI1+9dVBSg0Bt44XhzyivZtf0DAVmP5zVB5TZWWpYKRTqKKeV4fHWEboS/iCMRIDfhh10Xb+5C4bvJhvxvFqNywnPRdU8KRoPFyQxh0CkDuWNwWJbuwvPnXexf+hdT1/8KYAuXd/FOsnMKzwUkpK/jcdMRA5oey9SSJk9hbzxZpt2s8FEaFNvxBJbB/czLDZpl1WRzUiNqGkamZNkDG2+hmflI0m4v0GCpyBUrY3aSpu99yspqgIn6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=tmjxg/VH7ShKKNMS1orQ7X1x9lOMuM0AKzFYpv39gxc=; b=Qtd+qnMoDZojgAuCzTBCZ2QCka1HnM6kkqPrbA+/OX1wX088yvFMYEx9RByIo1xLRQT6vYPvnFPNATht3gGyC5th52aLESlO9HCTm0hVYErcLrtj5qfeYzlgBK77w+AVqAowvW7QYpKjCGTRj5Y0sLNu3JvkOJxgYO+jcJWtC1zNIKBVw2Ywba4TYh9nILJokc33Z/DQHMu4hFgU2TE2OsB1mP9wHZdD/t4JR5clj/YLw7G+XKE2zNz9NW8gtnHXj3xrgsk5EPw2QmPj3vNp5+OC4GBB78Z8qdnnSyHgVKusfDxROZhKj31gSwtGTm2bZZripfV+rlEupoUbtkXTJQ== Received: from CY5PR22CA0009.namprd22.prod.outlook.com (2603:10b6:930:16::20) by MN0PR12MB5978.namprd12.prod.outlook.com (2603:10b6:208:37d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 14:51:59 +0000 Received: from CY4PEPF0000C973.namprd02.prod.outlook.com (2603:10b6:930:16:cafe::f2) by CY5PR22CA0009.outlook.office365.com (2603:10b6:930:16::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32 via Frontend Transport; Mon, 8 May 2023 14:51:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CY4PEPF0000C973.mail.protection.outlook.com (10.167.242.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.18 via Frontend Transport; Mon, 8 May 2023 14:51:59 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Mon, 8 May 2023 07:51:48 -0700 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Mon, 8 May 2023 07:51:48 -0700 Received: from NV-CL38DL3.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Mon, 8 May 2023 07:51:47 -0700 From: "Nickle Wang" To: CC: Abner Chang , Igor Kulchytskyy Subject: [edk2-redfish-client][PATCH 3/6] Tool/Redfish-Profile-Simulator: Update patch method of computer system Date: Mon, 8 May 2023 22:51:47 +0800 Message-ID: <20230508145147.16771-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: CY4PEPF0000C973:EE_|MN0PR12MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: 2028a976-79c1-4efd-8a01-08db4fd3c6c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yeUXnVgbdeDg3HlbdNp7+acYCLicPkffjzAnZkgrPFa7HMmiakN0HNp42pwiGNhG0UTrTrWduExSEtYPu/fY0T39nICNHYu03dFT0+oIOY9B/HPwx893dfaeO5K65rMuBlSLNt/yt3agoNlSPtIIuPv5JRpbPg8MYOkxhD7JUAjPfCwVYeb+e8Kkh/NrTtJhIxomkUoCDT82hUI2OH+YplWUzGjFdUiR/ZCoFtluDeybJ3DMQ7yqfGrOgbxZW0JJEiRBQnXu4D6quF6PNtoSkxEUsPaqk41u7ZxvfoyHpVQX1QSeqqa2zasQ7t/S9mVy12dvccyvkpZo5z77cS7QkEmTsDk39t3mQC0Y96ViKXrzGmW0vyG/RyYUT/dHhDUg7HQimZawswoOBdatdlt0vPJTi92D91dfRHFCV8flAz62Bmi0+XhjHotjLv0AcV1OLa2c6vK4u/HiP+WivhfqJT62rdfp9DSOUxlFuQcEOD+cYnJolga3+K+nA33kZyyaVWaRCyi7ZLF1iFWADQ6hCdvmKTz4cJgDtRS9doHrdic00keWwq9XUE2xyjndlpszXg9YAJFc027/xeD3Kgts/l+fICCfX/Hox8IsEXsgAYWYmbzPr8Pcfopgcwo/5a2C6d9zJYFywoaV+xVCC8FoP96ZJyxcZSBBrwyWx9iQf8c= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(39860400002)(136003)(346002)(451199021)(46966006)(36840700001)(41300700001)(82310400005)(4326008)(316002)(6916009)(8676002)(8936002)(36860700001)(5660300002)(2616005)(336012)(1076003)(47076005)(426003)(186003)(83380400001)(86362001)(82740400003)(40480700001)(7636003)(356005)(26005)(70206006)(70586007)(36756003)(7696005)(19627235002)(54906003)(478600001)(15650500001)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 14:51:59.3295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2028a976-79c1-4efd-8a01-08db4fd3c6c2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000C973.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5978 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain Remove attribute check during patch of computer system and return content-type with JSON format in HTTP header. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Igor Kulchytskyy --- .../v1sim/resource.py | 4 ++- .../v1sim/systems.py | 28 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Tools/Redfish-Profile-Simulator/v1sim/resource.py b/Tools/Redf= ish-Profile-Simulator/v1sim/resource.py index ca7541f1..e722d16a 100644 --- a/Tools/Redfish-Profile-Simulator/v1sim/resource.py +++ b/Tools/Redfish-Profile-Simulator/v1sim/resource.py @@ -2,6 +2,7 @@ # Copyright Notice: # # Copyright (c) 2019, Intel Corporation. All rights reserved.
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # # Copyright Notice: @@ -47,6 +48,7 @@ class RfResource: try: # SHA1 should generate well-behaved etags response =3D flask.make_response(self.response) + response.mimetype =3D 'application/json' etag =3D hashlib.sha1(self.response.encode('utf-8')).hexdigest= () response.set_etag(etag) return response @@ -69,7 +71,7 @@ class RfResource: else: raise Exception("attribute %s not found" % key) =20 - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4)) + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json") return 0, 200, None, resp =20 def post_resource(self, post_data): diff --git a/Tools/Redfish-Profile-Simulator/v1sim/systems.py b/Tools/Redfi= sh-Profile-Simulator/v1sim/systems.py index de4b839a..6305a51e 100644 --- a/Tools/Redfish-Profile-Simulator/v1sim/systems.py +++ b/Tools/Redfish-Profile-Simulator/v1sim/systems.py @@ -2,7 +2,7 @@ # Copyright Notice: # # Copyright (c) 2019, Intel Corporation. All rights reserved.
-# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
+# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
# SPDX-License-Identifier: BSD-2-Clause-Patent # # Copyright Notice: @@ -63,15 +63,7 @@ class RfSystemObj(RfResource): self.components[item] =3D RfBootOptionCollection(base_path= , os.path.join(rel_path, item), parent=3Dself) =20 def patch_resource(self, patch_data): - # first verify client didn't send us a property we cant patch - for key in patch_data.keys(): - if key !=3D "AssetTag" and key !=3D "IndicatorLED" and key != =3D "Boot" and key !=3D "BiosVersion": - return 4, 400, "Invalid Patch Property Sent", "" - elif key =3D=3D "Boot": - for prop2 in patch_data["Boot"].keys(): - if prop2 !=3D "BootSourceOverrideEnabled" and prop2 != =3D "BootSourceOverrideTarget" and prop2 !=3D "BootNext" and prop2 !=3D "Bo= otOrder": - return 4, 400, "Invalid Patch Property Sent", "" - # now patch the valid properties sent + # patch the valid properties sent if "AssetTag" in patch_data: print("assetTag:{}".format(patch_data["AssetTag"])) self.res_data['AssetTag'] =3D patch_data['AssetTag'] @@ -100,7 +92,7 @@ class RfSystemObj(RfResource): if "BootOrder" in boot_data: self.res_data['Boot']['BootOrder'] =3D boot_data['BootOrde= r'] =20 - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4)) + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json") return 0, 200, None, resp =20 def reset_resource(self, reset_data): @@ -150,7 +142,7 @@ class RfMemoryCollection(RfCollection): post_data["@odata.etag"] =3D etag_str self.elements[str(newMemoryIdx)] =3D post_data =20 - resp =3D flask.Response(json.dumps(post_data,indent=3D4)) + resp =3D flask.Response(json.dumps(post_data,indent=3D4), mimetype= =3D"application/json") resp.headers["Location"] =3D newMemoryUrl resp.headers["ETag"] =3D etag_str =20 @@ -163,7 +155,7 @@ class RfMemoryCollection(RfCollection): patch_data["@odata.etag"] =3D etag_str =20 self.elements[str(Idx)] =3D {**self.elements[str(Idx)], **patch_da= ta} - resp =3D flask.Response(json.dumps(self.elements[str(Idx)],indent= =3D4)) + resp =3D flask.Response(json.dumps(self.elements[str(Idx)],indent= =3D4), mimetype=3D"application/json") return 0, 200, None, resp =20 def get_memory(self, Idx): @@ -172,7 +164,7 @@ class RfMemoryCollection(RfCollection): def delete_memory(self, Idx): print("in delete_memory") =20 - resp =3D flask.Response(json.dumps(self.elements[Idx],indent=3D4)) + resp =3D flask.Response(json.dumps(self.elements[Idx],indent=3D4),= mimetype=3D"application/json") =20 self.elements.pop(Idx) self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] - 1 @@ -228,7 +220,7 @@ class RfBiosSettings(RfResource): return 4, 400, "Invalid Patch Property Sent", "" else: self.res_data["Attributes"][key] =3D patch_data["Attribute= s"][key] - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4)) + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json") return 0, 200, None, resp =20 =20 @@ -297,13 +289,13 @@ class RfBootOptionCollection(RfCollection): post_data["@odata.id"] =3D newBootOptUrl self.bootOptions[str(newBootOptIdx)] =3D post_data =20 - resp =3D flask.Response(json.dumps(post_data,indent=3D4)) + resp =3D flask.Response(json.dumps(post_data,indent=3D4), mimetype= =3D"application/json") resp.headers["Location"] =3D newBootOptUrl return 0, 200, None, resp =20 def patch_bootOpt(self, Idx, patch_data): self.bootOptions[str(Idx)] =3D {**self.bootOptions[str(Idx)], **pa= tch_data} - resp =3D flask.Response(json.dumps(self.bootOptions[str(Idx)],inde= nt=3D4)) + resp =3D flask.Response(json.dumps(self.bootOptions[str(Idx)],inde= nt=3D4), mimetype=3D"application/json") return 0, 200, None, resp =20 def get_bootOpt(self, Idx): @@ -312,7 +304,7 @@ class RfBootOptionCollection(RfCollection): def delete_bootOpt(self, Idx): print("in delete_bootOpt") =20 - resp =3D flask.Response(json.dumps(self.bootOptions[Idx],indent=3D= 4)) + resp =3D flask.Response(json.dumps(self.bootOptions[Idx],indent=3D= 4), mimetype=3D"application/json") =20 self.bootOptions.pop(Idx) self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] - 1 --=20 2.17.1