Project

General

Profile

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

foreman-docker / app / models / container.rb @ ab73d5cf

1
class Container < ActiveRecord::Base
2
  include Authorizable
3

    
4
  belongs_to :compute_resource
5
  belongs_to :image, :class_name => 'DockerImage', :foreign_key => 'docker_image_id'
6
  belongs_to :tag,   :class_name => 'DockerTag',   :foreign_key => 'docker_tag_id'
7

    
8
  attr_accessible :command, :image, :name, :compute_resource_id, :entrypoint,
9
                  :cpu_set, :cpu_shares, :memory, :tty, :attach_stdin,
10
                  :attach_stdout, :attach_stderr, :tag, :uuid
11

    
12
  def parametrize
13
    { 'name'  => name, # key has to be lower case to be picked up by the Docker API
14
      'Image' => tag.tag.blank? ? image.image_id : "#{image.image_id}:#{tag.tag}",
15
      'Tty'          => tty,                    'Memory'       => memory,
16
      'Entrypoint'   => entrypoint.try(:split), 'Cmd'          => command.try(:split),
17
      'AttachStdout' => attach_stdout,          'AttachStdin'  => attach_stdin,
18
      'AttachStderr' => attach_stderr,          'CpuShares'    => cpu_shares,
19
      'Cpuset'       => cpu_set }
20
  end
21

    
22
  def in_fog
23
    @fog_container ||= compute_resource.vms.get(uuid)
24
  end
25
end