Module: ForemanBootdisk::ComputeResources::Vmware
- Defined in:
- app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb
Instance Method Summary collapse
- #bootdisk_datastore(vm_uuid) ⇒ Object
- #capabilities ⇒ Object
- #controller_config(vm_uuid) ⇒ Object
- #iso_attach(iso, vm_uuid) ⇒ Object
- #iso_detach(vm_uuid) ⇒ Object
- #iso_upload(iso, vm_uuid) ⇒ Object
- #parse_args(args = {}) ⇒ Object
Instance Method Details
#bootdisk_datastore(vm_uuid) ⇒ Object
20 21 22 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 20 def bootdisk_datastore(vm_uuid) find_vm_by_uuid(vm_uuid).volumes.first.datastore end |
#capabilities ⇒ Object
6 7 8 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 6 def capabilities super + [:bootdisk] end |
#controller_config(vm_uuid) ⇒ Object
61 62 63 64 65 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 61 def controller_config(vm_uuid) = OpenStruct.new(server_id: vm_uuid, attributes: {type: RbVmomi::VIM.VirtualAHCIController.class}) client.add_vm_controller() client.get_vm_first_sata_controller(vm_uuid) end |
#iso_attach(iso, vm_uuid) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 34 def iso_attach(iso, vm_uuid) controller = controller_config(vm_uuid) = { 'instance_uuid' => vm_uuid, 'iso' => "foreman_isos/#{iso}", 'datastore' => bootdisk_datastore(vm_uuid), 'start_connected' => true, 'connected' => true, 'allow_guest_control' => true, 'controller_key' => controller[:key] } vm = find_vm_by_uuid(vm_uuid) vm.stop if vm.ready? vm.reload client.vm_reconfig_cdrom vm.start if !vm.ready? end |
#iso_detach(vm_uuid) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 52 def iso_detach(vm_uuid) = { 'instance_uuid' => vm_uuid, 'start_connected' => false, 'connected' => false, } client.vm_reconfig_cdrom end |
#iso_upload(iso, vm_uuid) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 24 def iso_upload(iso, vm_uuid) = { '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 end |
#parse_args(args = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/models/concerns/foreman_bootdisk/compute_resources/vmware.rb', line 10 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 |