Class: Rudy::CLI::Disks
Instance Attribute Summary
Attributes inherited from CommandBase
#config
Instance Method Summary
collapse
Methods included from Huxtable
config, #config_dirname, create_domain, #current_group_name, #current_machine_address, #current_machine_bucket, #current_machine_count, #current_machine_group, #current_machine_hostname, #current_machine_image, #current_machine_name, #current_machine_os, #current_machine_size, #current_machine_user, #current_user_keypairname, #current_user_keypairpath, #defined_keypairpath, domain, domain_exists?, global, keypair_path_to_name, #known_machine_group?, ld, #ld, #le, le, li, #li, logger, reset_config, reset_global, #root_keypairname, #root_keypairpath, update_config, update_global, update_logger, #user_keypairname, #user_keypairpath
Instance Method Details
#disks ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rudy/cli/disks.rb', line 7
def disks
disk_list = get_disks
if @option.backups
backups = Rudy::Backups.list(more, less) || []
backups.each_with_index do |b, index|
disk_list << b.disk
end
end
seen = []
disk_list.each do |d|
next if seen.member?(d.name)
seen << d.name
print_stobject d
if @option.backups
d.backups.each_with_index do |b, index|
li ' %s' % b.name
end
end
end
end
|
#disks_create ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/rudy/cli/disks.rb', line 64
def disks_create
@mlist.each do |m|
li machine_separator(m.name, m.instid)
rbox = Rudy::Routines::Handlers::RyeTools.create_box m
rbox.stash = m
disk = Rudy::Disk.new m.position, @argv.first
disk.device = @option.device if @option.device
disk.size = @option.size if @option.size
disk.refresh! if disk.exists? li "Creating disk: #{disk.name}"
volumes = m.attached_volumes
volumes.reject! { |v| v.awsid == disk.volid } if disk.volid && disk.volume_attached?
disk_index = volumes.size + 2
Rudy::Routines::Handlers::Disks.create rbox, disk, disk_index
end
end
|
#disks_create_valid? ⇒ Boolean
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/rudy/cli/disks.rb', line 50
def disks_create_valid?
@mlist = Rudy::Machines.list
raise "No machines" if @mlist.nil?
raise "No path provided" unless @argv.first
if !@@global.force && Rudy::Disks.exists?( @argv.first)
raise "Disk exists" if Rudy::Disks.get(@argv.first).volume_attached?
end
raise "No size provided" unless @option.size
true
end
|
#disks_destroy_valid? ⇒ Boolean
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/rudy/cli/disks.rb', line 83
def disks_destroy_valid?
@dlist = Rudy::Disks.list
raise "No disks" if @dlist.nil?
@mlist = Rudy::Machines.list
raise "No machines" if @mlist.nil? && !@@global.force
raise "No path provided" unless @argv.first
raise "Disk does not exist" unless Rudy::Disks.exists? @argv.first
true
end
|
#disks_wash ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/rudy/cli/disks.rb', line 32
def disks_wash
dirt = (get_disks || []).select { |d| !d.volume_exists? }
if dirt.empty?
li "Nothing to wash in #{current_machine_group}"
return
end
li "The following disk metadata will be deleted:"
li dirt.collect {|d| d.name }
execute_check(:medium)
dirt.each do |d|
d.destroy(:force)
end
end
|