-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OS-4886. obsolete_snapshot_chains archive
- Loading branch information
Showing
3 changed files
with
139 additions
and
71 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
bumiworker/bumiworker/modules/archive/obsolete_snapshot_chains.py
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 bumiworker.bumiworker.consts import ArchiveReason | ||
from bumiworker.bumiworker.modules.recommendations.obsolete_snapshot_chains import ( | ||
ObsoleteSnapshotChains as ObsoleteSnapshotChainsRecommendation, | ||
SUPPORTED_CLOUDS, | ||
) | ||
from bumiworker.bumiworker.modules.obsolete_snapshots_base import ( | ||
ObsoleteSnapshotsArchiveBase | ||
) | ||
|
||
|
||
class ObsoleteSnapshotChains(ObsoleteSnapshotsArchiveBase, | ||
ObsoleteSnapshotChainsRecommendation): | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.reason_description_map[ArchiveReason.RECOMMENDATION_APPLIED] = ( | ||
'snapshot chain deleted') | ||
|
||
@property | ||
def supported_cloud_types(self): | ||
return SUPPORTED_CLOUDS | ||
|
||
@property | ||
def resource_type(self): | ||
return 'Snapshot Chain' | ||
|
||
def get_used_resources(self, now, cloud_account_id, cloud_config, | ||
obsolete_threshold): | ||
snapshots_to_chains = self._get_snapshots_to_chains( | ||
cloud_account_id) | ||
snapshots_used_by_images = self.get_snapshots_used_by_images( | ||
now, cloud_config) | ||
chains_used_by_images = self._group_by_chains( | ||
snapshots_to_chains, snapshots_used_by_images) | ||
snapshots_used_by_volumes = self.get_snapshots_used_by_volumes( | ||
now, cloud_account_id, obsolete_threshold) | ||
chains_used_by_volumes = self._group_by_chains( | ||
snapshots_to_chains, snapshots_used_by_volumes) | ||
chains_using_volumes = self._get_chains_using_volumes( | ||
now, cloud_account_id) | ||
return (chains_used_by_images, chains_using_volumes, | ||
chains_used_by_volumes) | ||
|
||
|
||
def main(organization_id, config_client, created_at, **kwargs): | ||
return ObsoleteSnapshotChains( | ||
organization_id, config_client, created_at).get() |
93 changes: 23 additions & 70 deletions
93
bumiworker/bumiworker/modules/archive/obsolete_snapshots.py
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