lib/fog/azurerm/requests/storage/delete_disk.rb in fog-azure-rm-0.1.0 vs lib/fog/azurerm/requests/storage/delete_disk.rb in fog-azure-rm-0.1.1

- old
+ new

@@ -1,31 +1,34 @@ module Fog module Storage class AzureRM # This class provides the actual implementation for service calls. class Real - def delete_disk(blob_name) - msg = "Deleting Disk: #{blob_name}." + # Delete a disk in Azure storage. + # + # @param disk_name [String] Name of disk + # @param options [Hash] + # @option options [String] container_name Sets name of the container which contains the disk. Default is 'vhds'. + # + # @return [Boolean] + # + def delete_disk(disk_name, options = {}) + msg = "Deleting disk(#{disk_name}). options: #{options}" Fog::Logger.debug msg - begin - result = delete_blob('vhds', "#{blob_name}.vhd") - rescue Azure::Core::Http::HTTPError => e - raise_azure_exception(e, msg) - end - if result.nil? - Fog::Logger.debug "Successfully deleted Disk: #{blob_name}." - true - else - Fog::Logger.debug 'Error deleting Disk.' - false - end + + container_name = options.delete(:container_name) + container_name = 'vhds' if container_name.nil? + delete_blob(container_name, "#{disk_name}.vhd") + + Fog::Logger.debug "Successfully deleted Disk: #{disk_name}." + true end end + # This class provides the mock implementation for unit tests. class Mock def delete_disk(*) - Fog::Logger.debug 'Deleting Disk: test_blob.' - Fog::Logger.debug 'Successfully deleted Disk: test_blob.' + Fog::Logger.debug 'Successfully deleted Disk' true end end end end