diff --git a/src/aws_cloudfront.py b/src/aws_cloudfront.py index e2a27bf..5976401 100644 --- a/src/aws_cloudfront.py +++ b/src/aws_cloudfront.py @@ -25,6 +25,7 @@ # get all cloudfront distributions and return a list of distributions def get_cloudfront_distributions(): + logger.debug('START - get_cloudfront_distributions()') session = aws_session_handler.get_session() cloudfront = session.client('cloudfront') distributions = cloudfront.list_distributions() @@ -36,6 +37,8 @@ def get_cloudfront_distributions(): # get information about a cloudfront distribution def get_cloudfront_distribution(distribution_id): + logger.debug('START - get_cloudfront_distribution(distribution_id)') + logger.debug('distribution_id: %s', distribution_id) session = aws_session_handler.get_session() cloudfront = session.client('cloudfront') distribution = cloudfront.get_distribution(Id=distribution_id) @@ -44,6 +47,9 @@ def get_cloudfront_distribution(distribution_id): # invalidate a cloudfront distribution def invalidate_cloudfront_distribution(distribution_id, paths): + logger.debug('START - invalidate_cloudfront_distribution(distribution_id, paths)') + logger.debug('distribution_id: %s', distribution_id) + logger.debug('paths: %s', paths) session = aws_session_handler.get_session() cloudfront = session.client('cloudfront') response = cloudfront.create_invalidation(DistributionId=distribution_id, InvalidationBatch={'Paths': {'Quantity': len(paths), 'Items': paths}, 'CallerReference': 'awsmanager'}) @@ -52,6 +58,8 @@ def invalidate_cloudfront_distribution(distribution_id, paths): # load tags of a cloudfront distribution def get_cloudfront_distribution_tags(distribution_id): + logger.debug('START - get_cloudfront_distribution_tags(distribution_id)') + logger.debug('distribution_id: %s', distribution_id) session = aws_session_handler.get_session() cloudfront = session.client('cloudfront') tags = cloudfront.list_tags_for_resource(Resource=distribution_id) diff --git a/src/aws_ec2.py b/src/aws_ec2.py index caac6fe..1d2ef96 100644 --- a/src/aws_ec2.py +++ b/src/aws_ec2.py @@ -24,6 +24,9 @@ # get information about an ec2 instance def get_ec2_instance(region, instance_id): + logger.debug('START - get_ec2_instance(region, instance_id)') + logger.debug('region: %s', region) + logger.debug('instance_id: %s', instance_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) instance = ec2.describe_instances(InstanceIds=[instance_id]) @@ -32,6 +35,9 @@ def get_ec2_instance(region, instance_id): # get all information about a volumeid def get_ec2_volume(region, volume_id): + logger.debug('START - get_ec2_volume(region, volume_id)') + logger.debug('region: %s', region) + logger.debug('volume_id: %s', volume_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) volume = ec2.describe_volumes(VolumeIds=[volume_id]) @@ -40,6 +46,8 @@ def get_ec2_volume(region, volume_id): # get all ec2 instances of a region and return a list of instances def get_ec2_instances(region): + logger.debug('START - get_ec2_instances(region)') + logger.debug('region: %s', region) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) instances = ec2.describe_instances() @@ -52,6 +60,9 @@ def get_ec2_instances(region): # start a given instance def start_ec2_instance(region, instance_id): + logger.debug('START - start_ec2_instance(region, instance_id)') + logger.debug('region: %s', region) + logger.debug('instance_id: %s', instance_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) ec2.start_instances(InstanceIds=[instance_id]) @@ -59,6 +70,9 @@ def start_ec2_instance(region, instance_id): # stop a given instance def stop_ec2_instance(region, instance_id): + logger.debug('START - stop_ec2_instance(region, instance_id)') + logger.debug('region: %s', region) + logger.debug('instance_id: %s', instance_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) ec2.stop_instances(InstanceIds=[instance_id]) @@ -66,6 +80,9 @@ def stop_ec2_instance(region, instance_id): # reboot a given instance def reboot_ec2_instance(region, instance_id): + logger.debug('START - reboot_ec2_instance(region, instance_id)') + logger.debug('region: %s', region) + logger.debug('instance_id: %s', instance_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) ec2.reboot_instances(InstanceIds=[instance_id]) @@ -73,6 +90,9 @@ def reboot_ec2_instance(region, instance_id): # terminate a given instance def terminate_ec2_instance(region, instance_id): + logger.debug('START - terminate_ec2_instance(region, instance_id)') + logger.debug('region: %s', region) + logger.debug('instance_id: %s', instance_id) session = aws_session_handler.get_session() ec2 = session.client('ec2', region_name=region) ec2.terminate_instances(InstanceIds=[instance_id]) diff --git a/src/aws_ecs.py b/src/aws_ecs.py index d1ccb92..58442ac 100644 --- a/src/aws_ecs.py +++ b/src/aws_ecs.py @@ -24,6 +24,8 @@ # get all ECS clusters of a region and return a list of ECS clusters def get_ecs_clusters(region): + logger.debug('START - get_ecs_clusters(region)') + logger.debug('region: %s', region) session = aws_session_handler.get_session() ecs = session.client("ecs", region_name=region) clusters = ecs.list_clusters() @@ -35,6 +37,9 @@ def get_ecs_clusters(region): # get all ECS services of a cluster and return a list of ECS services def get_ecs_services(region, cluster): + logger.debug('START - get_ecs_services(region, cluster)') + logger.debug('region: %s', region) + logger.debug('cluster: %s', cluster) session = aws_session_handler.get_session() ecs = session.client("ecs", region_name=region) services = ecs.list_services(cluster=cluster) @@ -46,6 +51,10 @@ def get_ecs_services(region, cluster): # get all ECS tasks of a service and return a list of ECS tasks def get_ecs_tasks(region, cluster, service): + logger.debug('START - get_ecs_tasks(region, cluster, service)') + logger.debug('region: %s', region) + logger.debug('cluster: %s', cluster) + logger.debug('service: %s', service) session = aws_session_handler.get_session() ecs = session.client("ecs", region_name=region) tasks = ecs.list_tasks(cluster=cluster, serviceName=service) @@ -57,6 +66,10 @@ def get_ecs_tasks(region, cluster, service): # load the details of the service def get_ecs_service_details(region, cluster, service): + logger.debug('START - get_ecs_service_details(region, cluster, service)') + logger.debug('region: %s', region) + logger.debug('cluster: %s', cluster) + logger.debug('service: %s', service) session = aws_session_handler.get_session() ecs = session.client("ecs", region_name=region) service_details = ecs.describe_services(cluster=cluster, services=[service]) @@ -65,6 +78,11 @@ def get_ecs_service_details(region, cluster, service): # set the desired count of a service def set_ecs_desired_count(region, cluster, service, count): + logger.debug('START - set_ecs_desired_count(region, cluster, service, count)') + logger.debug('region: %s', region) + logger.debug('cluster: %s', cluster) + logger.debug('service: %s', service) + logger.debug('count: %s', count) session = aws_session_handler.get_session() ecs = session.client("ecs", region_name=region) response = ecs.update_service(cluster=cluster, service=service, desiredCount=count) diff --git a/src/aws_lambda.py b/src/aws_lambda.py index 74f0846..e1b0ba1 100644 --- a/src/aws_lambda.py +++ b/src/aws_lambda.py @@ -25,6 +25,8 @@ # get all lambda functions of a region and return a list of functions def get_lambda_functions(region): + logger.debug('START - get_lambda_functions(region)') + logger.debug('region: %s', region) session = aws_session_handler.get_session() lambda_client = session.client('lambda', region_name=region) functions = lambda_client.list_functions() @@ -36,6 +38,9 @@ def get_lambda_functions(region): # get information about a lambda function def get_lambda_function(region, function_name): + logger.debug('START - get_lambda_function(region, function_name)') + logger.debug('region: %s', region) + logger.debug('function_name: %s', function_name) session = aws_session_handler.get_session() lambda_client = session.client('lambda', region_name=region) lambdafunction = lambda_client.get_function(FunctionName=function_name) @@ -44,6 +49,10 @@ def get_lambda_function(region, function_name): # invoke a lambda function def invoke_lambda_function(region, function_name, payload): + logger.debug('START - invoke_lambda_function(region, function_name, payload)') + logger.debug('region: %s', region) + logger.debug('function_name: %s', function_name) + logger.debug('payload: %s', payload) session = aws_session_handler.get_session() lambda_client = session.client('lambda', region_name=region) response = lambda_client.invoke(FunctionName=function_name, Payload=payload) diff --git a/src/aws_rds.py b/src/aws_rds.py index 8a5c166..e8aca80 100644 --- a/src/aws_rds.py +++ b/src/aws_rds.py @@ -24,6 +24,8 @@ # get all rds databases of a region and return a list of rds databases def get_rds_databases(region): + logger.debug('START - get_rds_databases(region)') + logger.debug('region: %s', region) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) databases = rds.describe_db_instances() @@ -34,6 +36,9 @@ def get_rds_databases(region): def get_rds_database(region, db_instance_identifier): + logger.debug('START - get_rds_database(region, db_instance_identifier)') + logger.debug('region: %s', region) + logger.debug('db_instance_identifier: %s', db_instance_identifier) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) database = rds.describe_db_instances(DBInstanceIdentifier=db_instance_identifier) @@ -41,6 +46,9 @@ def get_rds_database(region, db_instance_identifier): def start_rds_database(region, db_instance_identifier): + logger.debug('START - start_rds_database(region, db_instance_identifier)') + logger.debug('region: %s', region) + logger.debug('db_instance_identifier: %s', db_instance_identifier) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) response = rds.start_db_instance(DBInstanceIdentifier=db_instance_identifier) @@ -48,6 +56,9 @@ def start_rds_database(region, db_instance_identifier): def stop_rds_database(region, db_instance_identifier): + logger.debug('START - stop_rds_database(region, db_instance_identifier)') + logger.debug('region: %s', region) + logger.debug('db_instance_identifier: %s', db_instance_identifier) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) response = rds.stop_db_instance(DBInstanceIdentifier=db_instance_identifier) @@ -55,6 +66,9 @@ def stop_rds_database(region, db_instance_identifier): def reboot_rds_database(region, db_instance_identifier): + logger.debug('START - reboot_rds_database(region, db_instance_identifier)') + logger.debug('region: %s', region) + logger.debug('db_instance_identifier: %s', db_instance_identifier) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) response = rds.reboot_db_instance(DBInstanceIdentifier=db_instance_identifier) @@ -62,6 +76,9 @@ def reboot_rds_database(region, db_instance_identifier): def delete_rds_database(region, db_instance_identifier): + logger.debug('START - delete_rds_database(region, db_instance_identifier)') + logger.debug('region: %s', region) + logger.debug('db_instance_identifier: %s', db_instance_identifier) session = aws_session_handler.get_session() rds = session.client("rds", region_name=region) response = rds.delete_db_instance(DBInstanceIdentifier=db_instance_identifier) diff --git a/src/aws_s3.py b/src/aws_s3.py index 4c767ce..83e505c 100644 --- a/src/aws_s3.py +++ b/src/aws_s3.py @@ -24,6 +24,8 @@ # get all s3 buckets of a region and return a list of buckets def get_s3_buckets(region): + logger.debug('START - get_s3_buckets(region)') + logger.debug('region: %s', region) session = aws_session_handler.get_session() s3 = session.client('s3', region_name=region) buckets = s3.list_buckets() @@ -35,6 +37,9 @@ def get_s3_buckets(region): # get all objects of a bucket def get_s3_bucket_objects(region, bucket_name): + logger.debug('START - get_s3_bucket_objects(region, bucket_name)') + logger.debug('region: %s', region) + logger.debug('bucket_name: %s', bucket_name) s3 = boto3.client('s3', region_name=region) objects = s3.list_objects_v2(Bucket=bucket_name) objects_list = [] @@ -45,6 +50,11 @@ def get_s3_bucket_objects(region, bucket_name): # download an object from a bucket into given file def download_object(region, bucket_name, object_name, file_name): + logger.debug('START - download_object(region, bucket_name, object_name, file_name)') + logger.debug('region: %s', region) + logger.debug('bucket_name: %s', bucket_name) + logger.debug('object_name: %s', object_name) + logger.debug('file_name: %s', file_name) session = aws_session_handler.get_session() s3 = session.client('s3', region_name=region) s3.download_file(bucket_name, object_name, file_name) @@ -52,6 +62,11 @@ def download_object(region, bucket_name, object_name, file_name): # upload a file to a bucket def upload_file(region, bucket_name, file_name, object_name): + logger.debug('START - upload_file(region, bucket_name, file_name, object_name)') + logger.debug('region: %s', region) + logger.debug('bucket_name: %s', bucket_name) + logger.debug('file_name: %s', file_name) + logger.debug('object_name: %s', object_name) session = aws_session_handler.get_session() s3 = session.client('s3', region_name=region) s3.upload_file(file_name, bucket_name, object_name) @@ -59,6 +74,10 @@ def upload_file(region, bucket_name, file_name, object_name): # delete an object from a bucket def delete_object(region, bucket_name, object_name): + logger.debug('START - delete_object(region, bucket_name, object_name)') + logger.debug('region: %s', region) + logger.debug('bucket_name: %s', bucket_name) + logger.debug('object_name: %s', object_name) session = aws_session_handler.get_session() s3 = session.client('s3', region_name=region) s3.delete_object(Bucket=bucket_name, Key=object_name) diff --git a/src/configuration_ui.py b/src/configuration_ui.py index 7768f02..e96d208 100644 --- a/src/configuration_ui.py +++ b/src/configuration_ui.py @@ -22,6 +22,7 @@ # import workdir specific libraries import settings import icons +import webbrowser import logging_config # Setup the logging # noqa: F401 import logging @@ -91,3 +92,6 @@ def reloadAwsProfiles(self, event): # set the values self.comboBoxAwsProfile.Clear() self.comboBoxAwsProfile.Append(profiles) + + def openLogfile(self, event): + webbrowser.open_new_tab(self.textCtrlConfigLogfile.GetValue())