# File lib/deltacloud/drivers/vsphere/vsphere_driver.rb, line 75
    def images(credentials, opts=nil)
      cloud = new_client(credentials)
      img_arr = []

      # Skip traversing through all instances in all datacenters when ID
      # attribute is set
      safely do
        if opts[:id]
          template_vms = [ find_vm(credentials, opts[:id]) ].select { |vm| vm[:instance] }.compact
        else
          template_vms = list_virtual_machines(credentials).select { |vm| vm[:instance] && vm[:instance].summary.config[:template] }
        end
        img_arr = template_vms.collect do |image_hash|
          image, realm = image_hash[:instance], image_hash[:datastore]
          config = image.summary.config
          instance_state = convert_state(:instance, image.summary.runtime[:powerState])
          # Preload all properties to save multiple SOAP calls to vSphere
          properties = {
            :name => config[:name],
            :full_name => config[:guestFullName]
          }
          image_state = convert_state(:image, image.summary.runtime[:powerState])
          # This will determine image architecture using image description.
          # Ussualy description include '64-bit' or '32-bit'. In case you used
          # some weird template/OS it will fallback to 64 bit
          image_architecture = extract_architecture(properties[:full_name]) || 'x86_64'
          Image.new(
            :id => properties[:name],
            :name => properties[:name],
            :architecture => image_architecture,
            :owner_id => credentials.user,
            :description => properties[:full_name],
            :state => image_state
          )
        end
      end
      img_arr = filter_on( img_arr, :architecture, opts )
      img_arr.sort_by{|e| [e.owner_id, e.name]}
    end