Revision a77acc4a
Added by Thomas McKay about 9 years ago
lib/hammer_cli_csv.rb | ||
---|---|---|
14 | 14 |
|
15 | 15 |
module HammerCLICsv |
16 | 16 |
|
17 |
#def self.exception_handler_class |
|
18 |
# HammerCLICsv::ExceptionHandler |
|
19 |
#end |
|
20 |
|
|
21 | 17 |
require 'hammer_cli_csv/base' |
22 | 18 |
require 'hammer_cli_csv/exception_handler' |
23 | 19 |
|
... | ... | |
26 | 22 |
require 'hammer_cli_csv/architectures' |
27 | 23 |
require 'hammer_cli_csv/compute_profiles' |
28 | 24 |
require 'hammer_cli_csv/compute_resources' |
25 |
require 'hammer_cli_csv/content_hosts' |
|
29 | 26 |
require 'hammer_cli_csv/content_views' |
30 | 27 |
require 'hammer_cli_csv/domains' |
28 |
require 'hammer_cli_csv/host_collections' |
|
31 | 29 |
require 'hammer_cli_csv/hosts' |
32 | 30 |
require 'hammer_cli_csv/import' |
33 | 31 |
require 'hammer_cli_csv/lifecycle_environments' |
... | ... | |
45 | 43 |
require 'hammer_cli_csv/smart_proxies' |
46 | 44 |
require 'hammer_cli_csv/subnets' |
47 | 45 |
require 'hammer_cli_csv/subscriptions' |
48 |
require 'hammer_cli_csv/systems' |
|
49 |
require 'hammer_cli_csv/system_groups' |
|
50 | 46 |
require 'hammer_cli_csv/users' |
51 | 47 |
|
52 | 48 |
end |
lib/hammer_cli_csv/activation_keys.rb | ||
---|---|---|
48 | 48 |
SYSTEMGROUPS, SUBSCRIPTIONS] |
49 | 49 |
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization| |
50 | 50 |
@api.resource(:activation_keys).call(:index, {'per_page' => 999999, |
51 |
'organization_id' => organization['label']
|
|
52 |
})['results'].each do |activationkey| |
|
51 |
'organization_id' => organization['id']
|
|
52 |
})['results'].each do |activationkey|
|
|
53 | 53 |
puts "Writing activation key '#{activationkey['name']}'" if option_verbose? |
54 | 54 |
name = namify(activationkey['name']) |
55 | 55 |
count = 1 |
... | ... | |
57 | 57 |
limit = activationkey['usage_limit'].to_i < 0 ? 'Unlimited' : sytemgroup['usage_limit'] |
58 | 58 |
environment = activationkey['environment']['label'] |
59 | 59 |
contentview = activationkey['content_view']['name'] |
60 |
systemgroups = export_column(activationkey, 'systemGroups', 'name')
|
|
60 |
hostcollections = export_column(activationkey, 'systemGroups', 'name')
|
|
61 | 61 |
subscriptions = CSV.generate do |column| |
62 | 62 |
column << @api.resource(:subscriptions).call(:index, { |
63 | 63 |
'activation_key_id' => activationkey['id'] |
... | ... | |
68 | 68 |
end |
69 | 69 |
subscriptions.delete!("\n") |
70 | 70 |
csv << [name, count, organization['label'], description, limit, environment, contentview, |
71 |
systemgroups, subscriptions]
|
|
71 |
hostcollections, subscriptions]
|
|
72 | 72 |
end |
73 | 73 |
end |
74 | 74 |
end |
... | ... | |
87 | 87 |
@existing[line[ORGANIZATION]] = {} |
88 | 88 |
@api.resource(:activation_keys).call(:index, { |
89 | 89 |
'per_page' => 999999, |
90 |
'organization_id' => katello_organization(:name => line[ORGANIZATION])
|
|
90 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION])
|
|
91 | 91 |
})['results'].each do |activationkey| |
92 | 92 |
@existing[line[ORGANIZATION]][activationkey['name']] = activationkey['id'] if activationkey |
93 | 93 |
end |
... | ... | |
133 | 133 |
if line[SYSTEMGROUPS] && line[SYSTEMGROUPS] != '' |
134 | 134 |
# TODO: note that existing system groups are not removed |
135 | 135 |
CSV.parse_line(line[SYSTEMGROUPS], {:skip_blanks => true}).each do |name| |
136 |
@api.resource(:system_groups).call(:add_activation_keys, {
|
|
137 |
'id' => katello_systemgroup(line[ORGANIZATION], :name => name),
|
|
136 |
@api.resource(:host_collections).call(:add_activation_keys, {
|
|
137 |
'id' => katello_hostcollection(line[ORGANIZATION], :name => name),
|
|
138 | 138 |
'activation_key_ids' => [activationkey['id']] |
139 | 139 |
}) |
140 | 140 |
end |
lib/hammer_cli_csv/base.rb | ||
---|---|---|
126 | 126 |
result |
127 | 127 |
end |
128 | 128 |
|
129 |
def katello_organization(options = {}) |
|
130 |
@organizations ||= {} |
|
131 |
|
|
132 |
if options[:name] |
|
133 |
return nil if options[:name].nil? || options[:name].empty? |
|
134 |
options[:id] = @organizations[options[:name]] |
|
135 |
if !options[:id] |
|
136 |
organization = @api.resource(:organizations).call(:index, { |
|
137 |
:per_page => 999999, |
|
138 |
'search' => "name=\"#{options[:name]}\"" |
|
139 |
})['results'] |
|
140 |
raise "Organization '#{options[:name]}' not found" if !organization || organization.empty? |
|
141 |
options[:id] = organization[0]['label'] |
|
142 |
@organizations[options[:name]] = options[:id] |
|
143 |
end |
|
144 |
result = options[:id] |
|
145 |
else |
|
146 |
return nil if options[:id].nil? |
|
147 |
options[:name] = @organizations.key(options[:id]) |
|
148 |
if !options[:name] |
|
149 |
organization = @api.resource(:organizations).call(:show, {'id' => options[:id]}) |
|
150 |
raise "Organization 'id=#{options[:id]}' not found" if !organization || organization.empty? |
|
151 |
options[:name] = organization['name'] |
|
152 |
@organizations[options[:name]] = options[:id] |
|
153 |
end |
|
154 |
result = options[:name] |
|
155 |
end |
|
156 |
|
|
157 |
result |
|
158 |
end |
|
159 |
|
|
160 | 129 |
def foreman_location(options = {}) |
161 | 130 |
@locations ||= {} |
162 | 131 |
|
... | ... | |
435 | 404 |
if !options[:id] |
436 | 405 |
@api.resource(:lifecycle_environments).call(:index, { |
437 | 406 |
:per_page => 999999, |
438 |
'organization_id' => katello_organization(:name => organization),
|
|
407 |
'organization_id' => foreman_organization(:name => organization),
|
|
439 | 408 |
'library' => true |
440 | 409 |
})['results'].each do |environment| |
441 | 410 |
@environments[organization][environment['name']] = environment['id'] |
... | ... | |
469 | 438 |
if !options[:id] |
470 | 439 |
@api.resource(:content_views).call(:index, { |
471 | 440 |
:per_page => 999999, |
472 |
'organization_id' => katello_organization(:name => organization)
|
|
441 |
'organization_id' => foreman_organization(:name => organization)
|
|
473 | 442 |
})['results'].each do |contentview| |
474 | 443 |
@contentviews[organization][contentview['name']] = contentview['id'] |
475 | 444 |
end |
... | ... | |
502 | 471 |
if !options[:id] |
503 | 472 |
results = @api.resource(:subscriptions).call(:index, { |
504 | 473 |
:per_page => 999999, |
505 |
'organization_id' => katello_organization(:name => organization),
|
|
474 |
'organization_id' => foreman_organization(:name => organization),
|
|
506 | 475 |
'search' => "name:\"#{options[:name]}\"" |
507 | 476 |
}) |
508 | 477 |
raise "No subscriptions match '#{options[:name]}'" if results['subtotal'] == 0 |
... | ... | |
528 | 497 |
result |
529 | 498 |
end |
530 | 499 |
|
531 |
def katello_systemgroup(organization, options = {})
|
|
532 |
@systemgroups ||= {}
|
|
533 |
@systemgroups[organization] ||= {}
|
|
500 |
def katello_hostcollection(organization, options = {})
|
|
501 |
@hostcollections ||= {}
|
|
502 |
@hostcollections[organization] ||= {}
|
|
534 | 503 |
|
535 | 504 |
if options[:name] |
536 | 505 |
return nil if options[:name].nil? || options[:name].empty? |
537 |
options[:id] = @systemgroups[organization][options[:name]]
|
|
506 |
options[:id] = @hostcollections[organization][options[:name]]
|
|
538 | 507 |
if !options[:id] |
539 |
@api.resource(:system_groups).call(:index,
|
|
508 |
@api.resource(:host_collections).call(:index,
|
|
540 | 509 |
{ |
541 | 510 |
:per_page => 999999, |
542 |
'organization_id' => katello_organization(:name => organization),
|
|
511 |
'organization_id' => foreman_organization(:name => organization),
|
|
543 | 512 |
'search' => "name:\"#{options[:name]}\"" |
544 |
})['results'].each do |systemgroup|
|
|
545 |
@systemgroups[organization][systemgroup['name']] = systemgroup['id'] if systemgroup
|
|
513 |
})['results'].each do |hostcollection|
|
|
514 |
@hostcollections[organization][hostcollection['name']] = hostcollection['id'] if hostcollection
|
|
546 | 515 |
end |
547 |
options[:id] = @systemgroups[organization][options[:name]]
|
|
516 |
options[:id] = @hostcollections[organization][options[:name]]
|
|
548 | 517 |
raise "System group '#{options[:name]}' not found" if !options[:id] |
549 | 518 |
end |
550 | 519 |
result = options[:id] |
551 | 520 |
else |
552 | 521 |
return nil if options[:id].nil? |
553 |
options[:name] = @systemgroups.key(options[:id])
|
|
522 |
options[:name] = @hostcollections.key(options[:id])
|
|
554 | 523 |
if !options[:name] |
555 |
systemgroup = @api.resource(:system_groups).call(:show, {'id' => options[:id]})
|
|
556 |
raise "System group '#{options[:name]}' not found" if !systemgroup || systemgroup.empty?
|
|
557 |
options[:name] = systemgroup['name']
|
|
558 |
@systemgroups[options[:name]] = options[:id]
|
|
524 |
hostcollection = @api.resource(:host_collections).call(:show, {'id' => options[:id]})
|
|
525 |
raise "System group '#{options[:name]}' not found" if !hostcollection || hostcollection.empty?
|
|
526 |
options[:name] = hostcollection['name']
|
|
527 |
@hostcollections[options[:name]] = options[:id]
|
|
559 | 528 |
end |
560 | 529 |
result = options[:name] |
561 | 530 |
end |
lib/hammer_cli_csv/content_hosts.rb | ||
---|---|---|
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 |
# -= Systems CSV =- |
|
14 |
# |
|
15 |
# Columns |
|
16 |
# Name |
|
17 |
# - System 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 |
# MAC Address |
|
23 |
# - MAC address |
|
24 |
# - May contain '%d' which will be replaced with current iteration number of Count |
|
25 |
# - eg. "FF:FF:FF:FF:FF:%02x" -> "FF:FF:FF:FF:FF:0A" |
|
26 |
# - Warning: be sure to keep count below 255 or MAC hex will exceed limit |
|
27 |
# |
|
28 |
|
|
29 |
require 'hammer_cli' |
|
30 |
require 'json' |
|
31 |
require 'csv' |
|
32 |
require 'uri' |
|
33 |
|
|
34 |
module HammerCLICsv |
|
35 |
class CsvCommand |
|
36 |
class ContentHostsCommand < BaseCommand |
|
37 |
command_name 'content-hosts' |
|
38 |
desc 'import or export content hosts' |
|
39 |
|
|
40 |
ORGANIZATION = 'Organization' |
|
41 |
ENVIRONMENT = 'Environment' |
|
42 |
CONTENTVIEW = 'Content View' |
|
43 |
HOSTCOLLECTIONS = 'Host Collections' |
|
44 |
VIRTUAL = 'Virtual' |
|
45 |
HOST = 'Host' |
|
46 |
OPERATINGSYSTEM = 'OS' |
|
47 |
ARCHITECTURE = 'Arch' |
|
48 |
SOCKETS = 'Sockets' |
|
49 |
RAM = 'RAM' |
|
50 |
CORES = 'Cores' |
|
51 |
SLA = 'SLA' |
|
52 |
PRODUCTS = 'Products' |
|
53 |
SUBSCRIPTIONS = 'Subscriptions' |
|
54 |
|
|
55 |
def export |
|
56 |
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv| |
|
57 |
csv << [NAME, COUNT, ORGANIZATION, ENVIRONMENT, CONTENTVIEW, HOSTCOLLECTIONS, VIRTUAL, HOST, |
|
58 |
OPERATINGSYSTEM, ARCHITECTURE, SOCKETS, RAM, CORES, SLA, PRODUCTS, SUBSCRIPTIONS] |
|
59 |
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization| |
|
60 |
@api.resource(:systems).call(:index, { |
|
61 |
'per_page' => 999999, |
|
62 |
'organization_id' => foreman_organization(:name => organization['name']) |
|
63 |
})['results'].each do |system| |
|
64 |
system = @api.resource(:systems).call(:show, { |
|
65 |
'id' => system['uuid'], |
|
66 |
'fields' => 'full' |
|
67 |
}) |
|
68 |
|
|
69 |
name = system['name'] |
|
70 |
count = 1 |
|
71 |
organization_name = organization['name'] |
|
72 |
environment = system['environment']['label'] |
|
73 |
contentview = system['content_view']['name'] |
|
74 |
hostcollections = CSV.generate do |column| |
|
75 |
column << system['systemGroups'].collect do |hostcollection| |
|
76 |
hostcollection['name'] |
|
77 |
end |
|
78 |
end |
|
79 |
hostcollections.delete!("\n") |
|
80 |
virtual = system['facts']['virt.is_guest'] == 'true' ? 'Yes' : 'No' |
|
81 |
host = system['host'] |
|
82 |
operatingsystem = "#{system['facts']['distribution.name']} " if system['facts']['distribution.name'] |
|
83 |
operatingsystem += system['facts']['distribution.version'] if system['facts']['distribution.version'] |
|
84 |
architecture = system['facts']['uname.machine'] |
|
85 |
sockets = system['facts']['cpu.cpu_socket(s)'] |
|
86 |
ram = system['facts']['memory.memtotal'] |
|
87 |
cores = system['facts']['cpu.core(s)_per_socket'] |
|
88 |
sla = '' |
|
89 |
products = CSV.generate do |column| |
|
90 |
column << system['installedProducts'].collect do |product| |
|
91 |
"#{product['productId']}|#{product['productName']}" |
|
92 |
end |
|
93 |
end |
|
94 |
products.delete!("\n") |
|
95 |
subscriptions = CSV.generate do |column| |
|
96 |
column << @api.resource(:subscriptions).call(:index, { |
|
97 |
'system_id' => system['uuid'] |
|
98 |
})['results'].collect do |subscription| |
|
99 |
"#{subscription['product_id']}|#{subscription['product_name']}" |
|
100 |
end |
|
101 |
end |
|
102 |
subscriptions.delete!("\n") |
|
103 |
csv << [name, count, organization_name, environment, contentview, hostcollections, virtual, host, |
|
104 |
operatingsystem, architecture, sockets, ram, cores, sla, products, subscriptions] |
|
105 |
end |
|
106 |
end |
|
107 |
end |
|
108 |
end |
|
109 |
|
|
110 |
def import |
|
111 |
@existing = {} |
|
112 |
@host_guests = {} |
|
113 |
|
|
114 |
thread_import do |line| |
|
115 |
create_systems_from_csv(line) |
|
116 |
end |
|
117 |
|
|
118 |
print 'Updating host and guest associations...' if option_verbose? |
|
119 |
@host_guests.each do |host_id, guest_ids| |
|
120 |
@api.resource(:systems).call(:update, { |
|
121 |
'id' => host_id, |
|
122 |
'guest_ids' => guest_ids |
|
123 |
}) |
|
124 |
end |
|
125 |
puts 'done' if option_verbose? |
|
126 |
end |
|
127 |
|
|
128 |
def create_systems_from_csv(line) |
|
129 |
if !@existing[line[ORGANIZATION]] |
|
130 |
@existing[line[ORGANIZATION]] = {} |
|
131 |
@api.resource(:systems).call(:index, { |
|
132 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]), |
|
133 |
'page_size' => 999999})['results'].each do |system| |
|
134 |
@existing[line[ORGANIZATION]][system['name']] = system['uuid'] if system |
|
135 |
end |
|
136 |
end |
|
137 |
|
|
138 |
line[COUNT].to_i.times do |number| |
|
139 |
name = namify(line[NAME], number) |
|
140 |
|
|
141 |
# TODO w/ @daviddavis p-r |
|
142 |
#subscriptions(line).each do |subscription| |
|
143 |
# katello_subscription(line[ORGANIZATION], :name => subscription[:number]) |
|
144 |
#end |
|
145 |
|
|
146 |
if !@existing[line[ORGANIZATION]].include? name |
|
147 |
print "Creating system '#{name}'..." if option_verbose? |
|
148 |
system_id = @api.resource(:systems).call(:create, { |
|
149 |
'name' => name, |
|
150 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]), |
|
151 |
'environment_id' => katello_environment(line[ORGANIZATION], :name => line[ENVIRONMENT]), |
|
152 |
'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]), |
|
153 |
'facts' => facts(name, line), |
|
154 |
'installed_products' => products(line), |
|
155 |
'type' => 'system' |
|
156 |
})['uuid'] |
|
157 |
@existing[line[ORGANIZATION]][name] = system_id |
|
158 |
else |
|
159 |
print "Updating system '#{name}'..." if option_verbose? |
|
160 |
system_id = @api.resource(:systems).call(:update, { |
|
161 |
'id' => @existing[line[ORGANIZATION]][name], |
|
162 |
'system' => { |
|
163 |
'name' => name, |
|
164 |
'environment_id' => katello_environment(line[ORGANIZATION], :name => line[ENVIRONMENT]), |
|
165 |
'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]), |
|
166 |
'facts' => facts(name, line), |
|
167 |
'installed_products' => products(line) |
|
168 |
} |
|
169 |
})['uuid'] |
|
170 |
end |
|
171 |
|
|
172 |
if line[VIRTUAL] == 'Yes' && line[HOST] |
|
173 |
raise "Host system '#{line[HOST]}' not found" if !@existing[line[ORGANIZATION]][line[HOST]] |
|
174 |
@host_guests[@existing[line[ORGANIZATION]][line[HOST]]] ||= [] |
|
175 |
@host_guests[@existing[line[ORGANIZATION]][line[HOST]]] << system_id |
|
176 |
end |
|
177 |
|
|
178 |
set_host_collections(system_id, line) |
|
179 |
|
|
180 |
puts 'done' if option_verbose? |
|
181 |
end |
|
182 |
rescue RuntimeError => e |
|
183 |
raise "#{e}\n #{line}" |
|
184 |
end |
|
185 |
|
|
186 |
private |
|
187 |
|
|
188 |
def facts(name, line) |
|
189 |
facts = {} |
|
190 |
facts['cpu.core(s)_per_socket'] = line[CORES] |
|
191 |
facts['cpu.cpu_socket(s)'] = line[SOCKETS] |
|
192 |
facts['memory.memtotal'] = line[RAM] |
|
193 |
facts['uname.machine'] = line[ARCHITECTURE] |
|
194 |
if line[OPERATINGSYSTEM].index(' ') |
|
195 |
(facts['distribution.name'], facts['distribution.version']) = line[OPERATINGSYSTEM].split(' ') |
|
196 |
else |
|
197 |
(facts['distribution.name'], facts['distribution.version']) = ['RHEL', line[OPERATINGSYSTEM]] |
|
198 |
end |
|
199 |
facts['virt.is_guest'] = line[VIRTUAL] == 'Yes' ? true : false |
|
200 |
facts['virt.uuid'] = "#{line[ORGANIZATION]}/#{name}" if facts['virt.is_guest'] |
|
201 |
facts |
|
202 |
end |
|
203 |
|
|
204 |
def set_host_collections(system_id, line) |
|
205 |
CSV.parse_line(line[HOSTCOLLECTIONS]).each do |hostcollection_name| |
|
206 |
@api.resource(:host_collections).call(:add_systems, { |
|
207 |
'id' => katello_hostcollection(line[ORGANIZATION], :name => hostcollection_name), |
|
208 |
'system_ids' => [system_id] |
|
209 |
}) |
|
210 |
end |
|
211 |
end |
|
212 |
|
|
213 |
def products(line) |
|
214 |
return nil if !line[PRODUCTS] |
|
215 |
products = CSV.parse_line(line[PRODUCTS]).collect do |product_details| |
|
216 |
product = {} |
|
217 |
# TODO: these get passed straight through to candlepin; probably would be better to process in server |
|
218 |
# to allow underscore product_id here |
|
219 |
(product['productId'], product['productName']) = product_details.split('|') |
|
220 |
product |
|
221 |
end |
|
222 |
products |
|
223 |
end |
|
224 |
|
|
225 |
def subscriptions(line) |
|
226 |
return nil if !line[SUBSCRIPTIONS] |
|
227 |
subscriptions = CSV.parse_line(line[SUBSCRIPTIONS]).collect do |subscription_details| |
|
228 |
subscription = {} |
|
229 |
(subscription[:number], subscription[:name]) = subscription_details.split('|') |
|
230 |
subscription |
|
231 |
end |
|
232 |
subscriptions |
|
233 |
end |
|
234 |
end |
|
235 |
end |
|
236 |
end |
lib/hammer_cli_csv/host_collections.rb | ||
---|---|---|
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 |
# -= System Groups CSV =- |
|
14 |
# |
|
15 |
# Columns |
|
16 |
# Name |
|
17 |
# - System group name |
|
18 |
# - May contain '%d' which will be replaced with current iteration number of Count |
|
19 |
# - eg. "group%d" -> "group1" |
|
20 |
# Count |
|
21 |
# - Number of times to iterate on this line of the CSV file |
|
22 |
# Org Label |
|
23 |
# Limit |
|
24 |
# Description |
|
25 |
# |
|
26 |
|
|
27 |
require 'hammer_cli' |
|
28 |
require 'json' |
|
29 |
require 'csv' |
|
30 |
|
|
31 |
module HammerCLICsv |
|
32 |
class CsvCommand |
|
33 |
class HostCollectionsCommand < BaseCommand |
|
34 |
command_name 'host-collections' |
|
35 |
desc 'import or export host collections' |
|
36 |
|
|
37 |
ORGANIZATION = 'Organization' |
|
38 |
LIMIT = 'Limit' |
|
39 |
DESCRIPTION = 'Description' |
|
40 |
|
|
41 |
def export |
|
42 |
CSV.open(option_csv_file, 'wb') do |csv| |
|
43 |
csv << [NAME, COUNT, ORGANIZATION, LIMIT, DESCRIPTION] |
|
44 |
@api.resource(:organizations).call(:index, {'per_page' => 999999})['results'].each do |organization| |
|
45 |
@api.resource(:host_collections).call(:index, {'organization_id' => organization['id']}).each do |hostcollection| |
|
46 |
puts hostcollection |
|
47 |
csv << [hostcollection['name'], 1, organization['id'], |
|
48 |
hostcollection['max_systems'].to_i < 0 ? 'Unlimited' : sytemgroup['max_systems'], |
|
49 |
hostcollection['description']] |
|
50 |
end |
|
51 |
end |
|
52 |
end |
|
53 |
end |
|
54 |
|
|
55 |
def import |
|
56 |
@existing = {} |
|
57 |
|
|
58 |
thread_import do |line| |
|
59 |
create_hostcollections_from_csv(line) |
|
60 |
end |
|
61 |
end |
|
62 |
|
|
63 |
def create_hostcollections_from_csv(line) |
|
64 |
if !@existing[line[ORGANIZATION]] |
|
65 |
@existing[line[ORGANIZATION]] = {} |
|
66 |
@api.resource(:host_collections).call(:index, { |
|
67 |
'per_page' => 999999, |
|
68 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]) |
|
69 |
})['results'].each do |hostcollection| |
|
70 |
@existing[line[ORGANIZATION]][hostcollection['name']] = hostcollection['id'] |
|
71 |
end |
|
72 |
end |
|
73 |
|
|
74 |
line[COUNT].to_i.times do |number| |
|
75 |
name = namify(line[NAME], number) |
|
76 |
if !@existing[line[ORGANIZATION]].include? name |
|
77 |
print "Creating system group '#{name}'..." if option_verbose? |
|
78 |
@api.resource(:host_collections).call(:create, { |
|
79 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]), |
|
80 |
'name' => name, |
|
81 |
'max_systems' => (line[LIMIT] == 'Unlimited') ? -1 : line[LIMIT], |
|
82 |
'description' => line[DESCRIPTION] |
|
83 |
}) |
|
84 |
else |
|
85 |
print "Updating system group '#{name}'..." if option_verbose? |
|
86 |
@api.resource(:host_collections).call(:update, { |
|
87 |
'organization_id' => line[ORGANIZATION], |
|
88 |
'id' => @existing[line[ORGANIZATION]][name], |
|
89 |
'name' => name, |
|
90 |
'max_systems' => (line[LIMIT] == 'Unlimited') ? -1 : line[LIMIT], |
|
91 |
'description' => line[DESCRIPTION] |
|
92 |
}) |
|
93 |
end |
|
94 |
print "done\n" if option_verbose? |
|
95 |
end |
|
96 |
end |
|
97 |
end |
|
98 |
end |
|
99 |
end |
lib/hammer_cli_csv/import.rb | ||
---|---|---|
32 | 32 |
option '--users', 'FILE', 'source to import users' |
33 | 33 |
option '--hosts', 'FILE', 'source to import hosts' |
34 | 34 |
option '--organizations', 'FILE', 'source to import organizations' |
35 |
option '--locations', 'FILE', 'source to import locations' |
|
36 |
option '--puppet-environments', 'FILE', 'source to puppet environments' |
|
37 |
option '--operating-systems', 'FILE', 'source to operating systems' |
|
38 |
option '--architectures', 'FILE', 'source to architectures' |
|
39 |
option '--domains', 'FILE', 'source to domains' |
|
40 |
option '--architectures', 'FILE', 'source to architectures' |
|
41 |
option '--partition-tables', 'FILE', 'source to partition-tables' |
|
35 | 42 |
|
36 | 43 |
def ctx |
37 | 44 |
{ |
... | ... | |
54 | 61 |
}) |
55 | 62 |
|
56 | 63 |
# Swing the hammers |
57 |
swing('organizations')
|
|
58 |
swing('roles')
|
|
59 |
swing('users')
|
|
60 |
swing('hosts')
|
|
64 |
%w( organizations locations roles users puppet_environments operating_systems
|
|
65 |
hosts domains architectures partition_tables ).each do |resource|
|
|
66 |
swing(resource)
|
|
67 |
end
|
|
61 | 68 |
|
62 | 69 |
HammerCLI::EX_OK |
63 | 70 |
end |
64 | 71 |
|
65 | 72 |
def swing(resource) |
66 |
options_file = self.send("option_#{resource}") |
|
67 |
options_file ||= "#{option_dir}/#{resource}.csv" if option_dir |
|
68 |
args = %W{ csv #{resource} --csv-file #{options_file} } |
|
73 |
return if !self.send("option_#{resource}") && !option_dir |
|
74 |
options_file = self.send("option_#{resource}") || "#{option_dir}/#{resource.sub('_', '-')}.csv" |
|
75 |
raise "File for #{resource} '#{options_file}' does not exist" unless File.exists? options_file |
|
76 |
args = %W{ csv #{resource.sub('_', '-')} --csv-file #{options_file} } |
|
69 | 77 |
args << '-v' if option_verbose? |
70 |
hammer.run(args) if File.exists? options_file
|
|
78 |
hammer.run(args) |
|
71 | 79 |
end |
72 | 80 |
end |
73 | 81 |
end |
lib/hammer_cli_csv/lifecycle_environments.rb | ||
---|---|---|
42 | 42 |
@api.resource(:organizations).call(:index, {'per_page' => 999999})['results'].each do |organization| |
43 | 43 |
@api.resource(:environments).call(:index, { |
44 | 44 |
'per_page' => 999999, |
45 |
'organization_id' => organization['label']
|
|
45 |
'organization_id' => organization['id']
|
|
46 | 46 |
})['results'].each do |environment| |
47 | 47 |
if environment['label'] != 'Library' |
48 | 48 |
name = environment['name'] |
... | ... | |
62 | 62 |
@api.resource(:organizations).call(:index, {'per_page' => 999999})['results'].each do |organization| |
63 | 63 |
@api.resource(:environments).call(:index, { |
64 | 64 |
'per_page' => 999999, |
65 |
'organization_id' => katello_organization(:name => organization['name']),
|
|
65 |
'organization_id' => foreman_organization(:name => organization['name']),
|
|
66 | 66 |
'library' => true |
67 | 67 |
})['results'].each do |environment| |
68 | 68 |
@existing[organization['name']] ||= {} |
... | ... | |
84 | 84 |
if !@existing[line[ORGANIZATION]].include? name |
85 | 85 |
print "Creating environment '#{name}'..." if option_verbose? |
86 | 86 |
@api.resource(:environments).call(:create, { |
87 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
87 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
88 | 88 |
'name' => name, |
89 | 89 |
'label' => label, |
90 | 90 |
'prior' => katello_environment(line[ORGANIZATION], :name => prior), |
... | ... | |
96 | 96 |
'id' => @existing[line[ORGANIZATION]][name], |
97 | 97 |
'name' => name, |
98 | 98 |
'new_name' => name, |
99 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
99 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
100 | 100 |
'prior' => prior, |
101 | 101 |
'description' => line[DESCRIPTION] |
102 | 102 |
}) |
lib/hammer_cli_csv/organizations.rb | ||
---|---|---|
51 | 51 |
def import |
52 | 52 |
@existing = {} |
53 | 53 |
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization| |
54 |
@existing[organization['name']] = organization['label'] if organization
|
|
54 |
@existing[organization['name']] = organization['id'] if organization
|
|
55 | 55 |
end |
56 | 56 |
|
57 | 57 |
thread_import do |line| |
lib/hammer_cli_csv/permissions.rb | ||
---|---|---|
22 | 22 |
# Role |
23 | 23 |
# Description |
24 | 24 |
# Category |
25 |
# - organizations, environments, activation_keys, system_groups, providers, users, roles,
|
|
25 |
# - organizations, environments, activation_keys, host_collections, providers, users, roles,
|
|
26 | 26 |
# content_view_definitions, content_views, all |
27 | 27 |
# Verbs |
28 | 28 |
# organizations - gpg, redhat_products, delete_distributors, delete_systems, manage_nodes, |
... | ... | |
32 | 32 |
# promote_changesets, read_changesets, read_distributors, read_contents, read_systems, |
33 | 33 |
# register_distributors, register_systems, delete_distributors, delete_systems |
34 | 34 |
# activation_keys - manage_all, read_all |
35 |
# system_groups - create, delete, delete_systems, update, update_systems, read, read_systems
|
|
35 |
# host_collections - create, delete, delete_systems, update, update_systems, read, read_systems
|
|
36 | 36 |
# providers - create, delete, update, read |
37 | 37 |
# users - create, delete, update, read |
38 | 38 |
# roles - create, delete, update, read |
... | ... | |
107 | 107 |
details = parse_permission_csv(line) |
108 | 108 |
|
109 | 109 |
puts @permission_api.index({'role_id' => @roles['User System Group']}) |
110 |
# {"all_tags"=>false, "all_verbs"=>false, "created_at"=>"2013-11-11T02:31:23Z", "description"=>"and it's description!", "id"=>12, "name"=>"Accounting System Group Modify Systems", "organization_id"=>2, "resource_type_id"=>5, "role_id"=>124, "updated_at"=>"2013-11-11T02:31:23Z", "tags"=>[{"created_at"=>"2013-11-11T02:31:23Z", "formatted"=>{"name"=>6, "display_name"=>"Accounting"}, "id"=>2, "permission_id"=>12, "tag_id"=>6, "updated_at"=>"2013-11-11T02:31:23Z"}], "verbs"=>[{"created_at"=>"2013-11-07T19:44:45Z", "id"=>7, "updated_at"=>"2013-11-07T19:44:45Z", "verb"=>"update_systems"}], "resource_type"=>{"created_at"=>"2013-11-07T16:36:56Z", "id"=>5, "name"=>"system_groups", "updated_at"=>"2013-11-07T16:36:56Z"}}
|
|
110 |
# {"all_tags"=>false, "all_verbs"=>false, "created_at"=>"2013-11-11T02:31:23Z", "description"=>"and it's description!", "id"=>12, "name"=>"Accounting System Group Modify Systems", "organization_id"=>2, "resource_type_id"=>5, "role_id"=>124, "updated_at"=>"2013-11-11T02:31:23Z", "tags"=>[{"created_at"=>"2013-11-11T02:31:23Z", "formatted"=>{"name"=>6, "display_name"=>"Accounting"}, "id"=>2, "permission_id"=>12, "tag_id"=>6, "updated_at"=>"2013-11-11T02:31:23Z"}], "verbs"=>[{"created_at"=>"2013-11-07T19:44:45Z", "id"=>7, "updated_at"=>"2013-11-07T19:44:45Z", "verb"=>"update_systems"}], "resource_type"=>{"created_at"=>"2013-11-07T16:36:56Z", "id"=>5, "name"=>"host_collections", "updated_at"=>"2013-11-07T16:36:56Z"}}
|
|
111 | 111 |
|
112 | 112 |
@existing[@roles[details[:role]]] ||= {} |
113 | 113 |
@permission_api.index({'role_id' => @roles[details[:role]]}).each do |permission| |
lib/hammer_cli_csv/products.rb | ||
---|---|---|
45 | 45 |
@api.resource(:products).call(:index, { |
46 | 46 |
'per_page' => 999999, |
47 | 47 |
'enabled' => true, |
48 |
'organization_id' => katello_organization(:name => organization['name'])
|
|
48 |
'organization_id' => foreman_organization(:name => organization['name'])
|
|
49 | 49 |
})['results'].each do |product| |
50 | 50 |
# product = @api.resource(:products).call(:show, { |
51 | 51 |
# 'id' => product['id'], |
... | ... | |
78 | 78 |
if !@existing_products[line[ORGANIZATION]] |
79 | 79 |
@existing_products[line[ORGANIZATION]] = {} |
80 | 80 |
@api.resource(:products).call(:index, { |
81 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
81 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
82 | 82 |
'page_size' => 999999, |
83 | 83 |
'paged' => true |
84 | 84 |
})['results'].each do |product| |
... | ... | |
86 | 86 |
|
87 | 87 |
if product |
88 | 88 |
@api.resource(:repositories).call(:index, { |
89 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
89 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
90 | 90 |
'product_id' => product['id'], |
91 | 91 |
'enabled' => true, |
92 | 92 |
'library' => true, |
... | ... | |
111 | 111 |
end |
112 | 112 |
|
113 | 113 |
product_id = @api.resource(:products).call(:create, { |
114 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
114 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
115 | 115 |
'name' => name |
116 | 116 |
})['id'] |
117 | 117 |
@existing_products[line[ORGANIZATION]][name] = product_id |
... | ... | |
127 | 127 |
# Hash the existing repositories for the product |
128 | 128 |
if !@existing_repositories[line[ORGANIZATION] + name][repository_name] |
129 | 129 |
@api.resource(:repositories).call(:index, { |
130 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
130 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
131 | 131 |
'library' => true, |
132 | 132 |
'all' => false, |
133 | 133 |
'product_id' => product_id |
... | ... | |
142 | 142 |
# TMP |
143 | 143 |
puts 'TMP' |
144 | 144 |
@api.resource(:repositories).call(:index, { |
145 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
145 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
146 | 146 |
'library' => true, |
147 | 147 |
'all' => true, |
148 | 148 |
'product_id' => product_id |
... | ... | |
154 | 154 |
|
155 | 155 |
else |
156 | 156 |
repository_id = @api.resource(:repositories).call(:create, { |
157 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
157 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
158 | 158 |
'name' => repository_name, |
159 | 159 |
'label' => labelize(repository_name), |
160 | 160 |
'product_id' => product_id, |
... | ... | |
166 | 166 |
|
167 | 167 |
puts 'TODO: skipping sync' |
168 | 168 |
# task_id = @api.resource(:repositories).call(:sync, { |
169 |
# 'organization_id' => katello_organization(:name => line[ORGANIZATION]),
|
|
169 |
# 'organization_id' => foreman_organization(:name => line[ORGANIZATION]),
|
|
170 | 170 |
# 'id' => repository_id |
171 | 171 |
# })['id'] |
172 | 172 |
# TODO: wait for sync task |
lib/hammer_cli_csv/puppet_reports.rb | ||
---|---|---|
59 | 59 |
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization| |
60 | 60 |
@api.resource(:systems).call(:index, { |
61 | 61 |
'per_page' => 999999, |
62 |
'organization_id' => organization['label']
|
|
62 |
'organization_id' => organization['id']
|
|
63 | 63 |
})['results'].each do |system| |
64 | 64 |
system = @api.resource(:systems).call(:show, { |
65 | 65 |
'id' => system['uuid'], |
... | ... | |
71 | 71 |
organization_label = organization['label'] |
72 | 72 |
environment = system['environment']['label'] |
73 | 73 |
contentview = system['content_view']['name'] |
74 |
systemgroups = CSV.generate do |column|
|
|
75 |
column << system['systemGroups'].collect do |systemgroup|
|
|
76 |
systemgroup['name']
|
|
74 |
hostcollections = CSV.generate do |column|
|
|
75 |
column << system['systemGroups'].collect do |hostcollection|
|
|
76 |
hostcollection['name']
|
|
77 | 77 |
end |
78 | 78 |
end.delete!("\n") |
79 | 79 |
virtual = system['facts']['virt.is_guest'] == 'true' ? 'Yes' : 'No' |
... | ... | |
97 | 97 |
"#{subscription['product_id']}|#{subscription['product_name']}" |
98 | 98 |
end |
99 | 99 |
end.delete!("\n") |
100 |
csv << [name, count, organization_label, environment, contentview, systemgroups, virtual, host,
|
|
100 |
csv << [name, count, organization_label, environment, contentview, hostcollections, virtual, host,
|
|
101 | 101 |
operatingsystem, architecture, sockets, ram, cores, sla, products, subscriptions] |
102 | 102 |
end |
103 | 103 |
end |
... | ... | |
169 | 169 |
@host_guests[@existing[line[ORGANIZATION]][line[HOST]]] << system_id |
170 | 170 |
end |
171 | 171 |
|
172 |
set_system_groups(system_id, line)
|
|
172 |
set_host_collections(system_id, line)
|
|
173 | 173 |
|
174 | 174 |
puts 'done' if option_verbose? |
175 | 175 |
end |
... | ... | |
194 | 194 |
facts |
195 | 195 |
end |
196 | 196 |
|
197 |
def set_system_groups(system_id, line)
|
|
198 |
CSV.parse_line(line[SYSTEMGROUPS]).each do |systemgroup_name|
|
|
199 |
@api.resource(:systemgroups).call(:add_systems, {
|
|
200 |
'id' => katello_systemgroup(line[ORGANIZATION], :name => systemgroup_name),
|
|
197 |
def set_host_collections(system_id, line)
|
|
198 |
CSV.parse_line(line[SYSTEMGROUPS]).each do |hostcollection_name|
|
|
199 |
@api.resource(:hostcollections).call(:add_systems, {
|
|
200 |
'id' => katello_hostcollection(line[ORGANIZATION], :name => hostcollection_name),
|
|
201 | 201 |
'system_ids' => [system_id] |
202 | 202 |
}) |
203 | 203 |
end |
lib/hammer_cli_csv/system_groups.rb | ||
---|---|---|
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 |
# -= System Groups CSV =- |
|
14 |
# |
|
15 |
# Columns |
|
16 |
# Name |
|
17 |
# - System group name |
|
18 |
# - May contain '%d' which will be replaced with current iteration number of Count |
|
19 |
# - eg. "group%d" -> "group1" |
|
20 |
# Count |
|
21 |
# - Number of times to iterate on this line of the CSV file |
|
22 |
# Org Label |
|
23 |
# Limit |
|
24 |
# Description |
|
25 |
# |
|
26 |
|
|
27 |
require 'hammer_cli' |
|
28 |
require 'json' |
|
29 |
require 'csv' |
|
30 |
|
|
31 |
module HammerCLICsv |
|
32 |
class CsvCommand |
|
33 |
class SystemGroupsCommand < BaseCommand |
|
34 |
command_name 'system-groups' |
|
35 |
desc 'import or export system groups' |
|
36 |
|
|
37 |
ORGANIZATION = 'Organization' |
|
38 |
LIMIT = 'Limit' |
|
39 |
DESCRIPTION = 'Description' |
|
40 |
|
|
41 |
def export |
|
42 |
CSV.open(option_csv_file, 'wb') do |csv| |
|
43 |
csv << [NAME, COUNT, ORGANIZATION, LIMIT, DESCRIPTION] |
|
44 |
@api.resource(:organizations).call(:index, {'per_page' => 999999})['results'].each do |organization| |
|
45 |
@api.resource(:system_groups).call(:index, {'organization_id' => organization['label']}).each do |systemgroup| |
|
46 |
puts systemgroup |
|
47 |
csv << [systemgroup['name'], 1, organization['label'], |
|
48 |
systemgroup['max_systems'].to_i < 0 ? 'Unlimited' : sytemgroup['max_systems'], |
|
49 |
systemgroup['description']] |
|
50 |
end |
|
51 |
end |
|
52 |
end |
|
53 |
end |
|
54 |
|
|
55 |
def import |
|
56 |
@existing = {} |
|
57 |
|
|
58 |
thread_import do |line| |
|
59 |
create_systemgroups_from_csv(line) |
|
60 |
end |
|
61 |
end |
|
62 |
|
|
63 |
def create_systemgroups_from_csv(line) |
|
64 |
if !@existing[line[ORGANIZATION]] |
|
65 |
@existing[line[ORGANIZATION]] = {} |
|
66 |
@api.resource(:system_groups).call(:index, {'organization_id' => line[ORGANIZATION]})['results'].each do |systemgroup| |
|
67 |
@existing[line[ORGANIZATION]][systemgroup['name']] = systemgroup['id'] |
|
68 |
end |
|
69 |
end |
|
70 |
|
|
71 |
line[COUNT].to_i.times do |number| |
|
72 |
name = namify(line[NAME], number) |
|
73 |
if !@existing[line[ORGANIZATION]].include? name |
|
74 |
print "Creating system group '#{name}'..." if option_verbose? |
|
75 |
@api.resource(:system_groups).call(:create, { |
|
76 |
'organization_id' => line[ORGANIZATION], |
|
77 |
'name' => name, |
|
78 |
'max_systems' => (line[LIMIT] == 'Unlimited') ? -1 : line[LIMIT], |
|
79 |
'description' => line[DESCRIPTION] |
|
80 |
}) |
|
81 |
else |
|
82 |
print "Updating system group '#{name}'..." if option_verbose? |
|
83 |
@api.resource(:system_groups).call(:update, { |
|
84 |
'organization_id' => line[ORGANIZATION], |
|
85 |
'id' => @existing[line[ORGANIZATION]][name], |
|
86 |
'name' => name, |
|
87 |
'max_systems' => (line[LIMIT] == 'Unlimited') ? -1 : line[LIMIT], |
|
88 |
'description' => line[DESCRIPTION] |
|
89 |
}) |
|
90 |
end |
|
91 |
print "done\n" if option_verbose? |
|
92 |
end |
|
93 |
end |
|
94 |
end |
|
95 |
end |
|
96 |
end |
lib/hammer_cli_csv/systems.rb | ||
---|---|---|
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 |
# -= Systems CSV =- |
|
14 |
# |
|
15 |
# Columns |
|
16 |
# Name |
|
17 |
# - System 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 |
# MAC Address |
|
23 |
# - MAC address |
|
24 |
# - May contain '%d' which will be replaced with current iteration number of Count |
|
25 |
# - eg. "FF:FF:FF:FF:FF:%02x" -> "FF:FF:FF:FF:FF:0A" |
|
26 |
# - Warning: be sure to keep count below 255 or MAC hex will exceed limit |
|
27 |
# |
|
28 |
|
|
29 |
require 'hammer_cli' |
|
30 |
require 'json' |
|
31 |
require 'csv' |
|
32 |
require 'uri' |
|
33 |
|
|
34 |
module HammerCLICsv |
|
35 |
class CsvCommand |
|
36 |
class SystemsCommand < BaseCommand |
|
37 |
command_name 'systems' |
|
38 |
desc 'import or export systems' |
|
39 |
|
|
40 |
ORGANIZATION = 'Organization' |
|
41 |
ENVIRONMENT = 'Environment' |
|
42 |
CONTENTVIEW = 'Content View' |
|
43 |
SYSTEMGROUPS = 'System Groups' |
|
44 |
VIRTUAL = 'Virtual' |
|
45 |
HOST = 'Host' |
|
46 |
OPERATINGSYSTEM = 'OS' |
|
47 |
ARCHITECTURE = 'Arch' |
|
48 |
SOCKETS = 'Sockets' |
|
49 |
RAM = 'RAM' |
|
50 |
CORES = 'Cores' |
|
51 |
SLA = 'SLA' |
|
52 |
PRODUCTS = 'Products' |
|
53 |
SUBSCRIPTIONS = 'Subscriptions' |
|
54 |
|
|
55 |
def export |
|
56 |
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv| |
|
57 |
csv << [NAME, COUNT, ORGANIZATION, ENVIRONMENT, CONTENTVIEW, SYSTEMGROUPS, VIRTUAL, HOST, |
|
58 |
OPERATINGSYSTEM, ARCHITECTURE, SOCKETS, RAM, CORES, SLA, PRODUCTS, SUBSCRIPTIONS] |
|
59 |
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization| |
|
60 |
@api.resource(:systems).call(:index, { |
|
61 |
'per_page' => 999999, |
|
62 |
'organization_id' => katello_organization(:name => organization['name']) |
|
63 |
})['results'].each do |system| |
|
64 |
system = @api.resource(:systems).call(:show, { |
|
65 |
'id' => system['uuid'], |
|
66 |
'fields' => 'full' |
|
67 |
}) |
|
68 |
|
|
69 |
name = system['name'] |
|
70 |
count = 1 |
|
71 |
organization_name = organization['name'] |
|
72 |
environment = system['environment']['label'] |
|
73 |
contentview = system['content_view']['name'] |
|
74 |
systemgroups = CSV.generate do |column| |
|
75 |
column << system['systemGroups'].collect do |systemgroup| |
|
76 |
systemgroup['name'] |
|
77 |
end |
|
78 |
end |
|
79 |
systemgroups.delete!("\n") |
|
80 |
virtual = system['facts']['virt.is_guest'] == 'true' ? 'Yes' : 'No' |
|
81 |
host = system['host'] |
|
82 |
operatingsystem = "#{system['facts']['distribution.name']} " if system['facts']['distribution.name'] |
|
83 |
operatingsystem += system['facts']['distribution.version'] if system['facts']['distribution.version'] |
|
84 |
architecture = system['facts']['uname.machine'] |
|
85 |
sockets = system['facts']['cpu.cpu_socket(s)'] |
|
86 |
ram = system['facts']['memory.memtotal'] |
|
87 |
cores = system['facts']['cpu.core(s)_per_socket'] |
|
88 |
sla = '' |
|
89 |
products = CSV.generate do |column| |
|
90 |
column << system['installedProducts'].collect do |product| |
|
91 |
"#{product['productId']}|#{product['productName']}" |
|
92 |
end |
|
93 |
end |
|
94 |
products.delete!("\n") |
|
95 |
subscriptions = CSV.generate do |column| |
|
96 |
column << @api.resource(:subscriptions).call(:index, { |
|
97 |
'system_id' => system['uuid'] |
|
98 |
})['results'].collect do |subscription| |
|
99 |
"#{subscription['product_id']}|#{subscription['product_name']}" |
|
100 |
end |
|
101 |
end |
|
102 |
subscriptions.delete!("\n") |
|
103 |
csv << [name, count, organization_name, environment, contentview, systemgroups, virtual, host, |
|
104 |
operatingsystem, architecture, sockets, ram, cores, sla, products, subscriptions] |
|
105 |
end |
|
106 |
end |
|
107 |
end |
|
108 |
end |
|
109 |
|
|
110 |
def import |
|
111 |
@existing = {} |
|
112 |
@host_guests = {} |
|
113 |
|
|
114 |
thread_import do |line| |
|
115 |
create_systems_from_csv(line) |
|
116 |
end |
|
117 |
|
|
118 |
print 'Updating host and guest associations...' if option_verbose? |
|
119 |
@host_guests.each do |host_id, guest_ids| |
|
120 |
@api.resource(:systems).call(:update, { |
|
121 |
'id' => host_id, |
|
122 |
'guest_ids' => guest_ids |
|
123 |
}) |
|
124 |
end |
|
125 |
puts 'done' if option_verbose? |
|
126 |
end |
|
127 |
|
|
128 |
def create_systems_from_csv(line) |
|
129 |
if !@existing[line[ORGANIZATION]] |
|
130 |
@existing[line[ORGANIZATION]] = {} |
|
131 |
@api.resource(:systems).call(:index, { |
|
132 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]), |
|
133 |
'page_size' => 999999})['results'].each do |system| |
|
134 |
@existing[line[ORGANIZATION]][system['name']] = system['uuid'] if system |
|
135 |
end |
|
136 |
end |
|
137 |
|
|
138 |
line[COUNT].to_i.times do |number| |
|
139 |
name = namify(line[NAME], number) |
|
140 |
|
|
141 |
# TODO w/ @daviddavis p-r |
|
142 |
#subscriptions(line).each do |subscription| |
|
143 |
# katello_subscription(line[ORGANIZATION], :name => subscription[:number]) |
|
144 |
#end |
|
145 |
|
|
146 |
if !@existing[line[ORGANIZATION]].include? name |
|
147 |
print "Creating system '#{name}'..." if option_verbose? |
|
148 |
system_id = @api.resource(:systems).call(:create, { |
|
149 |
'name' => name, |
|
150 |
'organization_id' => katello_organization(:name => line[ORGANIZATION]), |
|
151 |
'environment_id' => katello_environment(line[ORGANIZATION], :name => line[ENVIRONMENT]), |
|
152 |
'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]), |
|
153 |
'facts' => facts(name, line), |
|
154 |
'installed_products' => products(line), |
|
155 |
'type' => 'system' |
|
156 |
})['uuid'] |
|
157 |
@existing[line[ORGANIZATION]][name] = system_id |
|
158 |
else |
|
159 |
print "Updating system '#{name}'..." if option_verbose? |
|
160 |
system_id = @api.resource(:systems).call(:update, { |
|
161 |
'id' => @existing[line[ORGANIZATION]][name], |
|
162 |
'system' => { |
|
163 |
'name' => name, |
|
164 |
'environment_id' => katello_environment(line[ORGANIZATION], :name => line[ENVIRONMENT]), |
|
165 |
'content_view_id' => katello_contentview(line[ORGANIZATION], :name => line[CONTENTVIEW]), |
|
166 |
'facts' => facts(name, line), |
|
167 |
'installed_products' => products(line) |
|
168 |
} |
|
169 |
})['uuid'] |
|
170 |
end |
|
171 |
|
|
172 |
if line[VIRTUAL] == 'Yes' && line[HOST] |
|
173 |
raise "Host system '#{line[HOST]}' not found" if !@existing[line[ORGANIZATION]][line[HOST]] |
|
174 |
@host_guests[@existing[line[ORGANIZATION]][line[HOST]]] ||= [] |
|
175 |
@host_guests[@existing[line[ORGANIZATION]][line[HOST]]] << system_id |
|
176 |
end |
|
177 |
|
|
178 |
set_system_groups(system_id, line) |
|
179 |
|
|
180 |
puts 'done' if option_verbose? |
|
181 |
end |
|
182 |
rescue RuntimeError => e |
|
183 |
raise "#{e}\n #{line}" |
|
184 |
end |
|
185 |
|
|
186 |
private |
|
187 |
|
|
188 |
def facts(name, line) |
|
189 |
facts = {} |
|
190 |
facts['cpu.core(s)_per_socket'] = line[CORES] |
|
191 |
facts['cpu.cpu_socket(s)'] = line[SOCKETS] |
|
192 |
facts['memory.memtotal'] = line[RAM] |
|
193 |
facts['uname.machine'] = line[ARCHITECTURE] |
|
194 |
if line[OPERATINGSYSTEM].index(' ') |
|
195 |
(facts['distribution.name'], facts['distribution.version']) = line[OPERATINGSYSTEM].split(' ') |
|
196 |
else |
|
197 |
(facts['distribution.name'], facts['distribution.version']) = ['RHEL', line[OPERATINGSYSTEM]] |
|
198 |
end |
|
199 |
facts['virt.is_guest'] = line[VIRTUAL] == 'Yes' ? true : false |
|
200 |
facts['virt.uuid'] = "#{line[ORGANIZATION]}/#{name}" if facts['virt.is_guest'] |
|
201 |
facts |
|
202 |
end |
|
203 |
|
|
204 |
def set_system_groups(system_id, line) |
|
205 |
CSV.parse_line(line[SYSTEMGROUPS]).each do |systemgroup_name| |
|
206 |
@api.resource(:system_groups).call(:add_systems, { |
|
207 |
'id' => katello_systemgroup(line[ORGANIZATION], :name => systemgroup_name), |
|
208 |
'system_ids' => [system_id] |
|
209 |
}) |
|
210 |
end |
|
211 |
end |
|
212 |
|
|
213 |
def products(line) |
|
214 |
return nil if !line[PRODUCTS] |
|
215 |
products = CSV.parse_line(line[PRODUCTS]).collect do |product_details| |
|
216 |
product = {} |
|
217 |
# TODO: these get passed straight through to candlepin; probably would be better to process in server |
|
218 |
# to allow underscore product_id here |
|
219 |
(product['productId'], product['productName']) = product_details.split('|') |
|
220 |
product |
|
221 |
end |
|
222 |
products |
|
223 |
end |
|
224 |
|
|
225 |
def subscriptions(line) |
|
226 |
return nil if !line[SUBSCRIPTIONS] |
|
227 |
subscriptions = CSV.parse_line(line[SUBSCRIPTIONS]).collect do |subscription_details| |
|
228 |
subscription = {} |
|
229 |
(subscription[:number], subscription[:name]) = subscription_details.split('|') |
|
230 |
subscription |
|
231 |
end |
|
232 |
subscriptions |
|
233 |
end |
|
234 |
end |
|
235 |
end |
|
236 |
end |
test/data/activation-keys.csv | ||
---|---|---|
1 |
Name,Count,Organization,Description,Limit,Environment,Content View,Host Collections,Subscriptions |
|
2 |
damon.dials@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee","""RH00004|Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)""" |
|
3 |
jenee.jahns@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
4 |
gilbert.guerriero@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
5 |
quiana.quesnel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
6 |
bernard.bigler@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
7 |
marietta.menzel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
8 |
ruby.rieser@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
9 |
leonor.limberg@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
10 |
herminia.hochmuth@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
11 |
luana.larson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
12 |
gilda.gutirrez@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
13 |
karlene.kirch@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
14 |
chelsea.calaway@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
15 |
tajuana.thies@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
16 |
dominica.dubberly@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
17 |
gregg.gault@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
18 |
boyd.buckle@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
19 |
georgeanna.griffiths@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
20 |
julio.jerabek@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
21 |
chaya.cordova@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
22 |
reinaldo.reardon@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
23 |
nancie.nassar@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
24 |
ayako.alday@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
25 |
skye.strobl@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
26 |
merle.miceli@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
27 |
sung.skipper@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
28 |
danilo.dilbeck@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
29 |
marylee.millsap@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
30 |
rolf.rueb@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
31 |
miriam.messenger@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
32 |
danae.drayer@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
33 |
stan.stokely@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
34 |
martin.magallon@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
35 |
orville.oneill@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
36 |
kourtney.kyle@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
37 |
tessa.treiber@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
38 |
kamilah.kurland@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
39 |
zelma.zemke@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
40 |
jefferson.jock@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
41 |
shirely.stowe@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
42 |
niesha.nold@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
43 |
bruce.butterworth@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
44 |
denna.debartolo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
45 |
janay.johnson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
46 |
kristen.kellems@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
47 |
tiny.tacy@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
48 |
dolores.delay@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
49 |
shira.sitzes@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
50 |
aron.askew@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
51 |
nydia.neil@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
52 |
theodore.talbert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
53 |
shani.spinks@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
54 |
diedra.darrow@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
55 |
judith.joachim@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
56 |
melda.metheny@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
57 |
nannie.nobles@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
58 |
annamae.audie@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
59 |
kalyn.kimzey@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
60 |
hsiu.henningsen@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
61 |
delcie.diez@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
62 |
edris.ekhoff@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
63 |
monique.maly@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
64 |
robbi.rosendahl@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
65 |
lakeesha.loiacono@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
66 |
coralee.culbert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
67 |
danette.dewitt@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
68 |
cinthia.cadieux@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
69 |
myron.mclawhorn@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
70 |
madeleine.magers@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
71 |
evita.epting@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
72 |
karrie.kindel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
73 |
moses.modisette@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
74 |
winifred.wessels@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
75 |
ashton.aumann@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
76 |
guillermina.gloster@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
77 |
jeremy.jong@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
78 |
marilou.mcintosh@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
79 |
rubin.ravenscroft@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
80 |
peggie.phillips@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
81 |
evelina.elders@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
82 |
edda.elam@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
83 |
fausto.fortino@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
84 |
elena.eisert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
85 |
mariella.molock@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
86 |
starla.scheiber@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
87 |
parker.paetzold@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
88 |
vallie.vizcaino@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
89 |
renea.rubenstein@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
90 |
lien.lipscomb@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
91 |
debby.dupuy@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
92 |
carolann.corbo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
93 |
lee.litchfield@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
94 |
lashon.locker@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
95 |
caroll.colquitt@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
96 |
lillian.louviere@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
97 |
rafaela.rasco@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
98 |
mandie.mcquinn@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
99 |
bambi.bivona@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
100 |
jacques.joaquin@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
101 |
wes.wallner@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
102 |
retta.rosso@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
103 |
melia.meche@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
104 |
nga.nordquist@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
105 |
georgine.grimmett@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
106 |
elden.easley@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
107 |
van.villanveva@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
108 |
shemika.spikes@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
109 |
bettina.budniewski@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
110 |
yun.yarberry@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
111 |
mac.malmberg@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
112 |
rory.rollinson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
113 |
silva.sotelo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
114 |
le.leggett@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
115 |
eartha.edie@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
116 |
tenisha.tinajero@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
117 |
hien.hamby@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
118 |
milford.mize@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
119 |
elnora.efaw@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
test/data/activationkeys.csv | ||
---|---|---|
1 |
Name,Count,Organization,Description,Limit,Environment,Content View,System Groups,Subscriptions |
|
2 |
damon.dials@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee","""RH00004|Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)""" |
|
3 |
jenee.jahns@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
4 |
gilbert.guerriero@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
5 |
quiana.quesnel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
6 |
bernard.bigler@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
7 |
marietta.menzel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
8 |
ruby.rieser@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
9 |
leonor.limberg@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
10 |
herminia.hochmuth@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
11 |
luana.larson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
12 |
gilda.gutirrez@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
13 |
karlene.kirch@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
14 |
chelsea.calaway@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
15 |
tajuana.thies@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
16 |
dominica.dubberly@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
17 |
gregg.gault@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
18 |
boyd.buckle@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
19 |
georgeanna.griffiths@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
20 |
julio.jerabek@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
21 |
chaya.cordova@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
22 |
reinaldo.reardon@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
23 |
nancie.nassar@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
24 |
ayako.alday@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
25 |
skye.strobl@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
26 |
merle.miceli@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
27 |
sung.skipper@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
28 |
danilo.dilbeck@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
29 |
marylee.millsap@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
30 |
rolf.rueb@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
31 |
miriam.messenger@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
32 |
danae.drayer@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
33 |
stan.stokely@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
34 |
martin.magallon@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
35 |
orville.oneill@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
36 |
kourtney.kyle@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
37 |
tessa.treiber@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
38 |
kamilah.kurland@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
39 |
zelma.zemke@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
40 |
jefferson.jock@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
41 |
shirely.stowe@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
42 |
niesha.nold@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
43 |
bruce.butterworth@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
44 |
denna.debartolo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
45 |
janay.johnson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
46 |
kristen.kellems@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
47 |
tiny.tacy@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
48 |
dolores.delay@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
49 |
shira.sitzes@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
50 |
aron.askew@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
51 |
nydia.neil@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
52 |
theodore.talbert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
53 |
shani.spinks@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
54 |
diedra.darrow@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
55 |
judith.joachim@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
56 |
melda.metheny@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
57 |
nannie.nobles@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
58 |
annamae.audie@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
59 |
kalyn.kimzey@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
60 |
hsiu.henningsen@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
61 |
delcie.diez@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
62 |
edris.ekhoff@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
63 |
monique.maly@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
64 |
robbi.rosendahl@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
65 |
lakeesha.loiacono@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
66 |
coralee.culbert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
67 |
danette.dewitt@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
68 |
cinthia.cadieux@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
69 |
myron.mclawhorn@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
70 |
madeleine.magers@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
71 |
evita.epting@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
72 |
karrie.kindel@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
73 |
moses.modisette@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
74 |
winifred.wessels@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
75 |
ashton.aumann@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
76 |
guillermina.gloster@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
77 |
jeremy.jong@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
78 |
marilou.mcintosh@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
79 |
rubin.ravenscroft@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
80 |
peggie.phillips@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
81 |
evelina.elders@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
82 |
edda.elam@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
83 |
fausto.fortino@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
84 |
elena.eisert@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
85 |
mariella.molock@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
86 |
starla.scheiber@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
87 |
parker.paetzold@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
88 |
vallie.vizcaino@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
89 |
renea.rubenstein@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
90 |
lien.lipscomb@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
91 |
debby.dupuy@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
92 |
carolann.corbo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
93 |
lee.litchfield@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
94 |
lashon.locker@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
95 |
caroll.colquitt@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
96 |
lillian.louviere@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
97 |
rafaela.rasco@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
98 |
mandie.mcquinn@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
99 |
bambi.bivona@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
100 |
jacques.joaquin@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
101 |
wes.wallner@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
102 |
retta.rosso@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
103 |
melia.meche@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
104 |
nga.nordquist@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
105 |
georgine.grimmett@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
106 |
elden.easley@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
107 |
van.villanveva@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
108 |
shemika.spikes@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
109 |
bettina.budniewski@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
110 |
yun.yarberry@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
111 |
mac.malmberg@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
112 |
rory.rollinson@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Employee" |
|
113 |
silva.sotelo@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
114 |
le.leggett@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
115 |
eartha.edie@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
116 |
tenisha.tinajero@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
117 |
hien.hamby@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
118 |
milford.mize@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
|
119 |
elnora.efaw@megacorp.com,1,Mega Corporation,"Individual account",1,Library,Default Organization View,"Contractor" |
test/data/content-hosts.csv | ||
---|---|---|
1 |
Name,Count,Organization,Environment,Content View,Host Collections,Virtual,Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions |
|
2 |
host%d,1,Mega Corporation,Library,Default Organization View,"Mega Corp HQ",No,,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests) |
|
3 |
guest%d,1,Mega Corporation,Library,Default Organization View,"Mega Corp HQ,Accounting",Yes,host0,RHEL 6.4,x86_64,1,4,1,Standard,"69|Red Hat Enterprise Linux Server,79|Red Hat Enterprise Linux Server",RH0103708|Red Hat Enterprise Linux Server Premium (8 sockets) (Up to 4 guests) |
|
4 |
|
test/data/host-collections.csv | ||
---|---|---|
1 |
Name,Count,Organization,Limit,Description |
|
2 |
Mega Corp HQ,1,Mega Corporation,Unlimited,Downtown headquarters |
|
3 |
Engineering,1,Mega Corporation,Unlimited,, |
|
4 |
Quality,1,Mega Corporation,Unlimited,, |
|
5 |
Accounting,1,Mega Corporation,Unlimited,, |
|
6 |
Facilities,1,Mega Corporation,Unlimited,, |
|
7 |
Shipping,1,Mega Corporation,Unlimited,, |
|
8 |
Lobby,1,Mega Corporation,Unlimited,, |
|
9 |
Customer Service,1,Mega Corporation,Unlimited,, |
|
10 |
Marketing,1,Mega Corporation,Unlimited,, |
|
11 |
HR,1,Mega Corporation,Unlimited,, |
|
12 |
Sales,1,Mega Corporation,Unlimited,, |
|
13 |
Legal,1,Mega Corporation,Unlimited,, |
|
14 |
Senior Leadership,1,Mega Corporation,Unlimited,, |
|
15 |
Employee,1,Mega Corporation,Unlimited,, |
|
16 |
Contractor,1,Mega Corporation,Unlimited,, |
test/data/lifecycle-environments.csv | ||
---|---|---|
1 |
"Name","Count","Label","Organization","Prior Environment","Description" |
|
2 |
"Development","1","Development","Mega Corporation","Library","" |
|
3 |
"Testing","1","Testing","Mega Corporation","Development","" |
|
4 |
"Stage","1","Stage","Mega Corporation","Testing","" |
|
5 |
"Production","1","Production","Mega Corporation","Stage","" |
|
6 |
"OpenStack","1","OpenStack","Mega Corporation","Library","" |
test/data/lifecycleenvironments.csv | ||
---|---|---|
1 |
"Name","Count","Label","Organization","Prior Environment","Description" |
|
2 |
"Development","1","Development","Mega Corporation","Library","" |
|
3 |
"Testing","1","Testing","Mega Corporation","Development","" |
|
4 |
"Stage","1","Stage","Mega Corporation","Testing","" |
|
5 |
"Production","1","Production","Mega Corporation","Stage","" |
|
6 |
"OpenStack","1","OpenStack","Mega Corporation","Library","" |
test/data/operating-systems.csv | ||
---|---|---|
1 |
"Name","Count","Family" |
|
2 |
"CentOS 6.4","1","Redhat" |
|
3 |
"Debian 6.0","1","Debian" |
|
4 |
"Debian 7.0","1","Debian" |
|
5 |
"Fedora 14","1","Redhat" |
|
6 |
"Fedora 17","1","Redhat" |
|
7 |
"Fedora 18","1","Redhat" |
|
8 |
"Fedora 19","1","Redhat" |
|
9 |
"OpenSuSE 11.4","1","Suse" |
|
10 |
"RHEL 5.8","1","Redhat" |
|
11 |
"RHEL 6.3","1","Redhat" |
|
12 |
"RHEL 5.7","1","Redhat" |
|
13 |
"RHEL 6.4","1","Redhat" |
|
14 |
"Solaris 5.10","1","Solaris" |
|
15 |
"Ubuntu 12.10","1","Debian" |
|
16 |
"Windows 6.1","1","Windows" |
Also available in: Unified diff
a lot of fixes and updates across many resources to match katello updates