Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
Signed-off-by: Alina Buzachis <[email protected]>
  • Loading branch information
alinabuzachis authored and tremble committed Sep 7, 2023
1 parent 5486480 commit d616413
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/module_utils/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def helper_describe_import_image_tasks(client, module, **params):
module.fail_json_aws(e, msg="Failed to describe the import image")


def ensure_result(module, import_image_info):
def ensure_ec2_import_image_result(module, import_image_info):
result = {"import_image": {}}

import_image_info["Tags"] = boto3_tag_list_to_ansible_dict(import_image_info["Tags"])
Expand Down
22 changes: 13 additions & 9 deletions plugins/modules/ec2_import_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,15 @@ def absent():

filters = {
"Filters": [
{"Name": "name", "Values": [module.params["task_name"]]}
{"Name": "task-state", "Values": ["active"]}
{"Name": "name", "Values": [module.params["task_name"]]},
{"Name": "task-state", "Values": ["active"]},
]
}

result = {"import_image": {}}
params = {}

if module.params.get("cancel_reason")
if module.params.get("cancel_reason"):
params["CancelReason"] = module.params["cancel_reason"]

import_image_info = helper_describe_import_image_tasks(client, module, **filters)
Expand All @@ -289,7 +289,7 @@ def absent():
try:
import_image_info = client.cancel_import_task(aws_retry=True, **params)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg"Failed to import the image")
module.fail_json_aws(e, msg="Failed to import the image")
else:
module.exit_json(changed=False, msg="The specified import task does not exist or it cannot be cancelled")

Expand Down Expand Up @@ -334,15 +334,19 @@ def present():

filters = {
"Filters": [
{"Name": "name", "Values": [module.params["task_name"]]}
{"Name": "task-state", "Values": ["completed", "active", "deleting"]}
{"Name": "name", "Values": [module.params["task_name"]]},
{"Name": "task-state", "Values": ["completed", "active", "deleting"]},
]
}
import_image_info = helper_describe_import_image_tasks(client, module, **filters)

if import_image_info:
# Import tasks cannot be modified
module.exit_json(changed=False, msg="An import task with the specified name already exists", **ensure_ec2_import_image_result(module, result))
module.exit_json(
changed=False,
msg="An import task with the specified name already exists",
**ensure_ec2_import_image_result(module, result),
)
else:
if module.check_mode:
module.exit_json(changed=True, msg="Would have created the import task if not in check mode")
Expand All @@ -351,9 +355,9 @@ def present():
client.import_image(aws_retry=True, **params)
import_image_info = helper_describe_import_image_tasks(client, module, **filters)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg"Failed to import the image")
module.fail_json_aws(e, msg="Failed to import the image")

module.exit_json(changed=True, **ensure_ec2_import_image_result(module, result))
module.exit_json(changed=True, **ensure_ec2_import_image_result(module, import_image_info))


def main():
Expand Down
5 changes: 3 additions & 2 deletions plugins/modules/ec2_import_image_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
pass # Handled by AnsibleAWSModule

from ansible_collections.amazon.aws.plugins.module_utils.modules import AnsibleAWSModule
from ansible_collections.amazon.aws.plugins.module_utils.retries import AWSRetry
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import helper_describe_import_image_tasks
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import ensure_ec2_import_image_result

Expand All @@ -184,13 +185,13 @@ def main():
client = module.client("ec2", retry_decorator=AWSRetry.jittered_backoff())

params = {
"Filters": smodule.params["filters"],
"Filters": module.params["filters"],
"ImportTaskIds": module.params["import_task_ids"],
}

import_image_info = helper_describe_import_image_tasks(client, module, **params)

module.exit_json(import_image=**ensure_ec2_import_image_result(result))
module.exit_json(import_image=ensure_ec2_import_image_result(import_image_info))


if __name__ == "__main__":
Expand Down

0 comments on commit d616413

Please sign in to comment.