hammer_cli_csv 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzY3ZmEyZWZkYzk3MTA0NDAzMDNkNzIxYTRhNDc5ZmJhYWVjNDQ5MA==
4
+ MjA5NThhYWI0N2FhOGQ1OGQzMzhhMjVkOTkzZjhkZmRiNmU4Y2Q4MQ==
5
5
  data.tar.gz: !binary |-
6
- MjBjNWJhOTBhOTE1YTU2MDI3YTAwYTRhMWI4OWJmNDQxMjY5ZmI0OQ==
6
+ MGE4ZDU4M2ZlOGFkNTdkZjI1YmMxZWFmN2YyZWQ4NjAzMTlhODc5Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWJjZDUxZDZiZjMwOTZiN2JlOWYwZmI0MTk0YTQwN2Y2OTYxMTdlYzc3Njlj
10
- ZTkyNThkZjJiMzM0OTMzYTgzYWZkNjBhNDk1Y2MyMmY0M2U2MzZjYTYwMzY3
11
- YjY0NzViZWZhNTAyNDY1NzBlNWUxYWZkMDA5MjgyMWFlZGRmYTE=
9
+ OWNhYjM3ODA5Mjc1MWJhM2E4ZGMzZWQyMzNjYzFiMzhjZGUxMjFmMGVlN2Vj
10
+ NWZlNjllYzRjYzRmMDY1YmMxNjAxYjk0ZjBkYzAzZWI3MjU2NzkyZDc4NTQw
11
+ MTczZjA0N2NiNDdlMWQzMGEwMjRhZTg5NTFhMDk4ZGZjYzY2ZGY=
12
12
  data.tar.gz: !binary |-
13
- Njg1OTg0NWMxNzRiODNkYzM4NDdhMDcyMmIzMTE2YzliNzc5ZTE0YTE3MWU3
14
- ZjNhZGUyYTk0YjBlZTkzMTg2MzhmYjMzMDQwNDY1MzhmNWYxOWU5NDBiZjBl
15
- MWNlYWI0MjA0MzRjYmVkNmYxZWIxZTM4MjE3OWMyOGQ1ZDIwNmQ=
13
+ YzA0YzQ0NDY4ZGE4NWU3N2I0N2Y5MzYwNGYxNTViOGY2Y2RhNTZjNTViOWM5
14
+ YzFiYzU2YjFiODU0OWQyMTllMTg1OGJkN2E2NTY0MmU1NWI0YjU4MzYwMDM1
15
+ MmY0YTIwN2Q5MWJjZTM3OWIyYzc2MDg4MTdkNzE1NTMzYTdmNTY=
@@ -27,11 +27,11 @@ module HammerCLICsv
27
27
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
28
28
  csv << [NAME, COUNT, ORGANIZATION, DESCRIPTION, LIMIT, ENVIRONMENT, CONTENTVIEW,
29
29
  SYSTEMGROUPS, SUBSCRIPTIONS]
30
- @api.resource(:organizations)
30
+ @api.resource(:organizations)\
31
31
  .call(:index, {
32
32
  :per_page => 999999
33
33
  })['results'].each do |organization|
34
- @api.resource(:activation_keys)
34
+ @api.resource(:activation_keys)\
35
35
  .call(:index, {
36
36
  'per_page' => 999999,
37
37
  'organization_id' => organization['id']
@@ -71,7 +71,7 @@ module HammerCLICsv
71
71
  def create_activationkeys_from_csv(line)
72
72
  if !@existing[line[ORGANIZATION]]
73
73
  @existing[line[ORGANIZATION]] = {}
74
- @api.resource(:activation_keys)
74
+ @api.resource(:activation_keys)\
75
75
  .call(:index, {
76
76
  'per_page' => 999999,
77
77
  'organization_id' => foreman_organization(:name => line[ORGANIZATION])
@@ -85,7 +85,7 @@ module HammerCLICsv
85
85
 
86
86
  if !@existing[line[ORGANIZATION]].include? name
87
87
  print "Creating activation key '#{name}'..." if option_verbose?
88
- activationkey = @api.resource(:activation_keys)
88
+ activationkey = @api.resource(:activation_keys)\
89
89
  .call(:create, {
90
90
  'name' => name,
91
91
  'environment_id' => lifecycle_environment(line[ORGANIZATION],
@@ -98,7 +98,7 @@ module HammerCLICsv
98
98
  @existing[line[ORGANIZATION]][activationkey['name']] = activationkey['id']
99
99
  else
100
100
  print "Updating activation key '#{name}'..." if option_verbose?
101
- activationkey = @api.resource(:activation_keys)
101
+ activationkey = @api.resource(:activation_keys)\
102
102
  .call(:update, {
103
103
  'id' => @existing[line[ORGANIZATION]][name],
104
104
  'name' => name,
@@ -122,7 +122,7 @@ module HammerCLICsv
122
122
  if line[SYSTEMGROUPS] && line[SYSTEMGROUPS] != ''
123
123
  # TODO: note that existing system groups are not removed
124
124
  CSV.parse_line(line[SYSTEMGROUPS], {:skip_blanks => true}).each do |name|
125
- @api.resource(:host_collections)
125
+ @api.resource(:host_collections)\
126
126
  .call(:add_activation_keys, {
127
127
  'id' => katello_hostcollection(line[ORGANIZATION], :name => name),
128
128
  'activation_key_ids' => [activationkey['id']]
@@ -142,19 +142,19 @@ module HammerCLICsv
142
142
  end
143
143
 
144
144
  # TODO: should there be a destroy_all similar to systems?
145
- @api.resource(:subscriptions)
145
+ @api.resource(:subscriptions)\
146
146
  .call(:index, {
147
147
  'per_page' => 999999,
148
148
  'activation_key_id' => activationkey['id']
149
149
  })['results'].each do |subscription|
150
- @api.resource(:subscriptions)
150
+ @api.resource(:subscriptions)\
151
151
  .call(:destroy, {
152
152
  'id' => subscription['id'],
153
153
  'activation_key_id' => activationkey['id']
154
154
  })
155
155
  end
156
156
 
157
- @api.resource(:subscriptions)
157
+ @api.resource(:subscriptions)\
158
158
  .call(:create, {
159
159
  'activation_key_id' => activationkey['id'],
160
160
  'subscriptions' => subscriptions
@@ -448,7 +448,7 @@ module HammerCLICsv
448
448
  return nil if options[:name].nil? || options[:name].empty?
449
449
  options[:id] = @lifecycle_environments[organization][options[:name]]
450
450
  if !options[:id]
451
- @api.resource(:lifecycle_environments)
451
+ @api.resource(:lifecycle_environments)\
452
452
  .call(:index, {
453
453
  :per_page => 999999,
454
454
  'organization_id' => foreman_organization(:name => organization)
@@ -515,7 +515,7 @@ module HammerCLICsv
515
515
  return nil if options[:name].nil? || options[:name].empty?
516
516
  options[:id] = @repositories[organization][options[:name]]
517
517
  if !options[:id]
518
- @api.resource(:repositories)
518
+ @api.resource(:repositories)\
519
519
  .call(:index, {
520
520
  :per_page => 999999,
521
521
  'organization_id' => foreman_organization(:name => organization)
@@ -670,7 +670,7 @@ module HammerCLICsv
670
670
  end
671
671
  end
672
672
  associations[organization] += [id] if !associations[organization].include? id
673
- @api.resource(:organizations)
673
+ @api.resource(:organizations)\
674
674
  .call(:update, {
675
675
  'id' => organization_id,
676
676
  'organization' => {
@@ -693,7 +693,7 @@ module HammerCLICsv
693
693
  end
694
694
  associations[location] += [id] if !associations[location].include? id
695
695
 
696
- @api.resource(:locations)
696
+ @api.resource(:locations)\
697
697
  .call(:update, {
698
698
  'id' => location_id,
699
699
  'location' => {
@@ -61,7 +61,7 @@ module HammerCLICsv
61
61
  name = namify(line[NAME], number)
62
62
  if !@existing.include? name
63
63
  print "Creating compute profile '#{name}'..." if option_verbose?
64
- id = @api.resource(:compute_profiles)
64
+ id = @api.resource(:compute_profiles)\
65
65
  .call(:create, {
66
66
  'compute_profile' => {
67
67
  'name' => name,
@@ -70,7 +70,7 @@ module HammerCLICsv
70
70
  })['id']
71
71
  else
72
72
  print "Updating compute profile '#{name}'..." if option_verbose?
73
- id = @api.resource(:compute_profiles)
73
+ id = @api.resource(:compute_profiles)\
74
74
  .call(:update, {
75
75
  'id' => @existing[name],
76
76
  'compute_profile' => {
@@ -59,7 +59,7 @@ module HammerCLICsv
59
59
  name = namify(line[NAME], number)
60
60
  if !@existing.include? name
61
61
  print "Creating compute resource '#{name}'..." if option_verbose?
62
- id = @api.resource(:compute_resources)
62
+ id = @api.resource(:compute_resources)\
63
63
  .call(:create, {
64
64
  'compute_resource' => {
65
65
  'name' => name,
@@ -68,7 +68,7 @@ module HammerCLICsv
68
68
  })['id']
69
69
  else
70
70
  print "Updating compute resource '#{name}'..." if option_verbose?
71
- id = @api.resource(:compute_resources)
71
+ id = @api.resource(:compute_resources)\
72
72
  .call(:update, {
73
73
  'id' => @existing[name],
74
74
  'compute_resource' => {
@@ -153,14 +153,14 @@ module HammerCLICsv
153
153
  end
154
154
 
155
155
  def export_foretello(csv)
156
- @api.resource(:organizations)
156
+ @api.resource(:organizations)\
157
157
  .call(:index, {:per_page => 999999})['results'].each do |organization|
158
- @api.resource(:systems)
158
+ @api.resource(:systems)\
159
159
  .call(:index, {
160
160
  'per_page' => 999999,
161
161
  'organization_id' => foreman_organization(:name => organization['name'])
162
162
  })['results'].each do |system|
163
- system = @api.resource(:systems)
163
+ system = @api.resource(:systems)\
164
164
  .call(:show, {
165
165
  'id' => system['uuid'],
166
166
  'fields' => 'full'
@@ -193,7 +193,7 @@ module HammerCLICsv
193
193
  end
194
194
  products.delete!("\n")
195
195
  subscriptions = CSV.generate do |column|
196
- column << @api.resource(:subscriptions)
196
+ column << @api.resource(:subscriptions)\
197
197
  .call(:index, {
198
198
  'system_id' => system['uuid']
199
199
  })['results'].collect do |subscription|
@@ -217,7 +217,7 @@ module HammerCLICsv
217
217
 
218
218
  print 'Updating host and guest associations...' if option_verbose?
219
219
  @host_guests.each do |host_id, guest_ids|
220
- @api.resource(:systems)
220
+ @api.resource(:systems)\
221
221
  .call(:update, {
222
222
  'id' => host_id,
223
223
  'guest_ids' => guest_ids
@@ -232,13 +232,13 @@ module HammerCLICsv
232
232
  # Fetching all content hosts is too slow and times out due to the complexity of the data
233
233
  # rendered in the json.
234
234
  # http://projects.theforeman.org/issues/6307
235
- total = @api.resource(:systems)
235
+ total = @api.resource(:systems)\
236
236
  .call(:index, {
237
237
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
238
238
  'per_page' => 1
239
239
  })['total'].to_i
240
240
  (total / 20 + 2).to_i.times do |page|
241
- @api.resource(:systems)
241
+ @api.resource(:systems)\
242
242
  .call(:index, {
243
243
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
244
244
  'page' => page,
@@ -259,7 +259,7 @@ module HammerCLICsv
259
259
 
260
260
  if !@existing[line[ORGANIZATION]].include? name
261
261
  print "Creating system '#{name}'..." if option_verbose?
262
- system_id = @api.resource(:systems)
262
+ system_id = @api.resource(:systems)\
263
263
  .call(:create, {
264
264
  'name' => name,
265
265
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
@@ -271,7 +271,7 @@ module HammerCLICsv
271
271
  @existing[line[ORGANIZATION]][name] = system_id
272
272
  else
273
273
  print "Updating system '#{name}'..." if option_verbose?
274
- system_id = @api.resource(:systems)
274
+ system_id = @api.resource(:systems)\
275
275
  .call(:update, {
276
276
  'id' => @existing[line[ORGANIZATION]][name],
277
277
  'system' => {
@@ -323,7 +323,7 @@ module HammerCLICsv
323
323
  def set_host_collections(system_id, line)
324
324
  return nil if !line[HOSTCOLLECTIONS]
325
325
  CSV.parse_line(line[HOSTCOLLECTIONS]).each do |hostcollection_name|
326
- @api.resource(:host_collections)
326
+ @api.resource(:host_collections)\
327
327
  .call(:add_systems, {
328
328
  'id' => katello_hostcollection(line[ORGANIZATION], :name => hostcollection_name),
329
329
  'system_ids' => [system_id]
@@ -41,7 +41,7 @@ module HammerCLICsv
41
41
  @existing_filters[line[ORGANIZATION]] ||= {}
42
42
  if !@existing_filters[line[ORGANIZATION]][line[CONTENTVIEW]]
43
43
  @existing_filters[line[ORGANIZATION]][line[CONTENTVIEW]] ||= {}
44
- @api.resource(:content_view_filters)
44
+ @api.resource(:content_view_filters)\
45
45
  .call(:index, {
46
46
  'per_page' => 999999,
47
47
  'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW])
@@ -60,7 +60,7 @@ module HammerCLICsv
60
60
  filter_id = @existing_filters[line[ORGANIZATION]][line[CONTENTVIEW]][name]
61
61
  if !filter_id
62
62
  print "Creating filter '#{name}' for content view filter '#{line[CONTENTVIEW]}'..." if option_verbose?
63
- filter_id = @api.resource(:content_view_filters)
63
+ filter_id = @api.resource(:content_view_filters)\
64
64
  .call(:create, {
65
65
  'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]),
66
66
  'name' => name,
@@ -72,7 +72,7 @@ module HammerCLICsv
72
72
  @existing_filters[line[ORGANIZATION]][name] = filter_id
73
73
  else
74
74
  print "Updating filter '#{name}' for content view filter '#{line[CONTENTVIEW]}'..." if option_verbose?
75
- @api.resource(:content_view_filters)
75
+ @api.resource(:content_view_filters)\
76
76
  .call(:update, {
77
77
  'id' => filter_id,
78
78
  'description' => line[DESCRIPTION],
@@ -85,7 +85,7 @@ module HammerCLICsv
85
85
  @existing_rules ||= {}
86
86
  @existing_rules[line[ORGANIZATION]] ||= {}
87
87
  @existing_rules[line[ORGANIZATION]][line[CONTENTVIEW]] ||= {}
88
- @api.resource(:content_view_filter_rules)
88
+ @api.resource(:content_view_filter_rules)\
89
89
  .call(:index, {
90
90
  'per_page' => 999999,
91
91
  'content_view_filter_id' => filter_id
@@ -35,7 +35,7 @@ module HammerCLICsv
35
35
  def create_contentviews_from_csv(line)
36
36
  if !@existing_contentviews[line[ORGANIZATION]]
37
37
  @existing_contentviews[line[ORGANIZATION]] ||= {}
38
- @api.resource(:content_views)
38
+ @api.resource(:content_views)\
39
39
  .call(:index, {
40
40
  'per_page' => 999999,
41
41
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
@@ -56,7 +56,7 @@ module HammerCLICsv
56
56
  contentview_id = @existing_contentviews[line[ORGANIZATION]][name]
57
57
  if !contentview_id
58
58
  print "Creating content view '#{name}'..." if option_verbose?
59
- contentview_id = @api.resource(:content_views)
59
+ contentview_id = @api.resource(:content_views)\
60
60
  .call(:create, {
61
61
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
62
62
  'name' => name,
@@ -68,7 +68,7 @@ module HammerCLICsv
68
68
  @existing_contentviews[line[ORGANIZATION]][name] = contentview_id
69
69
  else
70
70
  print "Updating content view '#{name}'..." if option_verbose?
71
- @api.resource(:content_views)
71
+ @api.resource(:content_views)\
72
72
  .call(:update, {
73
73
  'id' => contentview_id,
74
74
  'description' => line[DESCRIPTION],
@@ -41,11 +41,11 @@ module HammerCLICsv
41
41
  def export
42
42
  CSV.open(option_csv_file, 'wb') do |csv|
43
43
  csv << [NAME, COUNT, ORGANIZATION, LIMIT, DESCRIPTION]
44
- @api.resource(:organizations)
44
+ @api.resource(:organizations)\
45
45
  .call(:index, {
46
46
  'per_page' => 999999
47
47
  })['results'].each do |organization|
48
- @api.resource(:host_collections)
48
+ @api.resource(:host_collections)\
49
49
  .call(:index, {
50
50
  'organization_id' => organization['id']
51
51
  }).each do |hostcollection|
@@ -69,7 +69,7 @@ module HammerCLICsv
69
69
  def create_hostcollections_from_csv(line)
70
70
  if !@existing[line[ORGANIZATION]]
71
71
  @existing[line[ORGANIZATION]] = {}
72
- @api.resource(:host_collections)
72
+ @api.resource(:host_collections)\
73
73
  .call(:index, {
74
74
  'per_page' => 999999,
75
75
  'organization_id' => foreman_organization(:name => line[ORGANIZATION])
@@ -82,7 +82,7 @@ module HammerCLICsv
82
82
  name = namify(line[NAME], number)
83
83
  if !@existing[line[ORGANIZATION]].include? name
84
84
  print "Creating system group '#{name}'..." if option_verbose?
85
- @api.resource(:host_collections)
85
+ @api.resource(:host_collections)\
86
86
  .call(:create, {
87
87
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
88
88
  'name' => name,
@@ -91,7 +91,7 @@ module HammerCLICsv
91
91
  })
92
92
  else
93
93
  print "Updating system group '#{name}'..." if option_verbose?
94
- @api.resource(:host_collections)
94
+ @api.resource(:host_collections)\
95
95
  .call(:update, {
96
96
  'organization_id' => line[ORGANIZATION],
97
97
  'id' => @existing[line[ORGANIZATION]][name],
@@ -38,11 +38,11 @@ module HammerCLICsv
38
38
  def export
39
39
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
40
40
  csv << [NAME, COUNT, ORGANIZATION, PRIORENVIRONMENT, DESCRIPTION]
41
- @api.resource(:organizations)
41
+ @api.resource(:organizations)\
42
42
  .call(:index, {
43
43
  'per_page' => 999999
44
44
  })['results'].each do |organization|
45
- @api.resource(:lifecycle_environments)
45
+ @api.resource(:lifecycle_environments)\
46
46
  .call(:index, {
47
47
  'per_page' => 999999,
48
48
  'organization_id' => organization['id']
@@ -61,11 +61,11 @@ module HammerCLICsv
61
61
 
62
62
  def import
63
63
  @existing = {}
64
- @api.resource(:organizations)
64
+ @api.resource(:organizations)\
65
65
  .call(:index, {
66
66
  'per_page' => 999999
67
67
  })['results'].each do |organization|
68
- @api.resource(:lifecycle_environments)
68
+ @api.resource(:lifecycle_environments)\
69
69
  .call(:index, {
70
70
  'per_page' => 999999,
71
71
  'organization_id' => foreman_organization(:name => organization['name'])
@@ -87,7 +87,7 @@ module HammerCLICsv
87
87
  raise "Organization '#{line[ORGANIZATION]}' does not exist" if !@existing.include? line[ORGANIZATION]
88
88
  if !@existing[line[ORGANIZATION]].include? name
89
89
  print "Creating environment '#{name}'..." if option_verbose?
90
- @api.resource(:lifecycle_environments)
90
+ @api.resource(:lifecycle_environments)\
91
91
  .call(:create, {
92
92
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
93
93
  'name' => name,
@@ -96,7 +96,7 @@ module HammerCLICsv
96
96
  })
97
97
  else
98
98
  print "Updating environment '#{name}'..." if option_verbose?
99
- @api.resource(:lifecycle_environments)
99
+ @api.resource(:lifecycle_environments)\
100
100
  .call(:update, {
101
101
  'id' => @existing[line[ORGANIZATION]][name],
102
102
  'name' => name,
@@ -25,11 +25,11 @@ module HammerCLICsv
25
25
  def export
26
26
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
27
27
  csv << [NAME, COUNT, LABEL, ORGANIZATION, REPOSITORY, REPOSITORY_TYPE, REPOSITORY_URL]
28
- @api.resource(:organizations)
28
+ @api.resource(:organizations)\
29
29
  .call(:index, {
30
30
  :per_page => 999999
31
31
  })['results'].each do |organization|
32
- @api.resource(:products)
32
+ @api.resource(:products)\
33
33
  .call(:index, {
34
34
  'per_page' => 999999,
35
35
  'enabled' => true,
@@ -58,7 +58,7 @@ module HammerCLICsv
58
58
  def create_products_from_csv(line)
59
59
  if !@existing_products[line[ORGANIZATION]]
60
60
  @existing_products[line[ORGANIZATION]] = {}
61
- @api.resource(:products)
61
+ @api.resource(:products)\
62
62
  .call(:index, {
63
63
  'per_page' => 999999,
64
64
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
@@ -66,7 +66,7 @@ module HammerCLICsv
66
66
  })['results'].each do |product|
67
67
  @existing_products[line[ORGANIZATION]][product['name']] = product['id']
68
68
 
69
- @api.resource(:repositories)
69
+ @api.resource(:repositories)\
70
70
  .call(:index, {
71
71
  'page_size' => 999999, 'paged' => true,
72
72
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
@@ -89,7 +89,7 @@ module HammerCLICsv
89
89
  raise "Red Hat product '#{name}' does not exist in '#{line[ORGANIZATION]}'"
90
90
  end
91
91
 
92
- product_id = @api.resource(:products)
92
+ product_id = @api.resource(:products)\
93
93
  .call(:create, {
94
94
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
95
95
  'name' => name
@@ -105,7 +105,7 @@ module HammerCLICsv
105
105
  repository_name = namify(line[REPOSITORY], number)
106
106
 
107
107
  if !@existing_repositories[line[ORGANIZATION] + name][repository_name]
108
- @api.resource(:repositories)
108
+ @api.resource(:repositories)\
109
109
  .call(:index, {
110
110
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
111
111
  'library' => true,
@@ -121,7 +121,7 @@ module HammerCLICsv
121
121
  raise "Red Hat product '#{name}' does not have repository '#{repository_name}'" if line[REPOSITORY_TYPE] =~ /Red Hat/
122
122
 
123
123
  print "Creating repository '#{repository_name}' in product '#{name}'..." if option_verbose?
124
- repository = @api.resource(:repositories)
124
+ repository = @api.resource(:repositories)\
125
125
  .call(:create, {
126
126
  'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
127
127
  'name' => repository_name,
@@ -23,7 +23,7 @@ module HammerCLICsv
23
23
  def export
24
24
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
25
25
  csv << [NAME, COUNT, ORGANIZATIONS, LOCATIONS, KIND, SOURCE]
26
- @api.resource(:config_templates)
26
+ @api.resource(:config_templates)\
27
27
  .call(:index, {
28
28
  :per_page => 999999
29
29
  })['results'].each do |template_id|
@@ -42,7 +42,7 @@ module HammerCLICsv
42
42
 
43
43
  def import
44
44
  @existing = {}
45
- @api.resource(:config_templates)
45
+ @api.resource(:config_templates)\
46
46
  .call(:index, {
47
47
  :per_page => 999999
48
48
  })['results'].each do |template|
@@ -66,7 +66,7 @@ module HammerCLICsv
66
66
  name = namify(line[NAME], number)
67
67
  if !@existing.include? name
68
68
  print "Creating provisioning template '#{name}'..." if option_verbose?
69
- id = @api.resource(:config_templates)
69
+ id = @api.resource(:config_templates)\
70
70
  .call(:create, {
71
71
  'name' => name,
72
72
  'snippet' => line[KIND] == 'snippet',
@@ -76,7 +76,7 @@ module HammerCLICsv
76
76
  })['id']
77
77
  else
78
78
  print "Updating provisioning template '#{name}'..." if option_verbose?
79
- id = @api.resource(:config_template)
79
+ id = @api.resource(:config_template)\
80
80
  .call(:update, {
81
81
  'id' => @existing[name],
82
82
  'name' => name,
@@ -56,16 +56,16 @@ module HammerCLICsv
56
56
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
57
57
  csv << [NAME, COUNT, ORGANIZATION, ENVIRONMENT, CONTENTVIEW, SYSTEMGROUPS, VIRTUAL, HOST,
58
58
  OPERATINGSYSTEM, ARCHITECTURE, SOCKETS, RAM, CORES, SLA, PRODUCTS, SUBSCRIPTIONS]
59
- @api.resource(:organizations)
59
+ @api.resource(:organizations)\
60
60
  .call(:index, {
61
61
  :per_page => 999999
62
62
  })['results'].each do |organization|
63
- @api.resource(:systems)
63
+ @api.resource(:systems)\
64
64
  .call(:index, {
65
65
  'per_page' => 999999,
66
66
  'organization_id' => organization['id']
67
67
  })['results'].each do |system|
68
- system = @api.resource(:systems)
68
+ system = @api.resource(:systems)\
69
69
  .call(:show, {
70
70
  'id' => system['uuid'],
71
71
  'fields' => 'full'
@@ -98,7 +98,7 @@ module HammerCLICsv
98
98
  end
99
99
  products.delete!("\n")
100
100
  subscriptions = CSV.generate do |column|
101
- column << @api.resource(:subscriptions)
101
+ column << @api.resource(:subscriptions)\
102
102
  .call(:index, {
103
103
  'system_id' => system['uuid']
104
104
  })['results'].collect do |subscription|
@@ -123,7 +123,7 @@ module HammerCLICsv
123
123
 
124
124
  print 'Updating host and guest associations...' if option_verbose?
125
125
  @host_guests.each do |host_id, guest_ids|
126
- @api.resource(:systems)
126
+ @api.resource(:systems)\
127
127
  .call(:update, {
128
128
  'id' => host_id,
129
129
  'guest_ids' => guest_ids
@@ -135,7 +135,7 @@ module HammerCLICsv
135
135
  def create_systems_from_csv(line)
136
136
  if !@existing[line[ORGANIZATION]]
137
137
  @existing[line[ORGANIZATION]] = {}
138
- @api.resource(:systems)
138
+ @api.resource(:systems)\
139
139
  .call(:index, {
140
140
  'organization_id' => line[ORGANIZATION],
141
141
  'per_page' => 999999
@@ -154,7 +154,7 @@ module HammerCLICsv
154
154
 
155
155
  if !@existing[line[ORGANIZATION]].include? name
156
156
  print "Creating system '#{name}'..." if option_verbose?
157
- system_id = @api.resource(:systems)
157
+ system_id = @api.resource(:systems)\
158
158
  .call(:create, {
159
159
  'name' => name,
160
160
  'organization_id' => line[ORGANIZATION],
@@ -168,7 +168,7 @@ module HammerCLICsv
168
168
  else
169
169
  print "Updating system '#{name}'..." if option_verbose?
170
170
  puts line
171
- system_id = @api.resource(:systems)
171
+ system_id = @api.resource(:systems)\
172
172
  .call(:update, {
173
173
  'id' => @existing[line[ORGANIZATION]][name],
174
174
  'name' => name,
@@ -212,7 +212,7 @@ module HammerCLICsv
212
212
 
213
213
  def set_host_collections(system_id, line)
214
214
  CSV.parse_line(line[SYSTEMGROUPS]).each do |hostcollection_name|
215
- @api.resource(:hostcollections)
215
+ @api.resource(:hostcollections)\
216
216
  .call(:add_systems, {
217
217
  'id' => katello_hostcollection(line[ORGANIZATION], :name => hostcollection_name),
218
218
  'system_ids' => [system_id]
@@ -27,7 +27,7 @@ module HammerCLICsv
27
27
  def export
28
28
  CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
29
29
  csv << [NAME, COUNT]
30
- @api.resource(:reports)
30
+ @api.resource(:reports)\
31
31
  .call(:index, {
32
32
  'per_page' => 999999
33
33
  })['results'].each do |report|
@@ -40,7 +40,7 @@ module HammerCLICsv
40
40
 
41
41
  def import
42
42
  @existing_reports = {}
43
- @api.resource(:reports)
43
+ @api.resource(:reports)\
44
44
  .call(:index, {
45
45
  'per_page' => 999999
46
46
  })['results'].each do |report|
@@ -59,7 +59,7 @@ module HammerCLICsv
59
59
  if !@existing_reports[name]
60
60
  print "Creating report '#{name}'..." if option_verbose?
61
61
  reported_at = line[TIME] || Time.now
62
- report = @api.resource(:reports)
62
+ report = @api.resource(:reports)\
63
63
  .call(:create, {
64
64
  'host' => name,
65
65
  'reported_at' => reported_at,
@@ -77,7 +77,7 @@ module HammerCLICsv
77
77
  @existing_reports[name] = report['id']
78
78
  else
79
79
  print "Updating report '#{name}'..." if option_verbose?
80
- @api.resource(:reports)
80
+ @api.resource(:reports)\
81
81
  .call(:update, {
82
82
  'id' => @existing_reports[name]
83
83
  })
@@ -55,7 +55,7 @@ module HammerCLICsv
55
55
  name = namify(line[NAME], number)
56
56
  if !@existing.include? line[URL]
57
57
  print "Creating smart proxy '#{name}'..." if option_verbose?
58
- id = @api.resource(:smart_proxies)
58
+ id = @api.resource(:smart_proxies)\
59
59
  .call(:create, {
60
60
  'smart_proxy' => {
61
61
  'name' => name,
@@ -64,7 +64,7 @@ module HammerCLICsv
64
64
  })['id']
65
65
  else
66
66
  print "Updating smart proxy '#{name}'..." if option_verbose?
67
- id = @api.resource(:smart_proxies)
67
+ id = @api.resource(:smart_proxies)\
68
68
  .call(:update, {
69
69
  'id' => @existing[name],
70
70
  'smart_proxy' => {
@@ -85,7 +85,7 @@ module HammerCLICsv
85
85
  name = namify(line[NAME], number)
86
86
  if !@existing.include? name
87
87
  print "Creating subnet '#{name}'..." if option_verbose?
88
- id = @api.resource(:subnets)
88
+ id = @api.resource(:subnets)\
89
89
  .call(:create, {
90
90
  'subnet' => {
91
91
  'name' => name
@@ -93,7 +93,7 @@ module HammerCLICsv
93
93
  })['id']
94
94
  else
95
95
  print "Updating subnet '#{name}'..." if option_verbose?
96
- id = @api.resource(:subnets)
96
+ id = @api.resource(:subnets)\
97
97
  .call(:update, {
98
98
  'id' => @existing[name],
99
99
  'subnet' => {
@@ -11,6 +11,6 @@
11
11
 
12
12
  module HammerCLICsv
13
13
  def self.version
14
- @version ||= Gem::Version.new('0.0.1')
14
+ @version ||= Gem::Version.new('0.0.2')
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom McKay