Module: ForemanBootdisk::Orchestration::Compute
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/foreman_bootdisk/orchestration/compute.rb
Instance Method Summary collapse
- #bootdisk_attach_iso ⇒ Object
- #bootdisk_delete_iso ⇒ Object
- #bootdisk_detach_iso ⇒ Object
- #bootdisk_generate_iso_image ⇒ Object
- #bootdisk_isodir ⇒ Object
- #bootdisk_isofile ⇒ Object
- #bootdisk_upload_iso ⇒ Object
- #delAttachIsoImage ⇒ Object
- #delDeleteIsoImage ⇒ Object
- #delDetachIsoImage ⇒ Object
- #delGenerateIsoImage ⇒ Object
- #delIsoImage ⇒ Object
- #queue_bootdisk_compute ⇒ Object
- #setAttachIsoImage ⇒ Object
- #setDeleteIsoImage ⇒ Object
- #setDetachIsoImage ⇒ Object
- #setGenerateIsoImage ⇒ Object
- #setIsoImage ⇒ Object
Instance Method Details
#bootdisk_attach_iso ⇒ Object
68 69 70 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 68 def bootdisk_attach_iso compute_resource.iso_attach(File.basename(bootdisk_isofile), uuid) end |
#bootdisk_delete_iso ⇒ Object
64 65 66 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 64 def bootdisk_delete_iso compute_resource.iso_delete(bootdisk_isofile, uuid) end |
#bootdisk_detach_iso ⇒ Object
72 73 74 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 72 def bootdisk_detach_iso compute_resource.iso_detach(uuid) end |
#bootdisk_generate_iso_image ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 46 def bootdisk_generate_iso_image if self.build? && self.provisioning_template(kind: :PXELinux) && self.provisioning_template(kind: :PXEGrub2) logger.info format('Generating FULL HOST ISO image for %s', name) ForemanBootdisk::ISOGenerator.generate_full_host(self, dir: Dir.tmpdir) do |image| FileUtils.mv image, bootdisk_isofile end else logger.info format('Generating HOST ISO image for %s', name) ForemanBootdisk::ISOGenerator.generate(ipxe: bootdisk_template_render, dir: Dir.tmpdir) do |image| FileUtils.mv image, bootdisk_isofile end end end |
#bootdisk_isodir ⇒ Object
14 15 16 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 14 def bootdisk_isodir @bootdisk_isodir ||= Dir.mktmpdir end |
#bootdisk_isofile ⇒ Object
18 19 20 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 18 def bootdisk_isofile File.join(bootdisk_isodir, "#{name}.iso") end |
#bootdisk_upload_iso ⇒ Object
60 61 62 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 60 def bootdisk_upload_iso compute_resource.iso_upload(bootdisk_isofile, uuid) end |
#delAttachIsoImage ⇒ Object
100 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 100 def delAttachIsoImage; end |
#delDeleteIsoImage ⇒ Object
118 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 118 def delDeleteIsoImage; end |
#delDetachIsoImage ⇒ Object
109 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 109 def delDetachIsoImage; end |
#delGenerateIsoImage ⇒ Object
82 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 82 def delGenerateIsoImage; end |
#delIsoImage ⇒ Object
91 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 91 def delIsoImage; end |
#queue_bootdisk_compute ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 22 def queue_bootdisk_compute return unless compute? && errors.empty? return unless provision_method == 'bootdisk' # We want to add our queue jobs only if really necessary: # - in case of starting to create a new host # - in case of a rebuild if (old.nil? || !old.build?) && build? queue.create(name: _('Generating ISO image for %s') % self, priority: 5, action: [self, :setGenerateIsoImage]) queue.create(name: _('Upload ISO image to datastore for %s') % self, priority: 6, action: [self, :setIsoImage]) queue.create(name: _('Attach ISO image to CDROM drive for %s') % self, priority: 900, action: [self, :setAttachIsoImage]) # Detach ISO image when host sends 'built' HTTP POST request elsif old&.build? && !build? queue.create(name: _('Detach ISO image from CDROM drive for %s') % self, priority: 52, action: [self, :setDetachIsoImage]) queue.create(name: _('Delete ISO image for %s') % self, priority: 53, action: [self, :setDeleteIsoImage]) end true end |
#setAttachIsoImage ⇒ Object
93 94 95 96 97 98 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 93 def setAttachIsoImage logger.info format('Attaching ISO image to CDROM drive for %s', name) bootdisk_attach_iso rescue StandardError => e failure format(_('Failed to attach ISO image to CDROM drive of instance %{name}: %{message}'), name: name, message: e.), e end |
#setDeleteIsoImage ⇒ Object
111 112 113 114 115 116 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 111 def setDeleteIsoImage logger.info format('Delete ISO image for %s', name) bootdisk_delete_iso rescue StandardError => e failure format(_('Failed to delete ISO image of instance %{name}: %{message}'), name: name, message: e.), e end |
#setDetachIsoImage ⇒ Object
102 103 104 105 106 107 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 102 def setDetachIsoImage logger.info format('Detaching ISO image from CDROM drive for %s', name) bootdisk_detach_iso rescue StandardError => e failure format(_('Failed to detach ISO image from CDROM drive of instance %{name}: %{message}'), name: name, message: e.), e end |
#setGenerateIsoImage ⇒ Object
76 77 78 79 80 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 76 def setGenerateIsoImage bootdisk_generate_iso_image rescue StandardError => e failure format(_('Failed to generate ISO image for instance %{name}: %{message}'), name: name, message: e.), e end |
#setIsoImage ⇒ Object
84 85 86 87 88 89 |
# File 'app/models/concerns/foreman_bootdisk/orchestration/compute.rb', line 84 def setIsoImage logger.info "Uploading ISO image #{bootdisk_isofile} for #{name}" bootdisk_upload_iso rescue StandardError => e failure format(_('Failed to upload ISO image for instance %{name}: %{message}'), name: name, message: e.), e end |