Project

General

Profile

Download (1.7 KB) Statistics
| Branch: | Tag: | Revision:

foreman_docker / app / models / docker_container_wizard_state.rb @ fb471374

1
class DockerContainerWizardState < ApplicationRecord
2
  has_one :preliminary, :class_name => DockerContainerWizardStates::Preliminary,
3
                        :dependent => :destroy, :validate => true, :autosave => true
4
  has_one :image, :class_name => DockerContainerWizardStates::Image,
5
                  :dependent => :destroy, :validate => true, :autosave => true
6
  has_one :configuration, :class_name => DockerContainerWizardStates::Configuration,
7
                          :dependent => :destroy, :validate => true, :autosave => true
8
  has_one :environment, :class_name => DockerContainerWizardStates::Environment,
9
                        :dependent => :destroy, :validate => true, :autosave => true
10

    
11
  delegate :compute_resource_id,   :to => :preliminary
12
  delegate :compute_resource, :to => :preliminary
13

    
14
  delegate :environment_variables, :to => :environment
15
  delegate :exposed_ports, :to => :environment
16
  delegate :dns, :to => :environment
17

    
18
  def container_attributes
19
    { :repository_name     => image.repository_name,
20
      :tag                 => image.tag,
21
      :registry_id         => image.registry_id,
22
      :name                => configuration.name,
23
      :compute_resource_id => preliminary.compute_resource_id,
24
      :tty                 => environment.tty,
25
      :memory              => configuration.memory,
26
      :entrypoint          => configuration.entrypoint,
27
      :command             => configuration.command,
28
      :attach_stdout       => environment.attach_stdout,
29
      :attach_stdin        => environment.attach_stdin,
30
      :attach_stderr       => environment.attach_stderr,
31
      :cpu_shares          => configuration.cpu_shares,
32
      :cpu_set             => configuration.cpu_set
33
    }
34
  end
35
end