Sha256: 44542d257645dff131f987fdc567901d8ab6f599175db27668dd548cc759dcc9

Contents?: true

Size: 972 Bytes

Versions: 12

Compression:

Stored size: 972 Bytes

Contents

module Fog
  module Compute
    class AzureRM
      # This class provides the actual implementation for service calls.
      class Real
        def check_vm_exists(resource_group, name)
          msg = "Checking Virtual Machine #{name}"
          Fog::Logger.debug msg
          begin
            @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView')
            Fog::Logger.debug "Virtual machine #{name} exists."
            true
          rescue MsRestAzure::AzureOperationError => e
            if e.body['error']['code'] == 'ResourceNotFound'
              Fog::Logger.debug "Virtual machine #{name} doesn't exist."
              false
            else
              raise_azure_exception(e, msg)
            end
          end
        end
      end
      # This class provides the mock implementation for unit tests.
      class Mock
        def check_vm_exists(_resource_group, _name)
          true
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
fog-azure-rm-downgraded-0.3.1 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.3.1 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-downgraded-0.3.0 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.3.0 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.7 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.6 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.5 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.4 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.3 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.2 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.1 lib/fog/azurerm/requests/compute/check_vm_exists.rb
fog-azure-rm-0.2.0 lib/fog/azurerm/requests/compute/check_vm_exists.rb