hammer_cli_csv 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/config/cli_config.yml +9 -24
- data/lib/hammer_cli_csv/activation_keys.rb +220 -95
- data/lib/hammer_cli_csv/architectures.rb +7 -11
- data/lib/hammer_cli_csv/base.rb +67 -41
- data/lib/hammer_cli_csv/compute_profiles.rb +11 -15
- data/lib/hammer_cli_csv/compute_resources.rb +11 -15
- data/lib/hammer_cli_csv/containers.rb +10 -12
- data/lib/hammer_cli_csv/content_hosts.rb +285 -203
- data/lib/hammer_cli_csv/content_view_filters.rb +32 -36
- data/lib/hammer_cli_csv/content_views.rb +33 -37
- data/lib/hammer_cli_csv/csv.rb +17 -1
- data/lib/hammer_cli_csv/domains.rb +15 -19
- data/lib/hammer_cli_csv/export.rb +13 -5
- data/lib/hammer_cli_csv/host_collections.rb +20 -22
- data/lib/hammer_cli_csv/host_groups.rb +73 -65
- data/lib/hammer_cli_csv/hosts.rb +30 -34
- data/lib/hammer_cli_csv/import.rb +24 -10
- data/lib/hammer_cli_csv/installation_media.rb +74 -0
- data/lib/hammer_cli_csv/job_templates.rb +37 -41
- data/lib/hammer_cli_csv/lifecycle_environments.rb +15 -19
- data/lib/hammer_cli_csv/locations.rb +4 -6
- data/lib/hammer_cli_csv/operating_systems.rb +17 -21
- data/lib/hammer_cli_csv/organizations.rb +11 -13
- data/lib/hammer_cli_csv/partition_tables.rb +17 -21
- data/lib/hammer_cli_csv/products.rb +200 -92
- data/lib/hammer_cli_csv/provisioning_templates.rb +19 -23
- data/lib/hammer_cli_csv/puppet_environments.rb +8 -12
- data/lib/hammer_cli_csv/puppet_facts.rb +20 -24
- data/lib/hammer_cli_csv/puppet_reports.rb +47 -51
- data/lib/hammer_cli_csv/reports.rb +6 -10
- data/lib/hammer_cli_csv/roles.rb +12 -16
- data/lib/hammer_cli_csv/settings.rb +8 -6
- data/lib/hammer_cli_csv/smart_proxies.rb +9 -13
- data/lib/hammer_cli_csv/splice.rb +1 -3
- data/lib/hammer_cli_csv/subnets.rb +24 -28
- data/lib/hammer_cli_csv/subscriptions.rb +39 -91
- data/lib/hammer_cli_csv/sync_plans.rb +20 -24
- data/lib/hammer_cli_csv/users.rb +25 -29
- data/lib/hammer_cli_csv/utils/subscriptions.rb +130 -0
- data/lib/hammer_cli_csv/version.rb +1 -1
- data/lib/hammer_cli_csv.rb +2 -2
- data/test/csv_test.rb +32 -0
- data/test/csv_test_helper.rb +17 -2
- data/test/data/content-hosts.csv +3 -2
- data/test/data/hosts.csv +0 -11
- data/test/data/settings.csv +1 -0
- data/test/data/setup/content-hosts.csv +1 -0
- data/test/data/setup/content-views.csv +2 -0
- data/test/data/setup/lifecycle-environments.csv +5 -0
- data/test/data/setup/locations.csv +6 -0
- data/test/data/setup/organizations.csv +2 -0
- data/test/data/setup/subscriptions.csv +5 -0
- data/test/data/subscriptions.csv +15 -17
- data/test/export_test.rb +27 -0
- data/test/fixtures/vcr_cassettes/apipie.yml +18528 -0
- data/test/fixtures/vcr_cassettes/resources/activation_keys_import/create_and_update.yml +38033 -0
- data/test/fixtures/vcr_cassettes/resources/content_hosts_export/export.yml +18846 -0
- data/test/fixtures/vcr_cassettes/resources/content_hosts_export/export_subscriptions.yml +323 -0
- data/test/fixtures/vcr_cassettes/resources/content_hosts_import/create_and_update.yml +41884 -0
- data/test/fixtures/vcr_cassettes/resources/content_hosts_import/import_single_line.yml +38248 -0
- data/test/fixtures/vcr_cassettes/resources/settings_import/update_settings.yml +18832 -0
- data/test/fixtures/vcr_cassettes/resources/settings_import/update_settings_continue.yml +316 -0
- data/test/fixtures/vcr_cassettes/resources/subscriptions_import/manifest_does_not_exist.yml +18785 -0
- data/test/fixtures/vcr_cassettes/setup/setup_content_views/setup.yml +19090 -0
- data/test/fixtures/vcr_cassettes/setup/setup_lifecycle_environments/setup.yml +924 -0
- data/test/fixtures/vcr_cassettes/setup/setup_locations/setup.yml +21102 -0
- data/test/fixtures/vcr_cassettes/setup/setup_organizations/setup.yml +19278 -0
- data/test/fixtures/vcr_cassettes/setup/setup_subscriptions/setup.yml +419 -0
- data/test/import_test.rb +20 -25
- data/test/resources/activation_keys_test.rb +72 -0
- data/test/resources/content_hosts_test.rb +132 -0
- data/test/resources/settings_test.rb +81 -0
- data/test/resources/subscriptions_test.rb +56 -0
- data/test/setup/setup_content_views.rb +17 -0
- data/test/setup/setup_lifecycle_environments.rb +17 -0
- data/test/setup/setup_locations.rb +17 -0
- data/test/setup/setup_organizations.rb +17 -0
- data/test/setup/setup_subscriptions.rb +20 -0
- data/test/setup/setup_test.rb +10 -0
- data/test/test_runner.rb +175 -0
- data/test/vcr_setup.rb +54 -0
- metadata +77 -13
- data/lib/hammer_cli_csv/exception_handler.rb +0 -42
- data/lib/hammer_cli_csv/installation_medias.rb +0 -77
- data/test/content_hosts_test.rb +0 -61
- data/test/settings_test.rb +0 -30
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas McKay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hammer_cli_katello
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -60,7 +60,6 @@ files:
|
|
60
60
|
- lib/hammer_cli_csv/content_views.rb
|
61
61
|
- lib/hammer_cli_csv/csv.rb
|
62
62
|
- lib/hammer_cli_csv/domains.rb
|
63
|
-
- lib/hammer_cli_csv/exception_handler.rb
|
64
63
|
- lib/hammer_cli_csv/export.rb
|
65
64
|
- lib/hammer_cli_csv/headpin_api.rb
|
66
65
|
- lib/hammer_cli_csv/host_collections.rb
|
@@ -68,7 +67,7 @@ files:
|
|
68
67
|
- lib/hammer_cli_csv/hosts.rb
|
69
68
|
- lib/hammer_cli_csv/i18n.rb
|
70
69
|
- lib/hammer_cli_csv/import.rb
|
71
|
-
- lib/hammer_cli_csv/
|
70
|
+
- lib/hammer_cli_csv/installation_media.rb
|
72
71
|
- lib/hammer_cli_csv/job_templates.rb
|
73
72
|
- lib/hammer_cli_csv/lifecycle_environments.rb
|
74
73
|
- lib/hammer_cli_csv/locations.rb
|
@@ -89,12 +88,13 @@ files:
|
|
89
88
|
- lib/hammer_cli_csv/subscriptions.rb
|
90
89
|
- lib/hammer_cli_csv/sync_plans.rb
|
91
90
|
- lib/hammer_cli_csv/users.rb
|
91
|
+
- lib/hammer_cli_csv/utils/subscriptions.rb
|
92
92
|
- lib/hammer_cli_csv/version.rb
|
93
93
|
- test/activation_keys_test.rb
|
94
94
|
- test/apipie_resource_mock.rb
|
95
95
|
- test/config.template.yml
|
96
|
-
- test/content_hosts_test.rb
|
97
96
|
- test/content_views_test.rb
|
97
|
+
- test/csv_test.rb
|
98
98
|
- test/csv_test_helper.rb
|
99
99
|
- test/data/activation-keys.csv
|
100
100
|
- test/data/architectures.csv
|
@@ -116,19 +116,51 @@ files:
|
|
116
116
|
- test/data/reports.csv
|
117
117
|
- test/data/roles.csv
|
118
118
|
- test/data/settings.csv
|
119
|
+
- test/data/setup/content-hosts.csv
|
120
|
+
- test/data/setup/content-views.csv
|
121
|
+
- test/data/setup/lifecycle-environments.csv
|
122
|
+
- test/data/setup/locations.csv
|
123
|
+
- test/data/setup/organizations.csv
|
124
|
+
- test/data/setup/subscriptions.csv
|
119
125
|
- test/data/smart-proxies.csv
|
120
126
|
- test/data/subscriptions.csv
|
121
127
|
- test/data/users.csv
|
128
|
+
- test/export_test.rb
|
129
|
+
- test/fixtures/vcr_cassettes/apipie.yml
|
130
|
+
- test/fixtures/vcr_cassettes/resources/activation_keys_import/create_and_update.yml
|
131
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_export/export.yml
|
132
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_export/export_subscriptions.yml
|
133
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_import/create_and_update.yml
|
134
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_import/import_single_line.yml
|
135
|
+
- test/fixtures/vcr_cassettes/resources/settings_import/update_settings.yml
|
136
|
+
- test/fixtures/vcr_cassettes/resources/settings_import/update_settings_continue.yml
|
137
|
+
- test/fixtures/vcr_cassettes/resources/subscriptions_import/manifest_does_not_exist.yml
|
138
|
+
- test/fixtures/vcr_cassettes/setup/setup_content_views/setup.yml
|
139
|
+
- test/fixtures/vcr_cassettes/setup/setup_lifecycle_environments/setup.yml
|
140
|
+
- test/fixtures/vcr_cassettes/setup/setup_locations/setup.yml
|
141
|
+
- test/fixtures/vcr_cassettes/setup/setup_organizations/setup.yml
|
142
|
+
- test/fixtures/vcr_cassettes/setup/setup_subscriptions/setup.yml
|
122
143
|
- test/helpers/command.rb
|
123
144
|
- test/helpers/resource_disabled.rb
|
124
145
|
- test/hosts_test.rb
|
125
146
|
- test/import_test.rb
|
126
147
|
- test/job_templates_test.rb
|
127
148
|
- test/organizations_test.rb
|
149
|
+
- test/resources/activation_keys_test.rb
|
150
|
+
- test/resources/content_hosts_test.rb
|
151
|
+
- test/resources/settings_test.rb
|
152
|
+
- test/resources/subscriptions_test.rb
|
128
153
|
- test/roles_test.rb
|
129
|
-
- test/
|
154
|
+
- test/setup/setup_content_views.rb
|
155
|
+
- test/setup/setup_lifecycle_environments.rb
|
156
|
+
- test/setup/setup_locations.rb
|
157
|
+
- test/setup/setup_organizations.rb
|
158
|
+
- test/setup/setup_subscriptions.rb
|
159
|
+
- test/setup/setup_test.rb
|
130
160
|
- test/setup_test.rb
|
161
|
+
- test/test_runner.rb
|
131
162
|
- test/users_test.rb
|
163
|
+
- test/vcr_setup.rb
|
132
164
|
homepage: http://github.com/Katello/hammer-cli-csv
|
133
165
|
licenses:
|
134
166
|
- GPL-3
|
@@ -139,17 +171,17 @@ require_paths:
|
|
139
171
|
- lib
|
140
172
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
173
|
requirements:
|
142
|
-
- -
|
174
|
+
- - ">="
|
143
175
|
- !ruby/object:Gem::Version
|
144
176
|
version: '0'
|
145
177
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
178
|
requirements:
|
147
|
-
- -
|
179
|
+
- - ">="
|
148
180
|
- !ruby/object:Gem::Version
|
149
181
|
version: '0'
|
150
182
|
requirements: []
|
151
183
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.5.1
|
153
185
|
signing_key:
|
154
186
|
specification_version: 4
|
155
187
|
summary: CSV commands for Hammer
|
@@ -157,8 +189,8 @@ test_files:
|
|
157
189
|
- test/activation_keys_test.rb
|
158
190
|
- test/apipie_resource_mock.rb
|
159
191
|
- test/config.template.yml
|
160
|
-
- test/content_hosts_test.rb
|
161
192
|
- test/content_views_test.rb
|
193
|
+
- test/csv_test.rb
|
162
194
|
- test/csv_test_helper.rb
|
163
195
|
- test/data/activation-keys.csv
|
164
196
|
- test/data/architectures.csv
|
@@ -180,16 +212,48 @@ test_files:
|
|
180
212
|
- test/data/reports.csv
|
181
213
|
- test/data/roles.csv
|
182
214
|
- test/data/settings.csv
|
215
|
+
- test/data/setup/content-hosts.csv
|
216
|
+
- test/data/setup/content-views.csv
|
217
|
+
- test/data/setup/lifecycle-environments.csv
|
218
|
+
- test/data/setup/locations.csv
|
219
|
+
- test/data/setup/organizations.csv
|
220
|
+
- test/data/setup/subscriptions.csv
|
183
221
|
- test/data/smart-proxies.csv
|
184
222
|
- test/data/subscriptions.csv
|
185
223
|
- test/data/users.csv
|
224
|
+
- test/export_test.rb
|
225
|
+
- test/fixtures/vcr_cassettes/apipie.yml
|
226
|
+
- test/fixtures/vcr_cassettes/resources/activation_keys_import/create_and_update.yml
|
227
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_export/export.yml
|
228
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_export/export_subscriptions.yml
|
229
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_import/create_and_update.yml
|
230
|
+
- test/fixtures/vcr_cassettes/resources/content_hosts_import/import_single_line.yml
|
231
|
+
- test/fixtures/vcr_cassettes/resources/settings_import/update_settings.yml
|
232
|
+
- test/fixtures/vcr_cassettes/resources/settings_import/update_settings_continue.yml
|
233
|
+
- test/fixtures/vcr_cassettes/resources/subscriptions_import/manifest_does_not_exist.yml
|
234
|
+
- test/fixtures/vcr_cassettes/setup/setup_content_views/setup.yml
|
235
|
+
- test/fixtures/vcr_cassettes/setup/setup_lifecycle_environments/setup.yml
|
236
|
+
- test/fixtures/vcr_cassettes/setup/setup_locations/setup.yml
|
237
|
+
- test/fixtures/vcr_cassettes/setup/setup_organizations/setup.yml
|
238
|
+
- test/fixtures/vcr_cassettes/setup/setup_subscriptions/setup.yml
|
186
239
|
- test/helpers/command.rb
|
187
240
|
- test/helpers/resource_disabled.rb
|
188
241
|
- test/hosts_test.rb
|
189
242
|
- test/import_test.rb
|
190
243
|
- test/job_templates_test.rb
|
191
244
|
- test/organizations_test.rb
|
245
|
+
- test/resources/activation_keys_test.rb
|
246
|
+
- test/resources/content_hosts_test.rb
|
247
|
+
- test/resources/settings_test.rb
|
248
|
+
- test/resources/subscriptions_test.rb
|
192
249
|
- test/roles_test.rb
|
193
|
-
- test/
|
250
|
+
- test/setup/setup_content_views.rb
|
251
|
+
- test/setup/setup_lifecycle_environments.rb
|
252
|
+
- test/setup/setup_locations.rb
|
253
|
+
- test/setup/setup_organizations.rb
|
254
|
+
- test/setup/setup_subscriptions.rb
|
255
|
+
- test/setup/setup_test.rb
|
194
256
|
- test/setup_test.rb
|
257
|
+
- test/test_runner.rb
|
195
258
|
- test/users_test.rb
|
259
|
+
- test/vcr_setup.rb
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'hammer_cli/exception_handler'
|
2
|
-
|
3
|
-
module HammerCLICsv
|
4
|
-
class ExceptionHandler < HammerCLI::ExceptionHandler
|
5
|
-
def mappings
|
6
|
-
super + [
|
7
|
-
[Exception, :handle_csv_exception],
|
8
|
-
[RestClient::Forbidden, :handle_forbidden],
|
9
|
-
[RestClient::UnprocessableEntity, :handle_unprocessable_entity],
|
10
|
-
[ArgumentError, :handle_argument_error]
|
11
|
-
]
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
|
16
|
-
def handle_csv_exception(e)
|
17
|
-
$stderr.puts e.message
|
18
|
-
log_full_error e
|
19
|
-
HammerCLI::EX_DATAERR
|
20
|
-
end
|
21
|
-
|
22
|
-
def handle_unprocessable_entity(e)
|
23
|
-
response = JSON.parse(e.response)
|
24
|
-
response = response[response.keys[0]]
|
25
|
-
|
26
|
-
print_error response['full_messages']
|
27
|
-
HammerCLI::EX_DATAERR
|
28
|
-
end
|
29
|
-
|
30
|
-
def handle_argument_error(e)
|
31
|
-
print_error e.message
|
32
|
-
log_full_error e
|
33
|
-
HammerCLI::EX_USAGE
|
34
|
-
end
|
35
|
-
|
36
|
-
def handle_forbidden(e)
|
37
|
-
print_error 'Forbidden - server refused to process the request'
|
38
|
-
log_full_error e
|
39
|
-
HammerCLI::EX_NOPERM
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module HammerCLICsv
|
2
|
-
class CsvCommand
|
3
|
-
class InstallationMediasCommand < BaseCommand
|
4
|
-
command_name 'installation-medias'
|
5
|
-
desc 'import or export installation media'
|
6
|
-
|
7
|
-
OSFAMILY = 'OS Family'
|
8
|
-
PATH = 'Path'
|
9
|
-
ORGANIZATIONS = 'Organizations'
|
10
|
-
|
11
|
-
def export
|
12
|
-
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
|
13
|
-
csv << [NAME, PATH, OSFAMILY]
|
14
|
-
@api.resource(:media).call(:index, {:per_page => 999999})['results'].each do |installation_media|
|
15
|
-
name = installation_media['name']
|
16
|
-
count = 1
|
17
|
-
path = installation_media['path']
|
18
|
-
os_family = installation_media['os_family']
|
19
|
-
csv << [name, path, os_family]
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def import
|
25
|
-
@existing = {}
|
26
|
-
@api.resource(:media).call(:index, {:per_page => 999999})['results'].each do |installation_media|
|
27
|
-
@existing[installation_media['name']] = installation_media['id'] if installation_media
|
28
|
-
end
|
29
|
-
|
30
|
-
thread_import do |line|
|
31
|
-
create_installation_medias_from_csv(line)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def create_installation_medias_from_csv(line)
|
36
|
-
count(line[COUNT]).times do |number|
|
37
|
-
name = namify(line[NAME], number)
|
38
|
-
if !@existing.include? name
|
39
|
-
print "Creating installation_media '#{name}'..." if option_verbose?
|
40
|
-
installation_media_id = @api.resource(:media).call(:create, {
|
41
|
-
'name' => name
|
42
|
-
})['id']
|
43
|
-
else
|
44
|
-
print "Updating installation_media '#{name}'..." if option_verbose?
|
45
|
-
installation_media_id = @api.resource(:media).call(:update, {
|
46
|
-
'id' => @existing[name],
|
47
|
-
'name' => name
|
48
|
-
})['id']
|
49
|
-
end
|
50
|
-
|
51
|
-
# Update associated resources
|
52
|
-
installation_medias ||= {}
|
53
|
-
CSV.parse_line(line[ORGANIZATIONS]).each do |organization|
|
54
|
-
organization_id = foreman_organization(:name => organization)
|
55
|
-
if installation_medias[organization].nil?
|
56
|
-
installation_medias[organization] = @api.resource(:organizations).call(:show, {'id' => organization_id})['installation_medias'].collect do |installation_media|
|
57
|
-
installation_media['id']
|
58
|
-
end
|
59
|
-
end
|
60
|
-
installation_medias[organization] += [installation_media_id] if !installation_medias[organization].include? installation_media_id
|
61
|
-
|
62
|
-
@api.resource(:organizations).call(:update, {
|
63
|
-
'id' => organization_id,
|
64
|
-
'organization' => {
|
65
|
-
'installation_media_ids' => installation_medias[organization]
|
66
|
-
}
|
67
|
-
})
|
68
|
-
end
|
69
|
-
|
70
|
-
print "done\n" if option_verbose?
|
71
|
-
end
|
72
|
-
rescue RuntimeError => e
|
73
|
-
raise "#{e}\n #{line}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
data/test/content_hosts_test.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'csv_test_helper')
|
2
|
-
|
3
|
-
describe 'content-hosts' do
|
4
|
-
|
5
|
-
extend CommandTestHelper
|
6
|
-
|
7
|
-
context "import" do
|
8
|
-
it "update content host facts" do
|
9
|
-
set_user 'admin'
|
10
|
-
|
11
|
-
hostname = "host#{rand(10000)}"
|
12
|
-
|
13
|
-
# Create content host
|
14
|
-
file = Tempfile.new('content_hosts_test')
|
15
|
-
file.write("Name,Count,Organization,Environment,Content View,Host Collections,Virtual,Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions\n")
|
16
|
-
file.write("#{hostname},1,Mega Corporation,Library,Default Organization View,Mega Corp HQ,No,,RHEL 6.4,x86_64,1,4,1,,,\n")
|
17
|
-
file.rewind
|
18
|
-
|
19
|
-
stdout,stderr = capture {
|
20
|
-
hammer.run(%W{csv content-hosts --verbose --file #{file.path}})
|
21
|
-
}
|
22
|
-
stderr.must_equal ''
|
23
|
-
stdout[0..-2].must_equal "Creating content host '#{hostname}'...done\nUpdating hypervisor and guest associations...done"
|
24
|
-
file.unlink
|
25
|
-
|
26
|
-
# Update system
|
27
|
-
file = Tempfile.new('systems_test')
|
28
|
-
file.write("Name,Count,Organization,Environment,Content View,System Groups,Virtual,Host,OS,Arch,Sockets,RAM,Cores,SLA,Products,Subscriptions\n")
|
29
|
-
file.write("#{hostname},1,Mega Corporation,Library,Default Organization View,Mega Corp HQ,No,,RHEL 6.4,x86_64,1,8,1,,,\n")
|
30
|
-
file.rewind
|
31
|
-
|
32
|
-
stdout,stderr = capture {
|
33
|
-
hammer.run(%W{csv content-hosts --verbose --csv-file #{file.path}})
|
34
|
-
}
|
35
|
-
stderr.must_equal ''
|
36
|
-
stdout[0..-2].must_equal "Updating content host '#{hostname}'...done\nUpdating hypervisor and guest associations...done"
|
37
|
-
file.unlink
|
38
|
-
|
39
|
-
stdout,stderr = capture {
|
40
|
-
hammer.run(%W{organization list --search megacorp})
|
41
|
-
}
|
42
|
-
stdout.split("\n").length.must_equal 5
|
43
|
-
organization_id = stdout.split("\n")[3].split('|')[0].to_i
|
44
|
-
|
45
|
-
# Verify system
|
46
|
-
system = api.resource(:systems).call(:index, {
|
47
|
-
'organization_id' => organization_id,
|
48
|
-
'search' => hostname
|
49
|
-
})['results']
|
50
|
-
system.wont_be_nil
|
51
|
-
system.wont_be_empty
|
52
|
-
system[0]['name'].must_equal hostname
|
53
|
-
|
54
|
-
# Clean up
|
55
|
-
api.resource(:systems).call(:destroy, {
|
56
|
-
'id' => system[0]['id']
|
57
|
-
})
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
data/test/settings_test.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), 'csv_test_helper')
|
2
|
-
|
3
|
-
describe 'job-templates' do
|
4
|
-
|
5
|
-
extend CommandTestHelper
|
6
|
-
|
7
|
-
context "import" do
|
8
|
-
it "update settings w/ Count column" do
|
9
|
-
set_user 'admin'
|
10
|
-
|
11
|
-
name = "settings#{rand(10000)}"
|
12
|
-
|
13
|
-
file = Tempfile.new('settings_test')
|
14
|
-
# rubocop:disable LineLength
|
15
|
-
file.write <<-FILE
|
16
|
-
Name,Count,Value
|
17
|
-
idle_timeout,1,60000
|
18
|
-
FILE
|
19
|
-
file.rewind
|
20
|
-
|
21
|
-
stdout,stderr = capture {
|
22
|
-
hammer.run(%W{csv settings --verbose --file #{file.path}})
|
23
|
-
}
|
24
|
-
stderr.must_equal ''
|
25
|
-
lines = stdout.split("\n")
|
26
|
-
lines[0].must_equal "Updating setting 'idle_timeout'...done"
|
27
|
-
file.unlink
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|