agent: |
nCBKWuceU6CWEa8Rfvz1Validate the patch installation.
Validate the patch installation.
There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.
The Servers Patch Installation Run Report provides detailed insights into the patching process for each server, showcasing which patches were installed, failed, or are pending, along with the status of each installation attempt.
inputs
outputs
import json
def generate_compliance_report(patch_installation_results):
print("### Server Patch Installation Run Report\n")
for server in patch_installation_results:
vm_name = server['vm_name']
resource_group = server['resource_group']
patch_result = server['installation_result']
print(f"## Server: {vm_name} in Resource Group: {resource_group}\n")
print("#### General Information")
print(f"- **Assessment Status**: {patch_result['status']}")
print(f"- **Installation Activity ID**: {patch_result['installationActivityId']}")
print(f"- **Assessment Start Time**: {patch_result['startDateTime']}")
print(f"- **Reboot Status**: {patch_result['rebootStatus']}\n")
print("#### Patch Summary")
print(f"- **Installed Patches**: {patch_result['installedPatchCount']}")
print(f"- **Failed Patches**: {patch_result['failedPatchCount']}")
print(f"- **Not Selected Patches**: {patch_result['notSelectedPatchCount']}")
print(f"- **Pending Patches**: {patch_result['pendingPatchCount']}")
print(f"- **Excluded Patches**: {patch_result['excludedPatchCount']}")
print(f"- **Maintenance Window Exceeded**: {'Yes' if patch_result['maintenanceWindowExceeded'] else 'No'}\n")
print("### Detailed Patch Information")
print("The following patches were assessed for installation:\n")
for patch in patch_result["patches"]:
print(f" **{patch['name']}**")
print(f" - **Classification**: {', '.join(patch['classifications'])}")
print(f" - **Installation State**: {patch['installationState']}")
print(f" - **KB ID**: {patch['kbId']}\n")
print("### Action Items and Recommendations")
print("- **Review Not Selected Patches**: Review the patches not selected for installation.")
print("- **Monitor Installed Patches**: Ensure the installed patches do not cause issues.")
print("-"*50) # Separator between servers
#print(results)
# Example results below
# results = [{'vm_name': 'windows-server-vm-2', 'resource_group': 'DEFAULT-EASTUS-VM-2', 'installation_result': {'error': {'code': 'Success', 'details': [], 'innererror': None, 'message': '0 error/s reported', 'target': None}, 'excludedPatchCount': 1, 'failedPatchCount': 0, 'installationActivityId': 'd5de8eaf-f64b-478c-9236-b47868be9cf1', 'installedPatchCount': 0, 'maintenanceWindowExceeded': False, 'notSelectedPatchCount': 3, 'patches': [{'classifications': ['UpdateRollUp'], 'installationState': 'NotSelected', 'kbId': '890830', 'name': 'Windows Malicious Software Removal Tool x64 - v5.123 (KB890830)', 'patchId': '3a7c8e27-21f7-4808-b15b-e5a719b84aad', 'version': None}, {'classifications': ['Security'], 'installationState': 'NotSelected', 'kbId': '5037034', 'msrcSeverity': 'Important', 'name': '2024-04 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB5037034)', 'patchId': '8a9ba144-4d65-4534-8492-6e303a6e888c', 'version': None}, {'classifications': ['Definition'], 'installationState': 'Excluded', 'kbId': '2267602', 'name': 'Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.409.160.0) - Current Channel (Broad)', 'patchId': '9734ecf1-eae8-47df-987e-f929bed10354', 'version': None}, {'classifications': ['Security'], 'installationState': 'NotSelected', 'kbId': '5036896', 'name': '2024-04 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB5036896)', 'patchId': '7cd1ae7a-88d9-45ea-9c71-6b06dd0d25fe', 'version': None}], 'pendingPatchCount': 0, 'rebootStatus': 'NotNeeded', 'startDateTime': '2024-04-10T06:03:41+00:00', 'status': 'Succeeded'}}, {'vm_name': 'windows-server-vm', 'resource_group': 'DEFAULT-EASTUS-VM', 'installation_result': {'error': {'code': 'Success', 'details': [], 'innererror': None, 'message': '0 error/s reported', 'target': None}, 'excludedPatchCount': 1, 'failedPatchCount': 0, 'installationActivityId': '3ca6b219-98b6-49ba-8b83-0663f1183959', 'installedPatchCount': 0, 'maintenanceWindowExceeded': False, 'notSelectedPatchCount': 3, 'patches': [{'classifications': ['UpdateRollUp'], 'installationState': 'NotSelected', 'kbId': '890830', 'name': 'Windows Malicious Software Removal Tool x64 - v5.123 (KB890830)', 'patchId': '3a7c8e27-21f7-4808-b15b-e5a719b84aad', 'version': None}, {'classifications': ['Security'], 'installationState': 'NotSelected', 'kbId': '5037034', 'msrcSeverity': 'Important', 'name': '2024-04 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows Server 2019 for x64 (KB5037034)', 'patchId': '8a9ba144-4d65-4534-8492-6e303a6e888c', 'version': None}, {'classifications': ['Definition'], 'installationState': 'Excluded', 'kbId': '2267602', 'name': 'Security Intelligence Update for Microsoft Defender Antivirus - KB2267602 (Version 1.409.160.0) - Current Channel (Broad)', 'patchId': '9734ecf1-eae8-47df-987e-f929bed10354', 'version': None}, {'classifications': ['Security'], 'installationState': 'NotSelected', 'kbId': '5036896', 'name': '2024-04 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB5036896)', 'patchId': '7cd1ae7a-88d9-45ea-9c71-6b06dd0d25fe', 'version': None}], 'pendingPatchCount': 0, 'rebootStatus': 'NotNeeded', 'startDateTime': '2024-04-10T06:05:13+00:00', 'status': 'Succeeded'}}]
generate_compliance_report(results)
copied