Sha256: cee06f41e3861bd7050a54c4f00e653c2fee87e390ec9fe26fe6d522b9a83761

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

module Fog
  module Compute
    class AzureRM
      # This class provides the actual implemention for service calls.
      class Real
        def deallocate_virtual_machine(resource_group, name)
          Fog::Logger.debug "Deallocating Virtual Machine #{name} in Resource Group #{resource_group}."
          begin
            promise = @compute_mgmt_client.virtual_machines.deallocate(resource_group, name)
            promise.value!
            Fog::Logger.debug "Virtual Machine #{name} Deallocated Successfully."
            true
          rescue  MsRestAzure::AzureOperationError => e
            msg = "Error Deallocating Virtual Machine '#{name}' in Resource Group '#{resource_group}'. #{e.body['error']['message']}"
            raise msg
          end
        end
      end
      # This class provides the mock implementation for unit tests.
      class Mock
        def deallocate_virtual_machine(resource_group, name)
          Fog::Logger.debug "Virtual Machine #{name} from Resource group #{resource_group} Deallocated successfully."
          true
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.4 lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb
fog-azure-rm-0.0.3 lib/fog/azurerm/requests/compute/deallocate_virtual_machine.rb