-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from Trioxis/feature/determine-backup-actions-#27
Determine backup actions (fixes #27)
- Loading branch information
Showing
17 changed files
with
513 additions
and
108 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
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
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,50 @@ | ||
// Given a list of snapshots, returns a list of snapshots that have expired | ||
// This can be determined using ExpiryDate tags | ||
let findDeadSnapshots = (snapshotList) => { | ||
return [snapshotList]; | ||
}; | ||
|
||
// Helper function that checks if a single snapshot has expired or not. | ||
// Returns true if the snapshot has expired and needs to be deleted. | ||
let snapshotIsDead = (snapshot) => { | ||
return snapshot; | ||
}; | ||
|
||
// Given a list of EBS volumes and list of snapshots, matches each snapshot to the | ||
// EBS's Snapshots[BackupType] array. Returns an object containing the volume list | ||
// and a list of orphaned snapshots | ||
// The snapshot arrays are sorted by latest first | ||
let matchSnapsToVolumes = (volumes, snapList) => { | ||
snapList = sortSnapsByMostRecent(snapList); | ||
let matchedVolumes = volumes.map((volume) => { | ||
volume.Snapshots = {}; | ||
snapList = snapList.filter((snap) => { | ||
if (snap.FromVolumeName === volume.Name) { | ||
if (!volume.Snapshots[snap.BackupType]) volume.Snapshots[snap.BackupType] = []; | ||
volume.Snapshots[snap.BackupType].push(snap); | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}); | ||
return volume; | ||
}); | ||
let orphanedSnaps = snapList; | ||
return {matchedVolumes, orphanedSnaps}; | ||
}; | ||
|
||
// Sorts a list of snapshots by most recently created first | ||
let sortSnapsByMostRecent = (snapList) => { | ||
// sort in to latest first | ||
return snapList.sort((a, b) => { | ||
if (a.StartTime.isAfter(b.StartTime)) { | ||
return -1; | ||
} else if (a.StartTime.isSame(b.StartTime)) { | ||
return 0; | ||
} else { | ||
return 1; | ||
} | ||
}); | ||
}; | ||
|
||
export {findDeadSnapshots, snapshotIsDead, matchSnapsToVolumes, sortSnapsByMostRecent}; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.