Class: Container

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Authorizable, ForemanDocker::ParameterValidators, Taxonomix
Defined in:
app/models/container.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ForemanDocker::ParameterValidators

#parameters_symbol

Class Method Details

.humanize_class_name(_name = nil) ⇒ Object



60
61
62
# File 'app/models/container.rb', line 60

def self.humanize_class_name(_name = nil)
  _("Docker/Container")
end

Instance Method Details

#in_fogObject



56
57
58
# File 'app/models/container.rb', line 56

def in_fog
  @fog_container ||= compute_resource.vms.get(uuid)
end

#parametrizeObject



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

def parametrize
  { 'name'  => name, # key has to be lower case to be picked up by the Docker API
    'Image' => repository_pull_url,
    'Tty'          => tty,
    'Memory'       => ::ForemanDocker::Utility.parse_memory(memory),
    'Entrypoint'   => entrypoint.try(:split), 'Cmd'          => command.try(:split),
    'AttachStdout' => attach_stdout,          'AttachStdin'  => attach_stdin,
    'AttachStderr' => attach_stderr,          'CpuShares'    => cpu_shares,
    'Cpuset'       => cpu_set,
    'Env' => environment_variables.map { |env| "#{env.name}=#{env.value}" },
    'ExposedPorts' => Hash[*exposed_ports.map { |v| [v.name + "/" + v.value, {}] }.flatten],
    'HostConfig' => {
      'Dns' => dns.map { |env| "#{env.name}" }
    } }
end

#repository_pull_urlObject



34
35
36
37
38
# File 'app/models/container.rb', line 34

def repository_pull_url
  repo = tag.blank? ? repository_name : "#{repository_name}:#{tag}"
  repo = registry.prefixed_url(repo) if registry
  repo
end