From 905fe640ca5b846a2f791d4905a8f3de7ed65366 Mon Sep 17 00:00:00 2001 From: Rodrigo Estebanez Date: Thu, 27 Jun 2013 21:47:00 +0200 Subject: [PATCH] delete disks --- lib/fog/vcloudng/generators/compute/disks.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/fog/vcloudng/generators/compute/disks.rb b/lib/fog/vcloudng/generators/compute/disks.rb index 7f78e4c17..1e95f663e 100644 --- a/lib/fog/vcloudng/generators/compute/disks.rb +++ b/lib/fog/vcloudng/generators/compute/disks.rb @@ -85,6 +85,10 @@ module Fog @items << new_hard_disk end + def delete_hard_disk(disk_number) + @items.delete_if {|item| item['resource_type'] == 17 && item['element_name'] =~ /#{disk_number}$/ } + end + def disks { 'disks' => @items } end @@ -156,7 +160,7 @@ module Fog element_names = hard_disks.map{|item| item['element_name'] } only_numbers = element_names.map{|b| b.scan(/\d+/).first.to_i} # extract numbers last_number = only_numbers.sort.last # get the last number - hard_disks.detect{|hard_disk| hard_disk =! /#{last_number}/ } + hard_disks.detect{|hard_disk| hard_disk =~ /#{last_number}$/ } end def increase_hard_disk_name(hard_disk_name)