Sha256: c8e90426a8af2ce2ada8674bb67c5f4d3bb32b57aaa9cd6bac39a04617601183

Contents?: true

Size: 1 KB

Versions: 36

Compression:

Stored size: 1 KB

Contents

module Azure
  module Armrest
    class VirtualMachine < BaseModel
      # Indicates whether the VM is backed by a managed disk or a regular
      # storage account.
      #
      def managed_disk?
        check_for_model_view('managed_disk?')
        properties.storage_profile.os_disk.try(:managed_disk) ? true : false
      end

      # Returns the size (aka series) for the VM, e.g. "Standard_A0".
      #
      def size
        check_for_model_view('size')
        properties.hardware_profile.vm_size
      end

      alias flavor size

      # The operating system for the image, e.g. "Linux" or "Windows".
      #
      def operating_system
        check_for_model_view('operating_sytem')
        properties.storage_profile.os_disk.os_type
      end

      alias os operating_system

      private

      def check_for_model_view(method_name)
        unless respond_to?(:properties)
          raise NoMethodError, "The method '#{method_name}' is only valid for model view objects."
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
azure-armrest-0.9.3 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.9.2 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.7 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.6 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.5 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.9.1 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.9.0 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.4 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.3 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.2 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.1 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.8.0 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.7.5 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.7.4 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.7.3 lib/azure/armrest/model/virtual_machine.rb
azure-armrest-0.7.2 lib/azure/armrest/model/virtual_machine.rb