Class: ForemanAcd::AppInstance
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ForemanAcd::AppInstance
- Extended by:
- FriendlyId
- Includes:
- Authorizable, ForemanTasks::Concerns::ActionSubject, Parameterizable::ByIdName
- Defined in:
- app/models/foreman_acd/app_instance.rb
Overview
Application Instance
Instance Attribute Summary collapse
-
#hosts ⇒ Object
Returns the value of attribute hosts.
Class Method Summary collapse
Instance Method Summary collapse
- #clean_all_hosts ⇒ Object
- #clean_hosts_by_id(ids = []) ⇒ Object
- #deployment_state ⇒ Object
- #hosts_deployment_finished? ⇒ Boolean
- #initial_configure_job ⇒ Object
- #initial_configure_state ⇒ Object
Instance Attribute Details
#hosts ⇒ Object
Returns the value of attribute hosts.
25 26 27 |
# File 'app/models/foreman_acd/app_instance.rb', line 25 def hosts @hosts end |
Class Method Details
.humanize_class_name(_name = nil) ⇒ Object
27 28 29 |
# File 'app/models/foreman_acd/app_instance.rb', line 27 def self.humanize_class_name(_name = nil) _('App Instance') end |
.permission_name ⇒ Object
31 32 33 |
# File 'app/models/foreman_acd/app_instance.rb', line 31 def self. 'app_instances' end |
Instance Method Details
#clean_all_hosts ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/models/foreman_acd/app_instance.rb', line 35 def clean_all_hosts remember_host_ids = foreman_hosts.select(&:fresh_host?).map(&:host_id) # Clean the app instance association first foreman_hosts.update_all(:host_id => nil) # Remove all hosts afterwards delete_hosts(remember_host_ids) end |
#clean_hosts_by_id(ids = []) ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/models/foreman_acd/app_instance.rb', line 45 def clean_hosts_by_id(ids = []) # Clean the app instance association first foreman_hosts.where(:host_id => ids, :is_existing_host => false).update_all(:host_id => nil) # Remove all hosts afterwards delete_hosts(ids) end |
#deployment_state ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/models/foreman_acd/app_instance.rb', line 60 def deployment_state return :new if last_deploy_task.nil? return :initiated if !last_deploy_task.nil? && last_deploy_task.ended_at.nil? if all_hosts_deployed? :finished elsif last_deploy_task.ended_at? && last_deploy_task.result != 'success' :failed else :pending end end |
#hosts_deployment_finished? ⇒ Boolean
53 54 55 56 57 58 |
# File 'app/models/foreman_acd/app_instance.rb', line 53 def hosts_deployment_finished? return true if all_hosts_deployed? ::Foreman::Logging.logger('foreman_acd').info('Another host is still in build-phase. Wait for it...') false end |
#initial_configure_job ⇒ Object
73 74 75 76 77 78 |
# File 'app/models/foreman_acd/app_instance.rb', line 73 def initial_configure_job return nil if initial_configure_task.nil? return JobInvocation.find(initial_configure_task.output['configure_job_id']) if initial_configure_task.output.key?('configure_job_id') && !initial_configure_task.output['configure_job_id'].nil? nil end |
#initial_configure_state ⇒ Object
80 81 82 83 84 85 |
# File 'app/models/foreman_acd/app_instance.rb', line 80 def initial_configure_state return :unconfigured if initial_configure_job.nil? && initial_configure_task.nil? return :scheduled if initial_configure_job.nil? return :pending unless initial_configure_job.finished? initial_configure_job.status_label.to_sym end |