Skip to content

Commit

Permalink
option to re_use old volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil Guskov committed Mar 10, 2018
1 parent c1398fb commit f4aa2f2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/kitchen/driver/openstack/volume.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ def create_volume(config, os)
vanilla_options.select { |o| bdm[o] }.each do |key|
opt[key] = bdm[key]
end

volume_name = "#{config[:server_name]}-volume"

if bdm[:reuse_volume]
@logger.info "Attempting to re-use old Volume..."
volume = volume(os).volumes.find { |x| x.name == volume_name }
return volume.id if volume
end

@logger.info "Creating Volume..."
resp = volume(os).create_volume("#{config[:server_name]}-volume",
resp = volume(os).create_volume(volume_name,
"#{config[:server_name]} volume",
bdm[:volume_size],
opt)
Expand Down

0 comments on commit f4aa2f2

Please sign in to comment.