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.web12.38481.1655775996659062979 for ; Mon, 20 Jun 2022 18:46:37 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=jVt0VOMf; 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=01711e5ef9=nickle.wang@hpe.com) Received: from pps.filterd (m0134424.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25L1WN2T023951; Tue, 21 Jun 2022 01:46:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pps0720; bh=r9ArPUJWcLrE6h+gJGQyNeFC8gBC6emRF7bQZkZl7eY=; b=jVt0VOMf5Mi90UuNs2jGWVgZo6DL9N/tx84fdmGL1DnZVHKEstgrjTG46Ab7a3Kn9UCl 5JiAkM12cHIr7dxzk1/Tclqzvt00WZ+WjDgn9vavqXr6cMqUeUKo0/OSHlkkq58ybdTf B7KMtGuwvftQ0rDgKohOgHTxaFsdL/3Y0NIsGIP2seri7eAH//9gpNLI9NA6e6icq1sb if8kXcgN75u4QG6phPI52jkESCUWlc1GSy83bF3EdYonq9CB0VWrIcdQpxHe1LAhW5MZ z3911TLrCCsBrOTTip2zPbtwd+06cwPjEMNq1kqSwU8Az4sJsS/xFQLuLpquuI020xzV 7Q== Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3gtpjsq7un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Jun 2022 01:46:34 +0000 Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id EB5FE8058D4; Tue, 21 Jun 2022 01:46:33 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTP id 660F8802F37; Tue, 21 Jun 2022 01:46:32 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Nickle Wang , Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH v2 3/5] edk2-staging/RedfishClientPkg: Update patch method of computer system Date: Tue, 21 Jun 2022 09:46:27 +0800 Message-Id: <20220621014627.1324-1-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: cDbYY_iS-gXXoY8iiBpEtyNb5K94Xhcu X-Proofpoint-GUID: cDbYY_iS-gXXoY8iiBpEtyNb5K94Xhcu X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-20_06,2022-06-17_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxscore=0 adultscore=0 impostorscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxlogscore=560 lowpriorityscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206210006 Content-Transfer-Encoding: quoted-printable 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: Yang Atom Cc: Nick Ramirez --- .../v1sim/resource.py | 4 ++- .../v1sim/systems.py | 28 +++++++------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/resourc= e.py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/resource.py index ca7541f172..e722d16a0b 100644 --- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/resource.py +++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/resource.py @@ -2,6 +2,7 @@ # Copyright Notice:=0D #=0D # Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D +# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D # Copyright Notice:=0D @@ -47,6 +48,7 @@ class RfResource: try:=0D # SHA1 should generate well-behaved etags=0D response =3D flask.make_response(self.response)=0D + response.mimetype =3D 'application/json'=0D etag =3D hashlib.sha1(self.response.encode('utf-8')).hexdigest= ()=0D response.set_etag(etag)=0D return response=0D @@ -69,7 +71,7 @@ class RfResource: else:=0D raise Exception("attribute %s not found" % key)=0D =0D - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4))=0D + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json")=0D return 0, 200, None, resp=0D =0D def post_resource(self, post_data):=0D diff --git a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems= .py b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py index de4b839aeb..6305a51efb 100644 --- a/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py +++ b/RedfishClientPkg/Tools/Redfish-Profile-Simulator/v1sim/systems.py @@ -2,7 +2,7 @@ # Copyright Notice:=0D #=0D # Copyright (c) 2019, Intel Corporation. All rights reserved.
=0D -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D +# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D # Copyright Notice:=0D @@ -63,15 +63,7 @@ class RfSystemObj(RfResource): self.components[item] =3D RfBootOptionCollection(base_path= , os.path.join(rel_path, item), parent=3Dself)=0D =0D def patch_resource(self, patch_data):=0D - # first verify client didn't send us a property we cant patch=0D - for key in patch_data.keys():=0D - if key !=3D "AssetTag" and key !=3D "IndicatorLED" and key != =3D "Boot" and key !=3D "BiosVersion":=0D - return 4, 400, "Invalid Patch Property Sent", ""=0D - elif key =3D=3D "Boot":=0D - for prop2 in patch_data["Boot"].keys():=0D - if prop2 !=3D "BootSourceOverrideEnabled" and prop2 != =3D "BootSourceOverrideTarget" and prop2 !=3D "BootNext" and prop2 !=3D "Bo= otOrder":=0D - return 4, 400, "Invalid Patch Property Sent", ""=0D - # now patch the valid properties sent=0D + # patch the valid properties sent=0D if "AssetTag" in patch_data:=0D print("assetTag:{}".format(patch_data["AssetTag"]))=0D self.res_data['AssetTag'] =3D patch_data['AssetTag']=0D @@ -100,7 +92,7 @@ class RfSystemObj(RfResource): if "BootOrder" in boot_data:=0D self.res_data['Boot']['BootOrder'] =3D boot_data['BootOrde= r']=0D =0D - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4))=0D + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json")=0D return 0, 200, None, resp=0D =0D def reset_resource(self, reset_data):=0D @@ -150,7 +142,7 @@ class RfMemoryCollection(RfCollection): post_data["@odata.etag"] =3D etag_str=0D self.elements[str(newMemoryIdx)] =3D post_data=0D =0D - resp =3D flask.Response(json.dumps(post_data,indent=3D4))=0D + resp =3D flask.Response(json.dumps(post_data,indent=3D4), mimetype= =3D"application/json")=0D resp.headers["Location"] =3D newMemoryUrl=0D resp.headers["ETag"] =3D etag_str=0D =0D @@ -163,7 +155,7 @@ class RfMemoryCollection(RfCollection): patch_data["@odata.etag"] =3D etag_str=0D =0D self.elements[str(Idx)] =3D {**self.elements[str(Idx)], **patch_da= ta}=0D - resp =3D flask.Response(json.dumps(self.elements[str(Idx)],indent= =3D4))=0D + resp =3D flask.Response(json.dumps(self.elements[str(Idx)],indent= =3D4), mimetype=3D"application/json")=0D return 0, 200, None, resp=0D =0D def get_memory(self, Idx):=0D @@ -172,7 +164,7 @@ class RfMemoryCollection(RfCollection): def delete_memory(self, Idx):=0D print("in delete_memory")=0D =0D - resp =3D flask.Response(json.dumps(self.elements[Idx],indent=3D4))= =0D + resp =3D flask.Response(json.dumps(self.elements[Idx],indent=3D4),= mimetype=3D"application/json")=0D =0D self.elements.pop(Idx)=0D self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] - 1=0D @@ -228,7 +220,7 @@ class RfBiosSettings(RfResource): return 4, 400, "Invalid Patch Property Sent", ""=0D else:=0D self.res_data["Attributes"][key] =3D patch_data["Attribute= s"][key]=0D - resp =3D flask.Response(json.dumps(self.res_data,indent=3D4))=0D + resp =3D flask.Response(json.dumps(self.res_data,indent=3D4), mime= type=3D"application/json")=0D return 0, 200, None, resp=0D =0D =0D @@ -297,13 +289,13 @@ class RfBootOptionCollection(RfCollection): post_data["@odata.id"] =3D newBootOptUrl=0D self.bootOptions[str(newBootOptIdx)] =3D post_data=0D =0D - resp =3D flask.Response(json.dumps(post_data,indent=3D4))=0D + resp =3D flask.Response(json.dumps(post_data,indent=3D4), mimetype= =3D"application/json")=0D resp.headers["Location"] =3D newBootOptUrl=0D return 0, 200, None, resp=0D =0D def patch_bootOpt(self, Idx, patch_data):=0D self.bootOptions[str(Idx)] =3D {**self.bootOptions[str(Idx)], **pa= tch_data}=0D - resp =3D flask.Response(json.dumps(self.bootOptions[str(Idx)],inde= nt=3D4))=0D + resp =3D flask.Response(json.dumps(self.bootOptions[str(Idx)],inde= nt=3D4), mimetype=3D"application/json")=0D return 0, 200, None, resp=0D =0D def get_bootOpt(self, Idx):=0D @@ -312,7 +304,7 @@ class RfBootOptionCollection(RfCollection): def delete_bootOpt(self, Idx):=0D print("in delete_bootOpt")=0D =0D - resp =3D flask.Response(json.dumps(self.bootOptions[Idx],indent=3D= 4))=0D + resp =3D flask.Response(json.dumps(self.bootOptions[Idx],indent=3D= 4), mimetype=3D"application/json")=0D =0D self.bootOptions.pop(Idx)=0D self.res_data["Members@odata.count"] =3D self.res_data["Members@od= ata.count"] - 1=0D --=20 2.32.0.windows.2