Class: HammerCLICsv::CsvCommand::ContainersCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/hammer_cli_csv/containers.rb

Constant Summary collapse

REGISTRY =
'Registry'
REPOSITORY =
'Repository:Tag'
COMPUTERESOURCE =
'Compute Resource'
ATTACH =
'Attach I/O'
ENTRYPOINT =
'Entry Point'
COMMAND =
'Command'

Constants inherited from BaseCommand

BaseCommand::COUNT, BaseCommand::NAME

Instance Method Summary collapse

Methods inherited from BaseCommand

#apipie_check_param, #associate_locations, #associate_organizations, #authenticate_request, #build_os_name, #check_server_status, #collect_column, #count, #execute, #export_column, #foreman_architecture, #foreman_container, #foreman_domain, #foreman_environment, #foreman_filter, #foreman_host, #foreman_hostgroup, #foreman_location, #foreman_medium, #foreman_operatingsystem, #foreman_organization, #foreman_partitiontable, #foreman_permission, #foreman_provisioning_template, #foreman_role, #foreman_smart_proxy, #foreman_template_kind, #hammer, #hammer_context, #help, help_columns, #katello_contentview, #katello_contentviewversion, #katello_hostcollection, #katello_product, #katello_repository, #labelize, #lifecycle_environment, #namify, #pluralize, #split_os_name, #supported?, supported?, #thread_import

Methods included from Utils::Config

#api_connection

Instance Method Details

#create_containers_from_csv(line) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/hammer_cli_csv/containers.rb', line 38

def create_containers_from_csv(line)
  # TODO: containers cannot be updated (no api)
  # count(line[COUNT]).times do |number|
  #   name = namify(line[NAME], number)
  #   params =  { 'id' => foreman_container(:name => name),
  #               'container' => {
  #                 'name' => name,
  #                 'command' => line[COMMAND]
  #               }
  #             }
  #   print "Updating container '#{name}'..." if option_verbose?
  #   @api.resource(:containers).call(:update, params)
  # end
  # print "done\n" if option_verbose?
end

#export(csv) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hammer_cli_csv/containers.rb', line 14

def export(csv)
  csv << [NAME, REGISTRY, REPOSITORY, COMPUTERESOURCE, ATTACH, ENTRYPOINT, COMMAND]
  @api.resource(:containers).call(:index, {
      'per_page' => 999999,
      'search' => option_search
  })['results'].each do |container|
    csv << [container['name'],
            container['registry_name'],
            "#{container['repository_name']}:#{container['tag']}",
            container['compute_resource_name'],
            export_attach_types(container),
            container['entrypoint'],
            container['command']]
  end
end

#importObject



30
31
32
33
34
35
36
# File 'lib/hammer_cli_csv/containers.rb', line 30

def import
  @existing = {}

  thread_import do |line|
    create_containers_from_csv(line)
  end
end