Class: Rudy::CLI::AWS::EC2::Snapshots

Inherits:
CommandBase
  • Object
show all
Defined in:
lib/rudy/cli/aws/ec2/snapshots.rb

Instance Attribute Summary

Attributes inherited from CommandBase

#config

Instance Method Summary collapse

Methods included from Huxtable

change_environment, change_position, change_region, change_role, change_zone, #check_keys, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_size, #current_user, #current_user_keypairpath, debug?, #debug?, domain, domain_exists?, #group_metadata, #has_keypair?, #has_keys?, #has_pem_keys?, #has_root_keypair?, keypair_path_to_name, #known_machine_group?, #root_keypairname, #root_keypairpath, #switch_user, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath

Instance Method Details

#create_snapshotsObject



15
16
17
18
19
# File 'lib/rudy/cli/aws/ec2/snapshots.rb', line 15

def create_snapshots
  rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
  snap = execute_action { rsnap.create(@volume.awsid) }
  puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
end

#create_snapshots_valid?Boolean

Raises:

  • (Drydock::ArgError)


8
9
10
11
12
13
14
# File 'lib/rudy/cli/aws/ec2/snapshots.rb', line 8

def create_snapshots_valid?
  raise Drydock::ArgError.new('volume ID', @alias) unless @option.volume
  @rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
  @volume = @rvol.get(@argv.volid)
  raise "Volume #{@volume.awsid} does not exist" unless @volume
  true
end

#destroy_snapshotsObject



28
29
30
31
32
33
# File 'lib/rudy/cli/aws/ec2/snapshots.rb', line 28

def destroy_snapshots
  puts "Destroying: #{@snap.awsid}"
  execute_check(:medium)
  execute_action { @rsnap.destroy(@snap.awsid) }
  snapshots
end

#destroy_snapshots_valid?Boolean

Raises:

  • (Drydock::ArgError)


21
22
23
24
25
26
27
# File 'lib/rudy/cli/aws/ec2/snapshots.rb', line 21

def destroy_snapshots_valid?
  raise Drydock::ArgError.new('snapshot ID', @alias) unless @argv.snapid
  @rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
  @snap = @rsnap.get(@argv.snapid)
  raise "Snapshot #{@snap.awsid} does not exist" unless @snap
  true
end

#snapshotsObject



35
36
37
38
39
40
41
42
# File 'lib/rudy/cli/aws/ec2/snapshots.rb', line 35

def snapshots
  rsnap = Rudy::AWS::EC2::Snapshots.new(@@global.accesskey, @@global.secretkey, @@global.region)
  snaps = rsnap.list || []
  snaps.each do |snap|
    puts @@global.verbose > 0 ? snap.inspect : snap.dump(@@global.format)
  end
  puts "No snapshots" if snaps.empty?
end