Sha256: 54ab3529405d70207e781e34e52358c97b19965c525b7559d727d92c4a4e9687

Contents?: true

Size: 1.41 KB

Versions: 22

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module ForemanBootdisk
  module ComputeResources
    module Vmware
      def capabilities
        super + [:bootdisk]
      end

      def parse_args(args = {})
        args = super(args)
        if args[:provision_method] == 'bootdisk'
          args[:cdroms] = [new_cdrom]
          args[:boot_order] = %w[cdrom disk]
          args[:boot_retry] = 10
        end
        args
      end

      def bootdisk_datastore(vm_uuid)
        find_vm_by_uuid(vm_uuid).volumes.first.datastore
      end

      def iso_upload(iso, vm_uuid)
        options = {
          'local_path' => iso,
          'datacenter' => dc.name,
          'datastore' => bootdisk_datastore(vm_uuid),
          'upload_directory' => 'foreman_isos' # fog creates the directory if it does not exist
        }
        client.upload_iso options
      end

      def iso_attach(iso, vm_uuid)
        options = {
          'instance_uuid' => vm_uuid,
          'iso' => "foreman_isos/#{iso}",
          'datastore' => bootdisk_datastore(vm_uuid),
          'start_connected' => true,
          'connected' => true,
          'allow_guest_control' => true
        }
        client.vm_reconfig_cdrom options
      end

      def iso_detach(vm_uuid)
        options = {
          'instance_uuid' => vm_uuid,
          'start_connected' => false,
          'connected' => false,
        }
        client.vm_reconfig_cdrom options
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
foreman_bootdisk-21.2.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.1.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.9 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.0.4 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.0.3 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.8 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.0.2 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.7 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.0.1 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-21.0.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.6 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.4.1 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.5 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.4 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.3 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.2 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.1 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-19.0.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-18.1.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
foreman_bootdisk-18.0.0 app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb