Class: Rudy::CLI::AWS::EC2::Volumes
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
#destroy_volumes ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 30
def destroy_volumes
@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
raise "Volume #{@volume.awsid} is still in-use" if @volume.in_use?
raise "Volume #{@volume.awsid} is still attached" if @volume.attached?
raise "Volume #{@volume.awsid} is not available (#{@volume.state})" unless @volume.available?
puts "Destroying #{@volume.awsid}"
execute_check(:medium)
execute_action("Destroy Failed") { @rvol.destroy(@volume.awsid) }
vol = @rvol.get(@volume.awsid)
puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
end
|
#destroy_volumes_valid? ⇒ Boolean
25
26
27
28
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 25
def destroy_volumes_valid?
raise "You must supply a volume ID. See rudy volume -h" unless @argv.volid
true
end
|
#volumes ⇒ Object
92
93
94
95
96
97
98
99
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 92
def volumes
rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
volumes = rvol.list || []
volumes.each do |vol|
puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
end
puts "No volumes" if volumes.empty?
end
|
#volumes_attach ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 52
def volumes_attach
@option.device ||= "/dev/sdh"
rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
rinst = Rudy::AWS::EC2::Instances.new(@@global.accesskey, @@global.secretkey, @@global.region)
raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
raise "Volume #{@argv.volid} is already attached" if rvol.attached?(@argv.volid)
raise "Instance #{@option.instance} does not exist" unless rinst.exists?(@option.instance)
puts "Attaching #{@argv.volid} to #{@option.instance} on #{@option.device}"
execute_check(:low)
execute_action("Attach Failed") {
rvol.attach(@argv.volid, @option.instance, @option.device)
}
vol = rvol.get(@argv.volid)
puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
end
|
#volumes_attach_valid? ⇒ Boolean
47
48
49
50
51
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 47
def volumes_attach_valid?
raise "You must supply an instance ID." unless @option.instance
raise "You must supply a volume ID." unless @argv.volid
true
end
|
#volumes_create ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 14
def volumes_create
puts "Creating #{@option.size}GB volume in #{@@global.zone}"
rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
execute_check(:low)
vol = execute_action("Create Failed") {
rvol.create(@option.size, @@global.zone, @option.snapshot)
}
puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
end
|
#volumes_create_valid? ⇒ Boolean
9
10
11
12
13
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 9
def volumes_create_valid?
raise "You must supply a volume size. See rudy volume -h" unless @option.size
raise "You must supply a zone." unless @@global.zone
true
end
|
#volumes_detach ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 76
def volumes_detach
rvol = Rudy::AWS::EC2::Volumes.new(@@global.accesskey, @@global.secretkey, @@global.region)
raise "Volume #{@argv.volid} does not exist" unless rvol.exists?(@argv.volid)
vol = rvol.get(@argv.volid)
raise "Volume #{vol.awsid} is not attached" unless vol.attached?
puts "Detaching #{vol.awsid} from #{vol.instid}"
execute_check(:medium)
execute_action("Detach Failed") { rvol.detach(vol.awsid) }
vol = rvol.get(vol.awsid)
puts @global.verbose > 1 ? vol.inspect : vol.dump(@@global.format)
end
|
#volumes_detach_valid? ⇒ Boolean
71
72
73
74
|
# File 'lib/rudy/cli/aws/ec2/volumes.rb', line 71
def volumes_detach_valid?
raise "You must supply a volume ID." unless @argv.volid
true
end
|