Best Python code snippet using localstack_python
ssm.py
Source:ssm.py
...57def compliance_summary(config: Config) -> List[Dict[str, Any]]:58 """Compliance summary for running instances that have run the patch baseline."""59 instances_names = describe_instances_names(config)60 client = boto3.client("ssm", region_name=config.get("region", None))61 response = client.list_resource_compliance_summaries(62 Filters=[{"Key": "ComplianceType", "Values": ["Patch"], "Type": "EQUAL"}]63 )64 return [65 {66 "InstanceId": i["ResourceId"],67 "Name": instances_names.get(i["ResourceId"], None),68 "Status": i["Status"],69 "NonCompliantCount": i["NonCompliantSummary"]["NonCompliantCount"],70 "Last operation time": i["ExecutionSummary"]["ExecutionTime"],71 }72 for i in response["ResourceComplianceSummaryItems"]73 ]74def patch(75 config: Config, operation: Literal["scan", "install"], names: List[str], no_reboot: bool...
report.py
Source:report.py
...44 summary = []45 result = []46 filter_value = self.ssm_filter[0]['Values'][0]47 filter_ssm_res = [{'Key': self.ssm_filter[0]['Key'], 'Values': ['{}'.format(filter_value)], 'Type': self.ssm_filter[0]['Type'][0]}]48 response_ssm_res = ssm.list_resource_compliance_summaries(49 Filters=filter_ssm_res50 )51 for item in response_ssm_res['ResourceComplianceSummaryItems']:52 instance = item['ResourceId']53 #status = item['Status']54 inst_summary = {"InstanceId":instance,"Status": item['Status']}55 summary.append(inst_summary)56 response_ssm_patches_summ = ssm.describe_instance_patches(InstanceId=instance)57 for patch in response_ssm_patches_summ['Patches']:58 patch['InstanceId'] = instance59 patch['InstalledTime'] = str(patch['InstalledTime'])60 result.append(patch)61 return result,summary62 def _upload(self, creds, payload):...
list_ssm_resource_compliance_summaries.py
Source:list_ssm_resource_compliance_summaries.py
...1516 list_ssm = []17 next_token = None18 while True:19 response4 = ssm_client.list_resource_compliance_summaries(20 NextToken= next_token21 ) if next_token else ssm_client.list_resource_compliance_summaries()22 23 print(response4['ResourceComplianceSummaryItems'])24 for comp in response4['ResourceComplianceSummaryItems']:2526 status_var4 = comp['Status']27 Compliance_type = comp['ComplianceType']28 29 rank4 = 030 compliant_count = comp['CompliantSummary']['CompliantCount']31 non_compliant_count = comp['NonCompliantSummary']['NonCompliantCount']3233 ratio4 = non_compliant_count/( compliant_count+ non_compliant_count)34 if (status_var4 == "COMPLIANT" and Compliance_type == "Association") :35 rank4 = 1*2 +ratio4
...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!