Class: SnapshotOptimization

Inherits:
Ec2Script show all
Defined in:
lib/scripts/ec2/snapshot_optimization.rb

Overview

Identifies a number of resources that can be deleted:

  • duplicate snapshots for a given volume exceeding a certain threshold

  • unattached volumes created more than 1 day ago

Defined Under Namespace

Classes: DeleteDuplicateSnapshots, DeleteUnattachedVolumes, Done, IdentifyDuplicateSnapshots, IdentifyOrphanVolumes, RetrieveSnapshots, RetrieveVolumes, SnapshotOptimizationState

Constant Summary

Constants inherited from Ec2Script

Ec2Script::CS_AWS_TIMEOUT, Ec2Script::CS_SEC_GRP_DESC, Ec2Script::CS_SEC_GRP_NAME

Instance Method Summary collapse

Methods inherited from Ec2Script

#get_execution_result, #post_message, #register_progress_message_listener, #register_state_change_listener, #start_script

Constructor Details

#initialize(input_params) ⇒ SnapshotOptimization

Input parameters

  • ec2_api_handler => object that allows to access the EC2 API



15
16
17
# File 'lib/scripts/ec2/snapshot_optimization.rb', line 15

def initialize(input_params)
  super(input_params)
end

Instance Method Details

#check_input_parametersObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/scripts/ec2/snapshot_optimization.rb', line 19

def check_input_parameters()
  if @input_params[:ec2_api_handler] == nil
    raise Exception.new("no EC2 handler specified")
  end
  if @input_params[:delete_snapshots] == nil
    @input_params[:delete_snapshots] = false
  end
  if @input_params[:delete_volumes] == nil
    @input_params[:delete_volumes] = false
  end
  if @input_params[:max_duplicate_snapshots] == nil
    @input_params[:max_duplicate_snapshots] = 5
  end
end

#load_initial_stateObject



34
35
36
# File 'lib/scripts/ec2/snapshot_optimization.rb', line 34

def load_initial_state()
  SnapshotOptimizationState.load_state(@input_params)
end