mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #65810 from dmurphy18/fix_garethPR_64388
[master] Deprecations messages for boto modules moving to Salt extension, Gareth J Greenaway original author
This commit is contained in:
commit
2e3b133350
68 changed files with 1206 additions and 878 deletions
|
@ -66,6 +66,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO3 = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -107,7 +113,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)
|
||||
|
@ -115,9 +121,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("_")}
|
||||
|
@ -140,7 +144,7 @@ def _delete_resource(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Delete a generic Elasticache resource.
|
||||
|
@ -171,9 +175,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)
|
||||
|
@ -211,7 +213,7 @@ def _create_resource(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
try:
|
||||
wait = int(wait)
|
||||
|
@ -239,9 +241,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:
|
||||
|
@ -270,7 +270,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
|
||||
|
||||
|
@ -287,7 +287,7 @@ def _modify_resource(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
try:
|
||||
wait = int(wait)
|
||||
|
@ -315,9 +315,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:
|
||||
|
@ -346,7 +344,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
|
||||
|
||||
|
@ -374,7 +372,7 @@ def describe_cache_clusters(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -405,7 +403,7 @@ def create_cache_cluster(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Create a cache cluster.
|
||||
|
@ -442,7 +440,7 @@ def create_cache_cluster(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -454,7 +452,7 @@ def modify_cache_cluster(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Update a cache cluster in place.
|
||||
|
@ -496,7 +494,7 @@ def modify_cache_cluster(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -523,7 +521,7 @@ def delete_cache_cluster(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -578,7 +576,7 @@ def create_replication_group(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Create a replication group.
|
||||
|
@ -615,7 +613,7 @@ def create_replication_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -627,7 +625,7 @@ def modify_replication_group(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Modify a replication group.
|
||||
|
@ -661,7 +659,7 @@ def modify_replication_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -688,7 +686,7 @@ def delete_replication_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -783,13 +781,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(
|
||||
|
@ -801,7 +799,7 @@ def create_cache_subnet_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -836,14 +834,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(
|
||||
|
@ -855,7 +853,7 @@ def modify_cache_subnet_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -880,7 +878,7 @@ def delete_cache_subnet_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -948,7 +946,7 @@ def create_cache_security_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -973,7 +971,7 @@ def delete_cache_security_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1264,7 +1262,7 @@ def create_cache_parameter_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
||||
|
||||
|
@ -1289,5 +1287,5 @@ def delete_cache_parameter_group(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
|
|
|
@ -74,6 +74,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -70,6 +70,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO3 = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -60,6 +60,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=unused-import
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -106,6 +106,13 @@ except ImportError:
|
|||
# pylint: enable=import-error
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto libraries exist and if boto libraries are greater than
|
||||
|
@ -131,7 +138,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()
|
||||
]
|
||||
)
|
||||
|
@ -378,9 +385,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,
|
||||
|
@ -431,7 +438,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)}
|
||||
|
||||
|
@ -895,12 +902,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:
|
||||
|
@ -1622,7 +1629,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(
|
||||
|
@ -1799,7 +1806,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}"
|
||||
)
|
||||
|
||||
|
||||
|
@ -1809,9 +1816,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(
|
||||
|
|
|
@ -76,6 +76,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -119,7 +125,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:
|
||||
|
@ -429,12 +435,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,
|
||||
|
@ -508,7 +514,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)
|
||||
|
||||
|
@ -569,7 +575,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:
|
||||
|
@ -579,7 +585,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
|
||||
|
||||
|
@ -821,7 +827,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
|
||||
|
||||
|
@ -850,7 +856,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
|
||||
|
||||
|
|
|
@ -52,6 +52,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -184,7 +190,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
|
||||
|
@ -244,7 +250,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)
|
||||
|
@ -265,7 +271,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)
|
||||
|
@ -289,7 +295,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)
|
||||
|
||||
|
@ -320,6 +326,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)
|
||||
|
|
|
@ -68,6 +68,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -255,7 +261,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:
|
||||
|
|
|
@ -72,6 +72,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -424,7 +430,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):
|
||||
|
|
|
@ -65,6 +65,13 @@ except ImportError:
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto libraries exist.
|
||||
|
|
|
@ -67,6 +67,12 @@ except ImportError as e:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -214,7 +220,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)}
|
||||
|
||||
|
||||
|
@ -270,7 +276,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)}
|
||||
|
||||
|
||||
|
@ -299,7 +305,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)}
|
||||
|
||||
|
||||
|
@ -328,5 +334,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)}
|
||||
|
|
|
@ -100,6 +100,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -365,7 +371,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
|
||||
|
||||
|
|
|
@ -23,6 +23,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO3 = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -182,7 +188,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
|
||||
|
||||
|
||||
|
|
|
@ -80,6 +80,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -71,6 +71,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -685,7 +691,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)
|
||||
|
@ -811,7 +817,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",
|
||||
|
@ -1518,9 +1524,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(
|
||||
|
@ -1611,9 +1615,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(
|
||||
|
@ -1824,7 +1826,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"](
|
||||
|
@ -2233,7 +2235,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:
|
||||
|
|
|
@ -63,6 +63,13 @@ except ImportError:
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto3 libraries exist and if boto3 libraries are greater than
|
||||
|
|
|
@ -66,6 +66,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -156,7 +162,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 {}
|
||||
|
@ -178,12 +184,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
|
||||
|
||||
|
@ -207,7 +213,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 {}
|
||||
|
@ -277,7 +283,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 {}
|
||||
|
@ -356,7 +362,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 {}
|
||||
|
@ -383,7 +389,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 {}
|
||||
|
@ -464,7 +470,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
|
||||
|
@ -515,14 +521,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
|
||||
|
||||
|
@ -544,12 +550,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 = {}
|
||||
|
@ -589,12 +595,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
|
||||
|
||||
|
@ -665,7 +671,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
|
||||
|
@ -698,7 +704,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
|
||||
|
@ -723,7 +729,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
|
||||
|
||||
|
@ -745,7 +751,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
|
||||
|
||||
|
|
|
@ -100,6 +100,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -273,7 +279,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:
|
||||
|
@ -364,7 +370,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:
|
||||
|
|
|
@ -68,6 +68,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -1101,9 +1107,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
|
||||
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -62,6 +62,12 @@ except ImportError:
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -1733,7 +1739,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):
|
||||
|
|
|
@ -76,6 +76,13 @@ except ImportError:
|
|||
# pylint: enable=import-error
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto libraries exist and if boto libraries are greater than
|
||||
|
@ -148,7 +155,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}
|
||||
|
@ -915,7 +922,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):
|
||||
|
|
|
@ -66,6 +66,12 @@ log = logging.getLogger(__name__)
|
|||
|
||||
__virtualname__ = "boto_kinesis"
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -491,7 +497,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(
|
||||
|
|
|
@ -56,6 +56,12 @@ try:
|
|||
except (ImportError, AttributeError):
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -108,6 +108,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -176,7 +182,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):
|
||||
|
@ -272,7 +278,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 = {
|
||||
|
@ -313,7 +319,7 @@ def create_function(
|
|||
Timeout=Timeout,
|
||||
MemorySize=MemorySize,
|
||||
Publish=Publish,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
except ClientError as e:
|
||||
if (
|
||||
|
@ -645,7 +651,7 @@ def add_permission(
|
|||
StatementId=StatementId,
|
||||
Action=Action,
|
||||
Principal=str(Principal),
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
return {"updated": True}
|
||||
except ClientError as e:
|
||||
|
|
|
@ -127,6 +127,13 @@ def __virtual__():
|
|||
return salt.utils.versions.check_boto_reqs(boto3_ver="1.3.1")
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __init__(opts):
|
||||
if HAS_BOTO:
|
||||
__utils__["boto3.assign_funcs"](__name__, "rds")
|
||||
|
@ -294,9 +301,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,
|
||||
|
@ -336,7 +341,7 @@ def create(
|
|||
if not wait_status:
|
||||
return {
|
||||
"created": True,
|
||||
"message": "RDS instance {} created.".format(name),
|
||||
"message": f"RDS instance {name} created.",
|
||||
}
|
||||
|
||||
while True:
|
||||
|
@ -408,14 +413,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:
|
||||
|
@ -444,7 +449,7 @@ def create_read_replica(
|
|||
Tags=taglist,
|
||||
DBSubnetGroupName=db_subnet_group_name,
|
||||
StorageType=storage_type,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return {"exists": bool(rds_replica)}
|
||||
|
@ -535,12 +540,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)}
|
||||
|
@ -617,7 +622,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 = []
|
||||
|
@ -662,7 +667,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:
|
||||
|
@ -867,7 +872,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()
|
||||
|
@ -883,7 +888,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:
|
||||
|
@ -922,12 +927,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)}
|
||||
|
@ -952,7 +957,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)}
|
||||
|
@ -977,7 +982,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)}
|
||||
|
@ -1024,12 +1029,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)}
|
||||
|
@ -1058,7 +1063,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:
|
||||
|
@ -1166,7 +1171,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:
|
||||
|
@ -1189,12 +1194,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:
|
||||
|
|
|
@ -68,6 +68,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -589,7 +595,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()
|
||||
|
@ -698,7 +704,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()
|
||||
|
@ -797,7 +803,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()
|
||||
|
@ -886,7 +892,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()
|
||||
|
|
|
@ -70,6 +70,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -76,6 +76,12 @@ except ImportError:
|
|||
HAS_BOTO = False
|
||||
# pylint: enable=import-error
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -773,7 +779,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(
|
||||
|
|
|
@ -64,6 +64,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -509,7 +515,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
|
||||
|
||||
|
@ -552,7 +558,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:
|
||||
|
@ -776,7 +782,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(
|
||||
|
|
|
@ -59,6 +59,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -235,7 +241,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):
|
||||
|
@ -252,7 +258,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():
|
||||
|
|
|
@ -68,6 +68,13 @@ except ImportError:
|
|||
HAS_BOTO3 = False
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto3 libraries exist.
|
||||
|
|
|
@ -19,6 +19,12 @@ import salt.utils.versions
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -168,6 +168,12 @@ try:
|
|||
except ImportError:
|
||||
HAS_BOTO3 = False
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -242,7 +248,7 @@ def _create_resource(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Create a VPC resource. Returns the resource id if created, or False
|
||||
|
@ -265,9 +271,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)
|
||||
|
@ -293,9 +297,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:
|
||||
|
@ -310,7 +314,7 @@ def _delete_resource(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
"""
|
||||
Delete a VPC resource. Returns True if successful, otherwise False.
|
||||
|
@ -337,9 +341,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):
|
||||
|
@ -356,9 +358,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)}
|
||||
|
@ -383,7 +385,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)
|
||||
|
@ -392,7 +394,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)
|
||||
|
@ -416,7 +418,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
|
||||
|
@ -446,7 +448,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)
|
||||
|
@ -455,10 +457,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)
|
||||
|
@ -601,7 +603,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(
|
||||
|
@ -868,7 +870,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):
|
||||
|
@ -1013,7 +1015,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)
|
||||
|
||||
|
@ -1055,7 +1057,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(
|
||||
|
@ -1108,9 +1110,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)}
|
||||
|
@ -1222,7 +1222,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
|
||||
|
||||
|
@ -1462,9 +1462,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(
|
||||
|
@ -1622,7 +1620,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:
|
||||
|
@ -1769,9 +1767,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(
|
||||
|
@ -1784,7 +1780,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)
|
||||
|
@ -2035,9 +2031,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(
|
||||
|
@ -2177,9 +2171,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)
|
||||
|
@ -2284,7 +2276,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)):
|
||||
|
@ -2298,7 +2290,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(
|
||||
|
@ -2311,7 +2303,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(
|
||||
|
@ -2468,9 +2460,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(
|
||||
|
@ -2479,7 +2469,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)
|
||||
|
@ -2547,9 +2537,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:
|
||||
|
@ -2592,7 +2580,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(
|
||||
|
@ -2742,7 +2730,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(
|
||||
|
@ -2805,7 +2793,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(
|
||||
|
@ -2941,7 +2929,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)
|
||||
|
||||
|
@ -3013,7 +3001,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)):
|
||||
|
@ -3032,9 +3020,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:
|
||||
|
@ -3484,7 +3470,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(
|
||||
|
@ -3598,7 +3584,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)
|
||||
|
||||
|
@ -3755,9 +3741,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,
|
||||
|
@ -3778,7 +3762,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:
|
||||
|
@ -3787,7 +3771,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:
|
||||
|
@ -3989,7 +3973,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")
|
||||
|
|
|
@ -87,6 +87,12 @@ passed in as a dict, or as a string to pull from pillars or minion config:
|
|||
key: askdjghsdfjkghWupUjasdflkdfklgjsdfjajkghs
|
||||
"""
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -173,7 +179,7 @@ def cache_cluster_present(
|
|||
key=None,
|
||||
keyid=None,
|
||||
profile=None,
|
||||
**args
|
||||
**args,
|
||||
):
|
||||
"""
|
||||
Ensure a given cache cluster exists.
|
||||
|
@ -444,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"](
|
||||
|
@ -455,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...
|
||||
|
@ -476,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"](
|
||||
|
@ -487,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"](
|
||||
|
@ -496,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
|
||||
|
||||
|
||||
|
@ -552,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"](
|
||||
|
@ -562,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
|
||||
|
||||
|
||||
|
@ -637,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.
|
||||
|
@ -896,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"](
|
||||
|
@ -907,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...
|
||||
|
@ -928,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"](
|
||||
|
@ -939,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"](
|
||||
|
@ -948,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
|
||||
|
@ -1010,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"](
|
||||
|
@ -1020,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
|
||||
|
||||
|
||||
|
@ -1113,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"](
|
||||
|
@ -1123,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"](
|
||||
|
@ -1150,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
|
||||
|
@ -1202,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"](
|
||||
|
@ -1213,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
|
||||
|
|
|
@ -50,6 +50,12 @@ import salt.utils.json
|
|||
from salt.utils.versions import Version
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
__virtualname__ = "boto3_elasticsearch"
|
||||
|
||||
|
||||
|
@ -73,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__
|
||||
|
||||
|
@ -378,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":
|
||||
|
@ -455,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:
|
||||
|
@ -477,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
|
||||
|
||||
|
@ -529,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:
|
||||
|
@ -727,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(
|
||||
|
@ -819,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
|
||||
|
||||
|
@ -827,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:
|
||||
|
|
|
@ -73,6 +73,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__) # pylint: disable=W1699
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -241,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:
|
||||
|
@ -745,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)]
|
||||
|
||||
|
|
|
@ -70,6 +70,12 @@ import salt.utils.json
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -135,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:
|
||||
|
@ -152,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
|
||||
|
@ -246,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:
|
||||
|
@ -318,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"])
|
||||
|
@ -360,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
|
||||
|
||||
|
|
|
@ -62,6 +62,12 @@ import salt.utils.yaml
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -350,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
|
||||
|
||||
|
@ -435,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"]:
|
||||
|
@ -446,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
|
||||
|
||||
|
@ -460,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
|
||||
|
||||
|
@ -725,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(
|
||||
|
@ -754,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:
|
||||
|
@ -819,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()
|
||||
|
||||
|
@ -877,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(
|
||||
|
@ -928,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")
|
||||
|
@ -1027,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()
|
||||
|
||||
|
@ -1100,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
|
||||
|
@ -1116,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")
|
||||
|
@ -1156,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"):
|
||||
|
@ -1174,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"](
|
||||
|
@ -1183,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")}
|
||||
|
@ -1193,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")}
|
||||
|
@ -1202,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):
|
||||
|
@ -1213,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:
|
||||
|
@ -1236,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
|
||||
|
@ -1250,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
|
||||
|
@ -1266,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
|
||||
|
||||
|
@ -1327,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
|
||||
|
@ -1354,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
|
||||
|
@ -1367,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
|
||||
|
@ -1381,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
|
||||
|
@ -1390,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"):
|
||||
|
@ -1417,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"]:
|
||||
|
@ -1431,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
|
||||
|
@ -1553,7 +1557,7 @@ class _Swagger:
|
|||
_schema.update(
|
||||
{
|
||||
"$schema": _Swagger.JSON_SCHEMA_DRAFT_4,
|
||||
"title": "{} Schema".format(model),
|
||||
"title": f"{model} Schema",
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1570,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
|
||||
|
@ -1594,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"):
|
||||
|
@ -1745,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] = (
|
||||
|
@ -1822,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)
|
||||
|
@ -1848,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)
|
||||
|
@ -1871,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)
|
||||
|
@ -1886,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)
|
||||
|
@ -1896,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
|
||||
|
@ -2043,7 +2047,7 @@ def usage_plan_present(
|
|||
description=description,
|
||||
throttle=throttle,
|
||||
quota=quota,
|
||||
**common_args
|
||||
**common_args,
|
||||
)
|
||||
if "error" in result:
|
||||
ret["result"] = False
|
||||
|
@ -2053,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
|
||||
|
@ -2098,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
|
||||
|
@ -2112,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
|
||||
|
||||
|
@ -2153,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"]:
|
||||
|
@ -2173,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
|
||||
|
||||
|
@ -2235,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
|
||||
|
||||
|
@ -2278,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
|
||||
|
||||
|
@ -2336,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
|
||||
|
||||
|
@ -2385,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
|
||||
|
|
|
@ -202,6 +202,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -450,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"])
|
||||
|
@ -830,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
|
||||
|
|
|
@ -46,6 +46,12 @@ log = logging.getLogger(__name__)
|
|||
|
||||
__virtualname__ = "boto_cfn"
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -56,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",
|
||||
)
|
||||
|
||||
|
||||
|
@ -177,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"](
|
||||
|
@ -213,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"](
|
||||
|
@ -239,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
|
||||
|
@ -263,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)
|
||||
|
@ -280,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
|
||||
|
||||
|
@ -293,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
|
||||
|
|
|
@ -49,6 +49,12 @@ import logging
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -132,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
|
||||
|
||||
|
@ -154,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:
|
||||
|
@ -199,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
|
||||
|
@ -222,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
|
||||
|
|
|
@ -61,6 +61,13 @@ import salt.utils.data
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto is available.
|
||||
|
@ -165,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"](
|
||||
|
@ -193,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"](
|
||||
|
@ -224,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"](
|
||||
|
@ -278,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
|
||||
|
@ -345,7 +350,7 @@ def present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**adds
|
||||
**adds,
|
||||
)
|
||||
if bool(removes):
|
||||
r = __salt__["boto_cloudtrail.remove_tags"](
|
||||
|
@ -354,7 +359,7 @@ def present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**removes
|
||||
**removes,
|
||||
)
|
||||
|
||||
return ret
|
||||
|
@ -395,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"](
|
||||
|
@ -411,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
|
||||
|
|
|
@ -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,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -106,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])
|
||||
|
@ -120,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 = {
|
||||
|
@ -134,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
|
||||
|
@ -148,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
|
||||
|
@ -162,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
|
||||
|
||||
|
||||
|
@ -194,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"](
|
||||
|
@ -205,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
|
||||
|
|
|
@ -59,6 +59,12 @@ import salt.utils.json
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -183,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"](
|
||||
|
@ -205,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
|
||||
|
@ -250,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
|
||||
|
@ -361,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
|
||||
|
||||
|
@ -406,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
|
||||
|
|
|
@ -50,6 +50,12 @@ import logging
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -109,7 +115,7 @@ def _role_present(
|
|||
IdentityPoolId=IdentityPoolId,
|
||||
AuthenticatedRole=AuthenticatedRole,
|
||||
UnauthenticatedRole=UnauthenticatedRole,
|
||||
**conn_params
|
||||
**conn_params,
|
||||
)
|
||||
if not r.get("set"):
|
||||
ret["result"] = False
|
||||
|
@ -299,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:
|
||||
|
@ -413,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 = (
|
||||
|
|
|
@ -56,6 +56,12 @@ import difflib
|
|||
import salt.utils.data
|
||||
import salt.utils.json
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -133,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
|
||||
|
||||
|
@ -260,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
|
||||
|
||||
|
@ -596,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:
|
||||
|
@ -610,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
|
||||
|
|
|
@ -162,6 +162,11 @@ import sys
|
|||
|
||||
import salt.utils.dictupdate as dictupdate
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s %(name)s %(levelname)s %(message)s",
|
||||
|
@ -284,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"](
|
||||
|
@ -304,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
|
||||
|
@ -319,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)
|
||||
|
@ -335,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,
|
||||
|
@ -350,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", [])
|
||||
|
||||
|
@ -478,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
|
||||
|
||||
|
@ -591,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(
|
||||
|
@ -641,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
|
||||
|
@ -651,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):
|
||||
|
@ -779,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,
|
||||
|
@ -794,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)
|
||||
|
@ -860,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
|
||||
|
|
|
@ -60,6 +60,12 @@ from salt.exceptions import CommandExecutionError, SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -90,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:
|
||||
|
@ -104,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
|
||||
|
||||
|
||||
|
@ -138,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
|
||||
|
||||
|
||||
|
@ -284,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(
|
||||
|
@ -422,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"](
|
||||
|
@ -439,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
|
||||
|
||||
|
@ -561,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"](
|
||||
|
@ -590,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
|
||||
|
@ -602,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
|
||||
|
@ -888,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:
|
||||
|
@ -1015,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"](
|
||||
|
@ -1248,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]
|
||||
|
||||
|
@ -1269,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
|
||||
|
||||
|
@ -1283,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}
|
||||
|
@ -1309,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
|
||||
|
@ -1330,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
|
||||
|
@ -1450,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
|
||||
|
||||
|
@ -1665,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
|
||||
|
@ -1700,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=[
|
||||
|
@ -1715,7 +1717,7 @@ def volume_present(
|
|||
"tags": {"Name": volume_name},
|
||||
}
|
||||
],
|
||||
**args
|
||||
**args,
|
||||
)
|
||||
if _rt["success"] is False:
|
||||
raise SaltInvocationError(
|
||||
|
@ -1731,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(
|
||||
|
|
|
@ -80,6 +80,12 @@ import logging
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -227,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
|
||||
|
@ -261,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
|
||||
|
||||
|
||||
|
@ -320,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"](
|
||||
|
@ -336,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
|
||||
|
@ -380,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"](
|
||||
|
@ -391,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
|
||||
|
||||
|
||||
|
@ -445,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,
|
||||
|
@ -466,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
|
||||
|
||||
|
@ -483,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"]:
|
||||
|
@ -497,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
|
||||
|
||||
|
||||
|
@ -515,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"](
|
||||
|
@ -537,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
|
||||
|
|
|
@ -85,6 +85,12 @@ import salt.utils.json
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -222,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
|
||||
|
@ -235,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"](
|
||||
|
@ -262,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
|
||||
|
@ -311,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
|
||||
|
@ -324,7 +330,7 @@ def present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**comm_args
|
||||
**comm_args,
|
||||
)
|
||||
if not r.get("updated"):
|
||||
ret["result"] = False
|
||||
|
@ -369,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
|
||||
|
||||
|
@ -386,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
|
||||
|
|
|
@ -246,6 +246,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -549,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"](
|
||||
|
@ -592,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
|
||||
|
@ -611,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
|
||||
|
||||
|
@ -619,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(
|
||||
|
@ -629,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
|
||||
|
@ -706,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"])
|
||||
|
@ -718,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"](
|
||||
|
@ -740,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"](
|
||||
|
@ -758,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
|
||||
)
|
||||
|
@ -805,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:
|
||||
|
@ -833,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(
|
||||
|
@ -848,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
|
||||
|
||||
|
@ -858,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:
|
||||
|
@ -881,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
|
||||
|
||||
|
@ -890,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:
|
||||
|
@ -900,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
|
||||
|
||||
|
||||
|
@ -923,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:
|
||||
|
@ -955,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"](
|
||||
|
@ -964,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
|
||||
|
||||
|
||||
|
@ -982,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():
|
||||
|
@ -990,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"](
|
||||
|
@ -1002,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
|
||||
|
||||
|
||||
|
@ -1016,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 = []
|
||||
|
@ -1029,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:
|
||||
|
@ -1037,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"](
|
||||
|
@ -1058,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
|
||||
|
||||
|
||||
|
@ -1069,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 = []
|
||||
|
@ -1082,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:
|
||||
|
@ -1090,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"](
|
||||
|
@ -1100,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
|
||||
|
@ -1114,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
|
||||
|
||||
|
||||
|
@ -1210,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
|
||||
|
||||
|
@ -1296,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
|
||||
|
||||
|
@ -1325,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:
|
||||
|
@ -1343,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, [])),
|
||||
|
@ -1368,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, [])),
|
||||
|
@ -1394,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:
|
||||
|
@ -1413,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):
|
||||
|
@ -1428,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
|
||||
|
||||
|
||||
|
@ -1478,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"]:
|
||||
|
|
|
@ -38,6 +38,12 @@ import logging
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -64,7 +70,7 @@ def create_target_group(
|
|||
health_check_timeout_seconds=5,
|
||||
healthy_threshold_count=5,
|
||||
unhealthy_threshold_count=2,
|
||||
**kwargs
|
||||
**kwargs,
|
||||
):
|
||||
|
||||
"""
|
||||
|
@ -122,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"](
|
||||
|
@ -145,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
|
||||
|
||||
|
||||
|
@ -185,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"](
|
||||
|
@ -199,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
|
||||
|
||||
|
||||
|
@ -277,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
|
||||
|
||||
|
||||
|
@ -327,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"]:
|
||||
|
@ -348,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
|
||||
|
|
|
@ -146,6 +146,13 @@ log = logging.getLogger(__name__)
|
|||
__virtualname__ = "boto_iam"
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if elementtree xml library and boto are available.
|
||||
|
@ -155,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",
|
||||
)
|
||||
|
||||
|
||||
|
@ -207,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:
|
||||
|
@ -297,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
|
||||
|
@ -306,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
|
||||
|
@ -318,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
|
||||
|
@ -340,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
|
||||
|
@ -354,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
|
||||
|
||||
|
@ -418,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"](
|
||||
|
@ -434,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"][
|
||||
|
@ -442,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 = {}
|
||||
|
@ -456,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)
|
||||
|
@ -470,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"]
|
||||
|
@ -479,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
|
||||
|
||||
|
@ -525,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)
|
||||
|
@ -542,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"][
|
||||
|
@ -564,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
|
||||
|
||||
|
||||
|
@ -649,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"](
|
||||
|
@ -658,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)
|
||||
|
@ -666,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)
|
||||
|
@ -845,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(
|
||||
|
@ -865,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
|
||||
|
@ -884,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(
|
||||
|
@ -921,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"](
|
||||
|
@ -931,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:
|
||||
|
@ -976,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
|
||||
|
@ -997,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
|
||||
|
@ -1009,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
|
||||
|
@ -1023,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
|
||||
|
||||
|
@ -1119,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"](
|
||||
|
@ -1131,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
|
||||
|
@ -1178,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
|
||||
|
@ -1196,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
|
||||
|
@ -1229,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
|
||||
|
||||
|
||||
|
@ -1410,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(
|
||||
|
@ -1451,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(
|
||||
|
@ -1568,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()
|
||||
|
@ -1627,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
|
||||
|
||||
|
@ -1693,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:
|
||||
|
@ -1708,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:
|
||||
|
@ -1716,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
|
||||
|
||||
|
||||
|
@ -1780,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"](
|
||||
|
@ -1789,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
|
||||
|
@ -1798,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", {})
|
||||
|
@ -1816,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
|
||||
|
||||
|
@ -1883,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
|
||||
|
@ -1908,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
|
||||
|
||||
|
||||
|
@ -1959,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"](
|
||||
|
@ -1981,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
|
||||
|
||||
|
||||
|
@ -2019,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
|
||||
|
||||
|
||||
|
|
|
@ -94,6 +94,12 @@ from salt.utils.odict import OrderedDict
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -255,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"](
|
||||
|
@ -264,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
|
||||
|
@ -309,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"](
|
||||
|
@ -318,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
|
||||
|
||||
|
||||
|
@ -332,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"](
|
||||
|
@ -341,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[
|
||||
|
@ -591,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
|
||||
|
||||
|
||||
|
@ -615,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"](
|
||||
|
@ -624,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
|
||||
|
||||
|
||||
|
@ -637,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(
|
||||
|
@ -673,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(
|
||||
|
@ -693,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
|
||||
|
@ -726,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[
|
||||
|
|
|
@ -80,6 +80,12 @@ import salt.utils.json
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -157,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
|
||||
|
||||
|
@ -187,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
|
||||
|
||||
|
||||
|
@ -237,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"]
|
||||
|
@ -319,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
|
||||
|
||||
|
||||
|
@ -366,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"](
|
||||
|
@ -388,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
|
||||
|
@ -411,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
|
||||
|
@ -487,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
|
||||
|
@ -532,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
|
||||
|
||||
|
||||
|
@ -603,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"] = {}
|
||||
|
||||
|
@ -682,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"] = {}
|
||||
|
||||
|
@ -752,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"](
|
||||
|
@ -775,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"](
|
||||
|
@ -805,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
|
||||
|
@ -864,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"](
|
||||
|
@ -880,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
|
||||
|
|
|
@ -64,6 +64,12 @@ log = logging.getLogger(__name__)
|
|||
|
||||
__virtualname__ = "boto_kinesis"
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -140,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:
|
||||
|
@ -155,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
|
||||
|
@ -238,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:
|
||||
|
@ -345,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__[
|
||||
|
@ -439,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
|
||||
|
||||
|
@ -456,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
|
||||
|
||||
|
|
|
@ -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__():
|
||||
"""
|
||||
|
@ -174,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
|
||||
|
@ -212,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:
|
||||
|
@ -271,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
|
||||
|
||||
|
||||
|
@ -339,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
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -249,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"](
|
||||
|
@ -289,7 +295,7 @@ def function_present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**permission
|
||||
**permission,
|
||||
)
|
||||
if not r.get("updated"):
|
||||
ret["result"] = False
|
||||
|
@ -305,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
|
||||
|
@ -373,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):
|
||||
|
@ -461,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"](
|
||||
|
@ -502,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)
|
||||
|
@ -522,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"] = {
|
||||
|
@ -580,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():
|
||||
|
@ -609,7 +615,7 @@ def _function_permissions_present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**diff["new"]
|
||||
**diff["new"],
|
||||
)
|
||||
ret["changes"].setdefault("new", {}).setdefault("Permissions", {})[
|
||||
sid
|
||||
|
@ -665,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"](
|
||||
|
@ -681,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
|
||||
|
||||
|
||||
|
@ -746,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"](
|
||||
|
@ -768,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
|
||||
|
@ -792,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"](
|
||||
|
@ -854,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"](
|
||||
|
@ -870,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
|
||||
|
||||
|
||||
|
@ -885,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(
|
||||
|
|
|
@ -100,6 +100,12 @@ and autoscale groups are completely dependent on each other.
|
|||
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
|
|
@ -77,6 +77,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -306,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
|
||||
|
||||
|
@ -374,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
|
||||
|
||||
|
||||
|
@ -413,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"](
|
||||
|
@ -433,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"](
|
||||
|
@ -447,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"](
|
||||
|
@ -472,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
|
||||
|
||||
|
||||
|
@ -547,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"])
|
||||
|
@ -557,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"](
|
||||
|
@ -573,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
|
||||
|
||||
|
@ -642,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"](
|
||||
|
@ -663,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
|
||||
|
||||
|
||||
|
@ -681,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"](
|
||||
|
@ -693,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
|
||||
|
||||
|
||||
|
@ -762,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"](
|
||||
|
@ -777,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 = {}
|
||||
|
@ -799,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():
|
||||
|
@ -853,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
|
||||
|
|
|
@ -80,6 +80,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -211,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"](
|
||||
|
@ -244,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
|
||||
|
@ -268,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"](
|
||||
|
@ -295,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
|
||||
|
||||
|
||||
|
@ -376,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"](
|
||||
|
@ -396,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
|
||||
|
||||
|
||||
|
@ -575,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
|
||||
|
@ -609,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
|
||||
|
@ -622,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
|
||||
|
|
|
@ -57,6 +57,12 @@ import salt.utils.hashutils
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -177,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
|
||||
|
@ -253,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:
|
||||
|
@ -277,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
|
||||
|
||||
|
@ -301,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
|
||||
|
|
|
@ -145,6 +145,12 @@ import salt.utils.json
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -299,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):
|
||||
|
@ -440,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"](
|
||||
|
@ -481,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
|
||||
|
@ -501,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
|
||||
|
@ -647,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,
|
||||
|
@ -662,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
|
||||
|
@ -678,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
|
||||
|
@ -693,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
|
||||
|
@ -737,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"](
|
||||
|
@ -753,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
|
||||
|
|
|
@ -111,6 +111,12 @@ from salt.exceptions import SaltInvocationError
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -283,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"](
|
||||
|
@ -309,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
|
||||
|
||||
|
||||
|
@ -422,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(
|
||||
|
@ -509,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)
|
||||
|
@ -568,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
|
||||
|
@ -590,7 +594,7 @@ def _rules_present(
|
|||
key=key,
|
||||
keyid=keyid,
|
||||
profile=profile,
|
||||
**rule
|
||||
**rule,
|
||||
)
|
||||
if not _created:
|
||||
created = False
|
||||
|
@ -598,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
|
||||
|
@ -654,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)
|
||||
|
@ -714,7 +716,7 @@ def _rules_egress_present(
|
|||
keyid=keyid,
|
||||
profile=profile,
|
||||
egress=True,
|
||||
**rule
|
||||
**rule,
|
||||
)
|
||||
if not _deleted:
|
||||
deleted = False
|
||||
|
@ -722,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:
|
||||
|
@ -747,7 +749,7 @@ def _rules_egress_present(
|
|||
keyid=keyid,
|
||||
profile=profile,
|
||||
egress=True,
|
||||
**rule
|
||||
**rule,
|
||||
)
|
||||
if not _created:
|
||||
created = False
|
||||
|
@ -755,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:
|
||||
|
@ -831,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"](
|
||||
|
@ -847,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
|
||||
|
||||
|
||||
|
@ -884,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
|
||||
|
|
|
@ -57,6 +57,12 @@ 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",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
|
@ -106,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
|
||||
|
@ -118,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
|
||||
|
||||
|
@ -264,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}
|
||||
|
@ -276,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
|
||||
|
|
|
@ -65,6 +65,13 @@ import salt.utils.json
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
__deprecated__ = (
|
||||
3009,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
"""
|
||||
Only load if boto is available.
|
||||
|
@ -124,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
|
||||
|
@ -149,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
|
||||
|
@ -238,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
|
||||
|
@ -293,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
|
||||
|
||||
|
@ -309,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
|
||||
|
|
|
@ -144,11 +144,18 @@ 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,
|
||||
"boto",
|
||||
"https://github.com/salt-extensions/saltext-boto",
|
||||
)
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
@ -228,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"](
|
||||
|
@ -252,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
|
||||
|
@ -294,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"](
|
||||
|
@ -310,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
|
||||
|
||||
|
||||
|
@ -429,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
|
||||
|
||||
|
@ -457,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
|
||||
|
||||
|
||||
|
@ -509,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
|
||||
|
||||
|
@ -529,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
|
||||
|
||||
|
||||
|
@ -669,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"](
|
||||
|
@ -694,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."
|
||||
|
||||
|
@ -705,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
|
||||
|
@ -743,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"](
|
||||
|
@ -761,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
|
||||
|
@ -823,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"]:
|
||||
|
@ -841,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
|
||||
|
||||
|
||||
|
@ -904,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"](
|
||||
|
@ -926,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
|
||||
|
||||
|
||||
|
@ -977,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"](
|
||||
|
@ -1000,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
|
||||
|
||||
|
||||
|
@ -1162,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
|
||||
|
@ -1186,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
|
||||
|
||||
|
||||
|
@ -1247,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
|
||||
|
@ -1271,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
|
||||
|
@ -1325,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
|
||||
|
@ -1359,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(
|
||||
|
@ -1414,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
|
||||
|
@ -1538,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
|
||||
|
||||
|
@ -1557,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
|
||||
|
||||
|
||||
|
@ -1652,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
|
||||
|
||||
|
||||
|
@ -1742,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
|
||||
|
|
Loading…
Add table
Reference in a new issue