Sha256: 02e0cb45abf666b0830f78ab5b3afd37b6b67808c39445eeb3f167e871013bcc

Contents?: true

Size: 1.52 KB

Versions: 22

Compression:

Stored size: 1.52 KB

Contents

module Fog
  module Compute
    class AzureRM
      # Real class for Compute Request
      class Real
        def get_image(resource_group_name, image_name)
          msg = "Getting Image #{image_name} in Resource Group #{resource_group_name}"
          Fog::Logger.debug msg
          begin
            image = @compute_mgmt_client.images.get(resource_group_name, image_name)
          rescue MsRestAzure::AzureOperationError => e
            raise_azure_exception(e, msg)
          end
          Fog::Logger.debug "#{msg} successful"
          image
        end
      end

      # Mock class for Compute Request
      class Mock
        def get_image(*)
          body = {
            'id' => '/subscriptions/########-####-####-####-############/resourceGroups/TestRG/providers/Microsoft.Compute/images/TestImage',
            'name' => 'TestImage',
            'resource_group' => 'TestRG',
            'location' => 'West US',
            'storage_profile' => {
              'os_disk' => {
                'os_type' => 'Linux',
                'os_state' => 'Generalized',
                'blob_uri' => 'https://myblob.blob.core.windows.net/images/testimage.vhd',
                'caching' => 'ReadWrite',
                'disk_size_gb' => '5'
              },
              'data_disks' => []
            },
            'provisioning_state' => 'Succeeded'
          }
          image_mapper = Azure::ARM::Compute::Models::Image.mapper
          @compute_mgmt_client.deserialize(image_mapper, body, 'result.body')
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
fog-azure-rm-0.4.1 lib/fog/azurerm/requests/compute/get_image.rb
fog-azure-rm-0.4.0 lib/fog/azurerm/requests/compute/get_image.rb