From de670b39659552e86afec9812b8e6c8dc3e96ca4 Mon Sep 17 00:00:00 2001 From: "Daniel A. Wozniak" Date: Thu, 1 Jun 2023 14:45:36 -0700 Subject: [PATCH 1/5] Adding deprecation message to all boto modules in preparation for moving these to a salt extension --- salt/modules/boto3_elasticache.py | 7 +++++++ salt/modules/boto3_elasticsearch.py | 7 +++++++ salt/modules/boto3_route53.py | 7 +++++++ salt/modules/boto3_sns.py | 7 +++++++ salt/modules/boto_apigateway.py | 7 +++++++ salt/modules/boto_asg.py | 7 +++++++ salt/modules/boto_cfn.py | 7 +++++++ salt/modules/boto_cloudfront.py | 7 +++++++ salt/modules/boto_cloudtrail.py | 7 +++++++ salt/modules/boto_cloudwatch.py | 7 +++++++ salt/modules/boto_cloudwatch_event.py | 7 +++++++ salt/modules/boto_cognitoidentity.py | 7 +++++++ salt/modules/boto_datapipeline.py | 7 +++++++ salt/modules/boto_dynamodb.py | 7 +++++++ salt/modules/boto_ec2.py | 7 +++++++ salt/modules/boto_efs.py | 7 +++++++ salt/modules/boto_elasticache.py | 7 +++++++ salt/modules/boto_elasticsearch_domain.py | 7 +++++++ salt/modules/boto_elb.py | 7 +++++++ salt/modules/boto_elbv2.py | 7 +++++++ salt/modules/boto_iam.py | 7 +++++++ salt/modules/boto_iot.py | 7 +++++++ salt/modules/boto_kinesis.py | 7 +++++++ salt/modules/boto_kms.py | 7 +++++++ salt/modules/boto_lambda.py | 7 +++++++ salt/modules/boto_rds.py | 7 +++++++ salt/modules/boto_route53.py | 7 +++++++ salt/modules/boto_s3.py | 7 +++++++ salt/modules/boto_s3_bucket.py | 7 +++++++ salt/modules/boto_secgroup.py | 7 +++++++ salt/modules/boto_sns.py | 7 +++++++ salt/modules/boto_sqs.py | 7 +++++++ salt/modules/boto_ssm.py | 7 +++++++ salt/modules/boto_vpc.py | 7 +++++++ salt/states/boto3_elasticache.py | 6 ++++++ salt/states/boto3_elasticsearch.py | 7 +++++++ salt/states/boto3_route53.py | 6 ++++++ salt/states/boto3_sns.py | 6 ++++++ salt/states/boto_apigateway.py | 6 ++++++ salt/states/boto_asg.py | 6 ++++++ salt/states/boto_cfn.py | 7 +++++++ salt/states/boto_cloudfront.py | 7 +++++++ salt/states/boto_cloudtrail.py | 7 +++++++ salt/states/boto_cloudwatch_alarm.py | 6 ++++++ salt/states/boto_cloudwatch_event.py | 6 ++++++ salt/states/boto_cognitoidentity.py | 7 +++++++ salt/states/boto_datapipeline.py | 7 +++++++ salt/states/boto_dynamodb.py | 6 ++++++ salt/states/boto_ec2.py | 7 +++++++ salt/states/boto_elasticache.py | 7 +++++++ salt/states/boto_elasticsearch_domain.py | 6 ++++++ salt/states/boto_elb.py | 7 +++++++ salt/states/boto_elbv2.py | 8 ++++++++ salt/states/boto_iam.py | 8 ++++++++ salt/states/boto_iam_role.py | 7 +++++++ salt/states/boto_iot.py | 7 +++++++ salt/states/boto_kinesis.py | 8 ++++++++ salt/states/boto_lambda.py | 7 +++++++ salt/states/boto_lc.py | 6 ++++++ salt/states/boto_rds.py | 7 +++++++ salt/states/boto_route53.py | 7 +++++++ salt/states/boto_s3.py | 7 +++++++ salt/states/boto_s3_bucket.py | 7 +++++++ salt/states/boto_secgroup.py | 7 +++++++ salt/states/boto_sns.py | 8 ++++++++ salt/states/boto_sqs.py | 7 +++++++ salt/states/boto_vpc.py | 10 +++++++++- 67 files changed, 465 insertions(+), 1 deletion(-) diff --git a/salt/modules/boto3_elasticache.py b/salt/modules/boto3_elasticache.py index 1e52ea25a2c..a2f7bdf1c9c 100644 --- a/salt/modules/boto3_elasticache.py +++ b/salt/modules/boto3_elasticache.py @@ -66,6 +66,13 @@ try: except ImportError: HAS_BOTO3 = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto3_elasticsearch.py b/salt/modules/boto3_elasticsearch.py index 7462ea74d5d..4fe77a2095d 100644 --- a/salt/modules/boto3_elasticsearch.py +++ b/salt/modules/boto3_elasticsearch.py @@ -74,6 +74,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto3_route53.py b/salt/modules/boto3_route53.py index 32c971356c2..e1c2b873a91 100644 --- a/salt/modules/boto3_route53.py +++ b/salt/modules/boto3_route53.py @@ -70,6 +70,13 @@ try: except ImportError: HAS_BOTO3 = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto3_sns.py b/salt/modules/boto3_sns.py index 65ab6283f51..49d784fa19f 100644 --- a/salt/modules/boto3_sns.py +++ b/salt/modules/boto3_sns.py @@ -60,6 +60,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=unused-import +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_apigateway.py b/salt/modules/boto_apigateway.py index dad8858edb5..9f2463a708e 100644 --- a/salt/modules/boto_apigateway.py +++ b/salt/modules/boto_apigateway.py @@ -106,6 +106,13 @@ except ImportError: # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto libraries exist and if boto libraries are greater than diff --git a/salt/modules/boto_asg.py b/salt/modules/boto_asg.py index c52c7946791..8980c5ecb58 100644 --- a/salt/modules/boto_asg.py +++ b/salt/modules/boto_asg.py @@ -76,6 +76,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_cfn.py b/salt/modules/boto_cfn.py index 4c6b700482a..c3f2aacfbba 100644 --- a/salt/modules/boto_cfn.py +++ b/salt/modules/boto_cfn.py @@ -52,6 +52,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_cloudfront.py b/salt/modules/boto_cloudfront.py index 7e4db092d06..4587966a371 100644 --- a/salt/modules/boto_cloudfront.py +++ b/salt/modules/boto_cloudfront.py @@ -68,6 +68,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_cloudtrail.py b/salt/modules/boto_cloudtrail.py index 25c165bd424..154d86880b5 100644 --- a/salt/modules/boto_cloudtrail.py +++ b/salt/modules/boto_cloudtrail.py @@ -72,6 +72,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_cloudwatch.py b/salt/modules/boto_cloudwatch.py index f7967d23876..cdf9720c13e 100644 --- a/salt/modules/boto_cloudwatch.py +++ b/salt/modules/boto_cloudwatch.py @@ -65,6 +65,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto libraries exist. diff --git a/salt/modules/boto_cloudwatch_event.py b/salt/modules/boto_cloudwatch_event.py index 1e8def652d1..92091af075e 100644 --- a/salt/modules/boto_cloudwatch_event.py +++ b/salt/modules/boto_cloudwatch_event.py @@ -67,6 +67,13 @@ except ImportError as e: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_cognitoidentity.py b/salt/modules/boto_cognitoidentity.py index 5d8e7d8aa8f..9f2c05d773b 100644 --- a/salt/modules/boto_cognitoidentity.py +++ b/salt/modules/boto_cognitoidentity.py @@ -100,6 +100,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_datapipeline.py b/salt/modules/boto_datapipeline.py index 52d5872d360..9bc1cfa8381 100644 --- a/salt/modules/boto_datapipeline.py +++ b/salt/modules/boto_datapipeline.py @@ -23,6 +23,13 @@ try: except ImportError: HAS_BOTO3 = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_dynamodb.py b/salt/modules/boto_dynamodb.py index 29e2757f63b..c696e2b638e 100644 --- a/salt/modules/boto_dynamodb.py +++ b/salt/modules/boto_dynamodb.py @@ -80,6 +80,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_ec2.py b/salt/modules/boto_ec2.py index be4edce11dc..f2a50003ff3 100644 --- a/salt/modules/boto_ec2.py +++ b/salt/modules/boto_ec2.py @@ -71,6 +71,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_efs.py b/salt/modules/boto_efs.py index 70f226bf67c..f091de16ee9 100644 --- a/salt/modules/boto_efs.py +++ b/salt/modules/boto_efs.py @@ -63,6 +63,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto3 libraries exist and if boto3 libraries are greater than diff --git a/salt/modules/boto_elasticache.py b/salt/modules/boto_elasticache.py index 43f183b0f39..155ce8c4f0d 100644 --- a/salt/modules/boto_elasticache.py +++ b/salt/modules/boto_elasticache.py @@ -66,6 +66,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_elasticsearch_domain.py b/salt/modules/boto_elasticsearch_domain.py index 050ef2f011b..7adf6d38ec8 100644 --- a/salt/modules/boto_elasticsearch_domain.py +++ b/salt/modules/boto_elasticsearch_domain.py @@ -100,6 +100,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_elb.py b/salt/modules/boto_elb.py index 310b91134bf..16dccbf9952 100644 --- a/salt/modules/boto_elb.py +++ b/salt/modules/boto_elb.py @@ -68,6 +68,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_elbv2.py b/salt/modules/boto_elbv2.py index d91927caa67..1ce1d5da9f4 100644 --- a/salt/modules/boto_elbv2.py +++ b/salt/modules/boto_elbv2.py @@ -59,6 +59,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_iam.py b/salt/modules/boto_iam.py index 521b1ff7140..308b0511356 100644 --- a/salt/modules/boto_iam.py +++ b/salt/modules/boto_iam.py @@ -62,6 +62,13 @@ except ImportError: log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_iot.py b/salt/modules/boto_iot.py index 1243a1700f9..5c5dd07401e 100644 --- a/salt/modules/boto_iot.py +++ b/salt/modules/boto_iot.py @@ -76,6 +76,13 @@ except ImportError: # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto libraries exist and if boto libraries are greater than diff --git a/salt/modules/boto_kinesis.py b/salt/modules/boto_kinesis.py index 846defa5d6a..07b0245c3ad 100644 --- a/salt/modules/boto_kinesis.py +++ b/salt/modules/boto_kinesis.py @@ -66,6 +66,13 @@ log = logging.getLogger(__name__) __virtualname__ = "boto_kinesis" +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_kms.py b/salt/modules/boto_kms.py index ac106655d5b..02fdb86b59e 100644 --- a/salt/modules/boto_kms.py +++ b/salt/modules/boto_kms.py @@ -56,6 +56,13 @@ try: except (ImportError, AttributeError): HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_lambda.py b/salt/modules/boto_lambda.py index 5dcd82a3634..7b1ea276fed 100644 --- a/salt/modules/boto_lambda.py +++ b/salt/modules/boto_lambda.py @@ -108,6 +108,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_rds.py b/salt/modules/boto_rds.py index 129c80bc6fe..0122fe022a5 100644 --- a/salt/modules/boto_rds.py +++ b/salt/modules/boto_rds.py @@ -127,6 +127,13 @@ def __virtual__(): return salt.utils.versions.check_boto_reqs(boto3_ver="1.3.1") +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __init__(opts): if HAS_BOTO: __utils__["boto3.assign_funcs"](__name__, "rds") diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py index 500e6f2cb78..48d19d0bd32 100644 --- a/salt/modules/boto_route53.py +++ b/salt/modules/boto_route53.py @@ -68,6 +68,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_s3.py b/salt/modules/boto_s3.py index bef68657e9b..1ae7936a57c 100644 --- a/salt/modules/boto_s3.py +++ b/salt/modules/boto_s3.py @@ -70,6 +70,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_s3_bucket.py b/salt/modules/boto_s3_bucket.py index 9fc2417cbfc..b6382b4872a 100644 --- a/salt/modules/boto_s3_bucket.py +++ b/salt/modules/boto_s3_bucket.py @@ -76,6 +76,13 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_secgroup.py b/salt/modules/boto_secgroup.py index 97941147933..635fa2c2541 100644 --- a/salt/modules/boto_secgroup.py +++ b/salt/modules/boto_secgroup.py @@ -64,6 +64,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_sns.py b/salt/modules/boto_sns.py index 7df58b95e5a..417eaa66484 100644 --- a/salt/modules/boto_sns.py +++ b/salt/modules/boto_sns.py @@ -59,6 +59,13 @@ try: except ImportError: HAS_BOTO = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_sqs.py b/salt/modules/boto_sqs.py index c2a572ab248..afb127b85ae 100644 --- a/salt/modules/boto_sqs.py +++ b/salt/modules/boto_sqs.py @@ -68,6 +68,13 @@ except ImportError: HAS_BOTO3 = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto3 libraries exist. diff --git a/salt/modules/boto_ssm.py b/salt/modules/boto_ssm.py index f2908a46edc..10c403d2df7 100644 --- a/salt/modules/boto_ssm.py +++ b/salt/modules/boto_ssm.py @@ -19,6 +19,13 @@ import salt.utils.versions log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/modules/boto_vpc.py b/salt/modules/boto_vpc.py index ee7a757e2b2..cf712c9950e 100644 --- a/salt/modules/boto_vpc.py +++ b/salt/modules/boto_vpc.py @@ -168,6 +168,13 @@ try: except ImportError: HAS_BOTO3 = False +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto3_elasticache.py b/salt/states/boto3_elasticache.py index 0cf1a867851..80198076c99 100644 --- a/salt/states/boto3_elasticache.py +++ b/salt/states/boto3_elasticache.py @@ -87,6 +87,12 @@ passed in as a dict, or as a string to pull from pillars or minion config: key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs """ +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto3_elasticsearch.py b/salt/states/boto3_elasticsearch.py index ff0dae55457..92fcf6d073e 100644 --- a/salt/states/boto3_elasticsearch.py +++ b/salt/states/boto3_elasticsearch.py @@ -50,6 +50,13 @@ import salt.utils.json from salt.utils.versions import Version log = logging.getLogger(__name__) + +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) __virtualname__ = "boto3_elasticsearch" diff --git a/salt/states/boto3_route53.py b/salt/states/boto3_route53.py index 3edbc57a870..39014b2931c 100644 --- a/salt/states/boto3_route53.py +++ b/salt/states/boto3_route53.py @@ -73,6 +73,12 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) # pylint: disable=W1699 +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto3_sns.py b/salt/states/boto3_sns.py index 30509176e70..6ead5f0e859 100644 --- a/salt/states/boto3_sns.py +++ b/salt/states/boto3_sns.py @@ -70,6 +70,12 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_apigateway.py b/salt/states/boto_apigateway.py index f70edf470f1..135513c513e 100644 --- a/salt/states/boto_apigateway.py +++ b/salt/states/boto_apigateway.py @@ -62,6 +62,12 @@ import salt.utils.yaml log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_asg.py b/salt/states/boto_asg.py index 58a5baed2ca..b92ec2f926e 100644 --- a/salt/states/boto_asg.py +++ b/salt/states/boto_asg.py @@ -202,6 +202,12 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_cfn.py b/salt/states/boto_cfn.py index 971514a3b6b..8aca0c2e104 100644 --- a/salt/states/boto_cfn.py +++ b/salt/states/boto_cfn.py @@ -46,6 +46,13 @@ log = logging.getLogger(__name__) __virtualname__ = "boto_cfn" +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_cloudfront.py b/salt/states/boto_cloudfront.py index db83cc10b80..63d446f9a87 100644 --- a/salt/states/boto_cloudfront.py +++ b/salt/states/boto_cloudfront.py @@ -47,8 +47,15 @@ either passed in as a dict, or a string to pull from pillars or minion config: import difflib import logging + log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_cloudtrail.py b/salt/states/boto_cloudtrail.py index 5699ef2033d..a157fce4778 100644 --- a/salt/states/boto_cloudtrail.py +++ b/salt/states/boto_cloudtrail.py @@ -61,6 +61,13 @@ import salt.utils.data log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto is available. diff --git a/salt/states/boto_cloudwatch_alarm.py b/salt/states/boto_cloudwatch_alarm.py index a3737765dff..817bffc924c 100644 --- a/salt/states/boto_cloudwatch_alarm.py +++ b/salt/states/boto_cloudwatch_alarm.py @@ -55,6 +55,12 @@ as a passed in dict, or as a string to pull from pillars or minion config: import salt.utils.data +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_cloudwatch_event.py b/salt/states/boto_cloudwatch_event.py index 4a421549bfc..51d850215dc 100644 --- a/salt/states/boto_cloudwatch_event.py +++ b/salt/states/boto_cloudwatch_event.py @@ -59,6 +59,12 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_cognitoidentity.py b/salt/states/boto_cognitoidentity.py index cb6905a2781..6ba21169365 100644 --- a/salt/states/boto_cognitoidentity.py +++ b/salt/states/boto_cognitoidentity.py @@ -50,6 +50,13 @@ import logging log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_datapipeline.py b/salt/states/boto_datapipeline.py index e42e328791e..8c5a0d142f3 100644 --- a/salt/states/boto_datapipeline.py +++ b/salt/states/boto_datapipeline.py @@ -56,6 +56,13 @@ import difflib import salt.utils.data import salt.utils.json +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_dynamodb.py b/salt/states/boto_dynamodb.py index 8e563ba0574..14e5422e80b 100644 --- a/salt/states/boto_dynamodb.py +++ b/salt/states/boto_dynamodb.py @@ -162,6 +162,12 @@ import sys import salt.utils.dictupdate as dictupdate +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) logging.basicConfig( level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s", diff --git a/salt/states/boto_ec2.py b/salt/states/boto_ec2.py index 773016b48a7..995a706682f 100644 --- a/salt/states/boto_ec2.py +++ b/salt/states/boto_ec2.py @@ -60,6 +60,13 @@ from salt.exceptions import CommandExecutionError, SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_elasticache.py b/salt/states/boto_elasticache.py index f46b2f7a1b4..6a36924227a 100644 --- a/salt/states/boto_elasticache.py +++ b/salt/states/boto_elasticache.py @@ -78,8 +78,15 @@ passed in as a dict, or as a string to pull from pillars or minion config: import logging + log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_elasticsearch_domain.py b/salt/states/boto_elasticsearch_domain.py index 4c47222b560..ed5d4cbb534 100644 --- a/salt/states/boto_elasticsearch_domain.py +++ b/salt/states/boto_elasticsearch_domain.py @@ -85,6 +85,12 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_elb.py b/salt/states/boto_elb.py index 0fd59a31088..4e24c4237d7 100644 --- a/salt/states/boto_elb.py +++ b/salt/states/boto_elb.py @@ -246,6 +246,13 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_elbv2.py b/salt/states/boto_elbv2.py index b3c2fe2a2e0..d8069076b44 100644 --- a/salt/states/boto_elbv2.py +++ b/salt/states/boto_elbv2.py @@ -36,8 +36,16 @@ passed in as a dict, or as a string to pull from pillars or minion config: import copy import logging + log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_iam.py b/salt/states/boto_iam.py index 93400521fce..7a4a7f90bd4 100644 --- a/salt/states/boto_iam.py +++ b/salt/states/boto_iam.py @@ -146,6 +146,14 @@ log = logging.getLogger(__name__) __virtualname__ = "boto_iam" +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + + def __virtual__(): """ Only load if elementtree xml library and boto are available. diff --git a/salt/states/boto_iam_role.py b/salt/states/boto_iam_role.py index 67c41f760a0..d4ccfe79789 100644 --- a/salt/states/boto_iam_role.py +++ b/salt/states/boto_iam_role.py @@ -94,6 +94,13 @@ from salt.utils.odict import OrderedDict log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_iot.py b/salt/states/boto_iot.py index e14d1541949..9fb044cb92a 100644 --- a/salt/states/boto_iot.py +++ b/salt/states/boto_iot.py @@ -80,6 +80,13 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_kinesis.py b/salt/states/boto_kinesis.py index 5809ef711e5..b3bdb607750 100644 --- a/salt/states/boto_kinesis.py +++ b/salt/states/boto_kinesis.py @@ -60,10 +60,18 @@ pillars or minion config: # Keep pylint from chocking on ret import logging + log = logging.getLogger(__name__) __virtualname__ = "boto_kinesis" +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_lambda.py b/salt/states/boto_lambda.py index cd8bca05f52..ea8b500aec8 100644 --- a/salt/states/boto_lambda.py +++ b/salt/states/boto_lambda.py @@ -72,6 +72,13 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_lc.py b/salt/states/boto_lc.py index c993beb7243..3f7744a482d 100644 --- a/salt/states/boto_lc.py +++ b/salt/states/boto_lc.py @@ -100,6 +100,12 @@ and autoscale groups are completely dependent on each other. from salt.exceptions import SaltInvocationError +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): """ diff --git a/salt/states/boto_rds.py b/salt/states/boto_rds.py index b5894c1fbd3..1e607171064 100644 --- a/salt/states/boto_rds.py +++ b/salt/states/boto_rds.py @@ -77,6 +77,13 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_route53.py b/salt/states/boto_route53.py index 0143c4e276f..4cbef9d2f2c 100644 --- a/salt/states/boto_route53.py +++ b/salt/states/boto_route53.py @@ -80,6 +80,13 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_s3.py b/salt/states/boto_s3.py index d466374cc27..31880282272 100644 --- a/salt/states/boto_s3.py +++ b/salt/states/boto_s3.py @@ -57,6 +57,13 @@ import salt.utils.hashutils log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_s3_bucket.py b/salt/states/boto_s3_bucket.py index 66dc68db08d..e874c3548a8 100644 --- a/salt/states/boto_s3_bucket.py +++ b/salt/states/boto_s3_bucket.py @@ -145,6 +145,13 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_secgroup.py b/salt/states/boto_secgroup.py index b4037ad11a2..7f734e23429 100644 --- a/salt/states/boto_secgroup.py +++ b/salt/states/boto_secgroup.py @@ -111,6 +111,13 @@ from salt.exceptions import SaltInvocationError log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ diff --git a/salt/states/boto_sns.py b/salt/states/boto_sns.py index d4e4c05133b..0c8c6689f41 100644 --- a/salt/states/boto_sns.py +++ b/salt/states/boto_sns.py @@ -58,6 +58,14 @@ passed in as a dict, or as a string to pull from pillars or minion config: import re +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + + def __virtual__(): """ Only load if boto is available. diff --git a/salt/states/boto_sqs.py b/salt/states/boto_sqs.py index 0c3784070c9..2ec4eb80304 100644 --- a/salt/states/boto_sqs.py +++ b/salt/states/boto_sqs.py @@ -65,6 +65,13 @@ import salt.utils.json log = logging.getLogger(__name__) +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) + def __virtual__(): """ Only load if boto is available. diff --git a/salt/states/boto_vpc.py b/salt/states/boto_vpc.py index d822adbbeb7..f036be63622 100644 --- a/salt/states/boto_vpc.py +++ b/salt/states/boto_vpc.py @@ -144,11 +144,19 @@ Delete also accepts a VPC peering connection id. import logging +log = logging.getLogger(__name__) + import salt.utils.dictupdate as dictupdate __virtualname__ = "boto_vpc" -log = logging.getLogger(__name__) + +__deprecated__ = ( + 3009, + "Potassium", + "boto", + "https://github.com/salt-extensions/saltext-boto" +) def __virtual__(): From d695107f7cfd4fb8e3812116be0a575e46e3cf28 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 9 Jun 2023 09:32:16 -0700 Subject: [PATCH 2/5] Simplify the deprecation decorator and deprecated dictionary and only use the version number. --- salt/modules/boto3_elasticache.py | 7 +------ salt/modules/boto3_elasticsearch.py | 7 +------ salt/modules/boto3_route53.py | 7 +------ salt/modules/boto3_sns.py | 7 +------ salt/modules/boto_apigateway.py | 8 ++------ salt/modules/boto_asg.py | 7 +------ salt/modules/boto_cfn.py | 7 +------ salt/modules/boto_cloudfront.py | 7 +------ salt/modules/boto_cloudtrail.py | 7 +------ salt/modules/boto_cloudwatch.py | 8 ++------ salt/modules/boto_cloudwatch_event.py | 7 +------ salt/modules/boto_cognitoidentity.py | 7 +------ salt/modules/boto_datapipeline.py | 7 +------ salt/modules/boto_dynamodb.py | 7 +------ salt/modules/boto_ec2.py | 7 +------ salt/modules/boto_efs.py | 8 ++------ salt/modules/boto_elasticache.py | 7 +------ salt/modules/boto_elasticsearch_domain.py | 7 +------ salt/modules/boto_elb.py | 7 +------ salt/modules/boto_elbv2.py | 7 +------ salt/modules/boto_iam.py | 7 +------ salt/modules/boto_iot.py | 8 ++------ salt/modules/boto_kinesis.py | 7 +------ salt/modules/boto_kms.py | 7 +------ salt/modules/boto_lambda.py | 7 +------ salt/modules/boto_rds.py | 8 ++------ salt/modules/boto_route53.py | 7 +------ salt/modules/boto_s3.py | 7 +------ salt/modules/boto_s3_bucket.py | 7 +------ salt/modules/boto_secgroup.py | 7 +------ salt/modules/boto_sns.py | 7 +------ salt/modules/boto_sqs.py | 8 ++------ salt/modules/boto_ssm.py | 7 +------ salt/modules/boto_vpc.py | 7 +------ 34 files changed, 40 insertions(+), 204 deletions(-) diff --git a/salt/modules/boto3_elasticache.py b/salt/modules/boto3_elasticache.py index a2f7bdf1c9c..ff61198deb3 100644 --- a/salt/modules/boto3_elasticache.py +++ b/salt/modules/boto3_elasticache.py @@ -66,12 +66,7 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto3_elasticsearch.py b/salt/modules/boto3_elasticsearch.py index 4fe77a2095d..1778cccd264 100644 --- a/salt/modules/boto3_elasticsearch.py +++ b/salt/modules/boto3_elasticsearch.py @@ -74,12 +74,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto3_route53.py b/salt/modules/boto3_route53.py index e1c2b873a91..23dd1914ecb 100644 --- a/salt/modules/boto3_route53.py +++ b/salt/modules/boto3_route53.py @@ -70,12 +70,7 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto3_sns.py b/salt/modules/boto3_sns.py index 49d784fa19f..380085e9f97 100644 --- a/salt/modules/boto3_sns.py +++ b/salt/modules/boto3_sns.py @@ -60,12 +60,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=unused-import -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_apigateway.py b/salt/modules/boto_apigateway.py index 9f2463a708e..7682bb8e921 100644 --- a/salt/modules/boto_apigateway.py +++ b/salt/modules/boto_apigateway.py @@ -106,12 +106,8 @@ except ImportError: # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __virtual__(): """ diff --git a/salt/modules/boto_asg.py b/salt/modules/boto_asg.py index 8980c5ecb58..410706fba18 100644 --- a/salt/modules/boto_asg.py +++ b/salt/modules/boto_asg.py @@ -76,12 +76,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_cfn.py b/salt/modules/boto_cfn.py index c3f2aacfbba..86ef9de7732 100644 --- a/salt/modules/boto_cfn.py +++ b/salt/modules/boto_cfn.py @@ -52,12 +52,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_cloudfront.py b/salt/modules/boto_cloudfront.py index 4587966a371..64b3fe23eb9 100644 --- a/salt/modules/boto_cloudfront.py +++ b/salt/modules/boto_cloudfront.py @@ -68,12 +68,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_cloudtrail.py b/salt/modules/boto_cloudtrail.py index 154d86880b5..ec3815dad28 100644 --- a/salt/modules/boto_cloudtrail.py +++ b/salt/modules/boto_cloudtrail.py @@ -72,12 +72,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_cloudwatch.py b/salt/modules/boto_cloudwatch.py index cdf9720c13e..9676d18d2bb 100644 --- a/salt/modules/boto_cloudwatch.py +++ b/salt/modules/boto_cloudwatch.py @@ -65,12 +65,8 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __virtual__(): """ diff --git a/salt/modules/boto_cloudwatch_event.py b/salt/modules/boto_cloudwatch_event.py index 92091af075e..86b7c6cbbc6 100644 --- a/salt/modules/boto_cloudwatch_event.py +++ b/salt/modules/boto_cloudwatch_event.py @@ -67,12 +67,7 @@ except ImportError as e: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_cognitoidentity.py b/salt/modules/boto_cognitoidentity.py index 9f2c05d773b..0b4699078e3 100644 --- a/salt/modules/boto_cognitoidentity.py +++ b/salt/modules/boto_cognitoidentity.py @@ -100,12 +100,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_datapipeline.py b/salt/modules/boto_datapipeline.py index 9bc1cfa8381..88959d71b60 100644 --- a/salt/modules/boto_datapipeline.py +++ b/salt/modules/boto_datapipeline.py @@ -23,12 +23,7 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_dynamodb.py b/salt/modules/boto_dynamodb.py index c696e2b638e..d62d27b2fa9 100644 --- a/salt/modules/boto_dynamodb.py +++ b/salt/modules/boto_dynamodb.py @@ -80,12 +80,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_ec2.py b/salt/modules/boto_ec2.py index f2a50003ff3..31e2cb4e043 100644 --- a/salt/modules/boto_ec2.py +++ b/salt/modules/boto_ec2.py @@ -71,12 +71,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_efs.py b/salt/modules/boto_efs.py index f091de16ee9..ec99ab8624d 100644 --- a/salt/modules/boto_efs.py +++ b/salt/modules/boto_efs.py @@ -63,12 +63,8 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __virtual__(): """ diff --git a/salt/modules/boto_elasticache.py b/salt/modules/boto_elasticache.py index 155ce8c4f0d..3986a9389a3 100644 --- a/salt/modules/boto_elasticache.py +++ b/salt/modules/boto_elasticache.py @@ -66,12 +66,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_elasticsearch_domain.py b/salt/modules/boto_elasticsearch_domain.py index 7adf6d38ec8..42535d1a0b5 100644 --- a/salt/modules/boto_elasticsearch_domain.py +++ b/salt/modules/boto_elasticsearch_domain.py @@ -100,12 +100,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_elb.py b/salt/modules/boto_elb.py index 16dccbf9952..3b9e2690029 100644 --- a/salt/modules/boto_elb.py +++ b/salt/modules/boto_elb.py @@ -68,12 +68,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_elbv2.py b/salt/modules/boto_elbv2.py index 1ce1d5da9f4..90a888b2233 100644 --- a/salt/modules/boto_elbv2.py +++ b/salt/modules/boto_elbv2.py @@ -59,12 +59,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_iam.py b/salt/modules/boto_iam.py index 308b0511356..5ec99cdae7f 100644 --- a/salt/modules/boto_iam.py +++ b/salt/modules/boto_iam.py @@ -62,12 +62,7 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_iot.py b/salt/modules/boto_iot.py index 5c5dd07401e..a00ba03df15 100644 --- a/salt/modules/boto_iot.py +++ b/salt/modules/boto_iot.py @@ -76,12 +76,8 @@ except ImportError: # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __virtual__(): """ diff --git a/salt/modules/boto_kinesis.py b/salt/modules/boto_kinesis.py index 07b0245c3ad..4db0c09492b 100644 --- a/salt/modules/boto_kinesis.py +++ b/salt/modules/boto_kinesis.py @@ -66,12 +66,7 @@ log = logging.getLogger(__name__) __virtualname__ = "boto_kinesis" -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_kms.py b/salt/modules/boto_kms.py index 02fdb86b59e..6d3eaffc777 100644 --- a/salt/modules/boto_kms.py +++ b/salt/modules/boto_kms.py @@ -56,12 +56,7 @@ try: except (ImportError, AttributeError): HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_lambda.py b/salt/modules/boto_lambda.py index 7b1ea276fed..f86a2d7f192 100644 --- a/salt/modules/boto_lambda.py +++ b/salt/modules/boto_lambda.py @@ -108,12 +108,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_rds.py b/salt/modules/boto_rds.py index 0122fe022a5..bbde061b530 100644 --- a/salt/modules/boto_rds.py +++ b/salt/modules/boto_rds.py @@ -127,12 +127,8 @@ def __virtual__(): return salt.utils.versions.check_boto_reqs(boto3_ver="1.3.1") -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __init__(opts): if HAS_BOTO: diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py index 48d19d0bd32..e3f2278e96f 100644 --- a/salt/modules/boto_route53.py +++ b/salt/modules/boto_route53.py @@ -68,12 +68,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_s3.py b/salt/modules/boto_s3.py index 1ae7936a57c..016b9908180 100644 --- a/salt/modules/boto_s3.py +++ b/salt/modules/boto_s3.py @@ -70,12 +70,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_s3_bucket.py b/salt/modules/boto_s3_bucket.py index b6382b4872a..bc6d0318a68 100644 --- a/salt/modules/boto_s3_bucket.py +++ b/salt/modules/boto_s3_bucket.py @@ -76,12 +76,7 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_secgroup.py b/salt/modules/boto_secgroup.py index 635fa2c2541..79e21853b72 100644 --- a/salt/modules/boto_secgroup.py +++ b/salt/modules/boto_secgroup.py @@ -64,12 +64,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_sns.py b/salt/modules/boto_sns.py index 417eaa66484..fb64cced34c 100644 --- a/salt/modules/boto_sns.py +++ b/salt/modules/boto_sns.py @@ -59,12 +59,7 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_sqs.py b/salt/modules/boto_sqs.py index afb127b85ae..bcbd9444b3c 100644 --- a/salt/modules/boto_sqs.py +++ b/salt/modules/boto_sqs.py @@ -68,12 +68,8 @@ except ImportError: HAS_BOTO3 = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") + def __virtual__(): """ diff --git a/salt/modules/boto_ssm.py b/salt/modules/boto_ssm.py index 10c403d2df7..8722ef263cc 100644 --- a/salt/modules/boto_ssm.py +++ b/salt/modules/boto_ssm.py @@ -19,12 +19,7 @@ import salt.utils.versions log = logging.getLogger(__name__) -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): diff --git a/salt/modules/boto_vpc.py b/salt/modules/boto_vpc.py index cf712c9950e..63dc1f3120f 100644 --- a/salt/modules/boto_vpc.py +++ b/salt/modules/boto_vpc.py @@ -168,12 +168,7 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = ( - 3009, - "Potassium", - "boto", - "https://github.com/salt-extensions/saltext-boto" -) +__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") def __virtual__(): From 8774069f7d842492b015feefdef66b02b8c2c9d9 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 9 Jun 2023 14:12:44 -0700 Subject: [PATCH 3/5] fixing deprecated dict for states. --- salt/states/boto3_elasticache.py | 1 - salt/states/boto3_elasticsearch.py | 1 - salt/states/boto3_route53.py | 1 - salt/states/boto3_sns.py | 1 - salt/states/boto_apigateway.py | 1 - salt/states/boto_asg.py | 1 - salt/states/boto_cfn.py | 1 - salt/states/boto_cloudfront.py | 1 - salt/states/boto_cloudtrail.py | 1 - salt/states/boto_cloudwatch_alarm.py | 1 - salt/states/boto_cloudwatch_event.py | 1 - salt/states/boto_cognitoidentity.py | 1 - salt/states/boto_datapipeline.py | 1 - salt/states/boto_dynamodb.py | 1 - salt/states/boto_ec2.py | 1 - salt/states/boto_elasticache.py | 1 - salt/states/boto_elasticsearch_domain.py | 1 - salt/states/boto_elb.py | 1 - salt/states/boto_elbv2.py | 1 - salt/states/boto_iam.py | 1 - salt/states/boto_iam_role.py | 1 - salt/states/boto_iot.py | 1 - salt/states/boto_kinesis.py | 1 - salt/states/boto_kms.py | 6 ++++++ salt/states/boto_lambda.py | 1 - salt/states/boto_lc.py | 1 - salt/states/boto_rds.py | 1 - salt/states/boto_route53.py | 1 - salt/states/boto_s3.py | 1 - salt/states/boto_s3_bucket.py | 1 - salt/states/boto_secgroup.py | 1 - salt/states/boto_sns.py | 1 - salt/states/boto_sqs.py | 1 - salt/states/boto_vpc.py | 1 - 34 files changed, 6 insertions(+), 33 deletions(-) diff --git a/salt/states/boto3_elasticache.py b/salt/states/boto3_elasticache.py index 80198076c99..10989a8f1b8 100644 --- a/salt/states/boto3_elasticache.py +++ b/salt/states/boto3_elasticache.py @@ -89,7 +89,6 @@ passed in as a dict, or as a string to pull from pillars or minion config: __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto3_elasticsearch.py b/salt/states/boto3_elasticsearch.py index 92fcf6d073e..2b27080faea 100644 --- a/salt/states/boto3_elasticsearch.py +++ b/salt/states/boto3_elasticsearch.py @@ -53,7 +53,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto3_route53.py b/salt/states/boto3_route53.py index 39014b2931c..bbaf25e5148 100644 --- a/salt/states/boto3_route53.py +++ b/salt/states/boto3_route53.py @@ -75,7 +75,6 @@ log = logging.getLogger(__name__) # pylint: disable=W1699 __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto3_sns.py b/salt/states/boto3_sns.py index 6ead5f0e859..5f0b4a14148 100644 --- a/salt/states/boto3_sns.py +++ b/salt/states/boto3_sns.py @@ -72,7 +72,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_apigateway.py b/salt/states/boto_apigateway.py index 135513c513e..e96042d78fe 100644 --- a/salt/states/boto_apigateway.py +++ b/salt/states/boto_apigateway.py @@ -64,7 +64,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_asg.py b/salt/states/boto_asg.py index b92ec2f926e..5241d054d5a 100644 --- a/salt/states/boto_asg.py +++ b/salt/states/boto_asg.py @@ -204,7 +204,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cfn.py b/salt/states/boto_cfn.py index 8aca0c2e104..d994752abc5 100644 --- a/salt/states/boto_cfn.py +++ b/salt/states/boto_cfn.py @@ -48,7 +48,6 @@ __virtualname__ = "boto_cfn" __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cloudfront.py b/salt/states/boto_cloudfront.py index 63d446f9a87..71fe499a7d4 100644 --- a/salt/states/boto_cloudfront.py +++ b/salt/states/boto_cloudfront.py @@ -52,7 +52,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cloudtrail.py b/salt/states/boto_cloudtrail.py index a157fce4778..d9fb63c5e33 100644 --- a/salt/states/boto_cloudtrail.py +++ b/salt/states/boto_cloudtrail.py @@ -63,7 +63,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cloudwatch_alarm.py b/salt/states/boto_cloudwatch_alarm.py index 817bffc924c..b56074d4d78 100644 --- a/salt/states/boto_cloudwatch_alarm.py +++ b/salt/states/boto_cloudwatch_alarm.py @@ -57,7 +57,6 @@ import salt.utils.data __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cloudwatch_event.py b/salt/states/boto_cloudwatch_event.py index 51d850215dc..2e956eaf235 100644 --- a/salt/states/boto_cloudwatch_event.py +++ b/salt/states/boto_cloudwatch_event.py @@ -61,7 +61,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_cognitoidentity.py b/salt/states/boto_cognitoidentity.py index 6ba21169365..c514a336dc7 100644 --- a/salt/states/boto_cognitoidentity.py +++ b/salt/states/boto_cognitoidentity.py @@ -52,7 +52,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_datapipeline.py b/salt/states/boto_datapipeline.py index 8c5a0d142f3..4401bc18893 100644 --- a/salt/states/boto_datapipeline.py +++ b/salt/states/boto_datapipeline.py @@ -58,7 +58,6 @@ import salt.utils.json __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_dynamodb.py b/salt/states/boto_dynamodb.py index 14e5422e80b..c296684a395 100644 --- a/salt/states/boto_dynamodb.py +++ b/salt/states/boto_dynamodb.py @@ -164,7 +164,6 @@ import salt.utils.dictupdate as dictupdate __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_ec2.py b/salt/states/boto_ec2.py index 995a706682f..ba3e0953c12 100644 --- a/salt/states/boto_ec2.py +++ b/salt/states/boto_ec2.py @@ -62,7 +62,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_elasticache.py b/salt/states/boto_elasticache.py index 6a36924227a..9e4cdbdab6d 100644 --- a/salt/states/boto_elasticache.py +++ b/salt/states/boto_elasticache.py @@ -83,7 +83,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_elasticsearch_domain.py b/salt/states/boto_elasticsearch_domain.py index ed5d4cbb534..c4a25e04f1e 100644 --- a/salt/states/boto_elasticsearch_domain.py +++ b/salt/states/boto_elasticsearch_domain.py @@ -87,7 +87,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_elb.py b/salt/states/boto_elb.py index 4e24c4237d7..e3c975f389c 100644 --- a/salt/states/boto_elb.py +++ b/salt/states/boto_elb.py @@ -248,7 +248,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_elbv2.py b/salt/states/boto_elbv2.py index d8069076b44..5f74fcbfeaa 100644 --- a/salt/states/boto_elbv2.py +++ b/salt/states/boto_elbv2.py @@ -41,7 +41,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_iam.py b/salt/states/boto_iam.py index 7a4a7f90bd4..841e02abf0c 100644 --- a/salt/states/boto_iam.py +++ b/salt/states/boto_iam.py @@ -148,7 +148,6 @@ __virtualname__ = "boto_iam" __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_iam_role.py b/salt/states/boto_iam_role.py index d4ccfe79789..63927a108be 100644 --- a/salt/states/boto_iam_role.py +++ b/salt/states/boto_iam_role.py @@ -96,7 +96,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_iot.py b/salt/states/boto_iot.py index 9fb044cb92a..53a86b45a93 100644 --- a/salt/states/boto_iot.py +++ b/salt/states/boto_iot.py @@ -82,7 +82,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_kinesis.py b/salt/states/boto_kinesis.py index b3bdb607750..27fed723496 100644 --- a/salt/states/boto_kinesis.py +++ b/salt/states/boto_kinesis.py @@ -67,7 +67,6 @@ __virtualname__ = "boto_kinesis" __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_kms.py b/salt/states/boto_kms.py index aadc02093e8..26826d15ee6 100644 --- a/salt/states/boto_kms.py +++ b/salt/states/boto_kms.py @@ -59,6 +59,12 @@ config: import salt.utils.dictupdate as dictupdate from salt.exceptions import SaltInvocationError +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) + def __virtual__(): """ diff --git a/salt/states/boto_lambda.py b/salt/states/boto_lambda.py index ea8b500aec8..92453ddb289 100644 --- a/salt/states/boto_lambda.py +++ b/salt/states/boto_lambda.py @@ -74,7 +74,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_lc.py b/salt/states/boto_lc.py index 3f7744a482d..1a0c4d9cd11 100644 --- a/salt/states/boto_lc.py +++ b/salt/states/boto_lc.py @@ -102,7 +102,6 @@ from salt.exceptions import SaltInvocationError __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_rds.py b/salt/states/boto_rds.py index 1e607171064..c254a6c5bb1 100644 --- a/salt/states/boto_rds.py +++ b/salt/states/boto_rds.py @@ -79,7 +79,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_route53.py b/salt/states/boto_route53.py index 4cbef9d2f2c..ebd6d2194b0 100644 --- a/salt/states/boto_route53.py +++ b/salt/states/boto_route53.py @@ -82,7 +82,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_s3.py b/salt/states/boto_s3.py index 31880282272..864a899b8c4 100644 --- a/salt/states/boto_s3.py +++ b/salt/states/boto_s3.py @@ -59,7 +59,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_s3_bucket.py b/salt/states/boto_s3_bucket.py index e874c3548a8..cf8166fe8bd 100644 --- a/salt/states/boto_s3_bucket.py +++ b/salt/states/boto_s3_bucket.py @@ -147,7 +147,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_secgroup.py b/salt/states/boto_secgroup.py index 7f734e23429..ef73d7d2147 100644 --- a/salt/states/boto_secgroup.py +++ b/salt/states/boto_secgroup.py @@ -113,7 +113,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_sns.py b/salt/states/boto_sns.py index 0c8c6689f41..674268c5927 100644 --- a/salt/states/boto_sns.py +++ b/salt/states/boto_sns.py @@ -60,7 +60,6 @@ import re __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_sqs.py b/salt/states/boto_sqs.py index 2ec4eb80304..a8455d38a6f 100644 --- a/salt/states/boto_sqs.py +++ b/salt/states/boto_sqs.py @@ -67,7 +67,6 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) diff --git a/salt/states/boto_vpc.py b/salt/states/boto_vpc.py index f036be63622..669b97ef37f 100644 --- a/salt/states/boto_vpc.py +++ b/salt/states/boto_vpc.py @@ -153,7 +153,6 @@ __virtualname__ = "boto_vpc" __deprecated__ = ( 3009, - "Potassium", "boto", "https://github.com/salt-extensions/saltext-boto" ) From e698cfee2a73d890b62e35c53fc0a004114f4c1a Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Fri, 9 Jun 2023 09:58:32 -0700 Subject: [PATCH 4/5] Running pre-commit --- salt/modules/boto3_elasticache.py | 72 ++++----- salt/modules/boto_apigateway.py | 20 ++- salt/modules/boto_asg.py | 16 +- salt/modules/boto_cfn.py | 10 +- salt/modules/boto_cloudfront.py | 2 +- salt/modules/boto_cloudtrail.py | 2 +- salt/modules/boto_cloudwatch_event.py | 8 +- salt/modules/boto_cognitoidentity.py | 2 +- salt/modules/boto_datapipeline.py | 2 +- salt/modules/boto_ec2.py | 16 +- salt/modules/boto_elasticache.py | 36 ++--- salt/modules/boto_elasticsearch_domain.py | 4 +- salt/modules/boto_elb.py | 4 +- salt/modules/boto_iam.py | 2 +- salt/modules/boto_iot.py | 4 +- salt/modules/boto_kinesis.py | 2 +- salt/modules/boto_lambda.py | 8 +- salt/modules/boto_rds.py | 44 +++--- salt/modules/boto_route53.py | 8 +- salt/modules/boto_s3_bucket.py | 2 +- salt/modules/boto_secgroup.py | 6 +- salt/modules/boto_sns.py | 4 +- salt/modules/boto_vpc.py | 110 ++++++-------- salt/states/boto3_elasticache.py | 79 +++++----- salt/states/boto3_elasticsearch.py | 26 ++-- salt/states/boto3_route53.py | 7 +- salt/states/boto3_sns.py | 24 ++- salt/states/boto_apigateway.py | 107 +++++++------- salt/states/boto_asg.py | 7 +- salt/states/boto_cfn.py | 20 +-- salt/states/boto_cloudfront.py | 12 +- salt/states/boto_cloudtrail.py | 23 ++- salt/states/boto_cloudwatch_alarm.py | 23 +-- salt/states/boto_cloudwatch_event.py | 15 +- salt/states/boto_cognitoidentity.py | 12 +- salt/states/boto_datapipeline.py | 14 +- salt/states/boto_dynamodb.py | 46 +++--- salt/states/boto_ec2.py | 72 +++++---- salt/states/boto_elasticache.py | 42 +++--- salt/states/boto_elasticsearch_domain.py | 21 +-- salt/states/boto_elb.py | 126 ++++++++-------- salt/states/boto_elbv2.py | 45 +++--- salt/states/boto_iam.py | 172 +++++++++++----------- salt/states/boto_iam_role.py | 44 +++--- salt/states/boto_iot.py | 48 +++--- salt/states/boto_kinesis.py | 27 ++-- salt/states/boto_kms.py | 8 +- salt/states/boto_lambda.py | 46 +++--- salt/states/boto_lc.py | 3 +- salt/states/boto_rds.py | 58 ++++---- salt/states/boto_route53.py | 36 ++--- salt/states/boto_s3.py | 14 +- salt/states/boto_s3_bucket.py | 32 ++-- salt/states/boto_secgroup.py | 48 +++--- salt/states/boto_sns.py | 17 +-- salt/states/boto_sqs.py | 15 +- salt/states/boto_vpc.py | 76 +++++----- 57 files changed, 834 insertions(+), 915 deletions(-) diff --git a/salt/modules/boto3_elasticache.py b/salt/modules/boto3_elasticache.py index ff61198deb3..054beed1cd6 100644 --- a/salt/modules/boto3_elasticache.py +++ b/salt/modules/boto3_elasticache.py @@ -109,7 +109,7 @@ def _describe_resource( key=None, keyid=None, profile=None, - **args + **args, ): if conn is None: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) @@ -117,9 +117,7 @@ def _describe_resource( func = "describe_" + res_type + "s" f = getattr(conn, func) except (AttributeError, KeyError) as e: - raise SaltInvocationError( - "No function '{}()' found: {}".format(func, e.message) - ) + raise SaltInvocationError(f"No function '{func}()' found: {e.message}") # Undocumented, but you can't pass 'Marker' if searching for a specific resource... args.update({name_param: name} if name else {"Marker": ""}) args = {k: v for k, v in args.items() if not k.startswith("_")} @@ -142,7 +140,7 @@ def _delete_resource( key=None, keyid=None, profile=None, - **args + **args, ): """ Delete a generic Elasticache resource. @@ -173,9 +171,7 @@ def _delete_resource( func = "describe_" + res_type + "s" s = globals()[func] except (AttributeError, KeyError) as e: - raise SaltInvocationError( - "No function '{}()' found: {}".format(func, e.message) - ) + raise SaltInvocationError(f"No function '{func}()' found: {e.message}") try: f(**args) @@ -213,7 +209,7 @@ def _create_resource( key=None, keyid=None, profile=None, - **args + **args, ): try: wait = int(wait) @@ -241,9 +237,7 @@ def _create_resource( func = "describe_" + res_type + "s" s = globals()[func] except (AttributeError, KeyError) as e: - raise SaltInvocationError( - "No function '{}()' found: {}".format(func, e.message) - ) + raise SaltInvocationError(f"No function '{func}()' found: {e.message}") try: f(**args) if not wait: @@ -272,7 +266,7 @@ def _create_resource( ) return False except botocore.exceptions.ClientError as e: - msg = "Failed to create {} {}: {}".format(desc, name, e) + msg = f"Failed to create {desc} {name}: {e}" log.error(msg) return False @@ -289,7 +283,7 @@ def _modify_resource( key=None, keyid=None, profile=None, - **args + **args, ): try: wait = int(wait) @@ -317,9 +311,7 @@ def _modify_resource( func = "describe_" + res_type + "s" s = globals()[func] except (AttributeError, KeyError) as e: - raise SaltInvocationError( - "No function '{}()' found: {}".format(func, e.message) - ) + raise SaltInvocationError(f"No function '{func}()' found: {e.message}") try: f(**args) if not wait: @@ -348,7 +340,7 @@ def _modify_resource( ) return False except botocore.exceptions.ClientError as e: - msg = "Failed to modify {} {}: {}".format(desc, name, e) + msg = f"Failed to modify {desc} {name}: {e}" log.error(msg) return False @@ -376,7 +368,7 @@ def describe_cache_clusters( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -407,7 +399,7 @@ def create_cache_cluster( key=None, keyid=None, profile=None, - **args + **args, ): """ Create a cache cluster. @@ -444,7 +436,7 @@ def create_cache_cluster( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -456,7 +448,7 @@ def modify_cache_cluster( key=None, keyid=None, profile=None, - **args + **args, ): """ Update a cache cluster in place. @@ -498,7 +490,7 @@ def modify_cache_cluster( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -525,7 +517,7 @@ def delete_cache_cluster( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -580,7 +572,7 @@ def create_replication_group( key=None, keyid=None, profile=None, - **args + **args, ): """ Create a replication group. @@ -617,7 +609,7 @@ def create_replication_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -629,7 +621,7 @@ def modify_replication_group( key=None, keyid=None, profile=None, - **args + **args, ): """ Modify a replication group. @@ -663,7 +655,7 @@ def modify_replication_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -690,7 +682,7 @@ def delete_replication_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -785,13 +777,13 @@ def create_cache_subnet_group( ).get("subnets") if not sn: raise SaltInvocationError( - "Could not resolve Subnet Name {} to an ID.".format(subnet) + f"Could not resolve Subnet Name {subnet} to an ID." ) if len(sn) == 1: args["SubnetIds"] += [sn[0]["id"]] elif len(sn) > 1: raise CommandExecutionError( - "Subnet Name {} returned more than one ID.".format(subnet) + f"Subnet Name {subnet} returned more than one ID." ) args = {k: v for k, v in args.items() if not k.startswith("_")} return _create_resource( @@ -803,7 +795,7 @@ def create_cache_subnet_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -838,14 +830,14 @@ def modify_cache_subnet_group( args["SubnetIds"] += [sn[0]["id"]] elif len(sn) > 1: raise CommandExecutionError( - "Subnet Name {} returned more than one ID.".format(subnet) + f"Subnet Name {subnet} returned more than one ID." ) elif subnet.startswith("subnet-"): # Moderately safe assumption... :) Will be caught later if incorrect. args["SubnetIds"] += [subnet] else: raise SaltInvocationError( - "Could not resolve Subnet Name {} to an ID.".format(subnet) + f"Could not resolve Subnet Name {subnet} to an ID." ) args = {k: v for k, v in args.items() if not k.startswith("_")} return _modify_resource( @@ -857,7 +849,7 @@ def modify_cache_subnet_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -882,7 +874,7 @@ def delete_cache_subnet_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -950,7 +942,7 @@ def create_cache_security_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -975,7 +967,7 @@ def delete_cache_security_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -1266,7 +1258,7 @@ def create_cache_parameter_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) @@ -1291,5 +1283,5 @@ def delete_cache_parameter_group( key=key, keyid=keyid, profile=profile, - **args + **args, ) diff --git a/salt/modules/boto_apigateway.py b/salt/modules/boto_apigateway.py index 7682bb8e921..fe061491fd7 100644 --- a/salt/modules/boto_apigateway.py +++ b/salt/modules/boto_apigateway.py @@ -134,7 +134,7 @@ def _convert_datetime_str(response): if response: return dict( [ - (k, "{}".format(v)) if isinstance(v, datetime.date) else (k, v) + (k, f"{v}") if isinstance(v, datetime.date) else (k, v) for k, v in response.items() ] ) @@ -381,9 +381,9 @@ def create_api_resources( conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) for path_part in path_parts: if current_path == "/": - current_path = "{}{}".format(current_path, path_part) + current_path = f"{current_path}{path_part}" else: - current_path = "{}/{}".format(current_path, path_part) + current_path = f"{current_path}/{path_part}" r = describe_api_resource( restApiId, current_path, @@ -434,7 +434,7 @@ def delete_api_resources( conn.delete_resource(restApiId=restApiId, resourceId=resource["id"]) return {"deleted": True} else: - return {"deleted": False, "error": "no resource found by {}".format(path)} + return {"deleted": False, "error": f"no resource found by {path}"} except ClientError as e: return {"created": False, "error": __utils__["boto3.get_error"](e)} @@ -898,12 +898,12 @@ def overwrite_api_stage_variables( for old_var in old_vars: if old_var not in variables: patch_ops.append( - dict(op="remove", path="/variables/{}".format(old_var), value="") + dict(op="remove", path=f"/variables/{old_var}", value="") ) for var, val in variables.items(): if var not in old_vars or old_vars[var] != val: patch_ops.append( - dict(op="replace", path="/variables/{}".format(var), value=val) + dict(op="replace", path=f"/variables/{var}", value=val) ) if patch_ops: @@ -1625,7 +1625,7 @@ def _get_role_arn(name, region=None, key=None, keyid=None, profile=None): region=region, key=key, keyid=keyid, profile=profile ) - return "arn:aws:iam::{}:role/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:role/{name}" def create_api_integration( @@ -1802,7 +1802,7 @@ def _validate_throttle(throttle): if throttle is not None: if not isinstance(throttle, dict): raise TypeError( - "throttle must be a dictionary, provided value: {}".format(throttle) + f"throttle must be a dictionary, provided value: {throttle}" ) @@ -1812,9 +1812,7 @@ def _validate_quota(quota): """ if quota is not None: if not isinstance(quota, dict): - raise TypeError( - "quota must be a dictionary, provided value: {}".format(quota) - ) + raise TypeError(f"quota must be a dictionary, provided value: {quota}") periods = ["DAY", "WEEK", "MONTH"] if "period" not in quota or quota["period"] not in periods: raise ValueError( diff --git a/salt/modules/boto_asg.py b/salt/modules/boto_asg.py index 410706fba18..0926727c236 100644 --- a/salt/modules/boto_asg.py +++ b/salt/modules/boto_asg.py @@ -121,7 +121,7 @@ def exists(name, region=None, key=None, keyid=None, profile=None): if _conn: return True else: - msg = "The autoscale group does not exist in region {}".format(region) + msg = f"The autoscale group does not exist in region {region}" log.debug(msg) return False except boto.exception.BotoServerError as e: @@ -431,12 +431,12 @@ def update( key = tag.get("key") except KeyError: log.error("Tag missing key.") - return False, "Tag {} missing key".format(tag) + return False, f"Tag {tag} missing key" try: value = tag.get("value") except KeyError: log.error("Tag missing value.") - return False, "Tag {} missing value".format(tag) + return False, f"Tag {tag} missing value" propagate_at_launch = tag.get("propagate_at_launch", False) _tag = { "key": key, @@ -510,7 +510,7 @@ def update( retries -= 1 continue log.error(e) - msg = "Failed to update ASG {}".format(name) + msg = f"Failed to update ASG {name}" log.error(msg) return False, str(e) @@ -571,7 +571,7 @@ def delete(name, force=False, region=None, key=None, keyid=None, profile=None): while True: try: conn.delete_auto_scaling_group(name, force) - msg = "Deleted autoscale group {}.".format(name) + msg = f"Deleted autoscale group {name}." log.info(msg) return True except boto.exception.BotoServerError as e: @@ -581,7 +581,7 @@ def delete(name, force=False, region=None, key=None, keyid=None, profile=None): retries -= 1 continue log.error(e) - msg = "Failed to delete autoscale group {}".format(name) + msg = f"Failed to delete autoscale group {name}" log.error(msg) return False @@ -823,7 +823,7 @@ def create_launch_configuration( retries -= 1 continue log.error(e) - msg = "Failed to create LC {}".format(name) + msg = f"Failed to create LC {name}" log.error(msg) return False @@ -852,7 +852,7 @@ def delete_launch_configuration(name, region=None, key=None, keyid=None, profile retries -= 1 continue log.error(e) - msg = "Failed to delete LC {}".format(name) + msg = f"Failed to delete LC {name}" log.error(msg) return False diff --git a/salt/modules/boto_cfn.py b/salt/modules/boto_cfn.py index 86ef9de7732..5fe428b1386 100644 --- a/salt/modules/boto_cfn.py +++ b/salt/modules/boto_cfn.py @@ -186,7 +186,7 @@ def create( stack_policy_url, ) except BotoServerError as e: - msg = "Failed to create stack {}.\n{}".format(name, e) + msg = f"Failed to create stack {name}.\n{e}" log.error(msg) log.debug(e) return False @@ -246,7 +246,7 @@ def update_stack( log.debug("Updated result is : %s.", update) return update except BotoServerError as e: - msg = "Failed to update stack {}.".format(name) + msg = f"Failed to update stack {name}." log.debug(e) log.error(msg) return str(e) @@ -267,7 +267,7 @@ def delete(name, region=None, key=None, keyid=None, profile=None): try: return conn.delete_stack(name) except BotoServerError as e: - msg = "Failed to create stack {}.".format(name) + msg = f"Failed to create stack {name}." log.error(msg) log.debug(e) return str(e) @@ -291,7 +291,7 @@ def get_template(name, region=None, key=None, keyid=None, profile=None): return template except BotoServerError as e: log.debug(e) - msg = "Template {} does not exist".format(name) + msg = f"Template {name} does not exist" log.error(msg) return str(e) @@ -322,6 +322,6 @@ def validate_template( return conn.validate_template(template_body, template_url) except BotoServerError as e: log.debug(e) - msg = "Error while trying to validate template {}.".format(template_body) + msg = f"Error while trying to validate template {template_body}." log.error(msg) return str(e) diff --git a/salt/modules/boto_cloudfront.py b/salt/modules/boto_cloudfront.py index 64b3fe23eb9..a1b36b34ab7 100644 --- a/salt/modules/boto_cloudfront.py +++ b/salt/modules/boto_cloudfront.py @@ -257,7 +257,7 @@ def export_distributions(region=None, key=None, keyid=None, profile=None): {"config": config}, {"tags": tags}, ] - results["Manage CloudFront distribution {}".format(name)] = { + results[f"Manage CloudFront distribution {name}"] = { "boto_cloudfront.present": distribution_sls_data, } except botocore.exceptions.ClientError as exc: diff --git a/salt/modules/boto_cloudtrail.py b/salt/modules/boto_cloudtrail.py index ec3815dad28..1332c59c58e 100644 --- a/salt/modules/boto_cloudtrail.py +++ b/salt/modules/boto_cloudtrail.py @@ -426,7 +426,7 @@ def _get_trail_arn(name, region=None, key=None, keyid=None, profile=None): region = profile["region"] if region is None: region = "us-east-1" - return "arn:aws:cloudtrail:{}:{}:trail/{}".format(region, account_id, name) + return f"arn:aws:cloudtrail:{region}:{account_id}:trail/{name}" def add_tags(Name, region=None, key=None, keyid=None, profile=None, **kwargs): diff --git a/salt/modules/boto_cloudwatch_event.py b/salt/modules/boto_cloudwatch_event.py index 86b7c6cbbc6..bf566ba4b32 100644 --- a/salt/modules/boto_cloudwatch_event.py +++ b/salt/modules/boto_cloudwatch_event.py @@ -216,7 +216,7 @@ def describe(Name, region=None, key=None, keyid=None, profile=None): except ClientError as e: err = __utils__["boto3.get_error"](e) if e.response.get("Error", {}).get("Code") == "RuleNotFoundException": - return {"error": "Rule {} not found".format(Rule)} + return {"error": f"Rule {Rule} not found"} return {"error": __utils__["boto3.get_error"](e)} @@ -272,7 +272,7 @@ def list_targets(Rule, region=None, key=None, keyid=None, profile=None): except ClientError as e: err = __utils__["boto3.get_error"](e) if e.response.get("Error", {}).get("Code") == "RuleNotFoundException": - return {"error": "Rule {} not found".format(Rule)} + return {"error": f"Rule {Rule} not found"} return {"error": __utils__["boto3.get_error"](e)} @@ -301,7 +301,7 @@ def put_targets(Rule, Targets, region=None, key=None, keyid=None, profile=None): except ClientError as e: err = __utils__["boto3.get_error"](e) if e.response.get("Error", {}).get("Code") == "RuleNotFoundException": - return {"error": "Rule {} not found".format(Rule)} + return {"error": f"Rule {Rule} not found"} return {"error": __utils__["boto3.get_error"](e)} @@ -330,5 +330,5 @@ def remove_targets(Rule, Ids, region=None, key=None, keyid=None, profile=None): except ClientError as e: err = __utils__["boto3.get_error"](e) if e.response.get("Error", {}).get("Code") == "RuleNotFoundException": - return {"error": "Rule {} not found".format(Rule)} + return {"error": f"Rule {Rule} not found"} return {"error": __utils__["boto3.get_error"](e)} diff --git a/salt/modules/boto_cognitoidentity.py b/salt/modules/boto_cognitoidentity.py index 0b4699078e3..f79a6b0595e 100644 --- a/salt/modules/boto_cognitoidentity.py +++ b/salt/modules/boto_cognitoidentity.py @@ -367,7 +367,7 @@ def set_identity_pool_roles( if role_arn is None: return { "set": False, - "error": "invalid AuthenticatedRole {}".format(AuthenticatedRole), + "error": f"invalid AuthenticatedRole {AuthenticatedRole}", } AuthenticatedRole = role_arn diff --git a/salt/modules/boto_datapipeline.py b/salt/modules/boto_datapipeline.py index 88959d71b60..42a3fa63a1e 100644 --- a/salt/modules/boto_datapipeline.py +++ b/salt/modules/boto_datapipeline.py @@ -184,7 +184,7 @@ def pipeline_id_from_name(name, region=None, key=None, keyid=None, profile=None) if pipeline["name"] == name: r["result"] = pipeline["id"] return r - r["error"] = "No pipeline found with name={}".format(name) + r["error"] = f"No pipeline found with name={name}" return r diff --git a/salt/modules/boto_ec2.py b/salt/modules/boto_ec2.py index 31e2cb4e043..5b1f4c5011d 100644 --- a/salt/modules/boto_ec2.py +++ b/salt/modules/boto_ec2.py @@ -687,7 +687,7 @@ def find_instances( if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value if filters: filter_parameters["filters"].update(filters) @@ -813,7 +813,7 @@ def find_images( filter_parameters["filters"]["name"] = ami_name if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value images = conn.get_all_images(**filter_parameters) log.debug( "The filters criteria %s matched the following images:%s", @@ -1520,9 +1520,7 @@ def get_attribute( " command." ) if attribute not in attribute_list: - raise SaltInvocationError( - "Attribute must be one of: {}.".format(attribute_list) - ) + raise SaltInvocationError(f"Attribute must be one of: {attribute_list}.") try: if instance_name: instances = find_instances( @@ -1613,9 +1611,7 @@ def set_attribute( " command." ) if attribute not in attribute_list: - raise SaltInvocationError( - "Attribute must be one of: {}.".format(attribute_list) - ) + raise SaltInvocationError(f"Attribute must be one of: {attribute_list}.") try: if instance_name: instances = find_instances( @@ -1826,7 +1822,7 @@ def create_network_interface( ) vpc_id = vpc_id.get("vpc_id") if not vpc_id: - msg = "subnet_id {} does not map to a valid vpc id.".format(subnet_id) + msg = f"subnet_id {subnet_id} does not map to a valid vpc id." r["error"] = {"message": msg} return r _groups = __salt__["boto_secgroup.convert_to_group_ids"]( @@ -2235,7 +2231,7 @@ def set_volumes_tags( profile=profile, ) if not instance_id: - msg = "Couldn't resolve instance Name {} to an ID.".format(v) + msg = f"Couldn't resolve instance Name {v} to an ID." raise CommandExecutionError(msg) new_filters["attachment.instance_id"] = instance_id else: diff --git a/salt/modules/boto_elasticache.py b/salt/modules/boto_elasticache.py index 3986a9389a3..ce7b8bbe6e0 100644 --- a/salt/modules/boto_elasticache.py +++ b/salt/modules/boto_elasticache.py @@ -158,7 +158,7 @@ def create_replication_group( if config["status"] == "available": return True except boto.exception.BotoServerError as e: - msg = "Failed to create replication group {}.".format(name) + msg = f"Failed to create replication group {name}." log.error(msg) log.debug(e) return {} @@ -180,12 +180,12 @@ def delete_replication_group(name, region=None, key=None, keyid=None, profile=No return False try: conn.delete_replication_group(name) - msg = "Deleted ElastiCache replication group {}.".format(name) + msg = f"Deleted ElastiCache replication group {name}." log.info(msg) return True except boto.exception.BotoServerError as e: log.debug(e) - msg = "Failed to delete ElastiCache replication group {}".format(name) + msg = f"Failed to delete ElastiCache replication group {name}" log.error(msg) return False @@ -209,7 +209,7 @@ def describe_replication_group( try: cc = conn.describe_replication_groups(name) except boto.exception.BotoServerError as e: - msg = "Failed to get config for cache cluster {}.".format(name) + msg = f"Failed to get config for cache cluster {name}." log.error(msg) log.debug(e) return {} @@ -279,7 +279,7 @@ def get_config(name, region=None, key=None, keyid=None, profile=None): try: cc = conn.describe_cache_clusters(name, show_cache_node_info=True) except boto.exception.BotoServerError as e: - msg = "Failed to get config for cache cluster {}.".format(name) + msg = f"Failed to get config for cache cluster {name}." log.error(msg) log.debug(e) return {} @@ -358,7 +358,7 @@ def get_node_host(name, region=None, key=None, keyid=None, profile=None): try: cc = conn.describe_cache_clusters(name, show_cache_node_info=True) except boto.exception.BotoServerError as e: - msg = "Failed to get config for cache cluster {}.".format(name) + msg = f"Failed to get config for cache cluster {name}." log.error(msg) log.debug(e) return {} @@ -385,7 +385,7 @@ def get_group_host(name, region=None, key=None, keyid=None, profile=None): try: cc = conn.describe_replication_groups(name) except boto.exception.BotoServerError as e: - msg = "Failed to get config for cache cluster {}.".format(name) + msg = f"Failed to get config for cache cluster {name}." log.error(msg) log.debug(e) return {} @@ -466,7 +466,7 @@ def subnet_group_exists( try: ec = conn.describe_cache_subnet_groups(cache_subnet_group_name=name) if not ec: - msg = "ElastiCache subnet group does not exist in region {}".format(region) + msg = f"ElastiCache subnet group does not exist in region {region}" log.debug(msg) return False return True @@ -517,14 +517,14 @@ def create_subnet_group( try: ec = conn.create_cache_subnet_group(name, description, subnet_ids) if not ec: - msg = "Failed to create ElastiCache subnet group {}".format(name) + msg = f"Failed to create ElastiCache subnet group {name}" log.error(msg) return False log.info("Created ElastiCache subnet group %s", name) return True except boto.exception.BotoServerError as e: log.debug(e) - msg = "Failed to create ElastiCache subnet group {}".format(name) + msg = f"Failed to create ElastiCache subnet group {name}" log.error(msg) return False @@ -546,12 +546,12 @@ def get_cache_subnet_group(name, region=None, key=None, keyid=None, profile=None csg = csg["DescribeCacheSubnetGroupsResponse"] csg = csg["DescribeCacheSubnetGroupsResult"]["CacheSubnetGroups"][0] except boto.exception.BotoServerError as e: - msg = "Failed to get cache subnet group {}.".format(name) + msg = f"Failed to get cache subnet group {name}." log.error(msg) log.debug(e) return False except (IndexError, TypeError, KeyError): - msg = "Failed to get cache subnet group {} (2).".format(name) + msg = f"Failed to get cache subnet group {name} (2)." log.error(msg) return False ret = {} @@ -591,12 +591,12 @@ def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): return False try: conn.delete_cache_subnet_group(name) - msg = "Deleted ElastiCache subnet group {}.".format(name) + msg = f"Deleted ElastiCache subnet group {name}." log.info(msg) return True except boto.exception.BotoServerError as e: log.debug(e) - msg = "Failed to delete ElastiCache subnet group {}".format(name) + msg = f"Failed to delete ElastiCache subnet group {name}" log.error(msg) return False @@ -667,7 +667,7 @@ def create( return True log.info("Created cache cluster %s.", name) except boto.exception.BotoServerError as e: - msg = "Failed to create cache cluster {}.".format(name) + msg = f"Failed to create cache cluster {name}." log.error(msg) log.debug(e) return False @@ -700,7 +700,7 @@ def delete(name, wait=False, region=None, key=None, keyid=None, profile=None): log.info("Deleted cache cluster %s.", name) return True except boto.exception.BotoServerError as e: - msg = "Failed to delete cache cluster {}.".format(name) + msg = f"Failed to delete cache cluster {name}." log.error(msg) log.debug(e) return False @@ -725,7 +725,7 @@ def create_cache_security_group( log.info("Created cache security group %s.", name) return True else: - msg = "Failed to create cache security group {}.".format(name) + msg = f"Failed to create cache security group {name}." log.error(msg) return False @@ -747,7 +747,7 @@ def delete_cache_security_group(name, region=None, key=None, keyid=None, profile log.info("Deleted cache security group %s.", name) return True else: - msg = "Failed to delete cache security group {}.".format(name) + msg = f"Failed to delete cache security group {name}." log.error(msg) return False diff --git a/salt/modules/boto_elasticsearch_domain.py b/salt/modules/boto_elasticsearch_domain.py index 42535d1a0b5..89be33075ee 100644 --- a/salt/modules/boto_elasticsearch_domain.py +++ b/salt/modules/boto_elasticsearch_domain.py @@ -275,7 +275,7 @@ def create( except ValueError as e: return { "updated": False, - "error": "Error parsing {}: {}".format(k, e.message), + "error": f"Error parsing {k}: {e.message}", } kwargs[k] = val if "AccessPolicies" in kwargs: @@ -366,7 +366,7 @@ def update( except ValueError as e: return { "updated": False, - "error": "Error parsing {}: {}".format(k, e.message), + "error": f"Error parsing {k}: {e.message}", } call_args[k] = val if "AccessPolicies" in call_args: diff --git a/salt/modules/boto_elb.py b/salt/modules/boto_elb.py index 3b9e2690029..748cbc2be8e 100644 --- a/salt/modules/boto_elb.py +++ b/salt/modules/boto_elb.py @@ -1103,9 +1103,9 @@ def _build_tag_param_list(params, tags): i = 1 for key in keys: value = tags[key] - params["Tags.member.{}.Key".format(i)] = key + params[f"Tags.member.{i}.Key"] = key if value is not None: - params["Tags.member.{}.Value".format(i)] = value + params[f"Tags.member.{i}.Value"] = value i += 1 diff --git a/salt/modules/boto_iam.py b/salt/modules/boto_iam.py index 5ec99cdae7f..1b805b8804e 100644 --- a/salt/modules/boto_iam.py +++ b/salt/modules/boto_iam.py @@ -1735,7 +1735,7 @@ def _get_policy_arn(name, region=None, key=None, keyid=None, profile=None): return name account_id = get_account_id(region=region, key=key, keyid=keyid, profile=profile) - return "arn:aws:iam::{}:policy/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:policy/{name}" def policy_exists(policy_name, region=None, key=None, keyid=None, profile=None): diff --git a/salt/modules/boto_iot.py b/salt/modules/boto_iot.py index a00ba03df15..69f26390ca6 100644 --- a/salt/modules/boto_iot.py +++ b/salt/modules/boto_iot.py @@ -151,7 +151,7 @@ def describe_thing_type(thingTypeName, region=None, key=None, keyid=None, profil for dtype in ("creationDate", "deprecationDate"): dval = thingTypeMetadata.get(dtype) if dval and isinstance(dval, datetime.date): - thingTypeMetadata[dtype] = "{}".format(dval) + thingTypeMetadata[dtype] = f"{dval}" return {"thing_type": res} else: return {"thing_type": None} @@ -918,7 +918,7 @@ def list_topic_rules( conn.list_topic_rules, marker_flag="nextToken", marker_arg="nextToken", - **kwargs + **kwargs, ): rules.extend(ret["rules"]) if not bool(rules): diff --git a/salt/modules/boto_kinesis.py b/salt/modules/boto_kinesis.py index 4db0c09492b..1afebe915da 100644 --- a/salt/modules/boto_kinesis.py +++ b/salt/modules/boto_kinesis.py @@ -493,7 +493,7 @@ def reshard( # merge next_shard_id = _get_next_open_shard(stream_details, shard_id) if not next_shard_id: - r["error"] = "failed to find next shard after {}".format(shard_id) + r["error"] = f"failed to find next shard after {shard_id}" return r if force: log.debug( diff --git a/salt/modules/boto_lambda.py b/salt/modules/boto_lambda.py index f86a2d7f192..e6365979978 100644 --- a/salt/modules/boto_lambda.py +++ b/salt/modules/boto_lambda.py @@ -178,7 +178,7 @@ def _get_role_arn(name, region=None, key=None, keyid=None, profile=None): region = profile["region"] if region is None: region = "us-east-1" - return "arn:aws:iam::{}:role/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:role/{name}" def _filedata(infile): @@ -274,7 +274,7 @@ def create_function( dlZipFile = __salt__["cp.cache_file"](path=ZipFile) if dlZipFile is False: ret["result"] = False - ret["comment"] = "Failed to cache ZipFile `{}`.".format(ZipFile) + ret["comment"] = f"Failed to cache ZipFile `{ZipFile}`." return ret ZipFile = dlZipFile code = { @@ -315,7 +315,7 @@ def create_function( Timeout=Timeout, MemorySize=MemorySize, Publish=Publish, - **kwargs + **kwargs, ) except ClientError as e: if ( @@ -647,7 +647,7 @@ def add_permission( StatementId=StatementId, Action=Action, Principal=str(Principal), - **kwargs + **kwargs, ) return {"updated": True} except ClientError as e: diff --git a/salt/modules/boto_rds.py b/salt/modules/boto_rds.py index bbde061b530..815a7c94911 100644 --- a/salt/modules/boto_rds.py +++ b/salt/modules/boto_rds.py @@ -297,9 +297,7 @@ def create( if wait_status: wait_stati = ["available", "modifying", "backing-up"] if wait_status not in wait_stati: - raise SaltInvocationError( - "wait_status can be one of: {}".format(wait_stati) - ) + raise SaltInvocationError(f"wait_status can be one of: {wait_stati}") if vpc_security_groups: v_tmp = __salt__["boto_secgroup.convert_to_group_ids"]( groups=vpc_security_groups, @@ -339,7 +337,7 @@ def create( if not wait_status: return { "created": True, - "message": "RDS instance {} created.".format(name), + "message": f"RDS instance {name} created.", } while True: @@ -411,14 +409,14 @@ def create_read_replica( if not res.get("exists"): return { "exists": bool(res), - "message": "RDS instance source {} does not exists.".format(source_name), + "message": f"RDS instance source {source_name} does not exists.", } res = __salt__["boto_rds.exists"](name, tags, region, key, keyid, profile) if res.get("exists"): return { "exists": bool(res), - "message": "RDS replica instance {} already exists.".format(name), + "message": f"RDS replica instance {name} already exists.", } try: @@ -447,7 +445,7 @@ def create_read_replica( Tags=taglist, DBSubnetGroupName=db_subnet_group_name, StorageType=storage_type, - **kwargs + **kwargs, ) return {"exists": bool(rds_replica)} @@ -538,12 +536,12 @@ def create_parameter_group( if not rds: return { "created": False, - "message": "Failed to create RDS parameter group {}".format(name), + "message": f"Failed to create RDS parameter group {name}", } return { "exists": bool(rds), - "message": "Created RDS parameter group {}".format(name), + "message": f"Created RDS parameter group {name}", } except ClientError as e: return {"error": __utils__["boto3.get_error"](e)} @@ -620,7 +618,7 @@ def update_parameter_group( if not res.get("exists"): return { "exists": bool(res), - "message": "RDS parameter group {} does not exist.".format(name), + "message": f"RDS parameter group {name} does not exist.", } param_list = [] @@ -665,7 +663,7 @@ def describe(name, tags=None, region=None, key=None, keyid=None, profile=None): if not res.get("exists"): return { "exists": bool(res), - "message": "RDS instance {} does not exist.".format(name), + "message": f"RDS instance {name} does not exist.", } try: @@ -870,7 +868,7 @@ def delete( if not wait_for_deletion: return { "deleted": bool(res), - "message": "Deleted RDS instance {}.".format(name), + "message": f"Deleted RDS instance {name}.", } start_time = time.time() @@ -886,7 +884,7 @@ def delete( if not res.get("exists"): return { "deleted": bool(res), - "message": "Deleted RDS instance {} completely.".format(name), + "message": f"Deleted RDS instance {name} completely.", } if time.time() - start_time > timeout: @@ -925,12 +923,12 @@ def delete_option_group(name, region=None, key=None, keyid=None, profile=None): if not res: return { "deleted": bool(res), - "message": "Failed to delete RDS option group {}.".format(name), + "message": f"Failed to delete RDS option group {name}.", } return { "deleted": bool(res), - "message": "Deleted RDS option group {}.".format(name), + "message": f"Deleted RDS option group {name}.", } except ClientError as e: return {"error": __utils__["boto3.get_error"](e)} @@ -955,7 +953,7 @@ def delete_parameter_group(name, region=None, key=None, keyid=None, profile=None r = conn.delete_db_parameter_group(DBParameterGroupName=name) return { "deleted": bool(r), - "message": "Deleted RDS parameter group {}.".format(name), + "message": f"Deleted RDS parameter group {name}.", } except ClientError as e: return {"error": __utils__["boto3.get_error"](e)} @@ -980,7 +978,7 @@ def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): r = conn.delete_db_subnet_group(DBSubnetGroupName=name) return { "deleted": bool(r), - "message": "Deleted RDS subnet group {}.".format(name), + "message": f"Deleted RDS subnet group {name}.", } except ClientError as e: return {"error": __utils__["boto3.get_error"](e)} @@ -1027,12 +1025,12 @@ def describe_parameter_group( if not info: return { "results": bool(info), - "message": "Failed to get RDS description for group {}.".format(name), + "message": f"Failed to get RDS description for group {name}.", } return { "results": bool(info), - "message": "Got RDS descrition for group {}.".format(name), + "message": f"Got RDS descrition for group {name}.", } except ClientError as e: return {"error": __utils__["boto3.get_error"](e)} @@ -1061,7 +1059,7 @@ def describe_parameters( if not res.get("exists"): return { "result": False, - "message": "Parameter group {} does not exist".format(name), + "message": f"Parameter group {name} does not exist", } try: @@ -1169,7 +1167,7 @@ def modify_db_instance( if not res.get("exists"): return { "modified": False, - "message": "RDS db instance {} does not exist.".format(name), + "message": f"RDS db instance {name} does not exist.", } try: @@ -1192,12 +1190,12 @@ def modify_db_instance( if not info: return { "modified": bool(info), - "message": "Failed to modify RDS db instance {}.".format(name), + "message": f"Failed to modify RDS db instance {name}.", } return { "modified": bool(info), - "message": "Modified RDS db instance {}.".format(name), + "message": f"Modified RDS db instance {name}.", "results": dict(info), } except ClientError as e: diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py index e3f2278e96f..9cc62b34419 100644 --- a/salt/modules/boto_route53.py +++ b/salt/modules/boto_route53.py @@ -591,7 +591,7 @@ def get_record( else: _zone = conn.get_zone(zone) if not _zone: - msg = "Failed to retrieve zone {}".format(zone) + msg = f"Failed to retrieve zone {zone}" log.error(msg) return None _type = record_type.upper() @@ -700,7 +700,7 @@ def add_record( else: _zone = conn.get_zone(zone) if not _zone: - msg = "Failed to retrieve zone {}".format(zone) + msg = f"Failed to retrieve zone {zone}" log.error(msg) return False _type = record_type.upper() @@ -799,7 +799,7 @@ def update_record( else: _zone = conn.get_zone(zone) if not _zone: - msg = "Failed to retrieve zone {}".format(zone) + msg = f"Failed to retrieve zone {zone}" log.error(msg) return False _type = record_type.upper() @@ -888,7 +888,7 @@ def delete_record( else: _zone = conn.get_zone(zone) if not _zone: - msg = "Failed to retrieve zone {}".format(zone) + msg = f"Failed to retrieve zone {zone}" log.error(msg) return False _type = record_type.upper() diff --git a/salt/modules/boto_s3_bucket.py b/salt/modules/boto_s3_bucket.py index bc6d0318a68..6e653728d1c 100644 --- a/salt/modules/boto_s3_bucket.py +++ b/salt/modules/boto_s3_bucket.py @@ -775,7 +775,7 @@ def _get_role_arn(name, region=None, key=None, keyid=None, profile=None): region = profile["region"] if region is None: region = "us-east-1" - return "arn:aws:iam::{}:role/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:role/{name}" def put_replication( diff --git a/salt/modules/boto_secgroup.py b/salt/modules/boto_secgroup.py index 79e21853b72..95068692ebc 100644 --- a/salt/modules/boto_secgroup.py +++ b/salt/modules/boto_secgroup.py @@ -511,7 +511,7 @@ def create( log.info("Created security group %s.", name) return True else: - msg = "Failed to create security group {}.".format(name) + msg = f"Failed to create security group {name}." log.error(msg) return False @@ -554,7 +554,7 @@ def delete( log.info("Deleted security group %s with id %s.", group.name, group.id) return True else: - msg = "Failed to delete security group {}.".format(name) + msg = f"Failed to delete security group {name}." log.error(msg) return False else: @@ -778,7 +778,7 @@ def _find_vpcs( if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value vpcs = conn.get_all_vpcs(**filter_parameters) log.debug( diff --git a/salt/modules/boto_sns.py b/salt/modules/boto_sns.py index fb64cced34c..05ac52ddb31 100644 --- a/salt/modules/boto_sns.py +++ b/salt/modules/boto_sns.py @@ -237,7 +237,7 @@ def get_arn(name, region=None, key=None, keyid=None, profile=None): account_id = __salt__["boto_iam.get_account_id"]( region=region, key=key, keyid=keyid, profile=profile ) - return "arn:aws:sns:{}:{}:{}".format(_get_region(region, profile), account_id, name) + return f"arn:aws:sns:{_get_region(region, profile)}:{account_id}:{name}" def _get_region(region=None, profile=None): @@ -254,7 +254,7 @@ def _get_region(region=None, profile=None): def _subscriptions_cache_key(name): - return "{}_{}_subscriptions".format(_cache_get_key(), name) + return f"{_cache_get_key()}_{name}_subscriptions" def _invalidate_cache(): diff --git a/salt/modules/boto_vpc.py b/salt/modules/boto_vpc.py index 63dc1f3120f..b869538a443 100644 --- a/salt/modules/boto_vpc.py +++ b/salt/modules/boto_vpc.py @@ -244,7 +244,7 @@ def _create_resource( key=None, keyid=None, profile=None, - **kwargs + **kwargs, ): """ Create a VPC resource. Returns the resource id if created, or False @@ -267,9 +267,7 @@ def _create_resource( ): return { "created": False, - "error": { - "message": "A {} named {} already exists.".format(resource, name) - }, + "error": {"message": f"A {resource} named {name} already exists."}, } r = create_resource(**kwargs) @@ -295,9 +293,9 @@ def _create_resource( return {"created": True, "id": r.id} else: if name: - e = "{} {} was not created.".format(resource, name) + e = f"{resource} {name} was not created." else: - e = "{} was not created.".format(resource) + e = f"{resource} was not created." log.warning(e) return {"created": False, "error": {"message": e}} except BotoServerError as e: @@ -312,7 +310,7 @@ def _delete_resource( key=None, keyid=None, profile=None, - **kwargs + **kwargs, ): """ Delete a VPC resource. Returns True if successful, otherwise False. @@ -339,9 +337,7 @@ def _delete_resource( if not resource_id: return { "deleted": False, - "error": { - "message": "{} {} does not exist.".format(resource, name) - }, + "error": {"message": f"{resource} {name} does not exist."}, } if delete_resource(resource_id, **kwargs): @@ -358,9 +354,9 @@ def _delete_resource( return {"deleted": True} else: if name: - e = "{} {} was not deleted.".format(resource, name) + e = f"{resource} {name} was not deleted." else: - e = "{} was not deleted.".format(resource) + e = f"{resource} was not deleted." return {"deleted": False, "error": {"message": e}} except BotoServerError as e: return {"deleted": False, "error": __utils__["boto.get_error"](e)} @@ -385,7 +381,7 @@ def _get_resource( conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) - f = "get_all_{}".format(resource) + f = f"get_all_{resource}" if not f.endswith("s"): f = f + "s" get_resources = getattr(conn, f) @@ -394,7 +390,7 @@ def _get_resource( if name: filter_parameters["filters"] = {"tag:Name": name} if resource_id: - filter_parameters["{}_ids".format(resource)] = resource_id + filter_parameters[f"{resource}_ids"] = resource_id try: r = get_resources(**filter_parameters) @@ -418,7 +414,7 @@ def _get_resource( return r[0] else: raise CommandExecutionError( - 'Found more than one {} named "{}"'.format(resource, name) + f'Found more than one {resource} named "{name}"' ) else: return None @@ -448,7 +444,7 @@ def _find_resources( conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) - f = "get_all_{}".format(resource) + f = f"get_all_{resource}" if not f.endswith("s"): f = f + "s" get_resources = getattr(conn, f) @@ -457,10 +453,10 @@ def _find_resources( if name: filter_parameters["filters"] = {"tag:Name": name} if resource_id: - filter_parameters["{}_ids".format(resource)] = resource_id + filter_parameters[f"{resource}_ids"] = resource_id if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value try: r = get_resources(**filter_parameters) @@ -603,7 +599,7 @@ def _find_vpcs( if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value vpcs = conn.get_all_vpcs(**filter_parameters) log.debug( @@ -870,7 +866,7 @@ def delete( if not vpc_id: return { "deleted": False, - "error": {"message": "VPC {} not found".format(vpc_name)}, + "error": {"message": f"VPC {vpc_name} not found"}, } if conn.delete_vpc(vpc_id): @@ -1015,7 +1011,7 @@ def describe_vpcs( if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value vpcs = conn.get_all_vpcs(**filter_parameters) @@ -1057,7 +1053,7 @@ def _find_subnets(subnet_name=None, vpc_id=None, cidr=None, tags=None, conn=None if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value subnets = conn.get_all_subnets(**filter_parameters) log.debug( @@ -1110,9 +1106,7 @@ def create_subnet( if not vpc_id: return { "created": False, - "error": { - "message": "VPC {} does not exist.".format(vpc_name or vpc_id) - }, + "error": {"message": f"VPC {vpc_name or vpc_id} does not exist."}, } except BotoServerError as e: return {"created": False, "error": __utils__["boto.get_error"](e)} @@ -1224,7 +1218,7 @@ def subnet_exists( filter_parameters["filters"]["cidr"] = cidr if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value if zones: filter_parameters["filters"]["availability_zone"] = zones @@ -1464,9 +1458,7 @@ def create_internet_gateway( if not vpc_id: return { "created": False, - "error": { - "message": "VPC {} does not exist.".format(vpc_name or vpc_id) - }, + "error": {"message": f"VPC {vpc_name or vpc_id} does not exist."}, } r = _create_resource( @@ -1624,7 +1616,7 @@ def _find_nat_gateways( conn3.describe_nat_gateways, marker_flag="NextToken", marker_arg="NextToken", - **filter_parameters + **filter_parameters, ): for gw in ret.get("NatGateways", []): if gw.get("State") in states: @@ -1771,9 +1763,7 @@ def create_nat_gateway( if not subnet_id: return { "created": False, - "error": { - "message": "Subnet {} does not exist.".format(subnet_name) - }, + "error": {"message": f"Subnet {subnet_name} does not exist."}, } else: if not _get_resource( @@ -1786,7 +1776,7 @@ def create_nat_gateway( ): return { "created": False, - "error": {"message": "Subnet {} does not exist.".format(subnet_id)}, + "error": {"message": f"Subnet {subnet_id} does not exist."}, } conn3 = _get_conn3(region=region, key=key, keyid=keyid, profile=profile) @@ -2037,9 +2027,7 @@ def create_dhcp_options( if not vpc_id: return { "created": False, - "error": { - "message": "VPC {} does not exist.".format(vpc_name or vpc_id) - }, + "error": {"message": f"VPC {vpc_name or vpc_id} does not exist."}, } r = _create_resource( @@ -2179,9 +2167,7 @@ def associate_dhcp_options_to_vpc( if not vpc_id: return { "associated": False, - "error": { - "message": "VPC {} does not exist.".format(vpc_name or vpc_id) - }, + "error": {"message": f"VPC {vpc_name or vpc_id} does not exist."}, } conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) @@ -2286,7 +2272,7 @@ def create_network_acl( if not vpc_id: return { "created": False, - "error": {"message": "VPC {} does not exist.".format(_id)}, + "error": {"message": f"VPC {_id} does not exist."}, } if all((subnet_id, subnet_name)): @@ -2300,7 +2286,7 @@ def create_network_acl( if not subnet_id: return { "created": False, - "error": {"message": "Subnet {} does not exist.".format(subnet_name)}, + "error": {"message": f"Subnet {subnet_name} does not exist."}, } elif subnet_id: if not _get_resource( @@ -2313,7 +2299,7 @@ def create_network_acl( ): return { "created": False, - "error": {"message": "Subnet {} does not exist.".format(subnet_id)}, + "error": {"message": f"Subnet {subnet_id} does not exist."}, } r = _create_resource( @@ -2470,9 +2456,7 @@ def associate_network_acl_to_subnet( if not network_acl_id: return { "associated": False, - "error": { - "message": "Network ACL {} does not exist.".format(network_acl_name) - }, + "error": {"message": f"Network ACL {network_acl_name} does not exist."}, } if subnet_name: subnet_id = _get_resource_id( @@ -2481,7 +2465,7 @@ def associate_network_acl_to_subnet( if not subnet_id: return { "associated": False, - "error": {"message": "Subnet {} does not exist.".format(subnet_name)}, + "error": {"message": f"Subnet {subnet_name} does not exist."}, } try: conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) @@ -2549,9 +2533,7 @@ def disassociate_network_acl( if not subnet_id: return { "disassociated": False, - "error": { - "message": "Subnet {} does not exist.".format(subnet_name) - }, + "error": {"message": f"Subnet {subnet_name} does not exist."}, } if vpc_name or vpc_id: @@ -2594,7 +2576,7 @@ def _create_network_acl_entry( for v in ("rule_number", "protocol", "rule_action", "cidr_block"): if locals()[v] is None: - raise SaltInvocationError("{} is required.".format(v)) + raise SaltInvocationError(f"{v} is required.") if network_acl_name: network_acl_id = _get_resource_id( @@ -2744,7 +2726,7 @@ def delete_network_acl_entry( for v in ("rule_number", "egress"): if locals()[v] is None: - raise SaltInvocationError("{} is required.".format(v)) + raise SaltInvocationError(f"{v} is required.") if network_acl_name: network_acl_id = _get_resource_id( @@ -2807,7 +2789,7 @@ def create_route_table( if not vpc_id: return { "created": False, - "error": {"message": "VPC {} does not exist.".format(vpc_name or vpc_id)}, + "error": {"message": f"VPC {vpc_name or vpc_id} does not exist."}, } return _create_resource( @@ -2943,7 +2925,7 @@ def route_exists( if tags: for tag_name, tag_value in tags.items(): - filter_parameters["filters"]["tag:{}".format(tag_name)] = tag_value + filter_parameters["filters"][f"tag:{tag_name}"] = tag_value route_tables = conn.get_all_route_tables(**filter_parameters) @@ -3015,7 +2997,7 @@ def associate_route_table( if not subnet_id: return { "associated": False, - "error": {"message": "Subnet {} does not exist.".format(subnet_name)}, + "error": {"message": f"Subnet {subnet_name} does not exist."}, } if all((route_table_id, route_table_name)): @@ -3034,9 +3016,7 @@ def associate_route_table( if not route_table_id: return { "associated": False, - "error": { - "message": "Route table {} does not exist.".format(route_table_name) - }, + "error": {"message": f"Route table {route_table_name} does not exist."}, } try: @@ -3486,7 +3466,7 @@ def describe_route_tables( if tags: for tag_name, tag_value in tags.items(): filter_parameters["Filters"].append( - {"Name": "tag:{}".format(tag_name), "Values": [tag_value]} + {"Name": f"tag:{tag_name}", "Values": [tag_value]} ) route_tables = conn3.describe_route_tables(**filter_parameters).get( @@ -3600,7 +3580,7 @@ def _maybe_name_route_table(conn, vpcid, vpc_name): log.warning("no default route table found") return - name = "{}-default-table".format(vpc_name) + name = f"{vpc_name}-default-table" _maybe_set_name_tag(name, default_table) log.debug("Default route table name was set to: %s on vpc %s", name, vpcid) @@ -3757,9 +3737,7 @@ def request_vpc_peering_connection( vpc_name=peer_vpc_name, region=region, key=key, keyid=keyid, profile=profile ) if not peer_vpc_id: - return { - "error": "Could not resolve VPC name {} to an ID".format(peer_vpc_name) - } + return {"error": f"Could not resolve VPC name {peer_vpc_name} to an ID"} peering_params = { "VpcId": requester_vpc_id, @@ -3780,7 +3758,7 @@ def request_vpc_peering_connection( vpc_peering = conn.create_vpc_peering_connection(**peering_params) peering = vpc_peering.get("VpcPeeringConnection", {}) peering_conn_id = peering.get("VpcPeeringConnectionId", "ERROR") - msg = "VPC peering {} requested.".format(peering_conn_id) + msg = f"VPC peering {peering_conn_id} requested." log.debug(msg) if name: @@ -3789,7 +3767,7 @@ def request_vpc_peering_connection( Resources=[peering_conn_id], Tags=[{"Key": "Name", "Value": name}] ) log.debug("Applied name tag to vpc peering connection") - msg += " With name {}.".format(name) + msg += f" With name {name}." return {"msg": msg} except botocore.exceptions.ClientError as err: @@ -3991,7 +3969,7 @@ def delete_vpc_peering_connection( conn_id = _vpc_peering_conn_id_for_name(conn_name, conn) if not conn_id: raise SaltInvocationError( - "Couldn't resolve VPC peering connection {} to an ID".format(conn_name) + f"Couldn't resolve VPC peering connection {conn_name} to an ID" ) try: log.debug("Trying to delete vpc peering connection") diff --git a/salt/states/boto3_elasticache.py b/salt/states/boto3_elasticache.py index 10989a8f1b8..ae466827880 100644 --- a/salt/states/boto3_elasticache.py +++ b/salt/states/boto3_elasticache.py @@ -90,9 +90,10 @@ passed in as a dict, or as a string to pull from pillars or minion config: __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -178,7 +179,7 @@ def cache_cluster_present( key=None, keyid=None, profile=None, - **args + **args, ): """ Ensure a given cache cluster exists. @@ -449,7 +450,7 @@ def cache_cluster_present( else: create_args[k] = v if __opts__["test"]: - ret["comment"] = "Cache cluster {} would be created.".format(name) + ret["comment"] = f"Cache cluster {name} would be created." ret["result"] = None return ret created = __salt__["boto3_elasticache.create_cache_cluster"]( @@ -460,18 +461,18 @@ def cache_cluster_present( key=key, keyid=keyid, profile=profile, - **create_args + **create_args, ) if created: new = __salt__["boto3_elasticache.describe_cache_clusters"]( name, region=region, key=key, keyid=keyid, profile=profile ) - ret["comment"] = "Cache cluster {} was created.".format(name) + ret["comment"] = f"Cache cluster {name} was created." ret["changes"]["old"] = None ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to create {} cache cluster.".format(name) + ret["comment"] = f"Failed to create {name} cache cluster." if check_update: # Refresh this in case we're updating from 'only_on_modify' above... @@ -481,7 +482,7 @@ def cache_cluster_present( need_update = _diff_cache_cluster(updated["CacheClusters"][0], args) if need_update: if __opts__["test"]: - ret["comment"] = "Cache cluster {} would be modified.".format(name) + ret["comment"] = f"Cache cluster {name} would be modified." ret["result"] = None return ret modified = __salt__["boto3_elasticache.modify_cache_cluster"]( @@ -492,7 +493,7 @@ def cache_cluster_present( key=key, keyid=keyid, profile=profile, - **need_update + **need_update, ) if modified: new = __salt__["boto3_elasticache.describe_cache_clusters"]( @@ -501,14 +502,14 @@ def cache_cluster_present( if ret["comment"]: # 'create' just ran... ret["comment"] += " ... and then immediately modified." else: - ret["comment"] = "Cache cluster {} was modified.".format(name) + ret["comment"] = f"Cache cluster {name} was modified." ret["changes"]["old"] = current ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to modify cache cluster {}.".format(name) + ret["comment"] = f"Failed to modify cache cluster {name}." else: - ret["comment"] = "Cache cluster {} is in the desired state.".format(name) + ret["comment"] = f"Cache cluster {name} is in the desired state." return ret @@ -557,7 +558,7 @@ def cache_cluster_absent( ) if exists: if __opts__["test"]: - ret["comment"] = "Cache cluster {} would be removed.".format(name) + ret["comment"] = f"Cache cluster {name} would be removed." ret["result"] = None return ret deleted = __salt__["boto3_elasticache.delete_cache_cluster"]( @@ -567,16 +568,16 @@ def cache_cluster_absent( key=key, keyid=keyid, profile=profile, - **args + **args, ) if deleted: ret["changes"]["old"] = name ret["changes"]["new"] = None else: ret["result"] = False - ret["comment"] = "Failed to delete {} cache cluster.".format(name) + ret["comment"] = f"Failed to delete {name} cache cluster." else: - ret["comment"] = "Cache cluster {} already absent.".format(name) + ret["comment"] = f"Cache cluster {name} already absent." return ret @@ -642,7 +643,7 @@ def replication_group_present( key=None, keyid=None, profile=None, - **args + **args, ): """ Ensure a replication group exists and is in the given state. @@ -901,7 +902,7 @@ def replication_group_present( else: create_args[k] = v if __opts__["test"]: - ret["comment"] = "Replication group {} would be created.".format(name) + ret["comment"] = f"Replication group {name} would be created." ret["result"] = None return ret created = __salt__["boto3_elasticache.create_replication_group"]( @@ -912,18 +913,18 @@ def replication_group_present( key=key, keyid=keyid, profile=profile, - **create_args + **create_args, ) if created: new = __salt__["boto3_elasticache.describe_replication_groups"]( name, region=region, key=key, keyid=keyid, profile=profile ) - ret["comment"] = "Replication group {} was created.".format(name) + ret["comment"] = f"Replication group {name} was created." ret["changes"]["old"] = None ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to create {} replication group.".format(name) + ret["comment"] = f"Failed to create {name} replication group." if check_update: # Refresh this in case we're updating from 'only_on_modify' above... @@ -933,7 +934,7 @@ def replication_group_present( need_update = _diff_replication_group(updated, args) if need_update: if __opts__["test"]: - ret["comment"] = "Replication group {} would be modified.".format(name) + ret["comment"] = f"Replication group {name} would be modified." ret["result"] = None return ret modified = __salt__["boto3_elasticache.modify_replication_group"]( @@ -944,7 +945,7 @@ def replication_group_present( key=key, keyid=keyid, profile=profile, - **need_update + **need_update, ) if modified: new = __salt__["boto3_elasticache.describe_replication_groups"]( @@ -953,12 +954,12 @@ def replication_group_present( if ret["comment"]: # 'create' just ran... ret["comment"] += " ... and then immediately modified." else: - ret["comment"] = "Replication group {} was modified.".format(name) + ret["comment"] = f"Replication group {name} was modified." ret["changes"]["old"] = current[0] if current else None ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to modify replication group {}.".format(name) + ret["comment"] = f"Failed to modify replication group {name}." else: ret["comment"] = "Replication group {} is in the desired state.".format( name @@ -1015,7 +1016,7 @@ def replication_group_absent( ) if exists: if __opts__["test"]: - ret["comment"] = "Replication group {} would be removed.".format(name) + ret["comment"] = f"Replication group {name} would be removed." ret["result"] = None return ret deleted = __salt__["boto3_elasticache.delete_replication_group"]( @@ -1025,16 +1026,16 @@ def replication_group_absent( key=key, keyid=keyid, profile=profile, - **args + **args, ) if deleted: ret["changes"]["old"] = name ret["changes"]["new"] = None else: ret["result"] = False - ret["comment"] = "Failed to delete {} replication group.".format(name) + ret["comment"] = f"Failed to delete {name} replication group." else: - ret["comment"] = "Replication group {} already absent.".format(name) + ret["comment"] = f"Replication group {name} already absent." return ret @@ -1118,7 +1119,7 @@ def cache_subnet_group_present( else: check_update = False if __opts__["test"]: - ret["comment"] = "Cache subnet group {} would be created.".format(name) + ret["comment"] = f"Cache subnet group {name} would be created." ret["result"] = None return ret created = __salt__["boto3_elasticache.create_cache_subnet_group"]( @@ -1128,24 +1129,24 @@ def cache_subnet_group_present( key=key, keyid=keyid, profile=profile, - **args + **args, ) if created: new = __salt__["boto3_elasticache.describe_cache_subnet_groups"]( name, region=region, key=key, keyid=keyid, profile=profile ) - ret["comment"] = "Cache subnet group {} was created.".format(name) + ret["comment"] = f"Cache subnet group {name} was created." ret["changes"]["old"] = None ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to create {} cache subnet group.".format(name) + ret["comment"] = f"Failed to create {name} cache subnet group." if check_update: need_update = _diff_cache_subnet_group(current, args) if need_update: if __opts__["test"]: - ret["comment"] = "Cache subnet group {} would be modified.".format(name) + ret["comment"] = f"Cache subnet group {name} would be modified." ret["result"] = None return ret modified = __salt__["boto3_elasticache.modify_cache_subnet_group"]( @@ -1155,18 +1156,18 @@ def cache_subnet_group_present( key=key, keyid=keyid, profile=profile, - **need_update + **need_update, ) if modified: new = __salt__["boto3_elasticache.describe_cache_subnet_groups"]( name, region=region, key=key, keyid=keyid, profile=profile ) - ret["comment"] = "Cache subnet group {} was modified.".format(name) + ret["comment"] = f"Cache subnet group {name} was modified." ret["changes"]["old"] = current["CacheSubetGroups"][0] ret["changes"]["new"] = new[0] else: ret["result"] = False - ret["comment"] = "Failed to modify cache subnet group {}.".format(name) + ret["comment"] = f"Failed to modify cache subnet group {name}." else: ret["comment"] = "Cache subnet group {} is in the desired state.".format( name @@ -1207,7 +1208,7 @@ def cache_subnet_group_absent( ) if exists: if __opts__["test"]: - ret["comment"] = "Cache subnet group {} would be removed.".format(name) + ret["comment"] = f"Cache subnet group {name} would be removed." ret["result"] = None return ret deleted = __salt__["boto3_elasticache.delete_cache_subnet_group"]( @@ -1218,7 +1219,7 @@ def cache_subnet_group_absent( ret["changes"]["new"] = None else: ret["result"] = False - ret["comment"] = "Failed to delete {} cache_subnet group.".format(name) + ret["comment"] = f"Failed to delete {name} cache_subnet group." else: - ret["comment"] = "Cache subnet group {} already absent.".format(name) + ret["comment"] = f"Cache subnet group {name} already absent." return ret diff --git a/salt/states/boto3_elasticsearch.py b/salt/states/boto3_elasticsearch.py index 2b27080faea..45c92701c27 100644 --- a/salt/states/boto3_elasticsearch.py +++ b/salt/states/boto3_elasticsearch.py @@ -54,7 +54,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) __virtualname__ = "boto3_elasticsearch" @@ -79,7 +79,7 @@ def __virtual__(): if req not in __salt__: return ( False, - "A required function was not found in __salt__: {}".format(req), + f"A required function was not found in __salt__: {req}", ) return __virtualname__ @@ -384,7 +384,7 @@ def present( else: ret["result"] = True ret["comment"].append( - 'Elasticsearch Domain "{}" has been {}d.'.format(name, action) + f'Elasticsearch Domain "{name}" has been {action}d.' ) ret["changes"] = config_diff elif action == "upgrade": @@ -461,7 +461,7 @@ def absent(name, blocking=True, region=None, keyid=None, key=None, profile=None) if __opts__["test"]: ret["result"] = None ret["comment"].append( - 'Elasticsearch domain "{}" would have been removed.'.format(name) + f'Elasticsearch domain "{name}" would have been removed.' ) ret["changes"] = {"old": name, "new": None} else: @@ -483,14 +483,12 @@ def absent(name, blocking=True, region=None, keyid=None, key=None, profile=None) else: ret["result"] = True ret["comment"].append( - 'Elasticsearch domain "{}" has been deleted.'.format(name) + f'Elasticsearch domain "{name}" has been deleted.' ) ret["changes"] = {"old": name, "new": None} else: ret["result"] = True - ret["comment"].append( - 'Elasticsearch domain "{}" is already absent.'.format(name) - ) + ret["comment"].append(f'Elasticsearch domain "{name}" is already absent.') ret = _check_return_value(ret) return ret @@ -535,9 +533,7 @@ def upgraded( if not res["result"]: ret["result"] = False if "ResourceNotFoundException" in res["error"]: - ret["comment"].append( - 'The Elasticsearch domain "{}" does not exist.'.format(name) - ) + ret["comment"].append(f'The Elasticsearch domain "{name}" does not exist.') else: ret["comment"].append(res["error"]) else: @@ -733,9 +729,7 @@ def latest(name, minor_only=True, region=None, keyid=None, key=None, profile=Non pass if not current_version: ret["result"] = True - ret["comment"].append( - 'The Elasticsearch domain "{}" can not be upgraded.'.format(name) - ) + ret["comment"].append(f'The Elasticsearch domain "{name}" can not be upgraded.') elif not latest_version: ret["result"] = True ret["comment"].append( @@ -825,7 +819,7 @@ def tagged( current_tags = res["response"] or {} else: ret["result"] = False - ret["comment"].append('Elasticsearch domain "{}" does not exist.'.format(name)) + ret["comment"].append(f'Elasticsearch domain "{name}" does not exist.') if isinstance(ret["result"], bool): return ret @@ -833,7 +827,7 @@ def tagged( if not diff_tags: ret["result"] = True ret["comment"].append( - 'Elasticsearch domain "{}" already has the specified tags.'.format(name) + f'Elasticsearch domain "{name}" already has the specified tags.' ) else: if replace: diff --git a/salt/states/boto3_route53.py b/salt/states/boto3_route53.py index bbaf25e5148..51f82ecd49b 100644 --- a/salt/states/boto3_route53.py +++ b/salt/states/boto3_route53.py @@ -76,9 +76,10 @@ log = logging.getLogger(__name__) # pylint: disable=W1699 __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -246,7 +247,7 @@ def hosted_zone_present( update_comment = True if not (create or add_vpcs or del_vpcs or update_comment): - ret["comment"] = "Hostd Zone {} already in desired state".format(Name) + ret["comment"] = f"Hostd Zone {Name} already in desired state" return ret if create: @@ -750,7 +751,7 @@ def rr_present( # this appears to be incredibly difficult with the jinja templating engine # so inject the quotations here to make a viable ChangeBatch if Type == "TXT": - rr = '"{}"'.format(rr) + rr = f'"{rr}"' fixed_rrs += [rr] ResourceRecords = [{"Value": rr} for rr in sorted(fixed_rrs)] diff --git a/salt/states/boto3_sns.py b/salt/states/boto3_sns.py index 5f0b4a14148..ed89eeb16ef 100644 --- a/salt/states/boto3_sns.py +++ b/salt/states/boto3_sns.py @@ -73,9 +73,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -140,11 +141,11 @@ def topic_present( something_changed = False current = __salt__["boto3_sns.describe_topic"](name, region, key, keyid, profile) if current: - ret["comment"] = "AWS SNS topic {} present.".format(name) + ret["comment"] = f"AWS SNS topic {name} present." TopicArn = current["TopicArn"] else: if __opts__["test"]: - ret["comment"] = "AWS SNS topic {} would be created.".format(name) + ret["comment"] = f"AWS SNS topic {name} would be created." ret["result"] = None return ret else: @@ -157,7 +158,7 @@ def topic_present( ) something_changed = True else: - ret["comment"] = "Failed to create AWS SNS topic {}".format(name) + ret["comment"] = f"Failed to create AWS SNS topic {name}" log.error(ret["comment"]) ret["result"] = False return ret @@ -251,7 +252,7 @@ def topic_present( TopicArn, prot, endp, region=region, key=key, keyid=keyid, profile=profile ) if subbed: - msg = " Subscription {}:{} set on topic {}.".format(prot, endp, TopicArn) + msg = f" Subscription {prot}:{endp} set on topic {TopicArn}." ret["comment"] += msg something_changed = True else: @@ -323,11 +324,11 @@ def topic_absent( something_changed = False current = __salt__["boto3_sns.describe_topic"](name, region, key, keyid, profile) if not current: - ret["comment"] = "AWS SNS topic {} absent.".format(name) + ret["comment"] = f"AWS SNS topic {name} absent." else: TopicArn = current["TopicArn"] if __opts__["test"]: - ret["comment"] = "AWS SNS topic {} would be removed.".format(TopicArn) + ret["comment"] = f"AWS SNS topic {TopicArn} would be removed." if unsubscribe: ret["comment"] += " {} subscription(s) would be removed.".format( len(current["Subscriptions"]) @@ -365,17 +366,14 @@ def topic_absent( if not __salt__["boto3_sns.delete_topic"]( TopicArn, region=region, key=key, keyid=keyid, profile=profile ): - ret["comment"] = "Failed to delete SNS topic {}".format(TopicArn) + ret["comment"] = f"Failed to delete SNS topic {TopicArn}" log.error(ret["comment"]) ret["result"] = False else: - ret["comment"] = "AWS SNS topic {} deleted.".format(TopicArn) + ret["comment"] = f"AWS SNS topic {TopicArn} deleted." if unsubscribe: ret["comment"] += " ".join( - [ - "Subscription {} deleted".format(s) - for s in current["Subscriptions"] - ] + [f"Subscription {s} deleted" for s in current["Subscriptions"]] ) something_changed = True diff --git a/salt/states/boto_apigateway.py b/salt/states/boto_apigateway.py index e96042d78fe..c82d6191f3c 100644 --- a/salt/states/boto_apigateway.py +++ b/salt/states/boto_apigateway.py @@ -65,9 +65,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -355,7 +356,7 @@ def present( except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret @@ -440,7 +441,7 @@ def absent( swagger = _Swagger(api_name, stage_name, "", None, None, None, common_args) if not swagger.restApiId: - ret["comment"] = "[Rest API: {}] does not exist.".format(api_name) + ret["comment"] = f"[Rest API: {api_name}] does not exist." return ret if __opts__["test"]: @@ -451,7 +452,7 @@ def absent( "deleted.".format(stage_name, api_name) ) else: - ret["comment"] = "[stage: {}] will be deleted.".format(stage_name) + ret["comment"] = f"[stage: {stage_name}] will be deleted." ret["result"] = None return ret @@ -465,7 +466,7 @@ def absent( except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret @@ -730,11 +731,11 @@ class _Swagger: _name = self._paramdict.get("name") if _name: if self.location == "header": - return "method.request.header.{}".format(_name) + return f"method.request.header.{_name}" elif self.location == "query": - return "method.request.querystring.{}".format(_name) + return f"method.request.querystring.{_name}" elif self.location == "path": - return "method.request.path.{}".format(_name) + return f"method.request.path.{_name}" return None raise ValueError( "Parameter must have a name: {}".format( @@ -759,9 +760,7 @@ class _Swagger: self.name ) ) - raise ValueError( - "Body parameter must have a schema: {}".format(self.name) - ) + raise ValueError(f"Body parameter must have a schema: {self.name}") return None class SwaggerMethodResponse: @@ -824,7 +823,7 @@ class _Swagger: self._cfg = salt.utils.yaml.safe_load(sf) self._swagger_version = "" else: - raise OSError("Invalid swagger file path, {}".format(swagger_file_path)) + raise OSError(f"Invalid swagger file path, {swagger_file_path}") self._validate_swagger_file() @@ -882,7 +881,7 @@ class _Swagger: if model.get("type") != "object": raise ValueError( - "model schema {} must be type object".format(modelname) + f"model schema {modelname} must be type object" ) if "properties" not in model: raise ValueError( @@ -933,12 +932,12 @@ class _Swagger: field not in _Swagger.SWAGGER_OBJ_V2_FIELDS and not _Swagger.VENDOR_EXT_PATTERN.match(field) ): - raise ValueError("Invalid Swagger Object Field: {}".format(field)) + raise ValueError(f"Invalid Swagger Object Field: {field}") # check for Required Swagger fields by Saltstack boto apigateway state for field in _Swagger.SWAGGER_OBJ_V2_FIELDS_REQUIRED: if field not in self._cfg: - raise ValueError("Missing Swagger Object Field: {}".format(field)) + raise ValueError(f"Missing Swagger Object Field: {field}") # check for Swagger Version self._swagger_version = self._cfg.get("swagger") @@ -1032,7 +1031,7 @@ class _Swagger: for path in paths: if not path.startswith("/"): raise ValueError( - "Path object {} should start with /. Please fix it".format(path) + f"Path object {path} should start with /. Please fix it" ) return paths.items() @@ -1105,7 +1104,7 @@ class _Swagger: stages = __salt__["boto_apigateway.describe_api_stages"]( restApiId=self.restApiId, deploymentId=deploymentId, - **self._common_aws_args + **self._common_aws_args, ).get("stages") if stages: no_more_deployments = False @@ -1121,7 +1120,7 @@ class _Swagger: stage = __salt__["boto_apigateway.describe_api_stage"]( restApiId=self.restApiId, stageName=self._stage_name, - **self._common_aws_args + **self._common_aws_args, ).get("stage") if stage: deploymentId = stage.get("deploymentId") @@ -1161,7 +1160,7 @@ class _Swagger: restApiId=self.restApiId, stageName=self._stage_name, variables=stage_variables, - **self._common_aws_args + **self._common_aws_args, ) if not res.get("overwrite"): @@ -1179,7 +1178,7 @@ class _Swagger: stage = __salt__["boto_apigateway.describe_api_stage"]( restApiId=self.restApiId, stageName=self._stage_name, - **self._common_aws_args + **self._common_aws_args, ).get("stage") if not stage: stage = __salt__["boto_apigateway.create_api_stage"]( @@ -1188,7 +1187,7 @@ class _Swagger: deploymentId=self._deploymentId, description=stage_desc_json, variables=stage_variables, - **self._common_aws_args + **self._common_aws_args, ) if not stage.get("stage"): return {"set": False, "error": stage.get("error")} @@ -1198,7 +1197,7 @@ class _Swagger: restApiId=self.restApiId, stageName=self._stage_name, variables=stage_variables, - **self._common_aws_args + **self._common_aws_args, ) if not overwrite.get("stage"): return {"set": False, "error": overwrite.get("error")} @@ -1207,7 +1206,7 @@ class _Swagger: restApiId=self.restApiId, stageName=self._stage_name, deploymentId=self._deploymentId, - **self._common_aws_args + **self._common_aws_args, ) def _resolve_api_id(self): @@ -1218,7 +1217,7 @@ class _Swagger: apis = __salt__["boto_apigateway.describe_apis"]( name=self.rest_api_name, description=_Swagger.AWS_API_DESCRIPTION, - **self._common_aws_args + **self._common_aws_args, ).get("restapi") if apis: if len(apis) == 1: @@ -1241,7 +1240,7 @@ class _Swagger: result = __salt__["boto_apigateway.delete_api_stage"]( restApiId=self.restApiId, stageName=self._stage_name, - **self._common_aws_args + **self._common_aws_args, ) if not result.get("deleted"): ret["abort"] = True @@ -1255,7 +1254,7 @@ class _Swagger: result = __salt__["boto_apigateway.delete_api_deployment"]( restApiId=self.restApiId, deploymentId=deploymentId, - **self._common_aws_args + **self._common_aws_args, ) if not result.get("deleted"): ret["abort"] = True @@ -1271,7 +1270,7 @@ class _Swagger: ) else: # no matching stage_name/deployment found - ret["comment"] = "stage {} does not exist".format(self._stage_name) + ret["comment"] = f"stage {self._stage_name} does not exist" return ret @@ -1332,7 +1331,7 @@ class _Swagger: stageDescription=stage_desc_json, description=self.deployment_label_json, variables=stage_variables, - **self._common_aws_args + **self._common_aws_args, ) if not res.get("created"): ret["abort"] = True @@ -1359,7 +1358,7 @@ class _Swagger: delres = __salt__["boto_apigateway.delete_api_resources"]( restApiId=self.restApiId, path=resource.get("path"), - **self._common_aws_args + **self._common_aws_args, ) if not delres.get("deleted"): return delres @@ -1372,7 +1371,7 @@ class _Swagger: delres = __salt__["boto_apigateway.delete_api_model"]( restApiId=self.restApiId, modelName=model.get("name"), - **self._common_aws_args + **self._common_aws_args, ) if not delres.get("deleted"): return delres @@ -1386,7 +1385,7 @@ class _Swagger: if self.restApiId: res = self._cleanup_api() if not res.get("deleted"): - ret["comment"] = "Failed to cleanup restAreId {}".format(self.restApiId) + ret["comment"] = f"Failed to cleanup restAreId {self.restApiId}" ret["abort"] = True ret["result"] = False return ret @@ -1395,7 +1394,7 @@ class _Swagger: response = __salt__["boto_apigateway.create_api"]( name=self.rest_api_name, description=_Swagger.AWS_API_DESCRIPTION, - **self._common_aws_args + **self._common_aws_args, ) if not response.get("created"): @@ -1422,7 +1421,7 @@ class _Swagger: exists_response = __salt__["boto_apigateway.api_exists"]( name=self.rest_api_name, description=_Swagger.AWS_API_DESCRIPTION, - **self._common_aws_args + **self._common_aws_args, ) if exists_response.get("exists"): if __opts__["test"]: @@ -1436,7 +1435,7 @@ class _Swagger: delete_api_response = __salt__["boto_apigateway.delete_api"]( name=self.rest_api_name, description=_Swagger.AWS_API_DESCRIPTION, - **self._common_aws_args + **self._common_aws_args, ) if not delete_api_response.get("deleted"): ret["result"] = False @@ -1558,7 +1557,7 @@ class _Swagger: _schema.update( { "$schema": _Swagger.JSON_SCHEMA_DRAFT_4, - "title": "{} Schema".format(model), + "title": f"{model} Schema", } ) @@ -1575,7 +1574,7 @@ class _Swagger: restApiId=self.restApiId, modelName=model, schema=_dict_to_json_pretty(_schema), - **self._common_aws_args + **self._common_aws_args, ) if not update_model_schema_response.get("updated"): ret["result"] = False @@ -1599,7 +1598,7 @@ class _Swagger: modelDescription=model, schema=_dict_to_json_pretty(_schema), contentType="application/json", - **self._common_aws_args + **self._common_aws_args, ) if not create_model_response.get("created"): @@ -1750,7 +1749,7 @@ class _Swagger: method_response_params = {} method_integration_response_params = {} for header in method_response.headers: - response_header = "method.response.header.{}".format(header) + response_header = f"method.response.header.{header}" method_response_params[response_header] = False header_data = method_response.headers.get(header) method_integration_response_params[response_header] = ( @@ -1827,7 +1826,7 @@ class _Swagger: apiKeyRequired=api_key_required, requestParameters=method.get("params"), requestModels=method.get("models"), - **self._common_aws_args + **self._common_aws_args, ) if not m.get("created"): ret = _log_error_and_abort(ret, m) @@ -1853,7 +1852,7 @@ class _Swagger: uri=lambda_uri, credentials=lambda_integration_role, requestTemplates=method.get("request_templates"), - **self._common_aws_args + **self._common_aws_args, ) if not integration.get("created"): ret = _log_error_and_abort(ret, integration) @@ -1876,7 +1875,7 @@ class _Swagger: statusCode=httpStatus, responseParameters=method_response.get("params"), responseModels=method_response.get("models"), - **self._common_aws_args + **self._common_aws_args, ) if not mr.get("created"): ret = _log_error_and_abort(ret, mr) @@ -1891,7 +1890,7 @@ class _Swagger: selectionPattern=method_response.get("pattern"), responseParameters=method_response.get("integration_params"), responseTemplates=method_response.get("response_templates"), - **self._common_aws_args + **self._common_aws_args, ) if not mir.get("created"): ret = _log_error_and_abort(ret, mir) @@ -1901,7 +1900,7 @@ class _Swagger: ) else: raise ValueError( - "No responses specified for {} {}".format(resource_path, method_name) + f"No responses specified for {resource_path} {method_name}" ) return ret @@ -2048,7 +2047,7 @@ def usage_plan_present( description=description, throttle=throttle, quota=quota, - **common_args + **common_args, ) if "error" in result: ret["result"] = False @@ -2058,7 +2057,7 @@ def usage_plan_present( return ret ret["changes"]["old"] = {"plan": None} - ret["comment"] = "A new usage plan {} has been created".format(plan_name) + ret["comment"] = f"A new usage plan {plan_name} has been created" else: # need an existing plan modified to match given value @@ -2103,7 +2102,7 @@ def usage_plan_present( return ret ret["changes"]["old"] = {"plan": plan} - ret["comment"] = "usage plan {} has been updated".format(plan_name) + ret["comment"] = f"usage plan {plan_name} has been updated" newstate = __salt__["boto_apigateway.describe_usage_plans"]( name=plan_name, **common_args @@ -2117,7 +2116,7 @@ def usage_plan_present( except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret @@ -2158,7 +2157,7 @@ def usage_plan_absent(name, plan_name, region=None, key=None, keyid=None, profil return ret if not existing["plans"]: - ret["comment"] = "Usage plan {} does not exist already".format(plan_name) + ret["comment"] = f"Usage plan {plan_name} does not exist already" return ret if __opts__["test"]: @@ -2178,13 +2177,13 @@ def usage_plan_absent(name, plan_name, region=None, key=None, keyid=None, profil ) return ret - ret["comment"] = "Usage plan {} has been deleted".format(plan_name) + ret["comment"] = f"Usage plan {plan_name} has been deleted" ret["changes"]["old"] = {"plan": existing["plans"][0]} ret["changes"]["new"] = {"plan": None} except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret @@ -2240,7 +2239,7 @@ def usage_plan_association_present( return ret if not existing["plans"]: - ret["comment"] = "Usage plan {} does not exist".format(plan_name) + ret["comment"] = f"Usage plan {plan_name} does not exist" ret["result"] = False return ret @@ -2283,7 +2282,7 @@ def usage_plan_association_present( except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret @@ -2341,7 +2340,7 @@ def usage_plan_association_absent( return ret if not existing["plans"]: - ret["comment"] = "Usage plan {} does not exist".format(plan_name) + ret["comment"] = f"Usage plan {plan_name} does not exist" ret["result"] = False return ret @@ -2390,6 +2389,6 @@ def usage_plan_association_absent( except (ValueError, OSError) as e: ret["result"] = False - ret["comment"] = "{}".format(e.args) + ret["comment"] = f"{e.args}" return ret diff --git a/salt/states/boto_asg.py b/salt/states/boto_asg.py index 5241d054d5a..e3dc08e2bb0 100644 --- a/salt/states/boto_asg.py +++ b/salt/states/boto_asg.py @@ -205,9 +205,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -455,7 +456,7 @@ def present( ret["result"] = False return ret if "id" not in r: - ret["comment"] = "Subnet {} does not exist.".format(i) + ret["comment"] = f"Subnet {i} does not exist." ret["result"] = False return ret vpc_zone_identifier.append(r["id"]) @@ -835,7 +836,7 @@ def _alarms_present( if "scaling_policy" not in action: scaling_policy_actions_only = False if ":self:" in action: - action = action.replace(":self:", ":{}:".format(name)) + action = action.replace(":self:", f":{name}:") new_actions.append(action) info["attributes"][action_type] = new_actions # skip alarms that only have actions for scaling policy, if min_size == max_size for this ASG diff --git a/salt/states/boto_cfn.py b/salt/states/boto_cfn.py index d994752abc5..ca699beee5f 100644 --- a/salt/states/boto_cfn.py +++ b/salt/states/boto_cfn.py @@ -49,7 +49,7 @@ __virtualname__ = "boto_cfn" __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -62,7 +62,7 @@ def __virtual__(): else: return ( False, - "Cannot load {} state: boto_cfn module unavailable".format(__virtualname__), + f"Cannot load {__virtualname__} state: boto_cfn module unavailable", ) @@ -183,7 +183,7 @@ def present( log.debug("Templates are not the same. Compare value is %s", compare) # At this point we should be able to run update safely since we already validated the template if __opts__["test"]: - ret["comment"] = "Stack {} is set to be updated.".format(name) + ret["comment"] = f"Stack {name} is set to be updated." ret["result"] = None return ret updated = __salt__["boto_cfn.update_stack"]( @@ -219,11 +219,11 @@ def present( ) ret["changes"]["new"] = updated return ret - ret["comment"] = "Stack {} exists.".format(name) + ret["comment"] = f"Stack {name} exists." ret["changes"] = {} return ret if __opts__["test"]: - ret["comment"] = "Stack {} is set to be created.".format(name) + ret["comment"] = f"Stack {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_cfn.create"]( @@ -245,7 +245,7 @@ def present( profile, ) if created: - ret["comment"] = "Stack {} was created.".format(name) + ret["comment"] = f"Stack {name} was created." ret["changes"]["new"] = created return ret ret["result"] = False @@ -269,11 +269,11 @@ def absent(name, region=None, key=None, keyid=None, profile=None): """ ret = {"name": name, "result": True, "comment": "", "changes": {}} if not __salt__["boto_cfn.exists"](name, region, key, keyid, profile): - ret["comment"] = "Stack {} does not exist.".format(name) + ret["comment"] = f"Stack {name} does not exist." ret["changes"] = {} return ret if __opts__["test"]: - ret["comment"] = "Stack {} is set to be deleted.".format(name) + ret["comment"] = f"Stack {name} is set to be deleted." ret["result"] = None return ret deleted = __salt__["boto_cfn.delete"](name, region, key, keyid, profile) @@ -286,7 +286,7 @@ def absent(name, region=None, key=None, keyid=None, profile=None): ret["changes"] = {} return ret if deleted: - ret["comment"] = "Stack {} was deleted.".format(name) + ret["comment"] = f"Stack {name} was deleted." ret["changes"]["deleted"] = name return ret @@ -299,7 +299,7 @@ def _get_template(template, name): return __salt__["cp.get_file_str"](template) except OSError as e: log.debug(e) - ret["comment"] = "File {} not found.".format(template) + ret["comment"] = f"File {template} not found." ret["result"] = False return ret return template diff --git a/salt/states/boto_cloudfront.py b/salt/states/boto_cloudfront.py index 71fe499a7d4..1b52ead08a4 100644 --- a/salt/states/boto_cloudfront.py +++ b/salt/states/boto_cloudfront.py @@ -47,15 +47,15 @@ either passed in as a dict, or a string to pull from pillars or minion config: import difflib import logging - log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -138,7 +138,7 @@ def present( if old is None: if __opts__["test"]: ret["result"] = None - ret["comment"] = "Distribution {} set for creation.".format(name) + ret["comment"] = f"Distribution {name} set for creation." ret["changes"] = {"old": None, "new": name} return ret @@ -160,7 +160,7 @@ def present( return ret ret["result"] = True - ret["comment"] = "Created distribution {}.".format(name) + ret["comment"] = f"Created distribution {name}." ret["changes"] = {"old": None, "new": name} return ret else: @@ -205,7 +205,7 @@ def present( if __opts__["test"]: ret["result"] = None ret["comment"] = "\n".join( - ["Distribution {} set for new config:".format(name), changes_diff] + [f"Distribution {name} set for new config:", changes_diff] ) ret["changes"] = {"diff": changes_diff} return ret @@ -228,6 +228,6 @@ def present( return ret ret["result"] = True - ret["comment"] = "Updated distribution {}.".format(name) + ret["comment"] = f"Updated distribution {name}." ret["changes"] = {"diff": changes_diff} return ret diff --git a/salt/states/boto_cloudtrail.py b/salt/states/boto_cloudtrail.py index d9fb63c5e33..7540e4bdd9f 100644 --- a/salt/states/boto_cloudtrail.py +++ b/salt/states/boto_cloudtrail.py @@ -64,9 +64,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -171,7 +172,7 @@ def present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "CloudTrail {} is set to be created.".format(Name) + ret["comment"] = f"CloudTrail {Name} is set to be created." ret["result"] = None return ret r = __salt__["boto_cloudtrail.create"]( @@ -199,7 +200,7 @@ def present( ) ret["changes"]["old"] = {"trail": None} ret["changes"]["new"] = _describe - ret["comment"] = "CloudTrail {} created.".format(Name) + ret["comment"] = f"CloudTrail {Name} created." if LoggingEnabled: r = __salt__["boto_cloudtrail.start_logging"]( @@ -230,9 +231,7 @@ def present( ret["changes"]["new"]["trail"]["Tags"] = Tags return ret - ret["comment"] = os.linesep.join( - [ret["comment"], "CloudTrail {} is present.".format(Name)] - ) + ret["comment"] = os.linesep.join([ret["comment"], f"CloudTrail {Name} is present."]) ret["changes"] = {} # trail exists, ensure config matches _describe = __salt__["boto_cloudtrail.describe"]( @@ -284,7 +283,7 @@ def present( if need_update: if __opts__["test"]: - msg = "CloudTrail {} set to be modified.".format(Name) + msg = f"CloudTrail {Name} set to be modified." ret["comment"] = msg ret["result"] = None return ret @@ -351,7 +350,7 @@ def present( key=key, keyid=keyid, profile=profile, - **adds + **adds, ) if bool(removes): r = __salt__["boto_cloudtrail.remove_tags"]( @@ -360,7 +359,7 @@ def present( key=key, keyid=keyid, profile=profile, - **removes + **removes, ) return ret @@ -401,11 +400,11 @@ def absent(name, Name, region=None, key=None, keyid=None, profile=None): return ret if r and not r["exists"]: - ret["comment"] = "CloudTrail {} does not exist.".format(Name) + ret["comment"] = f"CloudTrail {Name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "CloudTrail {} is set to be removed.".format(Name) + ret["comment"] = f"CloudTrail {Name} is set to be removed." ret["result"] = None return ret r = __salt__["boto_cloudtrail.delete"]( @@ -417,5 +416,5 @@ def absent(name, Name, region=None, key=None, keyid=None, profile=None): return ret ret["changes"]["old"] = {"trail": Name} ret["changes"]["new"] = {"trail": None} - ret["comment"] = "CloudTrail {} deleted.".format(Name) + ret["comment"] = f"CloudTrail {Name} deleted." return ret diff --git a/salt/states/boto_cloudwatch_alarm.py b/salt/states/boto_cloudwatch_alarm.py index b56074d4d78..6ffe7f6db4d 100644 --- a/salt/states/boto_cloudwatch_alarm.py +++ b/salt/states/boto_cloudwatch_alarm.py @@ -58,9 +58,10 @@ import salt.utils.data __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -111,7 +112,7 @@ def present(name, attributes, region=None, key=None, keyid=None, profile=None): if alarm_details: for k, v in attributes.items(): if k not in alarm_details: - difference.append("{}={} (new)".format(k, v)) + difference.append(f"{k}={v} (new)") continue v = salt.utils.data.decode(v) v2 = salt.utils.data.decode(alarm_details[k]) @@ -125,7 +126,7 @@ def present(name, attributes, region=None, key=None, keyid=None, profile=None): continue if isinstance(v, list) and sorted(v) == sorted(v2): continue - difference.append("{}='{}' was: '{}'".format(k, v, v2)) + difference.append(f"{k}='{v}' was: '{v2}'") else: difference.append("new alarm") create_or_update_alarm_args = { @@ -139,10 +140,10 @@ def present(name, attributes, region=None, key=None, keyid=None, profile=None): if alarm_details: # alarm is present. update, or do nothing # check to see if attributes matches is_present. If so, do nothing. if len(difference) == 0: - ret["comment"] = "alarm {} present and matching".format(name) + ret["comment"] = f"alarm {name} present and matching" return ret if __opts__["test"]: - msg = "alarm {} is to be created/updated.".format(name) + msg = f"alarm {name} is to be created/updated." ret["comment"] = msg ret["result"] = None return ret @@ -153,10 +154,10 @@ def present(name, attributes, region=None, key=None, keyid=None, profile=None): ret["changes"]["diff"] = difference else: ret["result"] = False - ret["comment"] = "Failed to create {} alarm".format(name) + ret["comment"] = f"Failed to create {name} alarm" else: # alarm is absent. create it. if __opts__["test"]: - msg = "alarm {} is to be created/updated.".format(name) + msg = f"alarm {name} is to be created/updated." ret["comment"] = msg ret["result"] = None return ret @@ -167,7 +168,7 @@ def present(name, attributes, region=None, key=None, keyid=None, profile=None): ret["changes"]["new"] = attributes else: ret["result"] = False - ret["comment"] = "Failed to create {} alarm".format(name) + ret["comment"] = f"Failed to create {name} alarm" return ret @@ -199,7 +200,7 @@ def absent(name, region=None, key=None, keyid=None, profile=None): if is_present: if __opts__["test"]: - ret["comment"] = "alarm {} is set to be removed.".format(name) + ret["comment"] = f"alarm {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_cloudwatch.delete_alarm"]( @@ -210,8 +211,8 @@ def absent(name, region=None, key=None, keyid=None, profile=None): ret["changes"]["new"] = None else: ret["result"] = False - ret["comment"] = "Failed to delete {} alarm.".format(name) + ret["comment"] = f"Failed to delete {name} alarm." else: - ret["comment"] = "{} does not exist in {}.".format(name, region) + ret["comment"] = f"{name} does not exist in {region}." return ret diff --git a/salt/states/boto_cloudwatch_event.py b/salt/states/boto_cloudwatch_event.py index 2e956eaf235..9aeed0bf956 100644 --- a/salt/states/boto_cloudwatch_event.py +++ b/salt/states/boto_cloudwatch_event.py @@ -62,9 +62,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -188,7 +189,7 @@ def present( return ret ret["changes"]["old"] = {"rule": None} ret["changes"]["new"] = _describe - ret["comment"] = "CloudTrail {} created.".format(Name) + ret["comment"] = f"CloudTrail {Name} created." if bool(Targets): r = __salt__["boto_cloudwatch_event.put_targets"]( @@ -210,7 +211,7 @@ def present( return ret ret["comment"] = os.linesep.join( - [ret["comment"], "CloudWatch event rule {} is present.".format(Name)] + [ret["comment"], f"CloudWatch event rule {Name} is present."] ) ret["changes"] = {} # trail exists, ensure config matches @@ -255,7 +256,7 @@ def present( if need_update: if __opts__["test"]: - msg = "CloudWatch event rule {} set to be modified.".format(Name) + msg = f"CloudWatch event rule {Name} set to be modified." ret["comment"] = msg ret["result"] = None return ret @@ -366,11 +367,11 @@ def absent(name, Name=None, region=None, key=None, keyid=None, profile=None): return ret if r and not r["exists"]: - ret["comment"] = "CloudWatch event rule {} does not exist.".format(Name) + ret["comment"] = f"CloudWatch event rule {Name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "CloudWatch event rule {} is set to be removed.".format(Name) + ret["comment"] = f"CloudWatch event rule {Name} is set to be removed." ret["result"] = None return ret @@ -411,5 +412,5 @@ def absent(name, Name=None, region=None, key=None, keyid=None, profile=None): return ret ret["changes"]["old"] = {"rule": Name} ret["changes"]["new"] = {"rule": None} - ret["comment"] = "CloudWatch event rule {} deleted.".format(Name) + ret["comment"] = f"CloudWatch event rule {Name} deleted." return ret diff --git a/salt/states/boto_cognitoidentity.py b/salt/states/boto_cognitoidentity.py index c514a336dc7..5a65498533f 100644 --- a/salt/states/boto_cognitoidentity.py +++ b/salt/states/boto_cognitoidentity.py @@ -53,7 +53,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -115,7 +115,7 @@ def _role_present( IdentityPoolId=IdentityPoolId, AuthenticatedRole=AuthenticatedRole, UnauthenticatedRole=UnauthenticatedRole, - **conn_params + **conn_params, ) if not r.get("set"): ret["result"] = False @@ -305,7 +305,7 @@ def pool_present( if existing_identity_pool != updated_identity_pool: ret["changes"]["old"] = dict() ret["changes"]["new"] = dict() - change_key = "Identity Pool Name {}".format(IdentityPoolName) + change_key = f"Identity Pool Name {IdentityPoolName}" ret["changes"]["old"][change_key] = existing_identity_pool ret["changes"]["new"][change_key] = updated_identity_pool else: @@ -419,12 +419,10 @@ def pool_absent( if not ret["changes"]: ret["changes"]["old"] = dict() ret["changes"]["new"] = dict() - change_key = "Identity Pool Id {}".format(IdentityPoolId) + change_key = f"Identity Pool Id {IdentityPoolId}" ret["changes"]["old"][change_key] = IdentityPoolName ret["changes"]["new"][change_key] = None - ret["comment"] = "{}\n{}".format( - ret["comment"], "{} deleted".format(change_key) - ) + ret["comment"] = "{}\n{}".format(ret["comment"], f"{change_key} deleted") else: ret["result"] = False failure_comment = ( diff --git a/salt/states/boto_datapipeline.py b/salt/states/boto_datapipeline.py index 4401bc18893..a52a64f9d8c 100644 --- a/salt/states/boto_datapipeline.py +++ b/salt/states/boto_datapipeline.py @@ -59,7 +59,7 @@ import salt.utils.json __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -139,11 +139,11 @@ def present( profile=profile, ) if present: - ret["comment"] = "AWS data pipeline {} present".format(name) + ret["comment"] = f"AWS data pipeline {name} present" return ret if __opts__["test"]: - ret["comment"] = "Data pipeline {} is set to be created or updated".format(name) + ret["comment"] = f"Data pipeline {name} is set to be created or updated" ret["result"] = None return ret @@ -266,10 +266,10 @@ def present( if not old_pipeline_definition: ret["changes"]["new"] = "Pipeline created." - ret["comment"] = "Data pipeline {} created".format(name) + ret["comment"] = f"Data pipeline {name} created" else: ret["changes"]["diff"] = _diff(old_pipeline_definition, new_pipeline_definition) - ret["comment"] = "Data pipeline {} updated".format(name) + ret["comment"] = f"Data pipeline {name} updated" return ret @@ -602,7 +602,7 @@ def absent(name, region=None, key=None, keyid=None, profile=None): if "error" not in result_pipeline_id: pipeline_id = result_pipeline_id["result"] if __opts__["test"]: - ret["comment"] = "Data pipeline {} set to be deleted.".format(name) + ret["comment"] = f"Data pipeline {name} set to be deleted." ret["result"] = None return ret else: @@ -616,6 +616,6 @@ def absent(name, region=None, key=None, keyid=None, profile=None): ret["changes"]["old"] = {"pipeline_id": pipeline_id} ret["changes"]["new"] = None else: - ret["comment"] = "AWS data pipeline {} absent.".format(name) + ret["comment"] = f"AWS data pipeline {name} absent." return ret diff --git a/salt/states/boto_dynamodb.py b/salt/states/boto_dynamodb.py index c296684a395..813f03651fd 100644 --- a/salt/states/boto_dynamodb.py +++ b/salt/states/boto_dynamodb.py @@ -165,7 +165,7 @@ import salt.utils.dictupdate as dictupdate __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) logging.basicConfig( level=logging.INFO, @@ -289,7 +289,7 @@ def present( if not table_exists: if __opts__["test"]: ret["result"] = None - ret["comment"] = "DynamoDB table {} would be created.".format(name) + ret["comment"] = f"DynamoDB table {name} would be created." return ret else: is_created = __salt__["boto_dynamodb.create_table"]( @@ -309,11 +309,11 @@ def present( ) if not is_created: ret["result"] = False - ret["comment"] = "Failed to create table {}".format(name) + ret["comment"] = f"Failed to create table {name}" _add_changes(ret, changes_old, changes_new) return ret - comments.append("DynamoDB table {} was successfully created".format(name)) + comments.append(f"DynamoDB table {name} was successfully created") changes_new["table"] = name changes_new["read_capacity_units"] = read_capacity_units changes_new["write_capacity_units"] = write_capacity_units @@ -324,7 +324,7 @@ def present( changes_new["local_indexes"] = local_indexes changes_new["global_indexes"] = global_indexes else: - comments.append("DynamoDB table {} exists".format(name)) + comments.append(f"DynamoDB table {name} exists") # Ensure DynamoDB table provisioned throughput matches description = __salt__["boto_dynamodb.describe"](name, region, key, keyid, profile) @@ -340,7 +340,7 @@ def present( if not throughput_matches: if __opts__["test"]: ret["result"] = None - comments.append("DynamoDB table {} is set to be updated.".format(name)) + comments.append(f"DynamoDB table {name} is set to be updated.") else: is_updated = __salt__["boto_dynamodb.update"]( name, @@ -355,17 +355,17 @@ def present( ) if not is_updated: ret["result"] = False - ret["comment"] = "Failed to update table {}".format(name) + ret["comment"] = f"Failed to update table {name}" _add_changes(ret, changes_old, changes_new) return ret - comments.append("DynamoDB table {} was successfully updated".format(name)) + comments.append(f"DynamoDB table {name} was successfully updated") changes_old["read_capacity_units"] = (current_read_capacity_units,) changes_old["write_capacity_units"] = (current_write_capacity_units,) changes_new["read_capacity_units"] = (read_capacity_units,) changes_new["write_capacity_units"] = (write_capacity_units,) else: - comments.append("DynamoDB table {} throughput matches".format(name)) + comments.append(f"DynamoDB table {name} throughput matches") provisioned_indexes = description.get("Table", {}).get("GlobalSecondaryIndexes", []) @@ -483,7 +483,7 @@ def _global_indexes_present( index_name = next(iter(entry.values())) if not index_name: ret["result"] = False - ret["comment"] = "Index name not found for table {}".format(name) + ret["comment"] = f"Index name not found for table {name}" return ret gsi_config[index_name] = index @@ -596,11 +596,11 @@ def _add_global_secondary_index( ) if success: - comments.append("Created GSI {}".format(index_name)) + comments.append(f"Created GSI {index_name}") changes_new["global_indexes"][index_name] = gsi_config[index_name] else: ret["result"] = False - ret["comment"] = "Failed to create GSI {}".format(index_name) + ret["comment"] = f"Failed to create GSI {index_name}" def _update_global_secondary_indexes( @@ -646,9 +646,7 @@ def _update_global_secondary_indexes( ) if success: - comments.append( - "Updated GSIs with new throughputs {}".format(index_updates) - ) + comments.append(f"Updated GSIs with new throughputs {index_updates}") for index_name in index_updates: changes_old["global_indexes"][index_name] = provisioned_throughputs[ index_name @@ -656,7 +654,7 @@ def _update_global_secondary_indexes( changes_new["global_indexes"][index_name] = index_updates[index_name] else: ret["result"] = False - ret["comment"] = "Failed to update GSI throughputs {}".format(index_updates) + ret["comment"] = f"Failed to update GSI throughputs {index_updates}" def _determine_gsi_updates(existing_index_names, provisioned_gsi_config, gsi_config): @@ -784,7 +782,7 @@ def _ensure_backup_datapipeline_present( ): kwargs = { - "name": "{}-{}-backup".format(name, schedule_name), + "name": f"{name}-{schedule_name}-backup", "pipeline_objects": { "DefaultSchedule": { "name": schedule_name, @@ -799,7 +797,7 @@ def _ensure_backup_datapipeline_present( }, "parameter_values": { "myDDBTableName": name, - "myOutputS3Loc": "{}/{}/".format(s3_base_location, name), + "myOutputS3Loc": f"{s3_base_location}/{name}/", }, } return __states__["boto_datapipeline.present"](**kwargs) @@ -865,20 +863,20 @@ def absent(name, region=None, key=None, keyid=None, profile=None): ret = {"name": name, "result": True, "comment": "", "changes": {}} exists = __salt__["boto_dynamodb.exists"](name, region, key, keyid, profile) if not exists: - ret["comment"] = "DynamoDB table {} does not exist".format(name) + ret["comment"] = f"DynamoDB table {name} does not exist" return ret if __opts__["test"]: - ret["comment"] = "DynamoDB table {} is set to be deleted".format(name) + ret["comment"] = f"DynamoDB table {name} is set to be deleted" ret["result"] = None return ret is_deleted = __salt__["boto_dynamodb.delete"](name, region, key, keyid, profile) if is_deleted: - ret["comment"] = "Deleted DynamoDB table {}".format(name) - ret["changes"].setdefault("old", "Table {} exists".format(name)) - ret["changes"].setdefault("new", "Table {} deleted".format(name)) + ret["comment"] = f"Deleted DynamoDB table {name}" + ret["changes"].setdefault("old", f"Table {name} exists") + ret["changes"].setdefault("new", f"Table {name} deleted") else: - ret["comment"] = "Failed to delete DynamoDB table {}".format(name) + ret["comment"] = f"Failed to delete DynamoDB table {name}" ret["result"] = False return ret diff --git a/salt/states/boto_ec2.py b/salt/states/boto_ec2.py index ba3e0953c12..9cbf098f4e9 100644 --- a/salt/states/boto_ec2.py +++ b/salt/states/boto_ec2.py @@ -63,7 +63,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -96,12 +96,12 @@ def key_present( upload_public = __salt__["cp.get_file_str"](upload_public) except OSError as e: log.debug(e) - ret["comment"] = "File {} not found.".format(upload_public) + ret["comment"] = f"File {upload_public} not found." ret["result"] = False return ret if not exists: if __opts__["test"]: - ret["comment"] = "The key {} is set to be created.".format(name) + ret["comment"] = f"The key {name} is set to be created." ret["result"] = None return ret if save_private and not upload_public: @@ -110,29 +110,29 @@ def key_present( ) if created: ret["result"] = True - ret["comment"] = "The key {} is created.".format(name) + ret["comment"] = f"The key {name} is created." ret["changes"]["new"] = created else: ret["result"] = False - ret["comment"] = "Could not create key {} ".format(name) + ret["comment"] = f"Could not create key {name} " elif not save_private and upload_public: imported = __salt__["boto_ec2.import_key"]( name, upload_public, region, key, keyid, profile ) if imported: ret["result"] = True - ret["comment"] = "The key {} is created.".format(name) + ret["comment"] = f"The key {name} is created." ret["changes"]["old"] = None ret["changes"]["new"] = imported else: ret["result"] = False - ret["comment"] = "Could not create key {} ".format(name) + ret["comment"] = f"Could not create key {name} " else: ret["result"] = False ret["comment"] = "You can either upload or download a private key " else: ret["result"] = True - ret["comment"] = "The key name {} already exists".format(name) + ret["comment"] = f"The key name {name} already exists" return ret @@ -144,21 +144,21 @@ def key_absent(name, region=None, key=None, keyid=None, profile=None): exists = __salt__["boto_ec2.get_key"](name, region, key, keyid, profile) if exists: if __opts__["test"]: - ret["comment"] = "The key {} is set to be deleted.".format(name) + ret["comment"] = f"The key {name} is set to be deleted." ret["result"] = None return ret deleted = __salt__["boto_ec2.delete_key"](name, region, key, keyid, profile) log.debug("exists is %s", deleted) if deleted: ret["result"] = True - ret["comment"] = "The key {} is deleted.".format(name) + ret["comment"] = f"The key {name} is deleted." ret["changes"]["old"] = name else: ret["result"] = False - ret["comment"] = "Could not delete key {} ".format(name) + ret["comment"] = f"Could not delete key {name} " else: ret["result"] = True - ret["comment"] = "The key name {} does not exist".format(name) + ret["comment"] = f"The key name {name} does not exist" return ret @@ -290,7 +290,7 @@ def eni_present( ) return ret r["result"] = result_create["result"] - ret["comment"] = "Created ENI {}".format(name) + ret["comment"] = f"Created ENI {name}" ret["changes"]["id"] = r["result"]["id"] else: _ret = _eni_attribute( @@ -428,7 +428,7 @@ def _eni_attribute(metadata, attr, value, region, key, keyid, profile): if metadata[attr] == value: return ret if __opts__["test"]: - ret["comment"] = "ENI set to have {} updated.".format(attr) + ret["comment"] = f"ENI set to have {attr} updated." ret["result"] = None return ret result_update = __salt__["boto_ec2.modify_network_interface_attribute"]( @@ -445,7 +445,7 @@ def _eni_attribute(metadata, attr, value, region, key, keyid, profile): ret["result"] = False ret["comment"] = msg.format(attr, result_update["error"]["message"]) else: - ret["comment"] = "Updated ENI {}.".format(attr) + ret["comment"] = f"Updated ENI {attr}." ret["changes"][attr] = {"old": metadata[attr], "new": value} return ret @@ -567,7 +567,7 @@ def eni_absent( result_delete["error"]["message"] ) return ret - ret["comment"] = "Deleted ENI {}".format(name) + ret["comment"] = f"Deleted ENI {name}" ret["changes"]["id"] = None if release_eip and "allocationId" in r["result"]: _ret = __salt__["boto_ec2.release_eip_address"]( @@ -596,7 +596,7 @@ def snapshot_created( instance_name, wait_until_available=True, wait_timeout_seconds=300, - **kwargs + **kwargs, ): """ Create a snapshot from the given instance @@ -608,11 +608,11 @@ def snapshot_created( if not __salt__["boto_ec2.create_image"]( ami_name=ami_name, instance_name=instance_name, **kwargs ): - ret["comment"] = "Failed to create new AMI {ami_name}".format(ami_name=ami_name) + ret["comment"] = f"Failed to create new AMI {ami_name}" ret["result"] = False return ret - ret["comment"] = "Created new AMI {ami_name}".format(ami_name=ami_name) + ret["comment"] = f"Created new AMI {ami_name}" ret["changes"]["new"] = {ami_name: ami_name} if not wait_until_available: return ret @@ -894,7 +894,7 @@ def instance_present( if _create: if __opts__["test"]: - ret["comment"] = "The instance {} is set to be created.".format(name) + ret["comment"] = f"The instance {name} is set to be created." ret["result"] = None return ret if image_name: @@ -1021,7 +1021,7 @@ def instance_present( return ret else: if __opts__["test"]: - ret["comment"] = "Instance {} to be updated.".format(name) + ret["comment"] = f"Instance {name} to be updated." ret["result"] = None return ret r = __salt__["boto_ec2.associate_eip_address"]( @@ -1254,7 +1254,7 @@ def instance_absent( ) if not instances: ret["result"] = True - ret["comment"] = "Instance {} is already gone.".format(instance_id) + ret["comment"] = f"Instance {instance_id} is already gone." return ret instance = instances[0] @@ -1275,7 +1275,7 @@ def instance_absent( return ret if __opts__["test"]: - ret["comment"] = "The instance {} is set to be deleted.".format(name) + ret["comment"] = f"The instance {name} is set to be deleted." ret["result"] = None return ret @@ -1289,7 +1289,7 @@ def instance_absent( ) if not r: ret["result"] = False - ret["comment"] = "Failed to terminate instance {}.".format(instance_id) + ret["comment"] = f"Failed to terminate instance {instance_id}." return ret ret["changes"]["old"] = {"instance_id": instance_id} @@ -1315,9 +1315,7 @@ def instance_absent( else: # I /believe/ this situation is impossible but let's hedge our bets... ret["result"] = False - ret[ - "comment" - ] = "Can't determine AllocationId for address {}.".format(ip) + ret["comment"] = f"Can't determine AllocationId for address {ip}." return ret else: public_ip = instance.ip_address @@ -1336,7 +1334,7 @@ def instance_absent( ret["changes"]["old"]["public_ip"] = public_ip or r[0]["public_ip"] else: ret["result"] = False - ret["comment"] = "Failed to release EIP {}.".format(ip) + ret["comment"] = f"Failed to release EIP {ip}." return ret return ret @@ -1456,14 +1454,14 @@ def volume_absent( log.info("Matched Volume ID %s", vol) if __opts__["test"]: - ret["comment"] = "The volume {} is set to be deleted.".format(vol) + ret["comment"] = f"The volume {vol} is set to be deleted." ret["result"] = None return ret if __salt__["boto_ec2.delete_volume"](volume_id=vol, force=True, **args): - ret["comment"] = "Volume {} deleted.".format(vol) + ret["comment"] = f"Volume {vol} deleted." ret["changes"] = {"old": {"volume_id": vol}, "new": {"volume_id": None}} else: - ret["comment"] = "Error deleting volume {}.".format(vol) + ret["comment"] = f"Error deleting volume {vol}." ret["result"] = False return ret @@ -1671,9 +1669,7 @@ def volume_present( name=instance_name, in_states=running_states, **args ) if not instance_id: - raise SaltInvocationError( - "Instance with Name {} not found.".format(instance_name) - ) + raise SaltInvocationError(f"Instance with Name {instance_name} not found.") instances = __salt__["boto_ec2.find_instances"]( instance_id=instance_id, return_objs=True, **args @@ -1706,13 +1702,13 @@ def volume_present( encrypted=encrypted, kms_key_id=kms_key_id, wait_for_creation=True, - **args + **args, ) if "result" in _rt: volume_id = _rt["result"] else: raise SaltInvocationError( - "Error creating volume with name {}.".format(volume_name) + f"Error creating volume with name {volume_name}." ) _rt = __salt__["boto_ec2.set_volumes_tags"]( tag_maps=[ @@ -1721,7 +1717,7 @@ def volume_present( "tags": {"Name": volume_name}, } ], - **args + **args, ) if _rt["success"] is False: raise SaltInvocationError( @@ -1737,7 +1733,7 @@ def volume_present( volume_ids=[volume_id], return_objs=True, **args ) if len(vols) < 1: - raise SaltInvocationError("Volume {} do not exist".format(volume_id)) + raise SaltInvocationError(f"Volume {volume_id} do not exist") vol = vols[0] if vol.zone != instance.placement: raise SaltInvocationError( diff --git a/salt/states/boto_elasticache.py b/salt/states/boto_elasticache.py index 9e4cdbdab6d..2f0bfbf0d6d 100644 --- a/salt/states/boto_elasticache.py +++ b/salt/states/boto_elasticache.py @@ -78,15 +78,15 @@ passed in as a dict, or as a string to pull from pillars or minion config: import logging - log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -233,7 +233,7 @@ def present( return ret elif not config: if __opts__["test"]: - msg = "Cache cluster {} is set to be created.".format(name) + msg = f"Cache cluster {name} is set to be created." ret["comment"] = msg ret["result"] = None return ret @@ -267,11 +267,11 @@ def present( ret["changes"]["new"] = config else: ret["result"] = False - ret["comment"] = "Failed to create {} cache cluster.".format(name) + ret["comment"] = f"Failed to create {name} cache cluster." return ret # TODO: support modification of existing elasticache clusters else: - ret["comment"] = "Cache cluster {} is present.".format(name) + ret["comment"] = f"Cache cluster {name} is present." return ret @@ -326,7 +326,7 @@ def subnet_group_present( ) if not exists: if __opts__["test"]: - ret["comment"] = "Subnet group {} is set to be created.".format(name) + ret["comment"] = f"Subnet group {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_elasticache.create_subnet_group"]( @@ -342,11 +342,11 @@ def subnet_group_present( ) if not created: ret["result"] = False - ret["comment"] = "Failed to create {} subnet group.".format(name) + ret["comment"] = f"Failed to create {name} subnet group." return ret ret["changes"]["old"] = None ret["changes"]["new"] = name - ret["comment"] = "Subnet group {} created.".format(name) + ret["comment"] = f"Subnet group {name} created." return ret ret["comment"] = "Subnet group present." return ret @@ -386,7 +386,7 @@ def absent(name, wait=True, region=None, key=None, keyid=None, profile=None): if is_present: if __opts__["test"]: - ret["comment"] = "Cache cluster {} is set to be removed.".format(name) + ret["comment"] = f"Cache cluster {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_elasticache.delete"]( @@ -397,9 +397,9 @@ def absent(name, wait=True, region=None, key=None, keyid=None, profile=None): ret["changes"]["new"] = None else: ret["result"] = False - ret["comment"] = "Failed to delete {} cache cluster.".format(name) + ret["comment"] = f"Failed to delete {name} cache cluster." else: - ret["comment"] = "{} does not exist in {}.".format(name, region) + ret["comment"] = f"{name} does not exist in {region}." return ret @@ -451,7 +451,7 @@ def creategroup( ) if not is_present: if __opts__["test"]: - ret["comment"] = "Replication {} is set to be created.".format(name) + ret["comment"] = f"Replication {name} is set to be created." ret["result"] = None created = __salt__["boto_elasticache.create_replication_group"]( name, @@ -472,9 +472,9 @@ def creategroup( ret["result"] = True else: ret["result"] = False - ret["comment"] = "Failed to create {} replication group.".format(name) + ret["comment"] = f"Failed to create {name} replication group." else: - ret["comment"] = "{} replication group exists .".format(name) + ret["comment"] = f"{name} replication group exists ." ret["result"] = True return ret @@ -489,7 +489,7 @@ def subnet_group_absent( ) if not exists: ret["result"] = True - ret["comment"] = "{} ElastiCache subnet group does not exist.".format(name) + ret["comment"] = f"{name} ElastiCache subnet group does not exist." return ret if __opts__["test"]: @@ -503,11 +503,11 @@ def subnet_group_absent( ) if not deleted: ret["result"] = False - ret["comment"] = "Failed to delete {} ElastiCache subnet group.".format(name) + ret["comment"] = f"Failed to delete {name} ElastiCache subnet group." return ret ret["changes"]["old"] = name ret["changes"]["new"] = None - ret["comment"] = "ElastiCache subnet group {} deleted.".format(name) + ret["comment"] = f"ElastiCache subnet group {name} deleted." return ret @@ -521,14 +521,12 @@ def replication_group_absent( ) if not exists: ret["result"] = True - ret["comment"] = "{} ElastiCache replication group does not exist.".format(name) + ret["comment"] = f"{name} ElastiCache replication group does not exist." log.info(ret["comment"]) return ret if __opts__["test"]: - ret[ - "comment" - ] = "ElastiCache replication group {} is set to be removed.".format(name) + ret["comment"] = f"ElastiCache replication group {name} is set to be removed." ret["result"] = True return ret deleted = __salt__["boto_elasticache.delete_replication_group"]( @@ -543,6 +541,6 @@ def replication_group_absent( return ret ret["changes"]["old"] = name ret["changes"]["new"] = None - ret["comment"] = "ElastiCache replication group {} deleted.".format(name) + ret["comment"] = f"ElastiCache replication group {name} deleted." log.info(ret["comment"]) return ret diff --git a/salt/states/boto_elasticsearch_domain.py b/salt/states/boto_elasticsearch_domain.py index c4a25e04f1e..1d0a9b646da 100644 --- a/salt/states/boto_elasticsearch_domain.py +++ b/salt/states/boto_elasticsearch_domain.py @@ -88,9 +88,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -227,7 +228,7 @@ def present( AccessPolicies = salt.utils.json.loads(AccessPolicies) except ValueError as e: ret["result"] = False - ret["comment"] = "Failed to create domain: {}.".format(e.message) + ret["comment"] = f"Failed to create domain: {e.message}." return ret r = __salt__["boto_elasticsearch_domain.exists"]( DomainName=DomainName, region=region, key=key, keyid=keyid, profile=profile @@ -240,7 +241,7 @@ def present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Domain {} is set to be created.".format(DomainName) + ret["comment"] = f"Domain {DomainName} is set to be created." ret["result"] = None return ret r = __salt__["boto_elasticsearch_domain.create"]( @@ -267,11 +268,11 @@ def present( ) ret["changes"]["old"] = {"domain": None} ret["changes"]["new"] = _describe - ret["comment"] = "Domain {} created.".format(DomainName) + ret["comment"] = f"Domain {DomainName} created." return ret ret["comment"] = os.linesep.join( - [ret["comment"], "Domain {} is present.".format(DomainName)] + [ret["comment"], f"Domain {DomainName} is present."] ) ret["changes"] = {} # domain exists, ensure config matches @@ -316,7 +317,7 @@ def present( ret["changes"].setdefault("old", {})[k] = _describe[k] if need_update: if __opts__["test"]: - msg = "Domain {} set to be modified.".format(DomainName) + msg = f"Domain {DomainName} set to be modified." ret["comment"] = msg ret["result"] = None return ret @@ -329,7 +330,7 @@ def present( key=key, keyid=keyid, profile=profile, - **comm_args + **comm_args, ) if not r.get("updated"): ret["result"] = False @@ -374,11 +375,11 @@ def absent(name, DomainName, region=None, key=None, keyid=None, profile=None): return ret if r and not r["exists"]: - ret["comment"] = "Domain {} does not exist.".format(DomainName) + ret["comment"] = f"Domain {DomainName} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Domain {} is set to be removed.".format(DomainName) + ret["comment"] = f"Domain {DomainName} is set to be removed." ret["result"] = None return ret @@ -391,5 +392,5 @@ def absent(name, DomainName, region=None, key=None, keyid=None, profile=None): return ret ret["changes"]["old"] = {"domain": DomainName} ret["changes"]["new"] = {"domain": None} - ret["comment"] = "Domain {} deleted.".format(DomainName) + ret["comment"] = f"Domain {DomainName} deleted." return ret diff --git a/salt/states/boto_elb.py b/salt/states/boto_elb.py index e3c975f389c..86363bb9cda 100644 --- a/salt/states/boto_elb.py +++ b/salt/states/boto_elb.py @@ -249,7 +249,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -555,7 +555,7 @@ def present( if __salt__["boto_elb.set_instances"]( name, instance_ids, True, region, key, keyid, profile ): - ret["comment"] += " ELB {} instances would be updated.".format(name) + ret["comment"] += f" ELB {name} instances would be updated." ret["result"] = None else: success = __salt__["boto_elb.set_instances"]( @@ -598,7 +598,7 @@ def register_instances( ret = {"name": name, "result": True, "comment": "", "changes": {}} lb = __salt__["boto_elb.exists"](name, region, key, keyid, profile) if not lb: - msg = "Could not find lb {}".format(name) + msg = f"Could not find lb {name}" log.error(msg) ret.update({"comment": msg, "result": False}) return ret @@ -617,7 +617,7 @@ def register_instances( return ret if __opts__["test"]: - ret["comment"] = "ELB {} is set to register : {}.".format(name, new) + ret["comment"] = f"ELB {name} is set to register : {new}." ret["result"] = None return ret @@ -625,7 +625,7 @@ def register_instances( name, instances, region, key, keyid, profile ) if state: - msg = "Load Balancer {} has been changed".format(name) + msg = f"Load Balancer {name} has been changed" log.info(msg) new = set().union(nodes, instances) ret.update( @@ -635,7 +635,7 @@ def register_instances( } ) else: - msg = "Load balancer {} failed to add instances".format(name) + msg = f"Load balancer {name} failed to add instances" log.error(msg) ret.update({"comment": msg, "result": False}) return ret @@ -712,7 +712,7 @@ def _elb_present( ret["result"] = False return ret if "id" not in r: - ret["comment"] = "Subnet {} does not exist.".format(i) + ret["comment"] = f"Subnet {i} does not exist." ret["result"] = False return ret subnets.append(r["id"]) @@ -724,7 +724,7 @@ def _elb_present( ) vpc_id = vpc_id.get("vpc_id") if not vpc_id: - ret["comment"] = "Subnets {} do not map to a valid vpc id.".format(subnets) + ret["comment"] = f"Subnets {subnets} do not map to a valid vpc id." ret["result"] = False return ret _security_groups = __salt__["boto_secgroup.convert_to_group_ids"]( @@ -746,7 +746,7 @@ def _elb_present( exists = __salt__["boto_elb.exists"](name, region, key, keyid, profile) if not exists: if __opts__["test"]: - ret["comment"] = "ELB {} is set to be created.".format(name) + ret["comment"] = f"ELB {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_elb.create"]( @@ -764,12 +764,12 @@ def _elb_present( if created: ret["changes"]["old"] = {"elb": None} ret["changes"]["new"] = {"elb": name} - ret["comment"] = "ELB {} created.".format(name) + ret["comment"] = f"ELB {name} created." else: ret["result"] = False - ret["comment"] = "Failed to create {} ELB.".format(name) + ret["comment"] = f"Failed to create {name} ELB." else: - ret["comment"] = "ELB {} present.".format(name) + ret["comment"] = f"ELB {name} present." _ret = _security_groups_present( name, _security_groups, region, key, keyid, profile ) @@ -811,7 +811,7 @@ def _listeners_present(name, listeners, region, key, keyid, profile): ret = {"result": True, "comment": "", "changes": {}} lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) if not lb: - ret["comment"] = "{} ELB configuration could not be retrieved.".format(name) + ret["comment"] = f"{name} ELB configuration could not be retrieved." ret["result"] = False return ret if not listeners: @@ -839,7 +839,7 @@ def _listeners_present(name, listeners, region, key, keyid, profile): if __opts__["test"]: msg = [] if to_create or to_delete: - msg.append("ELB {} set to have listeners modified:".format(name)) + msg.append(f"ELB {name} set to have listeners modified:") for listener in to_create: msg.append( "Listener {} added.".format( @@ -854,7 +854,7 @@ def _listeners_present(name, listeners, region, key, keyid, profile): ) ret["result"] = None else: - msg.append("Listeners already set on ELB {}.".format(name)) + msg.append(f"Listeners already set on ELB {name}.") ret["comment"] = " ".join(msg) return ret @@ -864,9 +864,9 @@ def _listeners_present(name, listeners, region, key, keyid, profile): name, ports, region, key, keyid, profile ) if deleted: - ret["comment"] = "Deleted listeners on {} ELB.".format(name) + ret["comment"] = f"Deleted listeners on {name} ELB." else: - ret["comment"] = "Failed to delete listeners on {} ELB.".format(name) + ret["comment"] = f"Failed to delete listeners on {name} ELB." ret["result"] = False if to_create: @@ -887,7 +887,7 @@ def _listeners_present(name, listeners, region, key, keyid, profile): lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) ret["changes"]["listeners"]["new"] = lb["listeners"] else: - ret["comment"] = "Listeners already set on ELB {}.".format(name) + ret["comment"] = f"Listeners already set on ELB {name}." return ret @@ -896,7 +896,7 @@ def _security_groups_present(name, security_groups, region, key, keyid, profile) ret = {"result": True, "comment": "", "changes": {}} lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) if not lb: - ret["comment"] = "{} ELB configuration could not be retrieved.".format(name) + ret["comment"] = f"{name} ELB configuration could not be retrieved." ret["result"] = False return ret if not security_groups: @@ -906,21 +906,21 @@ def _security_groups_present(name, security_groups, region, key, keyid, profile) change_needed = True if change_needed: if __opts__["test"]: - ret["comment"] = "ELB {} set to have security groups modified.".format(name) + ret["comment"] = f"ELB {name} set to have security groups modified." ret["result"] = None return ret changed = __salt__["boto_elb.apply_security_groups"]( name, security_groups, region, key, keyid, profile ) if changed: - ret["comment"] = "Modified security_groups on {} ELB.".format(name) + ret["comment"] = f"Modified security_groups on {name} ELB." else: - ret["comment"] = "Failed to modify security_groups on {} ELB.".format(name) + ret["comment"] = f"Failed to modify security_groups on {name} ELB." ret["result"] = False ret["changes"]["old"] = {"security_groups": lb["security_groups"]} ret["changes"]["new"] = {"security_groups": security_groups} else: - ret["comment"] = "security_groups already set on ELB {}.".format(name) + ret["comment"] = f"security_groups already set on ELB {name}." return ret @@ -929,7 +929,7 @@ def _attributes_present(name, attributes, region, key, keyid, profile): _attributes = __salt__["boto_elb.get_attributes"](name, region, key, keyid, profile) if not _attributes: ret["result"] = False - ret["comment"] = "Failed to retrieve attributes for ELB {}.".format(name) + ret["comment"] = f"Failed to retrieve attributes for ELB {name}." return ret attrs_to_set = [] if "cross_zone_load_balancing" in attributes: @@ -961,7 +961,7 @@ def _attributes_present(name, attributes, region, key, keyid, profile): ) if attrs_to_set: if __opts__["test"]: - ret["comment"] = "ELB {} set to have attributes set.".format(name) + ret["comment"] = f"ELB {name} set to have attributes set." ret["result"] = None return ret was_set = __salt__["boto_elb.set_attributes"]( @@ -970,12 +970,12 @@ def _attributes_present(name, attributes, region, key, keyid, profile): if was_set: ret["changes"]["old"] = {"attributes": _attributes} ret["changes"]["new"] = {"attributes": attributes} - ret["comment"] = "Set attributes on ELB {}.".format(name) + ret["comment"] = f"Set attributes on ELB {name}." else: ret["result"] = False - ret["comment"] = "Failed to set attributes on ELB {}.".format(name) + ret["comment"] = f"Failed to set attributes on ELB {name}." else: - ret["comment"] = "Attributes already set on ELB {}.".format(name) + ret["comment"] = f"Attributes already set on ELB {name}." return ret @@ -988,7 +988,7 @@ def _health_check_present(name, health_check, region, key, keyid, profile): ) if not _health_check: ret["result"] = False - ret["comment"] = "Failed to retrieve health_check for ELB {}.".format(name) + ret["comment"] = f"Failed to retrieve health_check for ELB {name}." return ret need_to_set = False for attr, val in health_check.items(): @@ -996,7 +996,7 @@ def _health_check_present(name, health_check, region, key, keyid, profile): need_to_set = True if need_to_set: if __opts__["test"]: - ret["comment"] = "ELB {} set to have health check set.".format(name) + ret["comment"] = f"ELB {name} set to have health check set." ret["result"] = None return ret was_set = __salt__["boto_elb.set_health_check"]( @@ -1008,12 +1008,12 @@ def _health_check_present(name, health_check, region, key, keyid, profile): name, region, key, keyid, profile ) ret["changes"]["new"] = {"health_check": _health_check} - ret["comment"] = "Set health check on ELB {}.".format(name) + ret["comment"] = f"Set health check on ELB {name}." else: ret["result"] = False - ret["comment"] = "Failed to set health check on ELB {}.".format(name) + ret["comment"] = f"Failed to set health check on ELB {name}." else: - ret["comment"] = "Health check already set on ELB {}.".format(name) + ret["comment"] = f"Health check already set on ELB {name}." return ret @@ -1022,7 +1022,7 @@ def _zones_present(name, availability_zones, region, key, keyid, profile): lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) if not lb: ret["result"] = False - ret["comment"] = "Failed to retrieve ELB {}.".format(name) + ret["comment"] = f"Failed to retrieve ELB {name}." return ret to_enable = [] to_disable = [] @@ -1035,7 +1035,7 @@ def _zones_present(name, availability_zones, region, key, keyid, profile): to_disable.append(zone) if to_enable or to_disable: if __opts__["test"]: - ret["comment"] = "ELB {} to have availability zones set.".format(name) + ret["comment"] = f"ELB {name} to have availability zones set." ret["result"] = None return ret if to_enable: @@ -1043,11 +1043,9 @@ def _zones_present(name, availability_zones, region, key, keyid, profile): name, to_enable, region, key, keyid, profile ) if enabled: - ret["comment"] = "Enabled availability zones on {} ELB.".format(name) + ret["comment"] = f"Enabled availability zones on {name} ELB." else: - ret[ - "comment" - ] = "Failed to enable availability zones on {} ELB.".format(name) + ret["comment"] = f"Failed to enable availability zones on {name} ELB." ret["result"] = False if to_disable: disabled = __salt__["boto_elb.disable_availability_zones"]( @@ -1064,7 +1062,7 @@ def _zones_present(name, availability_zones, region, key, keyid, profile): lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) ret["changes"]["new"] = {"availability_zones": lb["availability_zones"]} else: - ret["comment"] = "Availability zones already set on ELB {}.".format(name) + ret["comment"] = f"Availability zones already set on ELB {name}." return ret @@ -1075,7 +1073,7 @@ def _subnets_present(name, subnets, region, key, keyid, profile): lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) if not lb: ret["result"] = False - ret["comment"] = "Failed to retrieve ELB {}.".format(name) + ret["comment"] = f"Failed to retrieve ELB {name}." return ret to_enable = [] to_disable = [] @@ -1088,7 +1086,7 @@ def _subnets_present(name, subnets, region, key, keyid, profile): to_disable.append(subnet) if to_enable or to_disable: if __opts__["test"]: - ret["comment"] = "ELB {} to have subnets set.".format(name) + ret["comment"] = f"ELB {name} to have subnets set." ret["result"] = None return ret if to_enable: @@ -1096,9 +1094,9 @@ def _subnets_present(name, subnets, region, key, keyid, profile): name, to_enable, region, key, keyid, profile ) if attached: - ret["comment"] = "Attached subnets on {} ELB.".format(name) + ret["comment"] = f"Attached subnets on {name} ELB." else: - ret["comment"] = "Failed to attach subnets on {} ELB.".format(name) + ret["comment"] = f"Failed to attach subnets on {name} ELB." ret["result"] = False if to_disable: detached = __salt__["boto_elb.detach_subnets"]( @@ -1106,13 +1104,13 @@ def _subnets_present(name, subnets, region, key, keyid, profile): ) if detached: ret["comment"] = " ".join( - [ret["comment"], "Detached subnets on {} ELB.".format(name)] + [ret["comment"], f"Detached subnets on {name} ELB."] ) else: ret["comment"] = " ".join( [ ret["comment"], - "Failed to detach subnets on {} ELB.".format(name), + f"Failed to detach subnets on {name} ELB.", ] ) ret["result"] = False @@ -1120,7 +1118,7 @@ def _subnets_present(name, subnets, region, key, keyid, profile): lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) ret["changes"]["new"] = {"subnets": lb["subnets"]} else: - ret["comment"] = "Subnets already set on ELB {}.".format(name) + ret["comment"] = f"Subnets already set on ELB {name}." return ret @@ -1216,7 +1214,7 @@ def _policies_present( lb = __salt__["boto_elb.get_elb_config"](name, region, key, keyid, profile) if not lb: - ret["comment"] = "{} ELB configuration could not be retrieved.".format(name) + ret["comment"] = f"{name} ELB configuration could not be retrieved." ret["result"] = False return ret @@ -1302,18 +1300,18 @@ def _policies_present( if __opts__["test"]: msg = [] if to_create or to_delete: - msg.append("ELB {} set to have policies modified:".format(name)) + msg.append(f"ELB {name} set to have policies modified:") for policy in to_create: - msg.append("Policy {} added.".format(policy)) + msg.append(f"Policy {policy} added.") for policy in to_delete: - msg.append("Policy {} deleted.".format(policy)) + msg.append(f"Policy {policy} deleted.") ret["result"] = None else: - msg.append("Policies already set on ELB {}.".format(name)) + msg.append(f"Policies already set on ELB {name}.") for listener in listeners_to_update: - msg.append("Listener {} policies updated.".format(listener)) + msg.append(f"Listener {listener} policies updated.") for backend in backends_to_update: - msg.append("Backend {} policies updated.".format(backend)) + msg.append(f"Backend {backend} policies updated.") ret["comment"] = " ".join(msg) return ret @@ -1331,7 +1329,7 @@ def _policies_present( ) if created: ret["changes"].setdefault(policy_name, {})["new"] = policy_name - comment = "Policy {} was created on ELB {}".format(policy_name, name) + comment = f"Policy {policy_name} was created on ELB {name}" ret["comment"] = " ".join([ret["comment"], comment]) ret["result"] = True else: @@ -1349,7 +1347,7 @@ def _policies_present( profile=profile, ) if policy_set: - policy_key = "listener_{}_policy".format(port) + policy_key = f"listener_{port}_policy" ret["changes"][policy_key] = { "old": list(actual_policies_by_listener.get(port, [])), "new": list(expected_policies_by_listener.get(port, [])), @@ -1374,7 +1372,7 @@ def _policies_present( profile=profile, ) if policy_set: - policy_key = "backend_{}_policy".format(port) + policy_key = f"backend_{port}_policy" ret["changes"][policy_key] = { "old": list(actual_policies_by_backend.get(port, [])), "new": list(expected_policies_by_backend.get(port, [])), @@ -1400,7 +1398,7 @@ def _policies_present( ) if deleted: ret["changes"].setdefault(policy_name, {})["old"] = policy_name - comment = "Policy {} was deleted from ELB {}".format(policy_name, name) + comment = f"Policy {policy_name} was deleted from ELB {name}" ret["comment"] = " ".join([ret["comment"], comment]) ret["result"] = True else: @@ -1419,7 +1417,7 @@ def _policy_cname(policy_dict): ).hexdigest() if policy_type.endswith("Type"): policy_type = policy_type[:-4] - return "{}-{}-{}".format(policy_type, policy_name, policy_hash) + return f"{policy_type}-{policy_name}-{policy_hash}" def absent(name, region=None, key=None, keyid=None, profile=None): @@ -1434,19 +1432,19 @@ def absent(name, region=None, key=None, keyid=None, profile=None): exists = __salt__["boto_elb.exists"](name, region, key, keyid, profile) if exists: if __opts__["test"]: - ret["comment"] = "ELB {} is set to be removed.".format(name) + ret["comment"] = f"ELB {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_elb.delete"](name, region, key, keyid, profile) if deleted: ret["changes"]["old"] = {"elb": name} ret["changes"]["new"] = {"elb": None} - ret["comment"] = "ELB {} deleted.".format(name) + ret["comment"] = f"ELB {name} deleted." else: ret["result"] = False - ret["comment"] = "Failed to delete {} ELB.".format(name) + ret["comment"] = f"Failed to delete {name} ELB." else: - ret["comment"] = "{} ELB does not exist.".format(name) + ret["comment"] = f"{name} ELB does not exist." return ret @@ -1484,7 +1482,7 @@ def _tags_present(name, tags, region, key, keyid, profile): ) if not _ret: ret["result"] = False - msg = "Error attempting to delete tag {}.".format(tags_to_remove) + msg = f"Error attempting to delete tag {tags_to_remove}." ret["comment"] = " ".join([ret["comment"], msg]) return ret if "old" not in ret["changes"]: diff --git a/salt/states/boto_elbv2.py b/salt/states/boto_elbv2.py index 5f74fcbfeaa..fa2527f0249 100644 --- a/salt/states/boto_elbv2.py +++ b/salt/states/boto_elbv2.py @@ -36,13 +36,12 @@ passed in as a dict, or as a string to pull from pillars or minion config: import copy import logging - log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -71,7 +70,7 @@ def create_target_group( health_check_timeout_seconds=5, healthy_threshold_count=5, unhealthy_threshold_count=2, - **kwargs + **kwargs, ): """ @@ -129,11 +128,11 @@ def create_target_group( if __salt__["boto_elbv2.target_group_exists"](name, region, key, keyid, profile): ret["result"] = True - ret["comment"] = "Target Group {} already exists".format(name) + ret["comment"] = f"Target Group {name} already exists" return ret if __opts__["test"]: - ret["comment"] = "Target Group {} will be created".format(name) + ret["comment"] = f"Target Group {name} will be created" return ret state = __salt__["boto_elbv2.create_target_group"]( @@ -152,16 +151,16 @@ def create_target_group( health_check_timeout_seconds=health_check_timeout_seconds, healthy_threshold_count=healthy_threshold_count, unhealthy_threshold_count=unhealthy_threshold_count, - **kwargs + **kwargs, ) if state: ret["changes"]["target_group"] = name ret["result"] = True - ret["comment"] = "Target Group {} created".format(name) + ret["comment"] = f"Target Group {name} created" else: ret["result"] = False - ret["comment"] = "Target Group {} creation failed".format(name) + ret["comment"] = f"Target Group {name} creation failed" return ret @@ -192,11 +191,11 @@ def delete_target_group(name, region=None, key=None, keyid=None, profile=None): name, region, key, keyid, profile ): ret["result"] = True - ret["comment"] = "Target Group {} does not exists".format(name) + ret["comment"] = f"Target Group {name} does not exists" return ret if __opts__["test"]: - ret["comment"] = "Target Group {} will be deleted".format(name) + ret["comment"] = f"Target Group {name} will be deleted" return ret state = __salt__["boto_elbv2.delete_target_group"]( @@ -206,10 +205,10 @@ def delete_target_group(name, region=None, key=None, keyid=None, profile=None): if state: ret["result"] = True ret["changes"]["target_group"] = name - ret["comment"] = "Target Group {} deleted".format(name) + ret["comment"] = f"Target Group {name} deleted" else: ret["result"] = False - ret["comment"] = "Target Group {} deletion failed".format(name) + ret["comment"] = f"Target Group {name} deletion failed" return ret @@ -284,18 +283,18 @@ def targets_registered( if changes: ret["changes"]["old"] = health if __opts__["test"]: - ret["comment"] = "Target Group {} would be changed".format(name) + ret["comment"] = f"Target Group {name} would be changed" ret["result"] = None ret["changes"]["new"] = newhealth_mock else: - ret["comment"] = "Target Group {} has been changed".format(name) + ret["comment"] = f"Target Group {name} has been changed" newhealth = __salt__["boto_elbv2.describe_target_health"]( name, region=region, key=key, keyid=keyid, profile=profile ) ret["changes"]["new"] = newhealth return ret else: - ret["comment"] = "Could not find target group {}".format(name) + ret["comment"] = f"Could not find target group {name}" return ret @@ -334,9 +333,9 @@ def targets_deregistered( targets = [targets] for target in targets: if target not in health or health.get(target) == "draining": - ret["comment"] = ret[ - "comment" - ] + "Target/s {} already deregistered\n".format(target) + ret["comment"] = ( + ret["comment"] + f"Target/s {target} already deregistered\n" + ) ret["result"] = True else: if __opts__["test"]: @@ -355,25 +354,23 @@ def targets_deregistered( changes = True ret["result"] = True else: - ret[ - "comment" - ] = "Target Group {} failed to remove targets".format(name) + ret["comment"] = f"Target Group {name} failed to remove targets" failure = True if failure: ret["result"] = False if changes: ret["changes"]["old"] = health if __opts__["test"]: - ret["comment"] = "Target Group {} would be changed".format(name) + ret["comment"] = f"Target Group {name} would be changed" ret["result"] = None ret["changes"]["new"] = newhealth_mock else: - ret["comment"] = "Target Group {} has been changed".format(name) + ret["comment"] = f"Target Group {name} has been changed" newhealth = __salt__["boto_elbv2.describe_target_health"]( name, region=region, key=key, keyid=keyid, profile=profile ) ret["changes"]["new"] = newhealth return ret else: - ret["comment"] = "Could not find target group {}".format(name) + ret["comment"] = f"Could not find target group {name}" return ret diff --git a/salt/states/boto_iam.py b/salt/states/boto_iam.py index 841e02abf0c..39b0df601a8 100644 --- a/salt/states/boto_iam.py +++ b/salt/states/boto_iam.py @@ -149,7 +149,7 @@ __virtualname__ = "boto_iam" __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -162,7 +162,7 @@ def __virtual__(): else: return ( False, - "Cannot load {} state: boto_iam module unavailable".format(__virtualname__), + f"Cannot load {__virtualname__} state: boto_iam module unavailable", ) @@ -214,7 +214,7 @@ def user_absent( ret = {"name": name, "result": True, "comment": "", "changes": {}} if not __salt__["boto_iam.get_user"](name, region, key, keyid, profile): ret["result"] = True - ret["comment"] = "IAM User {} does not exist.".format(name) + ret["comment"] = f"IAM User {name} does not exist." return ret # delete the user's access keys if delete_keys: @@ -304,7 +304,7 @@ def user_absent( ret["comment"] = " ".join( [ ret["comment"], - "Virtual MFA device {} is deleted.".format(serial), + f"Virtual MFA device {serial} is deleted.", ] ) # delete the user's login profile @@ -313,7 +313,7 @@ def user_absent( ret["comment"] = " ".join( [ ret["comment"], - "IAM user {} login profile is set to be deleted.".format(name), + f"IAM user {name} login profile is set to be deleted.", ] ) ret["result"] = None @@ -325,14 +325,14 @@ def user_absent( ret["comment"] = " ".join( [ ret["comment"], - "IAM user {} login profile is deleted.".format(name), + f"IAM user {name} login profile is deleted.", ] ) if __opts__["test"]: ret["comment"] = " ".join( [ ret["comment"], - "IAM user {} managed policies are set to be detached.".format(name), + f"IAM user {name} managed policies are set to be detached.", ] ) ret["result"] = None @@ -347,7 +347,7 @@ def user_absent( ret["comment"] = " ".join( [ ret["comment"], - "IAM user {} inline policies are set to be deleted.".format(name), + f"IAM user {name} inline policies are set to be deleted.", ] ) ret["result"] = None @@ -361,19 +361,17 @@ def user_absent( # finally, actually delete the user if __opts__["test"]: ret["comment"] = " ".join( - [ret["comment"], "IAM user {} is set to be deleted.".format(name)] + [ret["comment"], f"IAM user {name} is set to be deleted."] ) ret["result"] = None return ret deleted = __salt__["boto_iam.delete_user"](name, region, key, keyid, profile) if deleted is True: - ret["comment"] = " ".join( - [ret["comment"], "IAM user {} is deleted.".format(name)] - ) + ret["comment"] = " ".join([ret["comment"], f"IAM user {name} is deleted."]) ret["result"] = True ret["changes"]["deleted"] = name return ret - ret["comment"] = "IAM user {} could not be deleted.\n {}".format(name, deleted) + ret["comment"] = f"IAM user {name} could not be deleted.\n {deleted}" ret["result"] = False return ret @@ -425,14 +423,14 @@ def keys_present( ret = {"name": name, "result": True, "comment": "", "changes": {}} if not __salt__["boto_iam.get_user"](name, region, key, keyid, profile): ret["result"] = False - ret["comment"] = "IAM User {} does not exist.".format(name) + ret["comment"] = f"IAM User {name} does not exist." return ret if not isinstance(number, int): ret["comment"] = "The number of keys must be an integer." ret["result"] = False return ret if not os.path.isdir(save_dir): - ret["comment"] = "The directory {} does not exist.".format(save_dir) + ret["comment"] = f"The directory {save_dir} does not exist." ret["result"] = False return ret keys = __salt__["boto_iam.get_all_access_keys"]( @@ -441,7 +439,7 @@ def keys_present( if isinstance(keys, str): log.debug("keys are : false %s", keys) error, message = _get_error(keys) - ret["comment"] = "Could not get keys.\n{}\n{}".format(error, message) + ret["comment"] = f"Could not get keys.\n{error}\n{message}" ret["result"] = False return ret keys = keys["list_access_keys_response"]["list_access_keys_result"][ @@ -449,11 +447,11 @@ def keys_present( ] log.debug("Keys are : %s.", keys) if len(keys) >= number: - ret["comment"] = "The number of keys exist for user {}".format(name) + ret["comment"] = f"The number of keys exist for user {name}" ret["result"] = True return ret if __opts__["test"]: - ret["comment"] = "Access key is set to be created for {}.".format(name) + ret["comment"] = f"Access key is set to be created for {name}." ret["result"] = None return ret new_keys = {} @@ -463,7 +461,7 @@ def keys_present( ) if isinstance(created, str): error, message = _get_error(created) - ret["comment"] = "Could not create keys.\n{}\n{}".format(error, message) + ret["comment"] = f"Could not create keys.\n{error}\n{message}" ret["result"] = False return ret log.debug("Created is : %s", created) @@ -477,7 +475,7 @@ def keys_present( "secret_access_key" ] try: - with salt.utils.files.fopen("{}/{}".format(save_dir, name), "a") as _wrf: + with salt.utils.files.fopen(f"{save_dir}/{name}", "a") as _wrf: for key_num, key in new_keys.items(): key_id = key["key_id"] secret_key = key["secret_key"] @@ -486,17 +484,17 @@ def keys_present( save_format.format( key_id, secret_key, - "key_id-{}".format(key_num), - "key-{}".format(key_num), + f"key_id-{key_num}", + f"key-{key_num}", ) ) ) - ret["comment"] = "Keys have been written to file {}/{}.".format(save_dir, name) + ret["comment"] = f"Keys have been written to file {save_dir}/{name}." ret["result"] = True ret["changes"] = new_keys return ret except OSError: - ret["comment"] = "Could not write to file {}/{}.".format(save_dir, name) + ret["comment"] = f"Could not write to file {save_dir}/{name}." ret["result"] = False return ret @@ -532,7 +530,7 @@ def keys_absent( ret = {"name": access_keys, "result": True, "comment": "", "changes": {}} if not __salt__["boto_iam.get_user"](user_name, region, key, keyid, profile): ret["result"] = False - ret["comment"] = "IAM User {} does not exist.".format(user_name) + ret["comment"] = f"IAM User {user_name} does not exist." return ret for k in access_keys: ret = _delete_key(ret, k, user_name, region, key, keyid, profile) @@ -549,7 +547,7 @@ def _delete_key( if isinstance(keys, str): log.debug("Keys %s are a string. Something went wrong.", keys) ret["comment"] = " ".join( - [ret["comment"], "Key {} could not be deleted.".format(access_key_id)] + [ret["comment"], f"Key {access_key_id} could not be deleted."] ) return ret keys = keys["list_access_keys_response"]["list_access_keys_result"][ @@ -571,15 +569,15 @@ def _delete_key( ) if deleted: ret["comment"] = " ".join( - [ret["comment"], "Key {} has been deleted.".format(access_key_id)] + [ret["comment"], f"Key {access_key_id} has been deleted."] ) ret["changes"][access_key_id] = "deleted" return ret ret["comment"] = " ".join( - [ret["comment"], "Key {} could not be deleted.".format(access_key_id)] + [ret["comment"], f"Key {access_key_id} could not be deleted."] ) return ret - ret["comment"] = " ".join([ret["comment"], "Key {} does not exist.".format(k)]) + ret["comment"] = " ".join([ret["comment"], f"Key {k} does not exist."]) return ret @@ -656,7 +654,7 @@ def user_present( exists = __salt__["boto_iam.get_user"](name, region, key, keyid, profile) if not exists: if __opts__["test"]: - ret["comment"] = "IAM user {} is set to be created.".format(name) + ret["comment"] = f"IAM user {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.create_user"]( @@ -665,7 +663,7 @@ def user_present( if created: ret["changes"]["user"] = created ret["comment"] = " ".join( - [ret["comment"], "User {} has been created.".format(name)] + [ret["comment"], f"User {name} has been created."] ) if password: ret = _case_password(ret, name, password, region, key, keyid, profile) @@ -673,7 +671,7 @@ def user_present( ret["changes"] = dictupdate.update(ret["changes"], _ret["changes"]) ret["comment"] = " ".join([ret["comment"], _ret["comment"]]) else: - ret["comment"] = " ".join([ret["comment"], "User {} is present.".format(name)]) + ret["comment"] = " ".join([ret["comment"], f"User {name} is present."]) if password: ret = _case_password(ret, name, password, region, key, keyid, profile) _ret = _user_policies_present(name, _policies, region, key, keyid, profile) @@ -852,7 +850,7 @@ def _user_policies_detached(name, region=None, key=None, keyid=None, profile=Non ) oldpolicies = [x.get("policy_arn") for x in _list] if not _list: - ret["comment"] = "No attached policies in user {}.".format(name) + ret["comment"] = f"No attached policies in user {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be detached from user {}.".format( @@ -872,7 +870,7 @@ def _user_policies_detached(name, region=None, key=None, keyid=None, profile=Non newpolicies = [x.get("policy_arn") for x in _list] ret["changes"]["new"] = {"managed_policies": newpolicies} ret["result"] = False - ret["comment"] = "Failed to detach {} from user {}".format(policy_arn, name) + ret["comment"] = f"Failed to detach {policy_arn} from user {name}" return ret _list = __salt__["boto_iam.list_attached_user_policies"]( name, region=region, key=key, keyid=keyid, profile=profile @@ -891,7 +889,7 @@ def _user_policies_deleted(name, region=None, key=None, keyid=None, profile=None user_name=name, region=region, key=key, keyid=keyid, profile=profile ) if not oldpolicies: - ret["comment"] = "No inline policies in user {}.".format(name) + ret["comment"] = f"No inline policies in user {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be deleted from user {}.".format( @@ -928,7 +926,7 @@ def _case_password( ret, name, password, region=None, key=None, keyid=None, profile=None ): if __opts__["test"]: - ret["comment"] = "Login policy for {} is set to be changed.".format(name) + ret["comment"] = f"Login policy for {name} is set to be changed." ret["result"] = None return ret login = __salt__["boto_iam.create_login_profile"]( @@ -938,11 +936,11 @@ def _case_password( if login: if "Conflict" in login: ret["comment"] = " ".join( - [ret["comment"], "Login profile for user {} exists.".format(name)] + [ret["comment"], f"Login profile for user {name} exists."] ) else: ret["comment"] = " ".join( - [ret["comment"], "Password has been added to User {}.".format(name)] + [ret["comment"], f"Password has been added to User {name}."] ) ret["changes"]["password"] = "REDACTED" else: @@ -983,13 +981,13 @@ def group_absent(name, region=None, key=None, keyid=None, profile=None): ret = {"name": name, "result": True, "comment": "", "changes": {}} if not __salt__["boto_iam.get_group"](name, region, key, keyid, profile): ret["result"] = True - ret["comment"] = "IAM Group {} does not exist.".format(name) + ret["comment"] = f"IAM Group {name} does not exist." return ret if __opts__["test"]: ret["comment"] = " ".join( [ ret["comment"], - "IAM group {} managed policies are set to be detached.".format(name), + f"IAM group {name} managed policies are set to be detached.", ] ) ret["result"] = None @@ -1004,7 +1002,7 @@ def group_absent(name, region=None, key=None, keyid=None, profile=None): ret["comment"] = " ".join( [ ret["comment"], - "IAM group {} inline policies are set to be deleted.".format(name), + f"IAM group {name} inline policies are set to be deleted.", ] ) ret["result"] = None @@ -1016,7 +1014,7 @@ def group_absent(name, region=None, key=None, keyid=None, profile=None): if ret["result"] is False: return ret ret["comment"] = " ".join( - [ret["comment"], "IAM group {} users are set to be removed.".format(name)] + [ret["comment"], f"IAM group {name} users are set to be removed."] ) existing_users = __salt__["boto_iam.get_group_members"]( group_name=name, region=region, key=key, keyid=keyid, profile=profile @@ -1030,19 +1028,17 @@ def group_absent(name, region=None, key=None, keyid=None, profile=None): # finally, actually delete the group if __opts__["test"]: ret["comment"] = " ".join( - [ret["comment"], "IAM group {} is set to be deleted.".format(name)] + [ret["comment"], f"IAM group {name} is set to be deleted."] ) ret["result"] = None return ret deleted = __salt__["boto_iam.delete_group"](name, region, key, keyid, profile) if deleted is True: - ret["comment"] = " ".join( - [ret["comment"], "IAM group {} is deleted.".format(name)] - ) + ret["comment"] = " ".join([ret["comment"], f"IAM group {name} is deleted."]) ret["result"] = True ret["changes"]["deleted"] = name return ret - ret["comment"] = "IAM group {} could not be deleted.\n {}".format(name, deleted) + ret["comment"] = f"IAM group {name} could not be deleted.\n {deleted}" ret["result"] = False return ret @@ -1126,7 +1122,7 @@ def group_present( ) if not exists: if __opts__["test"]: - ret["comment"] = "IAM group {} is set to be created.".format(name) + ret["comment"] = f"IAM group {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.create_group"]( @@ -1138,15 +1134,13 @@ def group_present( profile=profile, ) if not created: - ret["comment"] = "Failed to create IAM group {}.".format(name) + ret["comment"] = f"Failed to create IAM group {name}." ret["result"] = False return ret ret["changes"]["group"] = created - ret["comment"] = " ".join( - [ret["comment"], "Group {} has been created.".format(name)] - ) + ret["comment"] = " ".join([ret["comment"], f"Group {name} has been created."]) else: - ret["comment"] = " ".join([ret["comment"], "Group {} is present.".format(name)]) + ret["comment"] = " ".join([ret["comment"], f"Group {name} is present."]) # Group exists, ensure group policies and users are set. _ret = _group_policies_present( name, _policies, region, key, keyid, profile, delete_policies @@ -1185,7 +1179,7 @@ def _case_group(ret, users, group_name, existing_users, region, key, keyid, prof ret["comment"] = " ".join( [ ret["comment"], - "User {} is already a member of group {}.".format(user, group_name), + f"User {user} is already a member of group {group_name}.", ] ) continue @@ -1203,7 +1197,7 @@ def _case_group(ret, users, group_name, existing_users, region, key, keyid, prof ret["comment"] = " ".join( [ ret["comment"], - "User {} has been added to group {}.".format(user, group_name), + f"User {user} has been added to group {group_name}.", ] ) ret["changes"][user] = group_name @@ -1236,7 +1230,7 @@ def _case_group(ret, users, group_name, existing_users, region, key, keyid, prof ), ] ) - ret["changes"][user] = "Removed from group {}.".format(group_name) + ret["changes"][user] = f"Removed from group {group_name}." return ret @@ -1417,7 +1411,7 @@ def _group_policies_detached(name, region=None, key=None, keyid=None, profile=No ) oldpolicies = [x.get("policy_arn") for x in _list] if not _list: - ret["comment"] = "No attached policies in group {}.".format(name) + ret["comment"] = f"No attached policies in group {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be detached from group {}.".format( @@ -1458,7 +1452,7 @@ def _group_policies_deleted(name, region=None, key=None, keyid=None, profile=Non group_name=name, region=region, key=key, keyid=keyid, profile=profile ) if not oldpolicies: - ret["comment"] = "No inline policies in group {}.".format(name) + ret["comment"] = f"No inline policies in group {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be deleted from group {}.".format( @@ -1575,7 +1569,7 @@ def account_policy( ret["comment"] = " ".join( [ ret["comment"], - "Policy value {} has been set to {}.".format(value, info[key]), + f"Policy value {value} has been set to {info[key]}.", ] ) ret["changes"][key] = str(value).lower() @@ -1634,18 +1628,18 @@ def server_cert_absent(name, region=None, key=None, keyid=None, profile=None): name, region, key, keyid, profile ) if not exists: - ret["comment"] = "Certificate {} does not exist.".format(name) + ret["comment"] = f"Certificate {name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Server certificate {} is set to be deleted.".format(name) + ret["comment"] = f"Server certificate {name} is set to be deleted." ret["result"] = None return ret deleted = __salt__["boto_iam.delete_server_cert"](name, region, key, keyid, profile) if not deleted: ret["result"] = False - ret["comment"] = "Certificate {} failed to be deleted.".format(name) + ret["comment"] = f"Certificate {name} failed to be deleted." return ret - ret["comment"] = "Certificate {} was deleted.".format(name) + ret["comment"] = f"Certificate {name} was deleted." ret["changes"] = deleted return ret @@ -1700,14 +1694,14 @@ def server_cert_present( ) log.debug("Variables are : %s.", locals()) if exists: - ret["comment"] = "Certificate {} exists.".format(name) + ret["comment"] = f"Certificate {name} exists." return ret if "salt://" in public_key: try: public_key = __salt__["cp.get_file_str"](public_key) except OSError as e: log.debug(e) - ret["comment"] = "File {} not found.".format(public_key) + ret["comment"] = f"File {public_key} not found." ret["result"] = False return ret if "salt://" in private_key: @@ -1715,7 +1709,7 @@ def server_cert_present( private_key = __salt__["cp.get_file_str"](private_key) except OSError as e: log.debug(e) - ret["comment"] = "File {} not found.".format(private_key) + ret["comment"] = f"File {private_key} not found." ret["result"] = False return ret if cert_chain is not None and "salt://" in cert_chain: @@ -1723,22 +1717,22 @@ def server_cert_present( cert_chain = __salt__["cp.get_file_str"](cert_chain) except OSError as e: log.debug(e) - ret["comment"] = "File {} not found.".format(cert_chain) + ret["comment"] = f"File {cert_chain} not found." ret["result"] = False return ret if __opts__["test"]: - ret["comment"] = "Server certificate {} is set to be created.".format(name) + ret["comment"] = f"Server certificate {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.upload_server_cert"]( name, public_key, private_key, cert_chain, path, region, key, keyid, profile ) if created is not False: - ret["comment"] = "Certificate {} was created.".format(name) + ret["comment"] = f"Certificate {name} was created." ret["changes"] = created return ret ret["result"] = False - ret["comment"] = "Certificate {} failed to be created.".format(name) + ret["comment"] = f"Certificate {name} failed to be created." return ret @@ -1787,7 +1781,7 @@ def policy_present( policy = __salt__["boto_iam.get_policy"](name, region, key, keyid, profile) if not policy: if __opts__["test"]: - ret["comment"] = "IAM policy {} is set to be created.".format(name) + ret["comment"] = f"IAM policy {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.create_policy"]( @@ -1796,7 +1790,7 @@ def policy_present( if created: ret["changes"]["policy"] = created ret["comment"] = " ".join( - [ret["comment"], "Policy {} has been created.".format(name)] + [ret["comment"], f"Policy {name} has been created."] ) else: ret["result"] = False @@ -1805,9 +1799,7 @@ def policy_present( return ret else: policy = policy.get("policy", {}) - ret["comment"] = " ".join( - [ret["comment"], "Policy {} is present.".format(name)] - ) + ret["comment"] = " ".join([ret["comment"], f"Policy {name} is present."]) _describe = __salt__["boto_iam.get_policy_version"]( name, policy.get("default_version_id"), region, key, keyid, profile ).get("policy_version", {}) @@ -1823,7 +1815,7 @@ def policy_present( if bool(r): if __opts__["test"]: - ret["comment"] = "Policy {} set to be modified.".format(name) + ret["comment"] = f"Policy {name} set to be modified." ret["result"] = None return ret @@ -1890,11 +1882,11 @@ def policy_absent(name, region=None, key=None, keyid=None, profile=None): name, region=region, key=key, keyid=keyid, profile=profile ) if not r: - ret["comment"] = "Policy {} does not exist.".format(name) + ret["comment"] = f"Policy {name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Policy {} is set to be removed.".format(name) + ret["comment"] = f"Policy {name} is set to be removed." ret["result"] = None return ret # delete non-default versions @@ -1915,18 +1907,18 @@ def policy_absent(name, region=None, key=None, keyid=None, profile=None): ) if not r: ret["result"] = False - ret["comment"] = "Failed to delete policy {}.".format(name) + ret["comment"] = f"Failed to delete policy {name}." return ret r = __salt__["boto_iam.delete_policy"]( name, region=region, key=key, keyid=keyid, profile=profile ) if not r: ret["result"] = False - ret["comment"] = "Failed to delete policy {}.".format(name) + ret["comment"] = f"Failed to delete policy {name}." return ret ret["changes"]["old"] = {"policy": name} ret["changes"]["new"] = {"policy": None} - ret["comment"] = "Policy {} deleted.".format(name) + ret["comment"] = f"Policy {name} deleted." return ret @@ -1966,17 +1958,17 @@ def saml_provider_present( log.debug(e) ret[ "comment" - ] = "SAML document file {} not found or could not be loaded".format(name) + ] = f"SAML document file {name} not found or could not be loaded" ret["result"] = False return ret for provider in __salt__["boto_iam.list_saml_providers"]( region=region, key=key, keyid=keyid, profile=profile ): if provider == name: - ret["comment"] = "SAML provider {} is present.".format(name) + ret["comment"] = f"SAML provider {name} is present." return ret if __opts__["test"]: - ret["comment"] = "SAML provider {} is set to be create.".format(name) + ret["comment"] = f"SAML provider {name} is set to be create." ret["result"] = None return ret created = __salt__["boto_iam.create_saml_provider"]( @@ -1988,11 +1980,11 @@ def saml_provider_present( profile=profile, ) if created: - ret["comment"] = "SAML provider {} was created.".format(name) + ret["comment"] = f"SAML provider {name} was created." ret["changes"]["new"] = name return ret ret["result"] = False - ret["comment"] = "SAML provider {} failed to be created.".format(name) + ret["comment"] = f"SAML provider {name} failed to be created." return ret @@ -2026,21 +2018,21 @@ def saml_provider_absent(name, region=None, key=None, keyid=None, profile=None): region=region, key=key, keyid=keyid, profile=profile ) if len(provider) == 0: - ret["comment"] = "SAML provider {} is absent.".format(name) + ret["comment"] = f"SAML provider {name} is absent." return ret if __opts__["test"]: - ret["comment"] = "SAML provider {} is set to be removed.".format(name) + ret["comment"] = f"SAML provider {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_iam.delete_saml_provider"]( name, region=region, key=key, keyid=keyid, profile=profile ) if deleted is not False: - ret["comment"] = "SAML provider {} was deleted.".format(name) + ret["comment"] = f"SAML provider {name} was deleted." ret["changes"]["old"] = name return ret ret["result"] = False - ret["comment"] = "SAML provider {} failed to be deleted.".format(name) + ret["comment"] = f"SAML provider {name} failed to be deleted." return ret diff --git a/salt/states/boto_iam_role.py b/salt/states/boto_iam_role.py index 63927a108be..1ae7e73d39e 100644 --- a/salt/states/boto_iam_role.py +++ b/salt/states/boto_iam_role.py @@ -97,7 +97,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -261,7 +261,7 @@ def _role_present( role = __salt__["boto_iam.describe_role"](name, region, key, keyid, profile) if not role: if __opts__["test"]: - ret["comment"] = "IAM role {} is set to be created.".format(name) + ret["comment"] = f"IAM role {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.create_role"]( @@ -270,12 +270,12 @@ def _role_present( if created: ret["changes"]["old"] = {"role": None} ret["changes"]["new"] = {"role": name} - ret["comment"] = "IAM role {} created.".format(name) + ret["comment"] = f"IAM role {name} created." else: ret["result"] = False - ret["comment"] = "Failed to create {} IAM role.".format(name) + ret["comment"] = f"Failed to create {name} IAM role." else: - ret["comment"] = "{} role present.".format(name) + ret["comment"] = f"{name} role present." if not policy_document: _policy_document = __salt__["boto_iam.build_policy"]( region, key, keyid, profile @@ -315,7 +315,7 @@ def _instance_profile_present(name, region=None, key=None, keyid=None, profile=N ) if not exists: if __opts__["test"]: - ret["comment"] = "Instance profile {} is set to be created.".format(name) + ret["comment"] = f"Instance profile {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_iam.create_instance_profile"]( @@ -324,10 +324,10 @@ def _instance_profile_present(name, region=None, key=None, keyid=None, profile=N if created: ret["changes"]["old"] = {"instance_profile": None} ret["changes"]["new"] = {"instance_profile": name} - ret["comment"] = "Instance profile {} created.".format(name) + ret["comment"] = f"Instance profile {name} created." else: ret["result"] = False - ret["comment"] = "Failed to create {} instance profile.".format(name) + ret["comment"] = f"Failed to create {name} instance profile." return ret @@ -338,7 +338,7 @@ def _instance_profile_associated(name, region=None, key=None, keyid=None, profil ) if not is_associated: if __opts__["test"]: - ret["comment"] = "Instance profile {} is set to be associated.".format(name) + ret["comment"] = f"Instance profile {name} is set to be associated." ret["result"] = None return ret associated = __salt__["boto_iam.associate_profile_to_role"]( @@ -347,7 +347,7 @@ def _instance_profile_associated(name, region=None, key=None, keyid=None, profil if associated: ret["changes"]["old"] = {"profile_associated": None} ret["changes"]["new"] = {"profile_associated": True} - ret["comment"] = "Instance profile {} associated.".format(name) + ret["comment"] = f"Instance profile {name} associated." else: ret["result"] = False ret[ @@ -597,19 +597,19 @@ def _role_absent(name, region=None, key=None, keyid=None, profile=None): exists = __salt__["boto_iam.role_exists"](name, region, key, keyid, profile) if exists: if __opts__["test"]: - ret["comment"] = "IAM role {} is set to be removed.".format(name) + ret["comment"] = f"IAM role {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_iam.delete_role"](name, region, key, keyid, profile) if deleted: ret["changes"]["old"] = {"role": name} ret["changes"]["new"] = {"role": None} - ret["comment"] = "IAM role {} removed.".format(name) + ret["comment"] = f"IAM role {name} removed." else: ret["result"] = False - ret["comment"] = "Failed to delete {} iam role.".format(name) + ret["comment"] = f"Failed to delete {name} iam role." else: - ret["comment"] = "{} role does not exist.".format(name) + ret["comment"] = f"{name} role does not exist." return ret @@ -621,7 +621,7 @@ def _instance_profile_absent(name, region=None, key=None, keyid=None, profile=No ) if exists: if __opts__["test"]: - ret["comment"] = "Instance profile {} is set to be removed.".format(name) + ret["comment"] = f"Instance profile {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_iam.delete_instance_profile"]( @@ -630,12 +630,12 @@ def _instance_profile_absent(name, region=None, key=None, keyid=None, profile=No if deleted: ret["changes"]["old"] = {"instance_profile": name} ret["changes"]["new"] = {"instance_profile": None} - ret["comment"] = "Instance profile {} removed.".format(name) + ret["comment"] = f"Instance profile {name} removed." else: ret["result"] = False - ret["comment"] = "Failed to delete {} instance profile.".format(name) + ret["comment"] = f"Failed to delete {name} instance profile." else: - ret["comment"] = "{} instance profile does not exist.".format(name) + ret["comment"] = f"{name} instance profile does not exist." return ret @@ -643,7 +643,7 @@ def _policies_absent(name, region=None, key=None, keyid=None, profile=None): ret = {"result": True, "comment": "", "changes": {}} _list = __salt__["boto_iam.list_role_policies"](name, region, key, keyid, profile) if not _list: - ret["comment"] = "No policies in role {}.".format(name) + ret["comment"] = f"No policies in role {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be removed from role {}.".format( @@ -679,7 +679,7 @@ def _policies_detached(name, region=None, key=None, keyid=None, profile=None): ) oldpolicies = [x.get("policy_arn") for x in _list] if not _list: - ret["comment"] = "No attached policies in role {}.".format(name) + ret["comment"] = f"No attached policies in role {name}." return ret if __opts__["test"]: ret["comment"] = "{} policies to be detached from role {}.".format( @@ -699,7 +699,7 @@ def _policies_detached(name, region=None, key=None, keyid=None, profile=None): newpolicies = [x.get("policy_arn") for x in _list] ret["changes"]["new"] = {"managed_policies": newpolicies} ret["result"] = False - ret["comment"] = "Failed to detach {} from role {}".format(policy_arn, name) + ret["comment"] = f"Failed to detach {policy_arn} from role {name}" return ret _list = __salt__["boto_iam.list_attached_role_policies"]( name, region=region, key=key, keyid=keyid, profile=profile @@ -732,7 +732,7 @@ def _instance_profile_disassociated( if associated: ret["changes"]["old"] = {"profile_associated": True} ret["changes"]["new"] = {"profile_associated": False} - ret["comment"] = "Instance profile {} disassociated.".format(name) + ret["comment"] = f"Instance profile {name} disassociated." else: ret["result"] = False ret[ diff --git a/salt/states/boto_iot.py b/salt/states/boto_iot.py index 53a86b45a93..8880248affe 100644 --- a/salt/states/boto_iot.py +++ b/salt/states/boto_iot.py @@ -83,7 +83,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -163,7 +163,7 @@ def thing_type_present( return ret if __opts__["test"]: - ret["comment"] = "Thing type {} is set to be created.".format(thingTypeName) + ret["comment"] = f"Thing type {thingTypeName} is set to be created." ret["result"] = None return ret @@ -193,7 +193,7 @@ def thing_type_present( ) ret["changes"]["old"] = {"thing_type": None} ret["changes"]["new"] = _describe - ret["comment"] = "Thing Type {} created.".format(thingTypeName) + ret["comment"] = f"Thing Type {thingTypeName} created." return ret @@ -243,7 +243,7 @@ def thing_type_absent( return ret if _describe and not _describe["thing_type"]: - ret["comment"] = "Thing Type {} does not exist.".format(thingTypeName) + ret["comment"] = f"Thing Type {thingTypeName} does not exist." return ret _existing_thing_type = _describe["thing_type"] @@ -325,7 +325,7 @@ def thing_type_absent( return ret ret["changes"]["old"] = _describe ret["changes"]["new"] = {"thing_type": None} - ret["comment"] = "Thing Type {} deleted.".format(thingTypeName) + ret["comment"] = f"Thing Type {thingTypeName} deleted." return ret @@ -372,7 +372,7 @@ def policy_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Policy {} is set to be created.".format(policyName) + ret["comment"] = f"Policy {policyName} is set to be created." ret["result"] = None return ret r = __salt__["boto_iot.create_policy"]( @@ -394,11 +394,11 @@ def policy_present( ) ret["changes"]["old"] = {"policy": None} ret["changes"]["new"] = _describe - ret["comment"] = "Policy {} created.".format(policyName) + ret["comment"] = f"Policy {policyName} created." return ret ret["comment"] = os.linesep.join( - [ret["comment"], "Policy {} is present.".format(policyName)] + [ret["comment"], f"Policy {policyName} is present."] ) ret["changes"] = {} # policy exists, ensure config matches @@ -417,7 +417,7 @@ def policy_present( r = salt.utils.data.compare_dicts(describeDict, policyDocument) if bool(r): if __opts__["test"]: - msg = "Policy {} set to be modified.".format(policyName) + msg = f"Policy {policyName} set to be modified." ret["comment"] = msg ret["result"] = None return ret @@ -493,11 +493,11 @@ def policy_absent(name, policyName, region=None, key=None, keyid=None, profile=N return ret if r and not r["exists"]: - ret["comment"] = "Policy {} does not exist.".format(policyName) + ret["comment"] = f"Policy {policyName} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Policy {} is set to be removed.".format(policyName) + ret["comment"] = f"Policy {policyName} is set to be removed." ret["result"] = None return ret # delete non-default versions @@ -538,7 +538,7 @@ def policy_absent(name, policyName, region=None, key=None, keyid=None, profile=N return ret ret["changes"]["old"] = {"policy": policyName} ret["changes"]["new"] = {"policy": None} - ret["comment"] = "Policy {} deleted.".format(policyName) + ret["comment"] = f"Policy {policyName} deleted." return ret @@ -609,11 +609,11 @@ def policy_attached( return ret ret["changes"]["old"] = {"attached": False} ret["changes"]["new"] = {"attached": True} - ret["comment"] = "Policy {} attached to {}.".format(policyName, principal) + ret["comment"] = f"Policy {policyName} attached to {principal}." return ret ret["comment"] = os.linesep.join( - [ret["comment"], "Policy {} is attached.".format(policyName)] + [ret["comment"], f"Policy {policyName} is attached."] ) ret["changes"] = {} @@ -688,11 +688,11 @@ def policy_detached( return ret ret["changes"]["old"] = {"attached": True} ret["changes"]["new"] = {"attached": False} - ret["comment"] = "Policy {} detached from {}.".format(policyName, principal) + ret["comment"] = f"Policy {policyName} detached from {principal}." return ret ret["comment"] = os.linesep.join( - [ret["comment"], "Policy {} is detached.".format(policyName)] + [ret["comment"], f"Policy {policyName} is detached."] ) ret["changes"] = {} @@ -758,7 +758,7 @@ def topic_rule_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Rule {} is set to be created.".format(ruleName) + ret["comment"] = f"Rule {ruleName} is set to be created." ret["result"] = None return ret r = __salt__["boto_iot.create_topic_rule"]( @@ -781,12 +781,10 @@ def topic_rule_present( ) ret["changes"]["old"] = {"rule": None} ret["changes"]["new"] = _describe - ret["comment"] = "Rule {} created.".format(ruleName) + ret["comment"] = f"Rule {ruleName} created." return ret - ret["comment"] = os.linesep.join( - [ret["comment"], "Rule {} is present.".format(ruleName)] - ) + ret["comment"] = os.linesep.join([ret["comment"], f"Rule {ruleName} is present."]) ret["changes"] = {} # policy exists, ensure config matches _describe = __salt__["boto_iot.describe_topic_rule"]( @@ -811,7 +809,7 @@ def topic_rule_present( ret["changes"].setdefault("old", {})[var] = _describe[var] if need_update: if __opts__["test"]: - msg = "Rule {} set to be modified.".format(ruleName) + msg = f"Rule {ruleName} set to be modified." ret["changes"] = {} ret["comment"] = msg ret["result"] = None @@ -870,11 +868,11 @@ def topic_rule_absent(name, ruleName, region=None, key=None, keyid=None, profile return ret if r and not r["exists"]: - ret["comment"] = "Rule {} does not exist.".format(ruleName) + ret["comment"] = f"Rule {ruleName} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Rule {} is set to be removed.".format(ruleName) + ret["comment"] = f"Rule {ruleName} is set to be removed." ret["result"] = None return ret r = __salt__["boto_iot.delete_topic_rule"]( @@ -886,5 +884,5 @@ def topic_rule_absent(name, ruleName, region=None, key=None, keyid=None, profile return ret ret["changes"]["old"] = {"rule": ruleName} ret["changes"]["new"] = {"rule": None} - ret["comment"] = "Rule {} deleted.".format(ruleName) + ret["comment"] = f"Rule {ruleName} deleted." return ret diff --git a/salt/states/boto_kinesis.py b/salt/states/boto_kinesis.py index 27fed723496..e720cb6a491 100644 --- a/salt/states/boto_kinesis.py +++ b/salt/states/boto_kinesis.py @@ -60,7 +60,6 @@ pillars or minion config: # Keep pylint from chocking on ret import logging - log = logging.getLogger(__name__) __virtualname__ = "boto_kinesis" @@ -68,7 +67,7 @@ __virtualname__ = "boto_kinesis" __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -147,7 +146,7 @@ def present( if exists["result"] is False: if __opts__["test"]: ret["result"] = None - comments.append("Kinesis stream {} would be created".format(name)) + comments.append(f"Kinesis stream {name} would be created") _add_changes(ret, changes_old, changes_new, comments) return ret else: @@ -162,11 +161,11 @@ def present( _add_changes(ret, changes_old, changes_new, comments) return ret - comments.append("Kinesis stream {} successfully created".format(name)) + comments.append(f"Kinesis stream {name} successfully created") changes_new["name"] = name changes_new["num_shards"] = num_shards else: - comments.append("Kinesis stream {} already exists".format(name)) + comments.append(f"Kinesis stream {name} already exists") stream_response = __salt__["boto_kinesis.get_stream_when_active"]( name, region, key, keyid, profile @@ -245,9 +244,7 @@ def present( " at {}".format(name, old_retention_hours) ) else: - comments.append( - "Kinesis stream {}: did not configure retention hours".format(name) - ) + comments.append(f"Kinesis stream {name}: did not configure retention hours") # Configure enhanced monitoring if enhanced_monitoring is not None: @@ -352,9 +349,7 @@ def present( enhanced_monitoring if len(enhanced_monitoring) > 0 else "None" ) else: - comments.append( - "Kinesis stream {}: did not configure enhanced monitoring".format(name) - ) + comments.append(f"Kinesis stream {name}: did not configure enhanced monitoring") # Reshard stream if necessary min_hash_key, max_hash_key, full_stream_details = __salt__[ @@ -446,11 +441,11 @@ def absent(name, region=None, key=None, keyid=None, profile=None): exists = __salt__["boto_kinesis.exists"](name, region, key, keyid, profile) if exists["result"] is False: - ret["comment"] = "Kinesis stream {} does not exist".format(name) + ret["comment"] = f"Kinesis stream {name} does not exist" return ret if __opts__["test"]: - ret["comment"] = "Kinesis stream {} would be deleted".format(name) + ret["comment"] = f"Kinesis stream {name} would be deleted" ret["result"] = None return ret @@ -463,9 +458,9 @@ def absent(name, region=None, key=None, keyid=None, profile=None): ) ret["result"] = False else: - ret["comment"] = "Deleted stream {}".format(name) - ret["changes"].setdefault("old", "Stream {} exists".format(name)) - ret["changes"].setdefault("new", "Stream {} deleted".format(name)) + ret["comment"] = f"Deleted stream {name}" + ret["changes"].setdefault("old", f"Stream {name} exists") + ret["changes"].setdefault("new", f"Stream {name} deleted") return ret diff --git a/salt/states/boto_kms.py b/salt/states/boto_kms.py index 26826d15ee6..52aad48d659 100644 --- a/salt/states/boto_kms.py +++ b/salt/states/boto_kms.py @@ -180,7 +180,7 @@ def _key_present( profile, ): ret = {"result": True, "comment": "", "changes": {}} - alias = "alias/{}".format(name) + alias = f"alias/{name}" r = __salt__["boto_kms.key_exists"](alias, region, key, keyid, profile) if "error" in r: ret["result"] = False @@ -218,7 +218,7 @@ def _key_present( return ret ret["changes"]["old"] = {"key": None} ret["changes"]["new"] = {"key": name} - ret["comment"] = "Key {} created.".format(name) + ret["comment"] = f"Key {name} created." else: rd = __salt__["boto_kms.describe_key"](alias, region, key, keyid, profile) if "error" in rd: @@ -277,7 +277,7 @@ def _key_enabled(key_metadata, enabled, region, key, keyid, profile): re["error"]["message"] ) else: - ret["comment"] = "{} key.".format(event) + ret["comment"] = f"{event} key." return ret @@ -345,7 +345,7 @@ def _key_rotation(key_metadata, key_rotation, region, key, keyid, profile): "old": {"key_rotation": not key_rotation}, "new": {"key_rotation": key_rotation}, } - ret["comment"] = "Set key rotation policy to {}.".format(key_rotation) + ret["comment"] = f"Set key rotation policy to {key_rotation}." return ret diff --git a/salt/states/boto_lambda.py b/salt/states/boto_lambda.py index 92453ddb289..4045a70d106 100644 --- a/salt/states/boto_lambda.py +++ b/salt/states/boto_lambda.py @@ -75,7 +75,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -255,7 +255,7 @@ def function_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Function {} is set to be created.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} is set to be created." ret["result"] = None return ret r = __salt__["boto_lambda.create_function"]( @@ -295,7 +295,7 @@ def function_present( key=key, keyid=keyid, profile=profile, - **permission + **permission, ) if not r.get("updated"): ret["result"] = False @@ -311,11 +311,11 @@ def function_present( )["permissions"] ret["changes"]["old"] = {"function": None} ret["changes"]["new"] = _describe - ret["comment"] = "Function {} created.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} created." return ret ret["comment"] = os.linesep.join( - [ret["comment"], "Function {} is present.".format(FunctionName)] + [ret["comment"], f"Function {FunctionName} is present."] ) ret["changes"] = {} # function exists, ensure config matches @@ -379,7 +379,7 @@ def _get_role_arn(name, region=None, key=None, keyid=None, profile=None): account_id = __salt__["boto_iam.get_account_id"]( region=region, key=key, keyid=keyid, profile=profile ) - return "arn:aws:iam::{}:role/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:role/{name}" def _resolve_vpcconfig(conf, region=None, key=None, keyid=None, profile=None): @@ -467,7 +467,7 @@ def _function_config_present( [ret["comment"], "Function config to be modified"] ) if __opts__["test"]: - ret["comment"] = "Function {} set to be modified.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} set to be modified." ret["result"] = None return ret _r = __salt__["boto_lambda.update_function_config"]( @@ -508,7 +508,7 @@ def _function_code_present( dlZipFile = __salt__["cp.cache_file"](path=ZipFile) if dlZipFile is False: ret["result"] = False - ret["comment"] = "Failed to cache ZipFile `{}`.".format(ZipFile) + ret["comment"] = f"Failed to cache ZipFile `{ZipFile}`." return ret ZipFile = dlZipFile size = os.path.getsize(ZipFile) @@ -528,7 +528,7 @@ def _function_code_present( update = True if update: if __opts__["test"]: - ret["comment"] = "Function {} set to be modified.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} set to be modified." ret["result"] = None return ret ret["changes"]["old"] = { @@ -586,7 +586,7 @@ def _function_permissions_present( [ret["comment"], "Function permissions to be modified"] ) if __opts__["test"]: - ret["comment"] = "Function {} set to be modified.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} set to be modified." ret["result"] = None return ret for sid, diff in diffs.items(): @@ -615,7 +615,7 @@ def _function_permissions_present( key=key, keyid=keyid, profile=profile, - **diff["new"] + **diff["new"], ) ret["changes"].setdefault("new", {}).setdefault("Permissions", {})[ sid @@ -671,11 +671,11 @@ def function_absent( return ret if r and not r["exists"]: - ret["comment"] = "Function {} does not exist.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Function {} is set to be removed.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} is set to be removed." ret["result"] = None return ret r = __salt__["boto_lambda.delete_function"]( @@ -687,7 +687,7 @@ def function_absent( return ret ret["changes"]["old"] = {"function": FunctionName} ret["changes"]["new"] = {"function": None} - ret["comment"] = "Function {} deleted.".format(FunctionName) + ret["comment"] = f"Function {FunctionName} deleted." return ret @@ -752,7 +752,7 @@ def alias_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Alias {} is set to be created.".format(Name) + ret["comment"] = f"Alias {Name} is set to be created." ret["result"] = None return ret r = __salt__["boto_lambda.create_alias"]( @@ -774,12 +774,10 @@ def alias_present( ) ret["changes"]["old"] = {"alias": None} ret["changes"]["new"] = _describe - ret["comment"] = "Alias {} created.".format(Name) + ret["comment"] = f"Alias {Name} created." return ret - ret["comment"] = os.linesep.join( - [ret["comment"], "Alias {} is present.".format(Name)] - ) + ret["comment"] = os.linesep.join([ret["comment"], f"Alias {Name} is present."]) ret["changes"] = {} _describe = __salt__["boto_lambda.describe_alias"]( FunctionName, Name, region=region, key=key, keyid=keyid, profile=profile @@ -798,7 +796,7 @@ def alias_present( [ret["comment"], "Alias config to be modified"] ) if __opts__["test"]: - ret["comment"] = "Alias {} set to be modified.".format(Name) + ret["comment"] = f"Alias {Name} set to be modified." ret["result"] = None return ret _r = __salt__["boto_lambda.update_alias"]( @@ -860,11 +858,11 @@ def alias_absent( return ret if r and not r["exists"]: - ret["comment"] = "Alias {} does not exist.".format(Name) + ret["comment"] = f"Alias {Name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Alias {} is set to be removed.".format(Name) + ret["comment"] = f"Alias {Name} is set to be removed." ret["result"] = None return ret r = __salt__["boto_lambda.delete_alias"]( @@ -876,7 +874,7 @@ def alias_absent( return ret ret["changes"]["old"] = {"alias": Name} ret["changes"]["new"] = {"alias": None} - ret["comment"] = "Alias {} deleted.".format(Name) + ret["comment"] = f"Alias {Name} deleted." return ret @@ -891,7 +889,7 @@ def _get_function_arn(name, region=None, key=None, keyid=None, profile=None): region = profile["region"] if region is None: region = "us-east-1" - return "arn:aws:lambda:{}:{}:function:{}".format(region, account_id, name) + return f"arn:aws:lambda:{region}:{account_id}:function:{name}" def event_source_mapping_present( diff --git a/salt/states/boto_lc.py b/salt/states/boto_lc.py index 1a0c4d9cd11..962de2a3e91 100644 --- a/salt/states/boto_lc.py +++ b/salt/states/boto_lc.py @@ -103,9 +103,10 @@ from salt.exceptions import SaltInvocationError __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. diff --git a/salt/states/boto_rds.py b/salt/states/boto_rds.py index c254a6c5bb1..9e12b069609 100644 --- a/salt/states/boto_rds.py +++ b/salt/states/boto_rds.py @@ -80,7 +80,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -312,7 +312,7 @@ def present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "RDS instance {} would be created.".format(name) + ret["comment"] = f"RDS instance {name} would be created." ret["result"] = None return ret @@ -380,9 +380,9 @@ def present( profile=profile, ) } - ret["comment"] = "RDS instance {} created.".format(name) + ret["comment"] = f"RDS instance {name} created." else: - ret["comment"] = "RDS instance {} exists.".format(name) + ret["comment"] = f"RDS instance {name} exists." return ret @@ -419,7 +419,7 @@ def replica_present( ) if not replica_exists.get("exists"): if __opts__["test"]: - ret["comment"] = "RDS read replica {} is set to be created ".format(name) + ret["comment"] = f"RDS read replica {name} is set to be created " ret["result"] = None return ret created = __salt__["boto_rds.create_read_replica"]( @@ -439,7 +439,7 @@ def replica_present( profile, ) if created: - ret["comment"] = "RDS replica {} created.".format(name) + ret["comment"] = f"RDS replica {name} created." ret["changes"]["old"] = {"instance": None} ret["changes"]["new"] = { "instance": __salt__["boto_rds.describe_db_instances"]( @@ -453,7 +453,7 @@ def replica_present( } else: ret["result"] = False - ret["comment"] = "Failed to create RDS replica {}.".format(name) + ret["comment"] = f"Failed to create RDS replica {name}." else: jmespath = "DBInstances[0].DBParameterGroups[0].DBParameterGroupName" pmg_name = __salt__["boto_rds.describe_db_instances"]( @@ -478,11 +478,11 @@ def replica_present( ret["result"] = False ret[ "comment" - ] = "Failed to update parameter group of {} RDS instance.".format(name) + ] = f"Failed to update parameter group of {name} RDS instance." ret["changes"]["old"] = pmg_name ret["changes"]["new"] = db_parameter_group_name ret["result"] = True - ret["comment"] = "RDS replica {} exists.".format(name) + ret["comment"] = f"RDS replica {name} exists." return ret @@ -553,7 +553,7 @@ def subnet_group_present( ret["result"] = False return ret if r["id"] is None: - ret["comment"] = "Subnet {} does not exist.".format(i) + ret["comment"] = f"Subnet {i} does not exist." ret["result"] = False return ret subnet_ids.append(r["id"]) @@ -563,7 +563,7 @@ def subnet_group_present( ) if not exists.get("exists"): if __opts__["test"]: - ret["comment"] = "Subnet group {} is set to be created.".format(name) + ret["comment"] = f"Subnet group {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_rds.create_subnet_group"]( @@ -579,14 +579,14 @@ def subnet_group_present( if not created: ret["result"] = False - ret["comment"] = "Failed to create {} subnet group.".format(name) + ret["comment"] = f"Failed to create {name} subnet group." return ret ret["changes"]["old"] = None ret["changes"]["new"] = name - ret["comment"] = "Subnet {} created.".format(name) + ret["comment"] = f"Subnet {name} created." return ret else: - ret["comment"] = "Subnet {} present.".format(name) + ret["comment"] = f"Subnet {name} present." return ret @@ -648,11 +648,11 @@ def absent( ) if not current: ret["result"] = True - ret["comment"] = "{} RDS already absent.".format(name) + ret["comment"] = f"{name} RDS already absent." return ret if __opts__["test"]: - ret["comment"] = "RDS {} would be removed.".format(name) + ret["comment"] = f"RDS {name} would be removed." ret["result"] = None return ret deleted = __salt__["boto_rds.delete"]( @@ -669,11 +669,11 @@ def absent( ) if not deleted: ret["result"] = False - ret["comment"] = "Failed to delete {} RDS.".format(name) + ret["comment"] = f"Failed to delete {name} RDS." return ret ret["changes"]["old"] = {"instance": current[0]} ret["changes"]["new"] = {"instance": None} - ret["comment"] = "RDS {} deleted.".format(name) + ret["comment"] = f"RDS {name} deleted." return ret @@ -687,11 +687,11 @@ def subnet_group_absent( ) if not exists: ret["result"] = True - ret["comment"] = "{} RDS subnet group does not exist.".format(name) + ret["comment"] = f"{name} RDS subnet group does not exist." return ret if __opts__["test"]: - ret["comment"] = "RDS subnet group {} is set to be removed.".format(name) + ret["comment"] = f"RDS subnet group {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_rds.delete_subnet_group"]( @@ -699,11 +699,11 @@ def subnet_group_absent( ) if not deleted: ret["result"] = False - ret["comment"] = "Failed to delete {} RDS subnet group.".format(name) + ret["comment"] = f"Failed to delete {name} RDS subnet group." return ret ret["changes"]["old"] = name ret["changes"]["new"] = None - ret["comment"] = "RDS subnet group {} deleted.".format(name) + ret["comment"] = f"RDS subnet group {name} deleted." return ret @@ -768,7 +768,7 @@ def parameter_present( ) if not res.get("exists"): if __opts__["test"]: - ret["comment"] = "Parameter group {} is set to be created.".format(name) + ret["comment"] = f"Parameter group {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_rds.create_parameter_group"]( @@ -783,12 +783,12 @@ def parameter_present( ) if not created: ret["result"] = False - ret["comment"] = "Failed to create {} parameter group.".format(name) + ret["comment"] = f"Failed to create {name} parameter group." return ret ret["changes"]["New Parameter Group"] = name - ret["comment"] = "Parameter group {} created.".format(name) + ret["comment"] = f"Parameter group {name} created." else: - ret["comment"] = "Parameter group {} present.".format(name) + ret["comment"] = f"Parameter group {name} present." if parameters is not None: params = {} changed = {} @@ -805,7 +805,7 @@ def parameter_present( if not options.get("result"): ret["result"] = False ret["comment"] = os.linesep.join( - [ret["comment"], "Faled to get parameters for group {}.".format(name)] + [ret["comment"], f"Faled to get parameters for group {name}."] ) return ret for parameter in options["parameters"].values(): @@ -859,14 +859,14 @@ def parameter_present( ret["comment"] = os.linesep.join( [ ret["comment"], - "Parameters {} for group {} are changed.".format(changed, name), + f"Parameters {changed} for group {name} are changed.", ] ) else: ret["comment"] = os.linesep.join( [ ret["comment"], - "Parameters {} for group {} are present.".format(params, name), + f"Parameters {params} for group {name} are present.", ] ) return ret diff --git a/salt/states/boto_route53.py b/salt/states/boto_route53.py index ebd6d2194b0..e9b2bc8f8cd 100644 --- a/salt/states/boto_route53.py +++ b/salt/states/boto_route53.py @@ -83,7 +83,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -217,13 +217,13 @@ def present( identifier, ) except SaltInvocationError as err: - ret["comment"] = "Error: {}".format(err) + ret["comment"] = f"Error: {err}" ret["result"] = False return ret if isinstance(record, dict) and not record: if __opts__["test"]: - ret["comment"] = "Route53 record {} set to be added.".format(name) + ret["comment"] = f"Route53 record {name} set to be added." ret["result"] = None return ret added = __salt__["boto_route53.add_record"]( @@ -250,10 +250,10 @@ def present( "ttl": ttl, "identifier": identifier, } - ret["comment"] = "Added {} Route53 record.".format(name) + ret["comment"] = f"Added {name} Route53 record." else: ret["result"] = False - ret["comment"] = "Failed to add {} Route53 record.".format(name) + ret["comment"] = f"Failed to add {name} Route53 record." return ret elif record: need_to_update = False @@ -274,7 +274,7 @@ def present( need_to_update = True if need_to_update: if __opts__["test"]: - ret["comment"] = "Route53 record {} set to be updated.".format(name) + ret["comment"] = f"Route53 record {name} set to be updated." ret["result"] = None return ret updated = __salt__["boto_route53.update_record"]( @@ -301,12 +301,12 @@ def present( "ttl": ttl, "identifier": identifier, } - ret["comment"] = "Updated {} Route53 record.".format(name) + ret["comment"] = f"Updated {name} Route53 record." else: ret["result"] = False - ret["comment"] = "Failed to update {} Route53 record.".format(name) + ret["comment"] = f"Failed to update {name} Route53 record." else: - ret["comment"] = "{} exists.".format(name) + ret["comment"] = f"{name} exists." return ret @@ -382,7 +382,7 @@ def absent( ) if record: if __opts__["test"]: - ret["comment"] = "Route53 record {} set to be deleted.".format(name) + ret["comment"] = f"Route53 record {name} set to be deleted." ret["result"] = None return ret deleted = __salt__["boto_route53.delete_record"]( @@ -402,12 +402,12 @@ def absent( if deleted: ret["changes"]["old"] = record ret["changes"]["new"] = None - ret["comment"] = "Deleted {} Route53 record.".format(name) + ret["comment"] = f"Deleted {name} Route53 record." else: ret["result"] = False - ret["comment"] = "Failed to delete {} Route53 record.".format(name) + ret["comment"] = f"Failed to delete {name} Route53 record." else: - ret["comment"] = "{} does not exist.".format(name) + ret["comment"] = f"{name} does not exist." return ret @@ -581,13 +581,13 @@ def hosted_zone_present( profile=profile, ) if res: - msg = "Hosted Zone {} successfully created".format(domain_name) + msg = f"Hosted Zone {domain_name} successfully created" log.info(msg) ret["comment"] = msg ret["changes"]["old"] = None ret["changes"]["new"] = res else: - ret["comment"] = "Creating Hosted Zone {} failed".format(domain_name) + ret["comment"] = f"Creating Hosted Zone {domain_name} failed" ret["result"] = False return ret @@ -615,11 +615,11 @@ def hosted_zone_absent( domain_name=domain_name, region=region, key=key, keyid=keyid, profile=profile ) if not deets: - ret["comment"] = "Hosted Zone {} already absent".format(domain_name) + ret["comment"] = f"Hosted Zone {domain_name} already absent" log.info(ret["comment"]) return ret if __opts__["test"]: - ret["comment"] = "Route53 Hosted Zone {} set to be deleted.".format(domain_name) + ret["comment"] = f"Route53 Hosted Zone {domain_name} set to be deleted." ret["result"] = None return ret # Not entirely comfortable with this - no safety checks around pub/priv, VPCs @@ -628,7 +628,7 @@ def hosted_zone_absent( if __salt__["boto_route53.delete_zone"]( zone=domain_name, region=region, key=key, keyid=keyid, profile=profile ): - ret["comment"] = "Route53 Hosted Zone {} deleted".format(domain_name) + ret["comment"] = f"Route53 Hosted Zone {domain_name} deleted" log.info(ret["comment"]) ret["changes"]["old"] = deets ret["changes"]["new"] = None diff --git a/salt/states/boto_s3.py b/salt/states/boto_s3.py index 864a899b8c4..1519835f56e 100644 --- a/salt/states/boto_s3.py +++ b/salt/states/boto_s3.py @@ -60,7 +60,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -183,7 +183,7 @@ def object_present( combined_extra_args_keys = frozenset(combined_extra_args.keys()) extra_keys = combined_extra_args_keys - supported_args if extra_keys: - msg = "extra_args keys {} are not supported".format(extra_keys) + msg = f"extra_args keys {extra_keys} are not supported" return {"error": msg} # Get the hash of the local file @@ -259,7 +259,7 @@ def object_present( } if s3_metadata == desired_metadata: ret["result"] = True - ret["comment"] = "S3 object {} is present.".format(name) + ret["comment"] = f"S3 object {name} is present." return ret action = "update" else: @@ -283,8 +283,8 @@ def object_present( if __opts__["test"]: ret["result"] = None - ret["comment"] = "S3 object {} set to be {}d.".format(name, action) - ret["comment"] += "\nChanges:\n{}".format(changes_diff) + ret["comment"] = f"S3 object {name} set to be {action}d." + ret["comment"] += f"\nChanges:\n{changes_diff}" ret["changes"] = {"diff": changes_diff} return ret @@ -307,7 +307,7 @@ def object_present( return ret ret["result"] = True - ret["comment"] = "S3 object {} {}d.".format(name, action) - ret["comment"] += "\nChanges:\n{}".format(changes_diff) + ret["comment"] = f"S3 object {name} {action}d." + ret["comment"] += f"\nChanges:\n{changes_diff}" ret["changes"] = {"diff": changes_diff} return ret diff --git a/salt/states/boto_s3_bucket.py b/salt/states/boto_s3_bucket.py index cf8166fe8bd..4d0d6b27126 100644 --- a/salt/states/boto_s3_bucket.py +++ b/salt/states/boto_s3_bucket.py @@ -148,7 +148,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -305,7 +305,7 @@ def _get_role_arn(name, region=None, key=None, keyid=None, profile=None): region = profile["region"] if region is None: region = "us-east-1" - return "arn:aws:iam::{}:role/{}".format(account_id, name) + return f"arn:aws:iam::{account_id}:role/{name}" def _compare_json(current, desired, region, key, keyid, profile): @@ -446,7 +446,7 @@ def present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "S3 bucket {} is set to be created.".format(Bucket) + ret["comment"] = f"S3 bucket {Bucket} is set to be created." ret["result"] = None return ret r = __salt__["boto_s3_bucket.create"]( @@ -487,13 +487,13 @@ def present( ("put_website", Website, Website), ): if testval is not None: - r = __salt__["boto_s3_bucket.{}".format(setter)]( + r = __salt__[f"boto_s3_bucket.{setter}"]( Bucket=Bucket, region=region, key=key, keyid=keyid, profile=profile, - **funcargs + **funcargs, ) if not r.get("updated"): ret["result"] = False @@ -507,14 +507,12 @@ def present( ) ret["changes"]["old"] = {"bucket": None} ret["changes"]["new"] = _describe - ret["comment"] = "S3 bucket {} created.".format(Bucket) + ret["comment"] = f"S3 bucket {Bucket} created." return ret # bucket exists, ensure config matches - ret["comment"] = " ".join( - [ret["comment"], "S3 bucket {} is present.".format(Bucket)] - ) + ret["comment"] = " ".join([ret["comment"], f"S3 bucket {Bucket} is present."]) ret["changes"] = {} _describe = __salt__["boto_s3_bucket.describe"]( Bucket=Bucket, region=region, key=key, keyid=keyid, profile=profile @@ -653,7 +651,7 @@ def present( if not __opts__["test"]: if deleter and desired is None: # Setting can be deleted, so use that to unset it - r = __salt__["boto_s3_bucket.{}".format(deleter)]( + r = __salt__[f"boto_s3_bucket.{deleter}"]( Bucket=Bucket, region=region, key=key, @@ -668,13 +666,13 @@ def present( ret["changes"] = {} return ret else: - r = __salt__["boto_s3_bucket.{}".format(setter)]( + r = __salt__[f"boto_s3_bucket.{setter}"]( Bucket=Bucket, region=region, key=key, keyid=keyid, profile=profile, - **(desired or {}) + **(desired or {}), ) if not r.get("updated"): ret["result"] = False @@ -684,7 +682,7 @@ def present( ret["changes"] = {} return ret if update and __opts__["test"]: - msg = "S3 bucket {} set to be modified.".format(Bucket) + msg = f"S3 bucket {Bucket} set to be modified." ret["comment"] = msg ret["result"] = None return ret @@ -699,7 +697,7 @@ def present( ) log.warning(msg) ret["result"] = False - ret["comment"] = "Failed to update bucket: {}.".format(msg) + ret["comment"] = f"Failed to update bucket: {msg}." return ret return ret @@ -743,11 +741,11 @@ def absent(name, Bucket, Force=False, region=None, key=None, keyid=None, profile return ret if r and not r["exists"]: - ret["comment"] = "S3 bucket {} does not exist.".format(Bucket) + ret["comment"] = f"S3 bucket {Bucket} does not exist." return ret if __opts__["test"]: - ret["comment"] = "S3 bucket {} is set to be removed.".format(Bucket) + ret["comment"] = f"S3 bucket {Bucket} is set to be removed." ret["result"] = None return ret r = __salt__["boto_s3_bucket.delete"]( @@ -759,5 +757,5 @@ def absent(name, Bucket, Force=False, region=None, key=None, keyid=None, profile return ret ret["changes"]["old"] = {"bucket": Bucket} ret["changes"]["new"] = {"bucket": None} - ret["comment"] = "S3 bucket {} deleted.".format(Bucket) + ret["comment"] = f"S3 bucket {Bucket} deleted." return ret diff --git a/salt/states/boto_secgroup.py b/salt/states/boto_secgroup.py index ef73d7d2147..32599c3c958 100644 --- a/salt/states/boto_secgroup.py +++ b/salt/states/boto_secgroup.py @@ -114,7 +114,7 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -289,7 +289,7 @@ def _security_group_present( ) if not exists: if __opts__["test"]: - ret["comment"] = "Security group {} is set to be created.".format(name) + ret["comment"] = f"Security group {name} is set to be created." ret["result"] = None return ret created = __salt__["boto_secgroup.create"]( @@ -315,12 +315,12 @@ def _security_group_present( vpc_name=vpc_name, ) ret["changes"]["new"] = {"secgroup": sg} - ret["comment"] = "Security group {} created.".format(name) + ret["comment"] = f"Security group {name} created." else: ret["result"] = False - ret["comment"] = "Failed to create {} security group.".format(name) + ret["comment"] = f"Failed to create {name} security group." else: - ret["comment"] = "Security group {} present.".format(name) + ret["comment"] = f"Security group {name} present." return ret @@ -428,7 +428,7 @@ def _get_rule_changes(rules, _rules): -1, ] if ip_protocol not in supported_protocols and ( - not "{}".format(ip_protocol).isdigit() or int(ip_protocol) > 255 + not f"{ip_protocol}".isdigit() or int(ip_protocol) > 255 ): raise SaltInvocationError( "Invalid ip_protocol {} specified in security group rule.".format( @@ -515,9 +515,7 @@ def _rules_present( vpc_name=vpc_name, ) if not sg: - ret[ - "comment" - ] = "{} security group configuration could not be retrieved.".format(name) + ret["comment"] = f"{name} security group configuration could not be retrieved." ret["result"] = False return ret rules = _split_rules(rules) @@ -574,12 +572,12 @@ def _rules_present( key=key, keyid=keyid, profile=profile, - **rule + **rule, ) if not _deleted: deleted = False if deleted: - ret["comment"] = "Removed rules on {} security group.".format(name) + ret["comment"] = f"Removed rules on {name} security group." else: ret["comment"] = "Failed to remove rules on {} security group.".format( name @@ -596,7 +594,7 @@ def _rules_present( key=key, keyid=keyid, profile=profile, - **rule + **rule, ) if not _created: created = False @@ -604,14 +602,14 @@ def _rules_present( ret["comment"] = " ".join( [ ret["comment"], - "Created rules on {} security group.".format(name), + f"Created rules on {name} security group.", ] ) else: ret["comment"] = " ".join( [ ret["comment"], - "Failed to create rules on {} security group.".format(name), + f"Failed to create rules on {name} security group.", ] ) ret["result"] = False @@ -660,9 +658,7 @@ def _rules_egress_present( vpc_name=vpc_name, ) if not sg: - ret[ - "comment" - ] = "{} security group configuration could not be retrieved.".format(name) + ret["comment"] = f"{name} security group configuration could not be retrieved." ret["result"] = False return ret rules_egress = _split_rules(rules_egress) @@ -720,7 +716,7 @@ def _rules_egress_present( keyid=keyid, profile=profile, egress=True, - **rule + **rule, ) if not _deleted: deleted = False @@ -728,7 +724,7 @@ def _rules_egress_present( ret["comment"] = " ".join( [ ret["comment"], - "Removed egress rule on {} security group.".format(name), + f"Removed egress rule on {name} security group.", ] ) else: @@ -753,7 +749,7 @@ def _rules_egress_present( keyid=keyid, profile=profile, egress=True, - **rule + **rule, ) if not _created: created = False @@ -761,7 +757,7 @@ def _rules_egress_present( ret["comment"] = " ".join( [ ret["comment"], - "Created egress rules on {} security group.".format(name), + f"Created egress rules on {name} security group.", ] ) else: @@ -837,7 +833,7 @@ def absent( if sg: if __opts__["test"]: - ret["comment"] = "Security group {} is set to be removed.".format(name) + ret["comment"] = f"Security group {name} is set to be removed." ret["result"] = None return ret deleted = __salt__["boto_secgroup.delete"]( @@ -853,12 +849,12 @@ def absent( if deleted: ret["changes"]["old"] = {"secgroup": sg} ret["changes"]["new"] = {"secgroup": None} - ret["comment"] = "Security group {} deleted.".format(name) + ret["comment"] = f"Security group {name} deleted." else: ret["result"] = False - ret["comment"] = "Failed to delete {} security group.".format(name) + ret["comment"] = f"Failed to delete {name} security group." else: - ret["comment"] = "{} security group does not exist.".format(name) + ret["comment"] = f"{name} security group does not exist." return ret @@ -890,7 +886,7 @@ def _tags_present( if not sg: ret[ "comment" - ] = "{} security group configuration could not be retrieved.".format(name) + ] = f"{name} security group configuration could not be retrieved." ret["result"] = False return ret tags_to_add = tags diff --git a/salt/states/boto_sns.py b/salt/states/boto_sns.py index 674268c5927..8199e209138 100644 --- a/salt/states/boto_sns.py +++ b/salt/states/boto_sns.py @@ -57,11 +57,10 @@ passed in as a dict, or as a string to pull from pillars or minion config: # Standard Libs import re - __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -113,10 +112,10 @@ def present(name, subscriptions=None, region=None, key=None, keyid=None, profile ) if is_present: ret["result"] = True - ret["comment"] = "AWS SNS topic {} present.".format(name) + ret["comment"] = f"AWS SNS topic {name} present." else: if __opts__["test"]: - msg = "AWS SNS topic {} is set to be created.".format(name) + msg = f"AWS SNS topic {name} is set to be created." ret["comment"] = msg ret["result"] = None return ret @@ -125,13 +124,13 @@ def present(name, subscriptions=None, region=None, key=None, keyid=None, profile name, region=region, key=key, keyid=keyid, profile=profile ) if created: - msg = "AWS SNS topic {} created.".format(name) + msg = f"AWS SNS topic {name} created." ret["comment"] = msg ret["changes"]["old"] = None ret["changes"]["new"] = {"topic": name, "subscriptions": []} ret["result"] = True else: - ret["comment"] = "Failed to create {} AWS SNS topic".format(name) + ret["comment"] = f"Failed to create {name} AWS SNS topic" ret["result"] = False return ret @@ -271,7 +270,7 @@ def absent(name, region=None, key=None, keyid=None, profile=None, unsubscribe=Fa name, region=region, key=key, keyid=keyid, profile=profile ) if deleted: - ret["comment"] = "AWS SNS topic {} deleted.".format(name) + ret["comment"] = f"AWS SNS topic {name} deleted." ret["changes"]["new"] = None if unsubscribe is False: ret["changes"]["old"] = {"topic": name} @@ -283,8 +282,8 @@ def absent(name, region=None, key=None, keyid=None, profile=None, unsubscribe=Fa } else: ret["result"] = False - ret["comment"] = "Failed to delete {} AWS SNS topic.".format(name) + ret["comment"] = f"Failed to delete {name} AWS SNS topic." else: - ret["comment"] = "AWS SNS topic {} does not exist.".format(name) + ret["comment"] = f"AWS SNS topic {name} does not exist." return ret diff --git a/salt/states/boto_sqs.py b/salt/states/boto_sqs.py index a8455d38a6f..6cd2a35225d 100644 --- a/salt/states/boto_sqs.py +++ b/salt/states/boto_sqs.py @@ -68,9 +68,10 @@ log = logging.getLogger(__name__) __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) + def __virtual__(): """ Only load if boto is available. @@ -130,12 +131,12 @@ def present( return ret if r["result"]: - ret["comment"].append("SQS queue {} present.".format(name)) + ret["comment"].append(f"SQS queue {name} present.") else: if __opts__["test"]: ret["result"] = None ret["comment"].append( - "SQS queue {} is set to be created.".format(name), + f"SQS queue {name} is set to be created.", ) ret["changes"] = {"old": None, "new": name} return ret @@ -155,7 +156,7 @@ def present( ) return ret - ret["comment"].append("SQS queue {} created.".format(name)) + ret["comment"].append(f"SQS queue {name} created.") ret["changes"]["old"] = None ret["changes"]["new"] = name # Return immediately, as the create call also set all attributes @@ -244,7 +245,7 @@ def present( return ret ret["comment"].append( - "Updated SQS queue attribute(s) {}.".format(attr_names), + f"Updated SQS queue attribute(s) {attr_names}.", ) ret["changes"]["attributes"] = {"diff": attributes_diff} return ret @@ -299,7 +300,7 @@ def absent( if __opts__["test"]: ret["result"] = None - ret["comment"] = "SQS queue {} is set to be removed.".format(name) + ret["comment"] = f"SQS queue {name} is set to be removed." ret["changes"] = {"old": name, "new": None} return ret @@ -315,7 +316,7 @@ def absent( ret["comment"] = str(r["error"]) return ret - ret["comment"] = "SQS queue {} was deleted.".format(name) + ret["comment"] = f"SQS queue {name} was deleted." ret["changes"]["old"] = name ret["changes"]["new"] = None return ret diff --git a/salt/states/boto_vpc.py b/salt/states/boto_vpc.py index 669b97ef37f..3146f01374b 100644 --- a/salt/states/boto_vpc.py +++ b/salt/states/boto_vpc.py @@ -154,7 +154,7 @@ __virtualname__ = "boto_vpc" __deprecated__ = ( 3009, "boto", - "https://github.com/salt-extensions/saltext-boto" + "https://github.com/salt-extensions/saltext-boto", ) @@ -235,7 +235,7 @@ def present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "VPC {} is set to be created.".format(name) + ret["comment"] = f"VPC {name} is set to be created." ret["result"] = None return ret r = __salt__["boto_vpc.create"]( @@ -259,7 +259,7 @@ def present( ) ret["changes"]["old"] = {"vpc": None} ret["changes"]["new"] = _describe - ret["comment"] = "VPC {} created.".format(name) + ret["comment"] = f"VPC {name} created." return ret ret["comment"] = "VPC present." return ret @@ -301,11 +301,11 @@ def absent(name, tags=None, region=None, key=None, keyid=None, profile=None): _id = r.get("id") if not _id: - ret["comment"] = "{} VPC does not exist.".format(name) + ret["comment"] = f"{name} VPC does not exist." return ret if __opts__["test"]: - ret["comment"] = "VPC {} is set to be removed.".format(name) + ret["comment"] = f"VPC {name} is set to be removed." ret["result"] = None return ret r = __salt__["boto_vpc.delete"]( @@ -317,7 +317,7 @@ def absent(name, tags=None, region=None, key=None, keyid=None, profile=None): return ret ret["changes"]["old"] = {"vpc": _id} ret["changes"]["new"] = {"vpc": None} - ret["comment"] = "VPC {} deleted.".format(name) + ret["comment"] = f"VPC {name} deleted." return ret @@ -436,7 +436,7 @@ def dhcp_options_present( return ret else: if __opts__["test"]: - ret["comment"] = "DHCP options {} are set to be created.".format(name) + ret["comment"] = f"DHCP options {name} are set to be created." ret["result"] = None return ret @@ -464,7 +464,7 @@ def dhcp_options_present( ret["changes"]["old"] = {"dhcp_options": None} ret["changes"]["new"] = {"dhcp_options": _new} - ret["comment"] = "DHCP options {} created.".format(name) + ret["comment"] = f"DHCP options {name} created." return ret @@ -516,11 +516,11 @@ def dhcp_options_absent( _id = r.get("id") if not _id: - ret["comment"] = "DHCP options {} do not exist.".format(name) + ret["comment"] = f"DHCP options {name} do not exist." return ret if __opts__["test"]: - ret["comment"] = "DHCP options {} are set to be deleted.".format(name) + ret["comment"] = f"DHCP options {name} are set to be deleted." ret["result"] = None return ret @@ -536,7 +536,7 @@ def dhcp_options_absent( ret["changes"]["old"] = {"dhcp_options": _id} ret["changes"]["new"] = {"dhcp_options": None} - ret["comment"] = "DHCP options {} deleted.".format(name) + ret["comment"] = f"DHCP options {name} deleted." return ret @@ -676,7 +676,7 @@ def subnet_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Subnet {} is set to be created.".format(name) + ret["comment"] = f"Subnet {name} is set to be created." ret["result"] = None return ret r = __salt__["boto_vpc.create_subnet"]( @@ -701,7 +701,7 @@ def subnet_present( ) ret["changes"]["old"] = {"subnet": None} ret["changes"]["new"] = _describe - ret["comment"] = "Subnet {} created.".format(name) + ret["comment"] = f"Subnet {name} created." else: ret["comment"] = "Subnet present." @@ -712,7 +712,7 @@ def subnet_present( ) if not _verify_subnet_association(route_table_desc, _describe["subnet"]["id"]): if __opts__["test"]: - msg = "Subnet is set to be associated with route table {}".format(rtid) + msg = f"Subnet is set to be associated with route table {rtid}" ret["comment"] = " ".join([ret["comment"], msg]) ret["result"] = None return ret @@ -750,7 +750,7 @@ def subnet_present( ret["result"] = False return ret else: - msg = "Subnet successfully associated with route table {}.".format(rtid) + msg = f"Subnet successfully associated with route table {rtid}." ret["comment"] = " ".join([ret["comment"], msg]) if "new" not in ret["changes"]: ret["changes"]["new"] = __salt__["boto_vpc.describe_subnet"]( @@ -768,7 +768,7 @@ def subnet_present( ret["comment"] = " ".join( [ ret["comment"], - "Subnet is already associated with route table {}".format(rtid), + f"Subnet is already associated with route table {rtid}", ] ) return ret @@ -830,7 +830,7 @@ def subnet_absent( _id = r.get("id") if not _id: - ret["comment"] = "{} subnet does not exist.".format(name) + ret["comment"] = f"{name} subnet does not exist." return ret if __opts__["test"]: @@ -848,7 +848,7 @@ def subnet_absent( ret["changes"]["old"] = {"subnet": _id} ret["changes"]["new"] = {"subnet": None} - ret["comment"] = "Subnet {} deleted.".format(name) + ret["comment"] = f"Subnet {name} deleted." return ret @@ -911,7 +911,7 @@ def internet_gateway_present( if not r.get("exists"): if __opts__["test"]: - ret["comment"] = "Internet gateway {} is set to be created.".format(name) + ret["comment"] = f"Internet gateway {name} is set to be created." ret["result"] = None return ret r = __salt__["boto_vpc.create_internet_gateway"]( @@ -933,9 +933,9 @@ def internet_gateway_present( ret["changes"]["old"] = {"internet_gateway": None} ret["changes"]["new"] = {"internet_gateway": r["id"]} - ret["comment"] = "Internet gateway {} created.".format(name) + ret["comment"] = f"Internet gateway {name} created." return ret - ret["comment"] = "Internet gateway {} present.".format(name) + ret["comment"] = f"Internet gateway {name} present." return ret @@ -984,11 +984,11 @@ def internet_gateway_absent( igw_id = r["id"] if not igw_id: - ret["comment"] = "Internet gateway {} does not exist.".format(name) + ret["comment"] = f"Internet gateway {name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Internet gateway {} is set to be removed.".format(name) + ret["comment"] = f"Internet gateway {name} is set to be removed." ret["result"] = None return ret r = __salt__["boto_vpc.delete_internet_gateway"]( @@ -1007,7 +1007,7 @@ def internet_gateway_absent( return ret ret["changes"]["old"] = {"internet_gateway": igw_id} ret["changes"]["new"] = {"internet_gateway": None} - ret["comment"] = "Internet gateway {} deleted.".format(name) + ret["comment"] = f"Internet gateway {name} deleted." return ret @@ -1169,7 +1169,7 @@ def _route_table_present( if not _id: if __opts__["test"]: - msg = "Route table {} is set to be created.".format(name) + msg = f"Route table {name} is set to be created." ret["comment"] = msg ret["result"] = None return ret @@ -1193,9 +1193,9 @@ def _route_table_present( ret["changes"]["old"] = {"route_table": None} ret["changes"]["new"] = {"route_table": r["id"]} - ret["comment"] = "Route table {} created.".format(name) + ret["comment"] = f"Route table {name} created." return ret - ret["comment"] = "Route table {} ({}) present.".format(name, _id) + ret["comment"] = f"Route table {name} ({_id}) present." return ret @@ -1254,7 +1254,7 @@ def _routes_present( ret["result"] = False return ret if r["id"] is None: - msg = "Internet gateway {} does not exist.".format(i) + msg = f"Internet gateway {i} does not exist." ret["comment"] = msg ret["result"] = False return ret @@ -1278,7 +1278,7 @@ def _routes_present( ret["result"] = False return ret if r["id"] is None: - msg = "VPC peering connection {} does not exist.".format(i) + msg = f"VPC peering connection {i} does not exist." ret["comment"] = msg ret["result"] = False return ret @@ -1332,7 +1332,7 @@ def _routes_present( to_delete.append(route) if to_create or to_delete: if __opts__["test"]: - msg = "Route table {} set to have routes modified.".format(route_table_name) + msg = f"Route table {route_table_name} set to have routes modified." ret["comment"] = msg ret["result"] = None return ret @@ -1366,7 +1366,7 @@ def _routes_present( key=key, keyid=keyid, profile=profile, - **r + **r, ) if not res["created"]: msg = "Failed to create route {} in route table {}: {}.".format( @@ -1421,7 +1421,7 @@ def _subnets_present( ret["result"] = False return ret if r["id"] is None: - msg = "Subnet {} does not exist.".format(i) + msg = f"Subnet {i} does not exist." ret["comment"] = msg ret["result"] = False return ret @@ -1545,11 +1545,11 @@ def route_table_absent(name, region=None, key=None, keyid=None, profile=None): rtbl_id = r["id"] if not rtbl_id: - ret["comment"] = "Route table {} does not exist.".format(name) + ret["comment"] = f"Route table {name} does not exist." return ret if __opts__["test"]: - ret["comment"] = "Route table {} is set to be removed.".format(name) + ret["comment"] = f"Route table {name} is set to be removed." ret["result"] = None return ret @@ -1564,7 +1564,7 @@ def route_table_absent(name, region=None, key=None, keyid=None, profile=None): return ret ret["changes"]["old"] = {"route_table": rtbl_id} ret["changes"]["new"] = {"route_table": None} - ret["comment"] = "Route table {} deleted.".format(name) + ret["comment"] = f"Route table {name} deleted." return ret @@ -1659,7 +1659,7 @@ def nat_gateway_present( inst = r[0] _id = inst.get("NatGatewayId") - ret["comment"] = "Nat gateway {} present.".format(_id) + ret["comment"] = f"Nat gateway {_id} present." return ret @@ -1749,9 +1749,7 @@ def nat_gateway_absent( r["error"]["message"] ) return ret - ret["comment"] = ", ".join( - (ret["comment"], "Nat gateway {} deleted.".format(rtbl_id)) - ) + ret["comment"] = ", ".join((ret["comment"], f"Nat gateway {rtbl_id} deleted.")) ret["changes"]["old"] = {"nat_gateway": rtbl_id} ret["changes"]["new"] = {"nat_gateway": None} return ret From f08ae486425a2a1c08779e778a39dc5858cf37e7 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Sun, 11 Jun 2023 22:12:17 +0100 Subject: [PATCH 5/5] Vertical tuples are more readable than horizontal ones Signed-off-by: Pedro Algarvio --- salt/modules/boto3_elasticache.py | 6 +++++- salt/modules/boto3_elasticsearch.py | 6 +++++- salt/modules/boto3_route53.py | 6 +++++- salt/modules/boto3_sns.py | 6 +++++- salt/modules/boto_apigateway.py | 6 +++++- salt/modules/boto_asg.py | 6 +++++- salt/modules/boto_cfn.py | 6 +++++- salt/modules/boto_cloudfront.py | 6 +++++- salt/modules/boto_cloudtrail.py | 6 +++++- salt/modules/boto_cloudwatch.py | 6 +++++- salt/modules/boto_cloudwatch_event.py | 6 +++++- salt/modules/boto_cognitoidentity.py | 6 +++++- salt/modules/boto_datapipeline.py | 6 +++++- salt/modules/boto_dynamodb.py | 6 +++++- salt/modules/boto_ec2.py | 6 +++++- salt/modules/boto_efs.py | 6 +++++- salt/modules/boto_elasticache.py | 6 +++++- salt/modules/boto_elasticsearch_domain.py | 6 +++++- salt/modules/boto_elb.py | 6 +++++- salt/modules/boto_elbv2.py | 6 +++++- salt/modules/boto_iam.py | 6 +++++- salt/modules/boto_iot.py | 6 +++++- salt/modules/boto_kinesis.py | 6 +++++- salt/modules/boto_kms.py | 6 +++++- salt/modules/boto_lambda.py | 6 +++++- salt/modules/boto_rds.py | 6 +++++- salt/modules/boto_route53.py | 6 +++++- salt/modules/boto_s3.py | 6 +++++- salt/modules/boto_s3_bucket.py | 6 +++++- salt/modules/boto_secgroup.py | 6 +++++- salt/modules/boto_sns.py | 6 +++++- salt/modules/boto_sqs.py | 6 +++++- salt/modules/boto_ssm.py | 6 +++++- salt/modules/boto_vpc.py | 6 +++++- 34 files changed, 170 insertions(+), 34 deletions(-) diff --git a/salt/modules/boto3_elasticache.py b/salt/modules/boto3_elasticache.py index 054beed1cd6..fd55ad51a13 100644 --- a/salt/modules/boto3_elasticache.py +++ b/salt/modules/boto3_elasticache.py @@ -66,7 +66,11 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto3_elasticsearch.py b/salt/modules/boto3_elasticsearch.py index 1778cccd264..fd50e3072d3 100644 --- a/salt/modules/boto3_elasticsearch.py +++ b/salt/modules/boto3_elasticsearch.py @@ -74,7 +74,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto3_route53.py b/salt/modules/boto3_route53.py index 23dd1914ecb..f7afa7d47ba 100644 --- a/salt/modules/boto3_route53.py +++ b/salt/modules/boto3_route53.py @@ -70,7 +70,11 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto3_sns.py b/salt/modules/boto3_sns.py index 380085e9f97..8c05dc0d7a0 100644 --- a/salt/modules/boto3_sns.py +++ b/salt/modules/boto3_sns.py @@ -60,7 +60,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=unused-import -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_apigateway.py b/salt/modules/boto_apigateway.py index fe061491fd7..e9fea549ac1 100644 --- a/salt/modules/boto_apigateway.py +++ b/salt/modules/boto_apigateway.py @@ -106,7 +106,11 @@ except ImportError: # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_asg.py b/salt/modules/boto_asg.py index 0926727c236..9e24d1b16c9 100644 --- a/salt/modules/boto_asg.py +++ b/salt/modules/boto_asg.py @@ -76,7 +76,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cfn.py b/salt/modules/boto_cfn.py index 5fe428b1386..366771c69ba 100644 --- a/salt/modules/boto_cfn.py +++ b/salt/modules/boto_cfn.py @@ -52,7 +52,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cloudfront.py b/salt/modules/boto_cloudfront.py index a1b36b34ab7..5cfb3987d93 100644 --- a/salt/modules/boto_cloudfront.py +++ b/salt/modules/boto_cloudfront.py @@ -68,7 +68,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cloudtrail.py b/salt/modules/boto_cloudtrail.py index 1332c59c58e..53bbdce42fd 100644 --- a/salt/modules/boto_cloudtrail.py +++ b/salt/modules/boto_cloudtrail.py @@ -72,7 +72,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cloudwatch.py b/salt/modules/boto_cloudwatch.py index 9676d18d2bb..63711f7c325 100644 --- a/salt/modules/boto_cloudwatch.py +++ b/salt/modules/boto_cloudwatch.py @@ -65,7 +65,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cloudwatch_event.py b/salt/modules/boto_cloudwatch_event.py index bf566ba4b32..67c52c42893 100644 --- a/salt/modules/boto_cloudwatch_event.py +++ b/salt/modules/boto_cloudwatch_event.py @@ -67,7 +67,11 @@ except ImportError as e: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_cognitoidentity.py b/salt/modules/boto_cognitoidentity.py index f79a6b0595e..cd407b9b619 100644 --- a/salt/modules/boto_cognitoidentity.py +++ b/salt/modules/boto_cognitoidentity.py @@ -100,7 +100,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_datapipeline.py b/salt/modules/boto_datapipeline.py index 42a3fa63a1e..9f32c4ae19b 100644 --- a/salt/modules/boto_datapipeline.py +++ b/salt/modules/boto_datapipeline.py @@ -23,7 +23,11 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_dynamodb.py b/salt/modules/boto_dynamodb.py index d62d27b2fa9..0d8427839a7 100644 --- a/salt/modules/boto_dynamodb.py +++ b/salt/modules/boto_dynamodb.py @@ -80,7 +80,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_ec2.py b/salt/modules/boto_ec2.py index 5b1f4c5011d..7d36cbc19b6 100644 --- a/salt/modules/boto_ec2.py +++ b/salt/modules/boto_ec2.py @@ -71,7 +71,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_efs.py b/salt/modules/boto_efs.py index ec99ab8624d..20ba6048213 100644 --- a/salt/modules/boto_efs.py +++ b/salt/modules/boto_efs.py @@ -63,7 +63,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_elasticache.py b/salt/modules/boto_elasticache.py index ce7b8bbe6e0..8a38be1b410 100644 --- a/salt/modules/boto_elasticache.py +++ b/salt/modules/boto_elasticache.py @@ -66,7 +66,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_elasticsearch_domain.py b/salt/modules/boto_elasticsearch_domain.py index 89be33075ee..1e66e4f2110 100644 --- a/salt/modules/boto_elasticsearch_domain.py +++ b/salt/modules/boto_elasticsearch_domain.py @@ -100,7 +100,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_elb.py b/salt/modules/boto_elb.py index 748cbc2be8e..643ea4da372 100644 --- a/salt/modules/boto_elb.py +++ b/salt/modules/boto_elb.py @@ -68,7 +68,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_elbv2.py b/salt/modules/boto_elbv2.py index 90a888b2233..ed5ab80764e 100644 --- a/salt/modules/boto_elbv2.py +++ b/salt/modules/boto_elbv2.py @@ -59,7 +59,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_iam.py b/salt/modules/boto_iam.py index 1b805b8804e..e16bbf36e42 100644 --- a/salt/modules/boto_iam.py +++ b/salt/modules/boto_iam.py @@ -62,7 +62,11 @@ except ImportError: log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_iot.py b/salt/modules/boto_iot.py index 69f26390ca6..d3995ca06ff 100644 --- a/salt/modules/boto_iot.py +++ b/salt/modules/boto_iot.py @@ -76,7 +76,11 @@ except ImportError: # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_kinesis.py b/salt/modules/boto_kinesis.py index 1afebe915da..c179529c9c5 100644 --- a/salt/modules/boto_kinesis.py +++ b/salt/modules/boto_kinesis.py @@ -66,7 +66,11 @@ log = logging.getLogger(__name__) __virtualname__ = "boto_kinesis" -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_kms.py b/salt/modules/boto_kms.py index 6d3eaffc777..37a654a5cd1 100644 --- a/salt/modules/boto_kms.py +++ b/salt/modules/boto_kms.py @@ -56,7 +56,11 @@ try: except (ImportError, AttributeError): HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_lambda.py b/salt/modules/boto_lambda.py index e6365979978..c8a7d2f4bcc 100644 --- a/salt/modules/boto_lambda.py +++ b/salt/modules/boto_lambda.py @@ -108,7 +108,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_rds.py b/salt/modules/boto_rds.py index 815a7c94911..01b7317497d 100644 --- a/salt/modules/boto_rds.py +++ b/salt/modules/boto_rds.py @@ -127,7 +127,11 @@ def __virtual__(): return salt.utils.versions.check_boto_reqs(boto3_ver="1.3.1") -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __init__(opts): diff --git a/salt/modules/boto_route53.py b/salt/modules/boto_route53.py index 9cc62b34419..4e5c4a762dd 100644 --- a/salt/modules/boto_route53.py +++ b/salt/modules/boto_route53.py @@ -68,7 +68,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_s3.py b/salt/modules/boto_s3.py index 016b9908180..adaef657d29 100644 --- a/salt/modules/boto_s3.py +++ b/salt/modules/boto_s3.py @@ -70,7 +70,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_s3_bucket.py b/salt/modules/boto_s3_bucket.py index 6e653728d1c..a30bd99d669 100644 --- a/salt/modules/boto_s3_bucket.py +++ b/salt/modules/boto_s3_bucket.py @@ -76,7 +76,11 @@ except ImportError: HAS_BOTO = False # pylint: enable=import-error -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_secgroup.py b/salt/modules/boto_secgroup.py index 95068692ebc..aa55fd1bb6b 100644 --- a/salt/modules/boto_secgroup.py +++ b/salt/modules/boto_secgroup.py @@ -64,7 +64,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_sns.py b/salt/modules/boto_sns.py index 05ac52ddb31..f283c62ebee 100644 --- a/salt/modules/boto_sns.py +++ b/salt/modules/boto_sns.py @@ -59,7 +59,11 @@ try: except ImportError: HAS_BOTO = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_sqs.py b/salt/modules/boto_sqs.py index bcbd9444b3c..98ccfb9c3ca 100644 --- a/salt/modules/boto_sqs.py +++ b/salt/modules/boto_sqs.py @@ -68,7 +68,11 @@ except ImportError: HAS_BOTO3 = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_ssm.py b/salt/modules/boto_ssm.py index 8722ef263cc..9a896b354e7 100644 --- a/salt/modules/boto_ssm.py +++ b/salt/modules/boto_ssm.py @@ -19,7 +19,11 @@ import salt.utils.versions log = logging.getLogger(__name__) -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__(): diff --git a/salt/modules/boto_vpc.py b/salt/modules/boto_vpc.py index b869538a443..381326d45d5 100644 --- a/salt/modules/boto_vpc.py +++ b/salt/modules/boto_vpc.py @@ -168,7 +168,11 @@ try: except ImportError: HAS_BOTO3 = False -__deprecated__ = (3009, "boto", "https://github.com/salt-extensions/saltext-boto") +__deprecated__ = ( + 3009, + "boto", + "https://github.com/salt-extensions/saltext-boto", +) def __virtual__():