Sha256: af2c284fb2bf9d8f9a66e1e66fe8b6d8710344f913fc4496a9302afe53cd62df

Contents?: true

Size: 1.3 KB

Versions: 34

Compression:

Stored size: 1.3 KB

Contents

module Fog
  module Compute
    class AzureRM
      # This class provides the actual implementation for service calls.
      class Real
        def check_vm_status(resource_group, name, async)
          msg = "Checking Virtual Machine #{name} status"
          Fog::Logger.debug msg
          begin
            virtual_machine = @compute_mgmt_client.virtual_machines.get(resource_group, name, 'instanceView')
          rescue  MsRestAzure::AzureOperationError => e
            raise_azure_exception(e, msg)
          end
          Fog::Logger.debug "Successfully returned status of Virtual Machine #{name} in Resource Group #{resource_group}"
          get_status(virtual_machine)
        end

        def get_status(virtual_machine)
          vm_statuses = virtual_machine.instance_view.statuses
          vm_status = nil
          vm_statuses.each do |status|
            if status.code.include? 'PowerState'
              Fog::Logger.debug status.display_status.to_s
              vm_status = status.code.split('/')[1]
            end
          end
          vm_status
        end
      end
      # This class provides the mock implementation for unit tests.
      class Mock
        def check_vm_status(_resource_group, _name)
          'running'
        end
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 3 rubygems

Version Path
fog-azure-rm-0.6.0 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.6 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.5 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.4 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.3 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.9 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.2 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.8 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.7 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.6 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.5 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-temp-0.0.5 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.4 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.3 lib/fog/azurerm/requests/compute/check_vm_status.rb
far-gem-0.5.1 lib/fog/azurerm/requests/compute/check_vm_status.rb
fog-azure-rm-0.4.2 lib/fog/azurerm/requests/compute/check_vm_status.rb