How to use describe_instance_patch_states method in localstack

Best Python code snippet using localstack_python

ssmutil.py

Source:ssmutil.py Github

copy

Full Screen

...44 return self.ssm_client.send_command(InstanceIds=[instance_id], DocumentName=patch_baseline_document, DocumentVersion=patch_baseline_document_version,45 TimeoutSeconds=patch_baseline_timeout, Comment=comments, Parameters=parameters, OutputS3BucketName=ssm_command_output_bucket,46 OutputS3KeyPrefix=ssm_command_output_s3_key_prefix)47 @AWSRetry.backoff()48 def describe_instance_patch_states(self, instance_id):49 return self.ssm_client.describe_instance_patch_states(InstanceIds=[instance_id])50 @AWSRetry.backoff()51 def describe_instance_information(self, instance_id):52 filters = [{'Key': "InstanceIds", 'Values': [instance_id]}]...

Full Screen

Full Screen

ec2_patching_with_ssm.py

Source:ec2_patching_with_ssm.py Github

copy

Full Screen

...21time.sleep(10)22waiter = client.get_waiter('command_executed')23waiter.wait(CommandId=response['Command']['CommandId'],InstanceId='i-08d4c52a7c56db0bc')24# Get Patch State25response = client.describe_instance_patch_states(26 InstanceIds=[27 'i-08d4c52a7c56db0bc',28 ],29 NextToken='string',30 MaxResults=5031)32#Get Patch details33response = client.describe_instance_patches(34 InstanceId='i-08d4c52a7c56db0bc',35 MaxResults=5036)37results = response["Patches"]38while "NextToken" in response:39 response = client.describe_instance_patches(InstanceId='i-08d4c52a7c56db0bc',MaxResults=50,NextToken=response['NextToken'])40 results.extend(response["Patches"])41print("Package status before patching\n"+str(results))42#Create AMI before patching43execution_response=client.start_automation_execution(44DocumentName='ami',45DocumentVersion='$LATEST',46Parameters={47 "InstanceId": [48 "i-08d4c52a7c56db0bc"49 ],50 "NoReboot": [51 "true"52 ],53 "AMINameValue": [54 "Ubuntu"55 ],56 "DeleteOnValue": [57 "19-10-2021"58 ]59 })60# Get AMI creation status61response = client.describe_automation_executions(62 Filters=[63 {64 'Key': 'ExecutionId',65 'Values': [execution_response['AutomationExecutionId']]66 },67 ],68 MaxResults=50,69)70while response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] in ["Pending","InProgress"]:71 print("Image creation in progress")72 time.sleep(10)73 response = client.describe_automation_executions(Filters=[{'Key': 'ExecutionId','Values': [execution_response['AutomationExecutionId']]},],MaxResults=50)74if response['AutomationExecutionMetadataList'][0]['AutomationExecutionStatus'] != "Success": 75 print("Image creation failed")76else:77 print("Image creation completed")78#Patch instance79print("Patching started")80response=client.send_command(81 InstanceIds=['i-08d4c52a7c56db0bc'],82 DocumentName='AWS-RunPatchBaseline',83 DocumentVersion='$LATEST',84 TimeoutSeconds=900,85 Parameters={86 'Operation': [87 'Install'88 ],89 'RebootOption': [90 'RebootIfNeeded'91 ]92 }93 )94time.sleep(10)95waiter = client.get_waiter('command_executed')96waiter.wait(CommandId=response['Command']['CommandId'],InstanceId='i-08d4c52a7c56db0bc',WaiterConfig={'Delay': 30,'MaxAttempts': 50})97# Post Patching State98response = client.describe_instance_patch_states(99 InstanceIds=[100 'i-08d4c52a7c56db0bc',101 ],102 NextToken='string',103 MaxResults=50104 )105#Post Patching details106response = client.describe_instance_patches(107 InstanceId='i-08d4c52a7c56db0bc',108 MaxResults=50109 )110results = response["Patches"]111while "NextToken" in response:112 response = client.describe_instance_patches(InstanceId='i-08d4c52a7c56db0bc',MaxResults=50,NextToken=response['NextToken'])...

Full Screen

Full Screen

report-patching-summary.py

Source:report-patching-summary.py Github

copy

Full Screen

...35 x += MAX_RESULTS36 next_token = None37 while True:38 if next_token is not None:39 r = client.describe_instance_patch_states(40 InstanceIds=temp,41 NextToken=next_token,42 MaxResults=MAX_RESULTS43 )44 else:45 r = client.describe_instance_patch_states(46 InstanceIds=temp,47 MaxResults=MAX_RESULTS48 )49 patch_states = patch_states + r['InstancePatchStates']50 if 'nextToken' in r:51 next_token = r['nextToken']52 else:53 break54print('InstanceId Failed Missing Installed InstalledOther InstalledRejected NotApplicable PatchGroup Date/Time')55for p in patch_states:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful