Skip to content

Commit

Permalink
update template
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil-jha committed Aug 3, 2023
1 parent ae69b21 commit f366146
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cloudwash/providers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ def dry_images():
rimages = []
if settings.aws.criteria.image.unassigned:
rimages = aws_client.list_templates(executable_by_me=False, owned_by_me=True)
free_images = aws_client.filter_free_images(
free_images = aws_client.list_free_images(
image_list=[image.raw.image_id for image in rimages]
)
remove_images = [
image
for image in free_images
if image not in settings.aws.exceptions.images
]
if settings.aws.criteria.image.delete_pattern:
if settings.aws.criteria.image.delete_image:
remove_images = [
image
for image in remove_images
if not image.startswith(settings.aws.criteria.image.delete_pattern)
if image.startswith(settings.aws.criteria.image.delete_image)
]
dry_data["IMAGES"]["delete"].extend(remove_images)
return remove_images
Expand Down
8 changes: 3 additions & 5 deletions cloudwash/providers/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ def dry_images():
for image in image_names
if image not in settings.azure.exceptions.images
]
if settings.azure.criteria.image.delete_pattern:
if settings.azure.criteria.image.delete_image:
remove_images = [
image
for image in remove_images
if not image.startswith(
settings.azure.criteria.image.delete_pattern
)
if image.startswith(settings.azure.criteria.image.delete_image)
]
dry_data["IMAGES"]["delete"].extend(remove_images)
return remove_images
Expand Down Expand Up @@ -156,7 +154,7 @@ def remove_vms(avms):
if kwargs["images"] or kwargs["_all"]:
rimages = dry_images()
if not is_dry_run and rimages:
azure_client.delete_compute_image_by_name(image_list=rimages)
azure_client.delete_compute_image_by_resource_group(image_list=rimages)
logger.info(f"Removed Images: \n{rimages}")

if kwargs["_all_rg"]:
Expand Down
6 changes: 6 additions & 0 deletions conf/aws.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ AWS:
DISC:
UNASSIGNED: True
NIC:
UNASSIGNED: True
IMAGE:
# Image name starts with
DELETE_IMAGE:

UNASSIGNED: True
PUBLIC_IP:
UNASSIGNED: True
Expand All @@ -30,3 +35,4 @@ AWS:
STACKS:
# CloudFormations names that would be skipped from cleanup
STACK_LIST: []
IMAGES: []
2 changes: 1 addition & 1 deletion conf/azure.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AZURE:
UNASSIGNED: True
IMAGE:
# Image name starts with
DELETE_PATTERN:
DELETE_IMAGE:

UNASSIGNED: True
PUBLIC_IP:
Expand Down
9 changes: 8 additions & 1 deletion settings.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ AZURE:
UNASSIGNED: True
IMAGE:
# Image name starts with
DELETE_PATTERN:
DELETE_IMAGE:

UNASSIGNED: True
PUBLIC_IP:
Expand Down Expand Up @@ -83,6 +83,12 @@ AWS:
DISC:
UNASSIGNED: True
NIC:
UNASSIGNED: True
# Image name starts with
IMAGE:
# Image name starts with
DELETE_IMAGE:

UNASSIGNED: True
PUBLIC_IP:
UNASSIGNED: True
Expand All @@ -100,3 +106,4 @@ AWS:
STACKS:
# CloudFormations names that would be skipped from cleanup
STACK_LIST: []
IMAGES: []

0 comments on commit f366146

Please sign in to comment.