Class: ForemanDeployments::Deployment

Inherits:
ActiveRecord::Base show all
Includes:
Authorizable, Concerns::BelongsToStackTaxonomy
Defined in:
app/models/foreman_deployments/deployment.rb

Instance Method Summary collapse

Methods inherited from ActiveRecord::Base

#to_hash

Instance Method Details

#configuratorObject



23
24
25
# File 'app/models/foreman_deployments/deployment.rb', line 23

def configurator
  @configurator ||= ForemanDeployments::Config::Configurator.new(parsed_stack)
end

#parsed_stackObject



19
20
21
# File 'app/models/foreman_deployments/deployment.rb', line 19

def parsed_stack
  @parsed_stack ||= ForemanDeployments::StackParser.parse(stack.definition) unless stack.nil?
end

#runObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/foreman_deployments/deployment.rb', line 27

def run
  fail(Foreman::Exception, _("You can't start a deployment that is already running!")) if status == :running

  # configure with user input
  configurator.configure(configuration)

  # validate
  parsed_stack.validate!

  self.task = ForemanTasks.async_task(Tasks::StackDeployAction, parsed_stack)
  save
end

#stackObject



15
16
17
# File 'app/models/foreman_deployments/deployment.rb', line 15

def stack
  configuration.stack if configuration
end

#statusObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/foreman_deployments/deployment.rb', line 40

def status
  # configuration, running, deployed, failed
  if task.nil?
    :configuration
  elsif task.state == 'paused'
    :paused
  elsif task.state == 'stopped'
    if task.result == 'success'
      :deployed
    else
      :failed
    end
  else
    :running
  end
end