Sha256: 3c39350af8e365167fb1e3175ed165b095985f40ddd7ad71d7e2c634463ac30f

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module Fog
  module Compute
    class Ovirt
      class V4
        class Real
          # rubocop:disable Metrics/AbcSize
          def list_template_volumes(template_id)
            template = client.system_service.templates_service.template_service(template_id).get
            attachments = client.follow_link(template.disk_attachments)
            attachments.map do |attachment|
              attachment_disk = client.follow_link(attachment.disk)
              attachment = client.follow_link(attachment)
              bootable = attachment.bootable
              interface = attachment.interface
              attachment_disk.bootable = bootable if attachment_disk.bootable.nil?
              attachment_disk.interface = interface if attachment_disk.interface.nil?
              attachment_disk.storage_domain = attachment_disk.storage_domains[0].id if attachment_disk.storage_domains[0].present?
              ovirt_attrs attachment_disk
            end
          end
          # rubocop:enable Metrics/AbcSize
        end
        class Mock
          def list_template_volumes(_template_id)
            xml = read_xml "volumes.xml"
            Nokogiri::XML(xml).xpath("/disks/disk").map do |vol|
              ovirt_attrs OvirtSDK4::Reader.read(vol.to_s)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-ovirt-1.1.6 lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb
fog-ovirt-1.1.5 lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb
fog-ovirt-1.1.4 lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb
fog-ovirt-1.1.3 lib/fog/ovirt/requests/compute/v4/list_template_volumes.rb