Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
yec-akamai committed Jul 22, 2024
1 parent f319908 commit 2ad5986
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/modules/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Manage a Linode Image.
| `wait` | <center>`bool`</center> | <center>Optional</center> | Wait for the image to have status `available` before returning. **(Default: `True`)** |
| `wait_timeout` | <center>`int`</center> | <center>Optional</center> | The amount of time, in seconds, to wait for an image to have status `available`. **(Default: `600`)** |
| `tags` | <center>`list`</center> | <center>Optional</center> | A list of customized tags of this new Image. **(Updatable)** |
| `regions_to_replicate` | <center>`list`</center> | <center>Optional</center> | A list of regions that customer wants to replicate this image in. At least one valid region is required and only core regions allowed. Existing images in the regions not passed will be removed. NOTE: Image replication may not currently be available to all users. **(Updatable)** |
| `replica_regions` | <center>`list`</center> | <center>Optional</center> | A list of regions that customer wants to replicate this image in. At least one valid region is required and only core regions allowed. Existing images in the regions not passed will be removed. NOTE: Image replication may not currently be available to all users. **(Updatable)** |

## Return Values

Expand Down
11 changes: 5 additions & 6 deletions plugins/modules/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
editable=True,
description=["A list of customized tags of this new Image."],
),
"regions_to_replicate": SpecField(
# `regions` send to API for image replication
"replica_regions": SpecField(
type=FieldType.list,
element_type=FieldType.string,
editable=True,
Expand Down Expand Up @@ -285,17 +286,15 @@ def _handle_present(self) -> None:

self._update_image(image)

regions_to_replicate = params.get("regions_to_replicate")
new_regions: list = (
[] if regions_to_replicate is None else regions_to_replicate
)
replica_regions = params.get("replica_regions")
new_regions: list = [] if replica_regions is None else replica_regions
old_regions = [r.region for r in image.regions]

# Replicate image in new regions
if new_regions != old_regions:
if new_regions is None or len(new_regions) == 0:
return self.fail(
msg="failed to replicate image {0}: regions_to_replicate value {1} is invalid. "
msg="failed to replicate image {0}: replica_regions value {1} is invalid. "
"At least one valid region is required.".format(
label, new_regions
)
Expand Down

0 comments on commit 2ad5986

Please sign in to comment.