Project

General

Profile

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

foreman-docker / app / models / docker_container_wizard_state.rb @ d2e54db4

1
class DockerContainerWizardState < ActiveRecord::Base
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 :environment_variables, :to => :environment
13
  delegate :exposed_ports, :to => :environment
14
  delegate :dns, :to => :environment
15

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