-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cloudwash supporting Containers cleanup
- Loading branch information
Showing
6 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
aws_data = ['VMS', 'NICS', 'DISCS', 'PIPS', 'RESOURCES', 'STACKS'] | ||
azure_data = ['VMS', 'NICS', 'DISCS', 'IMAGES', 'PIPS', 'RESOURCES'] | ||
gce_data = ['VMS', 'NICS', 'DISCS'] | ||
container_data = ['CONTAINERS'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from cloudwash.config import settings | ||
from cloudwash.entities.resources.base import ContainerCleanup | ||
from cloudwash.logger import logger | ||
from cloudwash.utils import dry_data | ||
|
||
|
||
class CleanContainers(ContainerCleanup): | ||
def __init__(self, client): | ||
self.client = client | ||
self._delete = [] | ||
self._stop = [] | ||
self.list() | ||
|
||
def _set_dry(self): | ||
dry_data['CONTAINERS']['delete'] = self._delete | ||
dry_data['CONTAINERS']['delete'] = self._stop | ||
|
||
def list(self): | ||
pass | ||
|
||
def stop(self): | ||
pass | ||
|
||
def remove(self): | ||
pass | ||
|
||
def cleanup(self): | ||
if not settings.dry_run: | ||
self.remove() | ||
|
||
|
||
class CleanPodmanContainers(CleanContainers): | ||
def list(self): | ||
if settings.podman.criteria.containers.something: | ||
pass | ||
# rdiscs = self.client.get_all_unattached_volumes() | ||
# rdiscs = [rdisc["VolumeId"] for rdisc in rdiscs] | ||
# self._delete.extend(rdiscs) | ||
self._set_dry() | ||
|
||
def stop(self): | ||
pass | ||
|
||
def remove(self): | ||
# self.client.remove_all_unused_volumes() | ||
logger.info(f"Removed Podman Containers: \n{self._delete}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Azure CR Cleanup Utilities""" | ||
from cloudwash.client import compute_client | ||
from cloudwash.config import settings | ||
from cloudwash.constants import container_data as data | ||
from cloudwash.entities.providers import PodmanCleanup | ||
from cloudwash.logger import logger | ||
from cloudwash.utils import dry_data | ||
from cloudwash.utils import echo_dry | ||
|
||
|
||
def cleanup(**kwargs): | ||
is_dry_run = kwargs.get("dry_run", False) | ||
for items in data: | ||
dry_data[items]['delete'] = [] | ||
with compute_client("podman") as podman_client: | ||
podmancleanup = PodmanCleanup(client=podman_client) | ||
# Actual Cleaning and dry execution | ||
if kwargs["containers"] or kwargs["_all"]: | ||
podmancleanup.containers.cleanup() | ||
if kwargs["images"] or kwargs["_all"]: | ||
podmancleanup.images.cleanup() | ||
if is_dry_run: | ||
echo_dry(dry_data) |