hammer_cli_csv 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/config/cli_config.yml +2 -0
- data/lib/hammer_cli_csv.rb +4 -11
- data/lib/hammer_cli_csv/activation_keys.rb +7 -21
- data/lib/hammer_cli_csv/architectures.rb +6 -37
- data/lib/hammer_cli_csv/base.rb +177 -21
- data/lib/hammer_cli_csv/compute_profiles.rb +4 -21
- data/lib/hammer_cli_csv/compute_resources.rb +4 -16
- data/lib/hammer_cli_csv/containers.rb +65 -0
- data/lib/hammer_cli_csv/content_hosts.rb +22 -26
- data/lib/hammer_cli_csv/content_view_filters.rb +90 -60
- data/lib/hammer_cli_csv/content_views.rb +4 -17
- data/lib/hammer_cli_csv/csv.rb +0 -12
- data/lib/hammer_cli_csv/domains.rb +74 -38
- data/lib/hammer_cli_csv/exception_handler.rb +0 -11
- data/lib/hammer_cli_csv/export.rb +14 -20
- data/lib/hammer_cli_csv/headpin_api.rb +0 -11
- data/lib/hammer_cli_csv/host_collections.rb +5 -23
- data/lib/hammer_cli_csv/host_groups.rb +115 -0
- data/lib/hammer_cli_csv/hosts.rb +32 -56
- data/lib/hammer_cli_csv/import.rb +46 -24
- data/lib/hammer_cli_csv/installation_medias.rb +4 -15
- data/lib/hammer_cli_csv/job_templates.rb +142 -0
- data/lib/hammer_cli_csv/lifecycle_environments.rb +5 -38
- data/lib/hammer_cli_csv/locations.rb +4 -33
- data/lib/hammer_cli_csv/operating_systems.rb +17 -33
- data/lib/hammer_cli_csv/organizations.rb +13 -41
- data/lib/hammer_cli_csv/partition_tables.rb +66 -54
- data/lib/hammer_cli_csv/products.rb +12 -24
- data/lib/hammer_cli_csv/provisioning_templates.rb +4 -18
- data/lib/hammer_cli_csv/puppet_environments.rb +36 -59
- data/lib/hammer_cli_csv/puppet_facts.rb +36 -58
- data/lib/hammer_cli_csv/puppet_reports.rb +4 -38
- data/lib/hammer_cli_csv/reports.rb +4 -15
- data/lib/hammer_cli_csv/roles.rb +4 -15
- data/lib/hammer_cli_csv/settings.rb +49 -0
- data/lib/hammer_cli_csv/smart_proxies.rb +9 -24
- data/lib/hammer_cli_csv/splice.rb +0 -12
- data/lib/hammer_cli_csv/subnets.rb +10 -21
- data/lib/hammer_cli_csv/subscriptions.rb +21 -24
- data/lib/hammer_cli_csv/sync_plans.rb +4 -19
- data/lib/hammer_cli_csv/users.rb +4 -15
- data/lib/hammer_cli_csv/version.rb +1 -12
- data/test/content_hosts_test.rb +1 -1
- data/test/content_views_test.rb +52 -0
- data/test/data/content-hosts.csv +1 -1
- data/test/data/content-view-filters.csv +1 -1
- data/test/data/content-views.csv +5 -5
- data/test/data/hosts.csv +2 -2
- data/test/data/operating-systems.csv +16 -16
- data/test/data/products.csv +1 -1
- data/test/data/settings.csv +5 -0
- data/test/import_test.rb +79 -0
- metadata +14 -18
@@ -1,32 +1,3 @@
|
|
1
|
-
# Copyright 2013-2014 Red Hat, Inc.
|
2
|
-
#
|
3
|
-
# This software is licensed to you under the GNU General Public
|
4
|
-
# License as published by the Free Software Foundation; either version
|
5
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
6
|
-
# There is NO WARRANTY for this software, express or implied,
|
7
|
-
# including the implied warranties of MERCHANTABILITY,
|
8
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
9
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
10
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
11
|
-
|
12
|
-
#
|
13
|
-
# -= Locations CSV =-
|
14
|
-
#
|
15
|
-
# Columns
|
16
|
-
# Name
|
17
|
-
# - Name of the location.
|
18
|
-
# - May contain '%d' which will be replaced with current iteration number of Count
|
19
|
-
# - eg. "location%d" -> "location1"
|
20
|
-
# Count
|
21
|
-
# - Number of times to iterate on this line of the CSV file
|
22
|
-
# Parent
|
23
|
-
# - Parent location
|
24
|
-
#
|
25
|
-
|
26
|
-
require 'hammer_cli'
|
27
|
-
require 'json'
|
28
|
-
require 'csv'
|
29
|
-
|
30
1
|
module HammerCLICsv
|
31
2
|
class CsvCommand
|
32
3
|
class LocationsCommand < BaseCommand
|
@@ -36,10 +7,10 @@ module HammerCLICsv
|
|
36
7
|
PARENT = 'Parent Location'
|
37
8
|
|
38
9
|
def export
|
39
|
-
CSV.open(
|
40
|
-
csv << [NAME,
|
10
|
+
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
|
11
|
+
csv << [NAME, PARENT]
|
41
12
|
@api.resource(:locations).call(:index, {:per_page => 999999})['results'].each do |location|
|
42
|
-
csv << [location['name'],
|
13
|
+
csv << [location['name'], '']
|
43
14
|
end
|
44
15
|
end
|
45
16
|
end
|
@@ -56,7 +27,7 @@ module HammerCLICsv
|
|
56
27
|
end
|
57
28
|
|
58
29
|
def create_locations_from_csv(line)
|
59
|
-
line[COUNT].
|
30
|
+
count(line[COUNT]).times do |number|
|
60
31
|
name = namify(line[NAME], number)
|
61
32
|
location_id = @existing[name]
|
62
33
|
if !location_id
|
@@ -1,14 +1,3 @@
|
|
1
|
-
# Copyright 2013-2014 Red Hat, Inc.
|
2
|
-
#
|
3
|
-
# This software is licensed to you under the GNU General Public
|
4
|
-
# License as published by the Free Software Foundation; either version
|
5
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
6
|
-
# There is NO WARRANTY for this software, express or implied,
|
7
|
-
# including the implied warranties of MERCHANTABILITY,
|
8
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
9
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
10
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
11
|
-
|
12
1
|
module HammerCLICsv
|
13
2
|
class CsvCommand
|
14
3
|
class OperatingSystemsCommand < BaseCommand
|
@@ -16,16 +5,16 @@ module HammerCLICsv
|
|
16
5
|
desc 'import or export operating systems'
|
17
6
|
|
18
7
|
FAMILY = 'Family'
|
8
|
+
DESCRIPTION = 'Description'
|
19
9
|
|
20
10
|
def export
|
21
|
-
CSV.open(
|
22
|
-
csv << [NAME,
|
11
|
+
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
|
12
|
+
csv << [NAME, DESCRIPTION, FAMILY]
|
23
13
|
@api.resource(:operatingsystems).call(:index, {:per_page => 999999})['results'].each do |operatingsystem|
|
24
14
|
name = build_os_name(operatingsystem['name'], operatingsystem['major'], operatingsystem['minor'])
|
25
|
-
count = 1
|
26
15
|
description = operatingsystem['description']
|
27
16
|
family = operatingsystem['family']
|
28
|
-
csv << [name,
|
17
|
+
csv << [name, description, family]
|
29
18
|
end
|
30
19
|
end
|
31
20
|
end
|
@@ -42,30 +31,25 @@ module HammerCLICsv
|
|
42
31
|
end
|
43
32
|
|
44
33
|
def create_operatingsystems_from_csv(line)
|
45
|
-
|
34
|
+
params = {
|
35
|
+
'operatingsystem' => {
|
36
|
+
'family' => line[FAMILY],
|
37
|
+
'description' => line[DESCRIPTION]
|
38
|
+
}
|
39
|
+
}
|
40
|
+
count(line[COUNT]).times do |number|
|
46
41
|
name = namify(line[NAME], number)
|
47
42
|
(osname, major, minor) = split_os_name(name)
|
43
|
+
params['operatingsystem']['name'] = osname
|
44
|
+
params['operatingsystem']['major'] = major
|
45
|
+
params['operatingsystem']['minor'] = minor
|
48
46
|
if !@existing.include? name
|
49
47
|
print "Creating operating system '#{name}'..." if option_verbose?
|
50
|
-
@api.resource(:operatingsystems).call(:create,
|
51
|
-
'operatingsystem' => {
|
52
|
-
'name' => osname,
|
53
|
-
'major' => major,
|
54
|
-
'minor' => minor,
|
55
|
-
'family' => line[FAMILY]
|
56
|
-
}
|
57
|
-
})
|
48
|
+
@api.resource(:operatingsystems).call(:create, params)
|
58
49
|
else
|
59
50
|
print "Updating operating system '#{name}'..." if option_verbose?
|
60
|
-
@
|
61
|
-
|
62
|
-
'operatingsystem' => {
|
63
|
-
'name' => osname,
|
64
|
-
'major' => major,
|
65
|
-
'minor' => minor,
|
66
|
-
'family' => line[FAMILY]
|
67
|
-
}
|
68
|
-
})
|
51
|
+
params['id'] = @existing[name]
|
52
|
+
@api.resource(:operatingsystems).call(:update, params)
|
69
53
|
end
|
70
54
|
print "done\n" if option_verbose?
|
71
55
|
end
|
@@ -1,36 +1,3 @@
|
|
1
|
-
# Copyright 2013-2014 Red Hat, Inc.
|
2
|
-
#
|
3
|
-
# This software is licensed to you under the GNU General Public
|
4
|
-
# License as published by the Free Software Foundation; either version
|
5
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
6
|
-
# There is NO WARRANTY for this software, express or implied,
|
7
|
-
# including the implied warranties of MERCHANTABILITY,
|
8
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
9
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
10
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
11
|
-
|
12
|
-
#
|
13
|
-
# -= Organizations CSV =-
|
14
|
-
#
|
15
|
-
# Columns
|
16
|
-
# Name
|
17
|
-
# - Name of the organization.
|
18
|
-
# - May contain '%d' which will be replaced with current iteration number of Count
|
19
|
-
# - eg. "organization%d" -> "organization1"
|
20
|
-
# Count
|
21
|
-
# - Number of times to iterate on this line of the CSV file
|
22
|
-
# Org Label
|
23
|
-
# - Label of the organization.
|
24
|
-
# - May contain '%d' which will be replaced with current iteration number of Count
|
25
|
-
# - eg. "organization%d" -> "organization1"
|
26
|
-
# Description
|
27
|
-
#
|
28
|
-
|
29
|
-
require 'hammer_cli'
|
30
|
-
#require 'net/http'
|
31
|
-
require 'json'
|
32
|
-
require 'csv'
|
33
|
-
|
34
1
|
module HammerCLICsv
|
35
2
|
class CsvCommand
|
36
3
|
class OrganizationsCommand < BaseCommand
|
@@ -41,16 +8,18 @@ module HammerCLICsv
|
|
41
8
|
DESCRIPTION = 'Description'
|
42
9
|
|
43
10
|
def export
|
44
|
-
CSV.open(
|
45
|
-
csv << [NAME,
|
11
|
+
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
|
12
|
+
csv << [NAME, LABEL, DESCRIPTION]
|
46
13
|
|
47
14
|
if @server_status['release'] == 'Headpin'
|
48
15
|
@headpin.get(:organizations).each do |organization|
|
49
|
-
|
16
|
+
next if option_organization && organization['name'] != option_organization
|
17
|
+
csv << [organization['name'], organization['label'], organization['description']]
|
50
18
|
end
|
51
19
|
else
|
52
20
|
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
|
53
|
-
|
21
|
+
next if option_organization && organization['name'] != option_organization
|
22
|
+
csv << [organization['name'], organization['label'], organization['description']]
|
54
23
|
end
|
55
24
|
end
|
56
25
|
end
|
@@ -68,10 +37,12 @@ module HammerCLICsv
|
|
68
37
|
end
|
69
38
|
|
70
39
|
def create_organizations_from_csv(line)
|
71
|
-
line[COUNT].
|
40
|
+
count(line[COUNT]).times do |number|
|
72
41
|
name = namify(line[NAME], number)
|
42
|
+
return if option_organization && name != option_organization
|
73
43
|
label = namify(line[LABEL], number)
|
74
|
-
|
44
|
+
organization_id = @existing[name]
|
45
|
+
if organization_id.nil?
|
75
46
|
print "Creating organization '#{name}'... " if option_verbose?
|
76
47
|
@api.resource(:organizations).call(:create, {
|
77
48
|
'name' => name,
|
@@ -83,10 +54,11 @@ module HammerCLICsv
|
|
83
54
|
})
|
84
55
|
else
|
85
56
|
print "Updating organization '#{name}'... " if option_verbose?
|
57
|
+
organization = @api.resource(:organizations).call(:show, {'id' => organization_id})
|
86
58
|
@api.resource(:organizations).call(:update, {
|
87
|
-
'id' =>
|
59
|
+
'id' => organization_id,
|
88
60
|
'organization' => {
|
89
|
-
'id' =>
|
61
|
+
'id' => organization_id,
|
90
62
|
'description' => line[DESCRIPTION]
|
91
63
|
}
|
92
64
|
})
|
@@ -1,50 +1,52 @@
|
|
1
|
-
# Copyright 2013-2014 Red Hat, Inc.
|
2
|
-
#
|
3
|
-
# This software is licensed to you under the GNU General Public
|
4
|
-
# License as published by the Free Software Foundation; either version
|
5
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
6
|
-
# There is NO WARRANTY for this software, express or implied,
|
7
|
-
# including the implied warranties of MERCHANTABILITY,
|
8
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
9
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
10
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
11
|
-
|
12
|
-
#
|
13
|
-
# -= Partition Tables CSV =-
|
14
|
-
#
|
15
|
-
# Columns
|
16
|
-
# Name
|
17
|
-
# - Partition table name
|
18
|
-
# - May contain '%d' which will be replaced with current iteration number of Count
|
19
|
-
# - eg. "os%d" -> "os1"
|
20
|
-
# Count
|
21
|
-
# - Number of times to iterate on this line of the CSV file
|
22
|
-
#
|
23
|
-
|
24
|
-
require 'hammer_cli'
|
25
|
-
require 'json'
|
26
|
-
require 'csv'
|
27
|
-
|
28
1
|
module HammerCLICsv
|
29
2
|
class CsvCommand
|
30
3
|
class PartitionTablesCommand < BaseCommand
|
31
4
|
command_name 'partition-tables'
|
32
5
|
desc 'import or export partition tables'
|
33
6
|
|
7
|
+
ORGANIZATIONS = 'Organizations'
|
8
|
+
LOCATIONS = 'Locations'
|
34
9
|
OSFAMILY = 'OS Family'
|
35
10
|
OPERATINGSYSTEMS = 'Operating Systems'
|
36
11
|
LAYOUT = 'Layout'
|
37
12
|
|
38
13
|
def export
|
39
|
-
|
40
|
-
|
14
|
+
# TODO: partition-tables do not return their organizations or locations
|
15
|
+
# http://projects.theforeman.org/issues/11175
|
16
|
+
organizations_map = {}
|
17
|
+
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
|
18
|
+
ptables = @api.resource(:ptables).call(:index, {'organization_id' => organization['id']})['results'].each do |ptable|
|
19
|
+
organizations_map[ptable['name']] ||= []
|
20
|
+
organizations_map[ptable['name']] << organization['name']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
locations_map = {}
|
24
|
+
@api.resource(:locations).call(:index, {:per_page => 999999})['results'].each do |location|
|
25
|
+
ptables = @api.resource(:ptables).call(:index, {'location_id' => location['id']})['results'].each do |ptable|
|
26
|
+
locations_map[ptable['name']] ||= []
|
27
|
+
locations_map[ptable['name']] << location['name']
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
|
32
|
+
csv << [NAME, ORGANIZATIONS, LOCATIONS, OSFAMILY, OPERATINGSYSTEMS, LAYOUT]
|
41
33
|
@api.resource(:ptables).call(:index, {:per_page => 999999})['results'].each do |ptable|
|
42
34
|
ptable = @api.resource(:ptables).call(:show, {'id' => ptable['id']})
|
43
35
|
name = ptable['name']
|
44
|
-
count = 1
|
45
36
|
osfamily = ptable['os_family']
|
46
37
|
layout = ptable['layout']
|
47
|
-
|
38
|
+
operatingsystems = export_column(ptable, 'operatingsystems', 'title')
|
39
|
+
|
40
|
+
organizations = CSV.generate do |column|
|
41
|
+
column << organizations_map[name] if organizations_map[name]
|
42
|
+
end
|
43
|
+
organizations.delete!("\n")
|
44
|
+
locations = CSV.generate do |column|
|
45
|
+
column << locations_map[name] if locations_map[name]
|
46
|
+
end
|
47
|
+
locations.delete!("\n")
|
48
|
+
|
49
|
+
csv << [name, organizations, locations, osfamily, operatingsystems, layout]
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
@@ -61,32 +63,42 @@ module HammerCLICsv
|
|
61
63
|
end
|
62
64
|
|
63
65
|
def create_ptables_from_csv(line)
|
64
|
-
|
66
|
+
params = {
|
67
|
+
'ptable' => {
|
68
|
+
'os_family' => line[OSFAMILY],
|
69
|
+
'layout' => line[LAYOUT]
|
70
|
+
}
|
71
|
+
}
|
72
|
+
# Check for backwards compatibility
|
73
|
+
if apipie_check_param(:ptable, :create, 'ptable[operatingsystem_ids]')
|
74
|
+
operatingsystems = collect_column(line[OPERATINGSYSTEMS]) do |operatingsystem|
|
75
|
+
foreman_operatingsystem(:name => operatingsystem)
|
76
|
+
end
|
77
|
+
params['ptable']['operatingsystem_ids'] = operatingsystems
|
78
|
+
end
|
79
|
+
if apipie_check_param(:ptable, :create, 'ptable[organization_ids]')
|
80
|
+
organizations = collect_column(line[ORGANIZATIONS]) do |organization|
|
81
|
+
foreman_organization(:name => organization)
|
82
|
+
end
|
83
|
+
params['ptable']['organization_ids'] = organizations
|
84
|
+
end
|
85
|
+
if apipie_check_param(:ptable, :create, 'ptable[location_ids]')
|
86
|
+
locations = collect_column(line[LOCATIONS]) do |location|
|
87
|
+
foreman_location(:name => location)
|
88
|
+
end
|
89
|
+
params['ptable']['location_ids'] = locations
|
90
|
+
end
|
91
|
+
|
92
|
+
count(line[COUNT]).times do |number|
|
65
93
|
name = namify(line[NAME], number)
|
66
|
-
|
67
|
-
foreman_operatingsystem(:name => operatingsystem_name)
|
68
|
-
end if line[OPERATINGSYSTEMS]
|
94
|
+
params['ptable']['name'] = name
|
69
95
|
if !@existing.include? name
|
70
|
-
print "Creating
|
71
|
-
@api.resource(:ptables).call(:create,
|
72
|
-
'ptable' => {
|
73
|
-
'name' => name,
|
74
|
-
'os_family' => line[OSFAMILY],
|
75
|
-
'operatingsystem_ids' => operatingsystem_ids,
|
76
|
-
'layout' => line[LAYOUT]
|
77
|
-
}
|
78
|
-
})
|
96
|
+
print "Creating partition-table '#{name}'... " if option_verbose?
|
97
|
+
@api.resource(:ptables).call(:create, params)
|
79
98
|
else
|
80
|
-
print "Updating
|
81
|
-
@
|
82
|
-
|
83
|
-
'ptable' => {
|
84
|
-
'name' => name,
|
85
|
-
'os_family' => line[OSFAMILY],
|
86
|
-
'operatingsystem_ids' => operatingsystem_ids,
|
87
|
-
'layout' => line[LAYOUT]
|
88
|
-
}
|
89
|
-
})
|
99
|
+
print "Updating partition-table '#{name}'..." if option_verbose?
|
100
|
+
params['id'] = @existing[name]
|
101
|
+
@api.resource(:ptables).call(:update, params)
|
90
102
|
end
|
91
103
|
print "done\n" if option_verbose?
|
92
104
|
end
|
@@ -1,23 +1,10 @@
|
|
1
|
-
# Copyright 2013-2014 Red Hat, Inc.
|
2
|
-
#
|
3
|
-
# This software is licensed to you under the GNU General Public
|
4
|
-
# License as published by the Free Software Foundation; either version
|
5
|
-
# 2 of the License (GPLv2) or (at your option) any later version.
|
6
|
-
# There is NO WARRANTY for this software, express or implied,
|
7
|
-
# including the implied warranties of MERCHANTABILITY,
|
8
|
-
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
|
9
|
-
# have received a copy of GPLv2 along with this software; if not, see
|
10
|
-
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
|
11
|
-
|
12
1
|
module HammerCLICsv
|
13
2
|
class CsvCommand
|
14
3
|
class ProductsCommand < BaseCommand
|
15
4
|
command_name 'products'
|
16
5
|
desc _('import or export products')
|
17
6
|
|
18
|
-
option %w(--
|
19
|
-
option %w(--sync), 'true|false', _('Sync product repositories (default true)')
|
20
|
-
|
7
|
+
option %w(--[no-]sync), :flag, _('Sync product repositories (default true)'), :default => true
|
21
8
|
LABEL = 'Label'
|
22
9
|
ORGANIZATION = 'Organization'
|
23
10
|
REPOSITORY = 'Repository'
|
@@ -26,8 +13,8 @@ module HammerCLICsv
|
|
26
13
|
DESCRIPTION = 'Description'
|
27
14
|
|
28
15
|
def export
|
29
|
-
CSV.open(
|
30
|
-
csv << [NAME,
|
16
|
+
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
|
17
|
+
csv << [NAME, LABEL, ORGANIZATION, REPOSITORY, REPOSITORY_TYPE, REPOSITORY_URL]
|
31
18
|
@api.resource(:organizations).call(:index, {
|
32
19
|
:per_page => 999999
|
33
20
|
})['results'].each do |organization|
|
@@ -41,9 +28,10 @@ module HammerCLICsv
|
|
41
28
|
'product_id' => product['id'],
|
42
29
|
'organization_id' => organization['id']
|
43
30
|
})['results'].each do |repository|
|
31
|
+
repository = @api.resource(:repositories).call(:show, {:id => repository['id']})
|
44
32
|
repository_type = repository['product_type'] == 'custom' ? 'Custom' : 'Red Hat'
|
45
33
|
repository_type += " #{repository['content_type'].capitalize}"
|
46
|
-
csv << [product['name'],
|
34
|
+
csv << [product['name'], product['label'], organization['name'],
|
47
35
|
repository['name'], repository_type, repository['url']]
|
48
36
|
end
|
49
37
|
end
|
@@ -87,7 +75,7 @@ module HammerCLICsv
|
|
87
75
|
end
|
88
76
|
end
|
89
77
|
|
90
|
-
line[COUNT].
|
78
|
+
count(line[COUNT]).times do |number|
|
91
79
|
name = namify(line[NAME], number)
|
92
80
|
product_id = @existing_products[line[ORGANIZATION]][name]
|
93
81
|
if product_id.nil?
|
@@ -140,7 +128,7 @@ module HammerCLICsv
|
|
140
128
|
@existing_repositories[line[ORGANIZATION] + name][line[LABEL]] = repository
|
141
129
|
end
|
142
130
|
|
143
|
-
sync_repository(line, repository)
|
131
|
+
sync_repository(line, name, repository)
|
144
132
|
puts _('done') if option_verbose?
|
145
133
|
end
|
146
134
|
|
@@ -161,14 +149,14 @@ module HammerCLICsv
|
|
161
149
|
end
|
162
150
|
end
|
163
151
|
|
164
|
-
def sync_repository(line, repository)
|
165
|
-
if
|
166
|
-
|
152
|
+
def sync_repository(line, name, repository)
|
153
|
+
if (HammerCLI::Settings.get(:csv, :products_sync) == true || HammerCLI::Settings.get(:csv, :products_sync).nil?) &&
|
154
|
+
option_sync?
|
167
155
|
if option_verbose?
|
168
156
|
print _("syncing repository '%{repository_name}' in product '%{name}'...") %
|
169
|
-
{:repository_name =>
|
157
|
+
{:repository_name => repository['name'], :name => name}
|
170
158
|
end
|
171
|
-
if repository['
|
159
|
+
if repository['last_sync']
|
172
160
|
print _("previously synced, skipping...") if option_verbose?
|
173
161
|
else
|
174
162
|
exec_sync_repository(line, repository)
|