How to use describe_maintenance_window_tasks method in localstack

Best Python code snippet using localstack_python

__init__.pyi

Source:__init__.pyi Github

copy

Full Screen

1"""2Main interface for ssm service.3Usage::4 ```python5 import boto36 from mypy_boto3_ssm import (7 Client,8 CommandExecutedWaiter,9 DescribeActivationsPaginator,10 DescribeAssociationExecutionTargetsPaginator,11 DescribeAssociationExecutionsPaginator,12 DescribeAutomationExecutionsPaginator,13 DescribeAutomationStepExecutionsPaginator,14 DescribeAvailablePatchesPaginator,15 DescribeEffectiveInstanceAssociationsPaginator,16 DescribeEffectivePatchesForPatchBaselinePaginator,17 DescribeInstanceAssociationsStatusPaginator,18 DescribeInstanceInformationPaginator,19 DescribeInstancePatchStatesForPatchGroupPaginator,20 DescribeInstancePatchStatesPaginator,21 DescribeInstancePatchesPaginator,22 DescribeInventoryDeletionsPaginator,23 DescribeMaintenanceWindowExecutionTaskInvocationsPaginator,24 DescribeMaintenanceWindowExecutionTasksPaginator,25 DescribeMaintenanceWindowExecutionsPaginator,26 DescribeMaintenanceWindowSchedulePaginator,27 DescribeMaintenanceWindowTargetsPaginator,28 DescribeMaintenanceWindowTasksPaginator,29 DescribeMaintenanceWindowsForTargetPaginator,30 DescribeMaintenanceWindowsPaginator,31 DescribeOpsItemsPaginator,32 DescribeParametersPaginator,33 DescribePatchBaselinesPaginator,34 DescribePatchGroupsPaginator,35 DescribePatchPropertiesPaginator,36 DescribeSessionsPaginator,37 GetInventoryPaginator,38 GetInventorySchemaPaginator,39 GetOpsSummaryPaginator,40 GetParameterHistoryPaginator,41 GetParametersByPathPaginator,42 ListAssociationVersionsPaginator,43 ListAssociationsPaginator,44 ListCommandInvocationsPaginator,45 ListCommandsPaginator,46 ListComplianceItemsPaginator,47 ListComplianceSummariesPaginator,48 ListDocumentVersionsPaginator,49 ListDocumentsPaginator,50 ListOpsItemEventsPaginator,51 ListOpsItemRelatedItemsPaginator,52 ListOpsMetadataPaginator,53 ListResourceComplianceSummariesPaginator,54 ListResourceDataSyncPaginator,55 SSMClient,56 )57 session = boto3.Session()58 client: SSMClient = boto3.client("ssm")59 session_client: SSMClient = session.client("ssm")60 command_executed_waiter: CommandExecutedWaiter = client.get_waiter("command_executed")61 describe_activations_paginator: DescribeActivationsPaginator = client.get_paginator("describe_activations")62 describe_association_execution_targets_paginator: DescribeAssociationExecutionTargetsPaginator = client.get_paginator("describe_association_execution_targets")63 describe_association_executions_paginator: DescribeAssociationExecutionsPaginator = client.get_paginator("describe_association_executions")64 describe_automation_executions_paginator: DescribeAutomationExecutionsPaginator = client.get_paginator("describe_automation_executions")65 describe_automation_step_executions_paginator: DescribeAutomationStepExecutionsPaginator = client.get_paginator("describe_automation_step_executions")66 describe_available_patches_paginator: DescribeAvailablePatchesPaginator = client.get_paginator("describe_available_patches")67 describe_effective_instance_associations_paginator: DescribeEffectiveInstanceAssociationsPaginator = client.get_paginator("describe_effective_instance_associations")68 describe_effective_patches_for_patch_baseline_paginator: DescribeEffectivePatchesForPatchBaselinePaginator = client.get_paginator("describe_effective_patches_for_patch_baseline")69 describe_instance_associations_status_paginator: DescribeInstanceAssociationsStatusPaginator = client.get_paginator("describe_instance_associations_status")70 describe_instance_information_paginator: DescribeInstanceInformationPaginator = client.get_paginator("describe_instance_information")71 describe_instance_patch_states_paginator: DescribeInstancePatchStatesPaginator = client.get_paginator("describe_instance_patch_states")72 describe_instance_patch_states_for_patch_group_paginator: DescribeInstancePatchStatesForPatchGroupPaginator = client.get_paginator("describe_instance_patch_states_for_patch_group")73 describe_instance_patches_paginator: DescribeInstancePatchesPaginator = client.get_paginator("describe_instance_patches")74 describe_inventory_deletions_paginator: DescribeInventoryDeletionsPaginator = client.get_paginator("describe_inventory_deletions")75 describe_maintenance_window_execution_task_invocations_paginator: DescribeMaintenanceWindowExecutionTaskInvocationsPaginator = client.get_paginator("describe_maintenance_window_execution_task_invocations")76 describe_maintenance_window_execution_tasks_paginator: DescribeMaintenanceWindowExecutionTasksPaginator = client.get_paginator("describe_maintenance_window_execution_tasks")77 describe_maintenance_window_executions_paginator: DescribeMaintenanceWindowExecutionsPaginator = client.get_paginator("describe_maintenance_window_executions")78 describe_maintenance_window_schedule_paginator: DescribeMaintenanceWindowSchedulePaginator = client.get_paginator("describe_maintenance_window_schedule")79 describe_maintenance_window_targets_paginator: DescribeMaintenanceWindowTargetsPaginator = client.get_paginator("describe_maintenance_window_targets")80 describe_maintenance_window_tasks_paginator: DescribeMaintenanceWindowTasksPaginator = client.get_paginator("describe_maintenance_window_tasks")81 describe_maintenance_windows_paginator: DescribeMaintenanceWindowsPaginator = client.get_paginator("describe_maintenance_windows")82 describe_maintenance_windows_for_target_paginator: DescribeMaintenanceWindowsForTargetPaginator = client.get_paginator("describe_maintenance_windows_for_target")83 describe_ops_items_paginator: DescribeOpsItemsPaginator = client.get_paginator("describe_ops_items")84 describe_parameters_paginator: DescribeParametersPaginator = client.get_paginator("describe_parameters")85 describe_patch_baselines_paginator: DescribePatchBaselinesPaginator = client.get_paginator("describe_patch_baselines")86 describe_patch_groups_paginator: DescribePatchGroupsPaginator = client.get_paginator("describe_patch_groups")87 describe_patch_properties_paginator: DescribePatchPropertiesPaginator = client.get_paginator("describe_patch_properties")88 describe_sessions_paginator: DescribeSessionsPaginator = client.get_paginator("describe_sessions")89 get_inventory_paginator: GetInventoryPaginator = client.get_paginator("get_inventory")90 get_inventory_schema_paginator: GetInventorySchemaPaginator = client.get_paginator("get_inventory_schema")91 get_ops_summary_paginator: GetOpsSummaryPaginator = client.get_paginator("get_ops_summary")92 get_parameter_history_paginator: GetParameterHistoryPaginator = client.get_paginator("get_parameter_history")93 get_parameters_by_path_paginator: GetParametersByPathPaginator = client.get_paginator("get_parameters_by_path")94 list_association_versions_paginator: ListAssociationVersionsPaginator = client.get_paginator("list_association_versions")95 list_associations_paginator: ListAssociationsPaginator = client.get_paginator("list_associations")96 list_command_invocations_paginator: ListCommandInvocationsPaginator = client.get_paginator("list_command_invocations")97 list_commands_paginator: ListCommandsPaginator = client.get_paginator("list_commands")98 list_compliance_items_paginator: ListComplianceItemsPaginator = client.get_paginator("list_compliance_items")99 list_compliance_summaries_paginator: ListComplianceSummariesPaginator = client.get_paginator("list_compliance_summaries")100 list_document_versions_paginator: ListDocumentVersionsPaginator = client.get_paginator("list_document_versions")101 list_documents_paginator: ListDocumentsPaginator = client.get_paginator("list_documents")102 list_ops_item_events_paginator: ListOpsItemEventsPaginator = client.get_paginator("list_ops_item_events")103 list_ops_item_related_items_paginator: ListOpsItemRelatedItemsPaginator = client.get_paginator("list_ops_item_related_items")104 list_ops_metadata_paginator: ListOpsMetadataPaginator = client.get_paginator("list_ops_metadata")105 list_resource_compliance_summaries_paginator: ListResourceComplianceSummariesPaginator = client.get_paginator("list_resource_compliance_summaries")106 list_resource_data_sync_paginator: ListResourceDataSyncPaginator = client.get_paginator("list_resource_data_sync")107 ```108"""109from .client import SSMClient110from .paginator import (111 DescribeActivationsPaginator,112 DescribeAssociationExecutionsPaginator,113 DescribeAssociationExecutionTargetsPaginator,114 DescribeAutomationExecutionsPaginator,115 DescribeAutomationStepExecutionsPaginator,116 DescribeAvailablePatchesPaginator,117 DescribeEffectiveInstanceAssociationsPaginator,118 DescribeEffectivePatchesForPatchBaselinePaginator,119 DescribeInstanceAssociationsStatusPaginator,120 DescribeInstanceInformationPaginator,121 DescribeInstancePatchesPaginator,122 DescribeInstancePatchStatesForPatchGroupPaginator,123 DescribeInstancePatchStatesPaginator,124 DescribeInventoryDeletionsPaginator,125 DescribeMaintenanceWindowExecutionsPaginator,126 DescribeMaintenanceWindowExecutionTaskInvocationsPaginator,127 DescribeMaintenanceWindowExecutionTasksPaginator,128 DescribeMaintenanceWindowSchedulePaginator,129 DescribeMaintenanceWindowsForTargetPaginator,130 DescribeMaintenanceWindowsPaginator,131 DescribeMaintenanceWindowTargetsPaginator,132 DescribeMaintenanceWindowTasksPaginator,133 DescribeOpsItemsPaginator,134 DescribeParametersPaginator,135 DescribePatchBaselinesPaginator,136 DescribePatchGroupsPaginator,137 DescribePatchPropertiesPaginator,138 DescribeSessionsPaginator,139 GetInventoryPaginator,140 GetInventorySchemaPaginator,141 GetOpsSummaryPaginator,142 GetParameterHistoryPaginator,143 GetParametersByPathPaginator,144 ListAssociationsPaginator,145 ListAssociationVersionsPaginator,146 ListCommandInvocationsPaginator,147 ListCommandsPaginator,148 ListComplianceItemsPaginator,149 ListComplianceSummariesPaginator,150 ListDocumentsPaginator,151 ListDocumentVersionsPaginator,152 ListOpsItemEventsPaginator,153 ListOpsItemRelatedItemsPaginator,154 ListOpsMetadataPaginator,155 ListResourceComplianceSummariesPaginator,156 ListResourceDataSyncPaginator,157)158from .waiter import CommandExecutedWaiter159Client = SSMClient160__all__ = (161 "Client",162 "CommandExecutedWaiter",163 "DescribeActivationsPaginator",164 "DescribeAssociationExecutionTargetsPaginator",165 "DescribeAssociationExecutionsPaginator",166 "DescribeAutomationExecutionsPaginator",167 "DescribeAutomationStepExecutionsPaginator",168 "DescribeAvailablePatchesPaginator",169 "DescribeEffectiveInstanceAssociationsPaginator",170 "DescribeEffectivePatchesForPatchBaselinePaginator",171 "DescribeInstanceAssociationsStatusPaginator",172 "DescribeInstanceInformationPaginator",173 "DescribeInstancePatchStatesForPatchGroupPaginator",174 "DescribeInstancePatchStatesPaginator",175 "DescribeInstancePatchesPaginator",176 "DescribeInventoryDeletionsPaginator",177 "DescribeMaintenanceWindowExecutionTaskInvocationsPaginator",178 "DescribeMaintenanceWindowExecutionTasksPaginator",179 "DescribeMaintenanceWindowExecutionsPaginator",180 "DescribeMaintenanceWindowSchedulePaginator",181 "DescribeMaintenanceWindowTargetsPaginator",182 "DescribeMaintenanceWindowTasksPaginator",183 "DescribeMaintenanceWindowsForTargetPaginator",184 "DescribeMaintenanceWindowsPaginator",185 "DescribeOpsItemsPaginator",186 "DescribeParametersPaginator",187 "DescribePatchBaselinesPaginator",188 "DescribePatchGroupsPaginator",189 "DescribePatchPropertiesPaginator",190 "DescribeSessionsPaginator",191 "GetInventoryPaginator",192 "GetInventorySchemaPaginator",193 "GetOpsSummaryPaginator",194 "GetParameterHistoryPaginator",195 "GetParametersByPathPaginator",196 "ListAssociationVersionsPaginator",197 "ListAssociationsPaginator",198 "ListCommandInvocationsPaginator",199 "ListCommandsPaginator",200 "ListComplianceItemsPaginator",201 "ListComplianceSummariesPaginator",202 "ListDocumentVersionsPaginator",203 "ListDocumentsPaginator",204 "ListOpsItemEventsPaginator",205 "ListOpsItemRelatedItemsPaginator",206 "ListOpsMetadataPaginator",207 "ListResourceComplianceSummariesPaginator",208 "ListResourceDataSyncPaginator",209 "SSMClient",...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...98 e = sys.exc_info()[1]99 print("%s" %e)100 101def CheckTask(ssm, Window_ID, task_name):102 task_info = ssm.describe_maintenance_window_tasks(103 WindowId = Window_ID104 )105 for task in task_info['Tasks']:106 if task['Name'] == task_name:107 Task_ID = task['WindowTaskId']108 return Task_ID109 Task_ID = 'None'110 return Task_ID111def RegisterTask(ssm, Window_ID, task_name, mw_targets, s3_bucket, s3_folder):112 try:113 ssm.register_task_with_maintenance_window(114 Name = task_name,115 WindowId = Window_ID,116 Targets=[...

Full Screen

Full Screen

ssm_patching_cleanup.py

Source:ssm_patching_cleanup.py Github

copy

Full Screen

1#!/usr/bin/env python32#3# Author: Dan Farmer4# License: GPL35# See the "LICENSE" file for full details6"""Destroy SSM Patch Manager resources on an AWS account.7- All Maintenance Window Tasks for 'AWS-ApplyPatchBaseline' or 'AWS-RunPatchBaseline'8- All Maintenance Windows with no tasks or only patching tasks as above9- All Patch Baseline registrations for Patch Groups10- All custom Patch Baselines"""11import argparse12import logging13import boto314import helpers15def main():16 """Delete SSM Patch Manager resources.17 Parse command-line arguments18 Establish region19 Iterate through Maintenance Windows20 Iterate through Tasks21 Delete patching-specific Tasks22 Delete Maintenance Windows with no Tasks23 Iterate through Patch Groups24 Deregister Baseline for Patch Groups25 Iterate through Patch Baselines26 Delete non-default Baselines"""27 args = parse_args()28 if args.loglevel:29 logging.basicConfig(level=args.loglevel)30 region = helpers.get_region(args.region)31 logging.info('Using region %s', region)32 ssm_client = boto3.client('ssm', region_name=region)33 # Iterate through Maintenance Windows34 mw_enabled_filter = {'Key':'Enabled', 'Values':['true']}35 for maint_window in helpers.get_items(client=ssm_client,36 function='describe_maintenance_windows',37 item_name='WindowIdentities',38 Filters=[mw_enabled_filter]):39 logging.info('Considering Maintenance Window %s', maint_window['WindowId'])40 # Iterate through Tasks41 for task in helpers.get_items(client=ssm_client,42 function='describe_maintenance_window_tasks',43 item_name='Tasks',44 WindowId=maint_window['WindowId']):45 logging.info('Considering Task %s', task['WindowTaskId'])46 # If TaskArn is one of the AWS-supplied SSM Patch Manager tasks, delete it47 if ((task['TaskArn'] == 'AWS-ApplyPatchBaseline') or48 (task['TaskArn'] == 'AWS-RunPatchBaseline')):49 logging.info('Task %s has TaskArn %s, deleting',50 task['WindowTaskId'], task['TaskArn'])51 delete_task(ssm_client, maint_window['WindowId'], task['WindowTaskId'])52 else:53 logging.info('Task %s has TaskArn %s',54 task['WindowTaskId'], task['TaskArn'])55 # Re-fetch the Tasks for this Maintenance Window56 tasks = helpers.get_items(client=ssm_client,57 function='describe_maintenance_window_tasks',58 item_name='Tasks',59 WindowId=maint_window['WindowId'])60 tasks_number = sum(1 for task in tasks)61 logging.info('Number of tasks remaining for Maintenance Window %s: %s',62 maint_window['WindowId'], tasks_number)63 # If no Tasks remain for this Maintenance Window, delete it64 if tasks_number == 0:65 delete_maintenance_window(ssm_client, maint_window['WindowId'])66 # Iterate through Patch Groups; Deregister baselines67 for patch_group in helpers.get_items(client=ssm_client,68 function='describe_patch_groups',69 item_name='Mappings'):70 deregister_baseline(ssm_client,71 patch_group['PatchGroup'],72 patch_group['BaselineIdentity']['BaselineId'])73 # Iterate through Baselines74 for baseline in helpers.get_items(client=ssm_client,75 function='describe_patch_baselines',76 item_name='BaselineIdentities'):77 logging.info('Considering Patch Baseline %s', baseline['BaselineId'])78 # If this is not a Default Baseline, delete it79 if not baseline['DefaultBaseline']:80 logging.info('Baseline %s is not a Default Baseline, deleting', baseline['BaselineId'])81 delete_baseline(ssm_client, baseline['BaselineId'])82 else:83 logging.info('Baseline %s is a Default Baseline', baseline['BaselineId'])84def parse_args():85 """Create arguments.86 Return args namespace"""87 parser = argparse.ArgumentParser()88 parser.add_argument('-r', '--region', type=str, help='AWS region', default=False)89 parser.add_argument('-l', '--loglevel', type=str, required=False,90 choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],91 help='Logging/output verbosity')92 return parser.parse_args()93def delete_task(ssm_client, maint_window_id, task_id):94 """Delete Maintenance Window Task."""95 response = ssm_client.deregister_task_from_maintenance_window(WindowId=maint_window_id,96 WindowTaskId=task_id)97 if response['WindowTaskId']:98 print("Deregistered Task {0} from Maintenance Window {1}".format(task_id, maint_window_id))99 else:100 logging.error('Failed to deregister Task %s from Maintenance Window %s',101 task_id, maint_window_id)102def delete_maintenance_window(ssm_client, maint_window_id):103 """Delete Maintenance Window."""104 response = ssm_client.delete_maintenance_window(WindowId=maint_window_id)105 if response['WindowId']:106 print("Deleted Maintenance Window {0}".format(maint_window_id))107 else:108 logging.error('Failed to delete Maintenance Window %s', maint_window_id)109def deregister_baseline(ssm_client, patch_group, baseline):110 """Deregister Baseline for Patch Group."""111 response = ssm_client.deregister_patch_baseline_for_patch_group(BaselineId=baseline,112 PatchGroup=patch_group)113 if response['PatchGroup']:114 print("Deregistered Baseline {0} for Patch Group {1}".format(baseline, patch_group))115 else:116 logging.error('Failed to deregister Baseline %s for Patch Group %s', baseline, patch_group)117def delete_baseline(ssm_client, baseline):118 """Delete a Patch Baseline."""119 response = ssm_client.delete_patch_baseline(BaselineId=baseline)120 if response['BaselineId']:121 print("Deleted Patch Baseline {0}".format(baseline))122 else:123 logging.error('Failed to delete Patch Baseline %s', baseline)124if __name__ == '__main__':...

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