Class: Chef::Knife::SceVolumeCreate
Instance Method Summary
collapse
Methods included from SceBase
#connection, #connection_storage, #datacenter_id, included, #locate_config_value, #msg_pair
Instance Method Details
#run ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/chef/knife/sce_volume_create.rb', line 55
def run
$stdout.sync = true
Fog.timeout = Chef::Config[:knife][:sce_max_timeout] || 6000
validate!
disk_launch_desc = {
:name => config[:name],
:offering_id => config[:offering_id],
:format => config[:format].upcase,
:location_id => datacenter_id,
:size => config[:size]
}
puts "Creating volume #{config[:name]}"
volume = connection_storage.volumes.create(disk_launch_desc)
puts "Volume #{config[:name]} created, volume ID is #{volume.id}. Waiting for ready..."
volume.wait_for { ready? }
puts "Volume #{config[:name]} ready to use."
puts "\n"
volume.id.to_s
msg_pair("Volume ID", volume.id.to_s )
msg_pair("Name", volume.name.to_s )
msg_pair("State", volume.state.to_s )
msg_pair("Size", volume.size.to_s )
msg_pair("Location", connection.locations.get(volume.location_id).name )
msg_pair("Format", volume.format.to_s )
msg_pair("Offering ID", volume.offering_id.to_s )
msg_pair("Owner", volume.owner.to_s )
end
|
#validate! ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/chef/knife/sce_volume_create.rb', line 95
def validate!
super([:ibm_username, :ibm_password, :size, :format, :offering_id, :datacenter, :name])
@offering = connection_storage.offerings.get( config[:offering_id] )
if @offering.nil?
ui.error("Storage offering #{config[:offering_id]} does not exist.")
exit 1
else
formats = []
@offering.supported_formats.each do |format|
formats << format["id"]
end
sizes = @offering.supported_sizes.split(",")
if !formats.include?( config[:format].upcase )
ui.error("Format #{config[:format].upcase} not supported.")
exit 1
end
if !sizes.include?( config[:size] )
ui.error("Format #{config[:size]} not supported.")
exit 1
end
end
end
|