Project

General

Profile

Download (25.2 KB) Statistics
| Branch: | Tag: | Revision:

hammer-cli-csv / README.md @ 4a6b2238

1
# hammer-cli-csv [![Build Status](https://travis-ci.org/Katello/hammer-cli-csv.svg?branch=master)](https://travis-ci.org/Katello/hammer-cli-csv) [![Coverage Status](https://coveralls.io/repos/github/Katello/hammer-cli-csv/badge.svg?branch=master)](https://coveralls.io/github/Katello/hammer-cli-csv?branch=master)
2

    
3
## Introduction
4

    
5
[Hammer](https://github.com/theforeman/hammer-cli/blob/master/README.md) is a command line interface (CLI) framework which provides a core to which modules may be added. This module, hammer-cli-csv, adds commands to interact with the following products: [Foreman](https://theforeman.org) standalone, [Katello](http://www.katello.org/), Red Hat's Satellite-6, and Red Hat's Subscription Asset Manager (SAM).
6

    
7
The purpose of this module's commands are to allow a convenient mechanism to both export to and import from CSV files (comma separated values). Each of the server's supported resource types, such as organizations and users, is handled.
8

    
9
Some possible uses include
10

    
11
* Import demo or development data easily and consistently
12
* Export another server's data and then import into elsewhere for testing and debug
13
* Export for backup and auditing
14

    
15
The following sections will cover installation, usage, and examples. All of the resource types are follow in the order which generally is required for dependency resolution (eg. roles must exist to assign to users so the role section comes first).
16

    
17
## Installation
18

    
19
```bash
20
gem install hammer_cli_csv
21
gem install hammer_cli_katello
22

    
23
mkdir -p ~/.hammer/cli.modules.d/
24

    
25
cat <<EOQ > ~/.hammer/cli.modules.d/csv.yml
26
:csv:
27
  :enable_module: true
28
EOQ
29

    
30
# to confirm things work, this should return useful output
31
hammer csv --help
32

    
33
```
34

    
35
## General Usage
36

    
37
Supported commands and options are available by using the --help option. Additional subcommands and options may be listed here but are considered "tech preview" to indicate the lack of testing and official support.
38

    
39
| Option | Description |
40
| ---------------:| :--------------|
41
| --export | If not specified will run import. |
42
| --file FILE_NAME | File to import from or export to. If not specified reads or writes to/from stdin and stdout. Note: On ruby-1.8.7 this option is required. |
43
| --prefix PREFIX | Convenience method to add a prefix to all Count substituted values. See examples below. |
44
| --server SERVER | The server to run against. Overrides any config file value. |
45
| --username USERNAME | Username for server. Overrides any config file value. |
46
| --password PASSWORD | Password for user. Overrides any config file value. |
47
| --verbose | Display verbose progress information during import. |
48
| --continue-on-error | Continue processing even if individual resource error |
49

    
50
## Count Substitution
51

    
52
Some columns of input data have a special syntax available termed "Count substitution" below.
53

    
54
This hammer module started out as a way to generate large amounts of test data. As such, it was convenient to be able to add a single row to an input CSV file and have it generate multiple records.
55

    
56
Take this Organization CSV as an example:
57

    
58
```
59
Name, Count, Label, Description
60
# Start a row with a # to indicate a comment, a row to be skipped
61
Organization %d, 4, testorg%d, A test organization
62
```
63

    
64
The single row, with a Count value of four, would generate four organizations ("Organization 0", "Organization 1", "Organization 2", and "Organization 3"). Notice that the Label column, which must be unique, also has the Count column substition.
65

    
66
During export, the Count column will always be one (1).
67

    
68
## Examples
69

    
70
## Organizations
71

    
72
**Overview**
73
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=organizations&state=open)
74
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/organizations_test.rb)
75
* Sample data
76
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/organizations.csv)
77

    
78
**CSV Columns**
79

    
80
*Note: % column indicates Count substituion*
81

    
82
| Column Title | Column Description | % |
83
| :----------- | :----------------- | :-: |
84
| Name         | Name of the organization to update or create | x |
85
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
86
| Label | Unique organization label | x |   |
87
| Description | Organization description |   |
88

    
89
**Examples**
90

    
91
Here is an example of a CSV file to create an organization
92

    
93
```
94
Name, Count, Label, Description
95
# Start a row with a # to indicate a comment, a row to be skipped
96
Mega Corporation, 1, megacorp, The number one mega company in the world!
97
```
98

    
99
If above is saved to a file such as **megacorp/organizations.csv** the following command will run import to create or update the organization.
100

    
101
```
102
$ hammer csv organizations --version --csv-file megacorp/organizations.csv
103
Updating organization 'Mega Corporation'... done
104

    
105
$ hammer csv organizations --csv-export
106
"Name","Count","Label","Description"
107
"Mega Corporation","1","megacorp","The number one mega company in the world!"
108

    
109
# Import but prefix all substitution columns with a string
110
$ hammer csv organizations --verbose --csv-file test/data/organizations.csv --prefix xyz
111
Creating organization 'xyzMega Corporation'... done
112

    
113
# Export and pipe to import with a new prefix
114
$ hammer csv organizations --csv-export | hammer csv organizations --verbose --csv-file test/data/organizations.csv --prefix abc
115
Creating organization 'abcMega Corporation'... done
116
```
117

    
118
## Locations
119

    
120
**Overview**
121
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=locations&state=open)
122
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/locations_test.rb)
123
* Sample data
124
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/locations.csv)
125

    
126
**CSV Columns**
127

    
128
*Note: % column indicates Count substituion*
129

    
130
| Column Title | Column Description | % |
131
| :----------- | :----------------- | :-: |
132
| Name         | Name of the location to update or create | x |
133
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
134
| Parent Location | Parent location |   |
135

    
136
## Puppet Environments
137

    
138
**Overview**
139
* Due to the implications of removing a puppet environment from an organization or location, this column only adds to what is present already.
140
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=puppet-environments&state=open)
141
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/puppet_environments_test.rb)
142
* Sample data
143
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/puppet-environments.csv)
144

    
145
**CSV Columns**
146

    
147
*Note: % column indicates Count substituion*
148

    
149
| Column Title | Column Description | % |
150
| :----------- | :----------------- | :-: |
151
| Name         | Name of the puppet environments to update or create | x |
152
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
153
| Organizations | Comma separated list of organizations |   |
154

    
155
## Operating Systems
156

    
157
**Overview**
158
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=operating-systems&state=open)
159
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/operating_systems_test.rb)
160
* Sample data
161
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/operating-systems.csv)
162

    
163
**CSV Columns**
164

    
165
*Note: % column indicates Count substituion*
166

    
167
| Column Title | Column Description | % |
168
| :----------- | :----------------- | :-: |
169
| Name         | Name of the operating systems to update or create | x |
170
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
171
| Family | Operating system family |   |
172
| Description | Operating system description |   |
173
| Password Hash | MD5, SHA256, SHA512, or Base64 |   |
174
| Partition Tables | List of partition table names |   |
175
| Architectures | List of architectures names |   |
176
| Media | List of media names |   |
177
| Provisioning Templates | List of provisioning template names |   |
178
| Parameters | List of parameters |   |
179

    
180
## Domains
181

    
182
**Overview**
183
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=domains&state=open)
184
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/domains_test.rb)
185
* Sample data
186
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/domains.csv)
187

    
188
**CSV Columns**
189

    
190
*Note: % column indicates Count substituion*
191

    
192
| Column Title | Column Description | % |
193
| :----------- | :----------------- | :-: |
194
| Name         | Name of the domains to update or create | x |
195
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
196
| Full Name | Full name of the domain |   |
197
| Organizations | Comma separated list of organizations |   |
198

    
199
## Architectures
200

    
201
**Overview**
202
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=architectures&state=open)
203
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/architectures_test.rb)
204
* Sample data
205
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/architectures.csv)
206

    
207
**CSV Columns**
208

    
209
*Note: % column indicates Count substituion*
210

    
211
| Column Title | Column Description | % |
212
| :----------- | :----------------- | :-: |
213
| Name         | Name of the architectures to update or create | x |
214
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
215
| Operating Systems | Comma separated list of operating system names |   |
216

    
217
## Partition Tables
218

    
219
**Overview**
220
* Import and export of the Organizations and Locations columns does not apply to all versions and will be silently ignored when unsupported.
221
* Importing Operating Systems column does not apply to all versions and will be silently ignored when unsupported.
222
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=partition-tables&state=open)
223
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/partition_tables_test.rb)
224
* Sample data
225
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/partition-tables.csv)
226

    
227
**CSV Columns**
228

    
229
*Note: % column indicates Count substituion*
230

    
231
| Column Title | Column Description | % |
232
| :----------- | :----------------- | :-: |
233
| Name         | Name of the partition tables to update or create | x |
234
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
235
| OS Family | Operating system family |   |
236
| Operating Systems | Comma separated list of operating system names |   |
237
| Layout | Disk layout |   |
238

    
239
## Lifecycle Environments
240

    
241
**Overview**
242
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=lifecycle-environments&state=open)
243
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/lifecycle_environments_test.rb)
244
* Sample data
245
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/lifecycle-environments.csv)
246

    
247
**CSV Columns**
248

    
249
*Note: % column indicates Count substituion*
250

    
251
| Column Title | Column Description | % |
252
| :----------- | :----------------- | :-: |
253
| Name         | Name of the lifecycle environments to update or create | x |
254
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
255
| Organization | Organization name |   |
256
| Prior Environment | Previous organization name in path |   |
257
| Description | Lifecycle environment description |   |
258

    
259
## Host Collections
260

    
261
| Additional arguments | Description |
262
| ---------------:| :--------------|
263
| --organization | Only process organization matching this name |
264

    
265
**Overview**
266
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=host-collections&state=open)
267
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/host_collections_test.rb)
268
* Sample data
269
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/host-collections.csv)
270

    
271
**CSV Columns**
272

    
273
*Note: % column indicates Count substituion*
274

    
275
| Column Title | Column Description | % |
276
| :----------- | :----------------- | :-: |
277
| Name         | Name of the host collections to update or create | x |
278
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
279
| Organization | Organization name |   |
280
| Limit | Usage limit |   |
281
| Description | Host collection description |   |
282

    
283
## Products
284

    
285
| Additional arguments | Description |
286
| ---------------:| :--------------|
287
| --organization | Only process organization matching this name |
288
| --[no-]sync | Sync product repositories (default true) |
289

    
290
**Overview**
291
* Due to the length of time that syncing repositories can take, the --no-sync option may be used to skip this step. To always disable syncing, ':products_sync: false' may be specified in configuration file.
292
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=products&state=open)
293
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/products_test.rb)
294
* Sample data
295
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/products.csv)
296

    
297
**CSV Columns**
298

    
299
*Note: % column indicates Count substituion*
300

    
301
| Column Title | Column Description | % |
302
| :----------- | :----------------- | :-: |
303
| Name         | Name of the host collections to update or create | x |
304
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
305
| Label | Unique label  |   |
306
| Organization | Organization name |   |
307
| Repository | Repository name |   |
308
| Repository Url | Repository Url |   |
309
| Description | Repository description |   |
310

    
311
## Provisioning Templates
312

    
313
| Additional arguments | Description |
314
| ---------------:| :--------------|
315
| --organization | Only process organization matching this name |
316

    
317
**Overview**
318
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=provisioning-templates&state=open)
319
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/provisioning_templates_test.rb)
320
* Sample data
321
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/provisioning_templates.csv)
322

    
323
**CSV Columns**
324

    
325
*Note: % column indicates Count substituion*
326

    
327
| Column Title | Column Description | % |
328
| :----------- | :----------------- | :-: |
329
| Name         | Name of the provisioning templates to update or create | x |
330
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
331
| Organizations  | Comma separated list of organizations |   |
332
| Locations  | Comma separated list of locations |   |
333
| Operating Systems  | Comma separated list of associated operating systems |   |
334
| Host Group / Puppet Environment Combinations  | Comma separated list of host group and puppet environment associations |   |
335
| Kind  | Kind of template (eg. snippet) |   |
336
| Template  | Full text of template |   |
337

    
338
## Subscriptions
339

    
340
| Additional arguments | Description |
341
| ---------------:| :--------------|
342
| --organization | Only process organization matching this name |
343

    
344
**Overview**
345
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=subscriptions&state=open)
346
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/subscriptions_test.rb)
347
* Sample data
348
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/subscriptions.csv)
349

    
350
Import will only process rows with a Name of "Manifest" and trigger a manifest import to run on the specified Manifest File. Subscription rows are not be processed.
351

    
352
Export will output a summary of the subscriptions currently imported into the organizations. These rows will have a description in the Name column as a comment (value starting with a #). For example,
353
```
354
Name,Organization,Manifest File,Subscription Name,Quantity,Product SKU,Contract Number,Account Number
355
# Subscription,Mega Corporation,,"OpenShift Enterprise Premium, 2 Cores",2,MCT2735,10999111,5700573
356
```
357

    
358
**CSV Columns**
359

    
360
*Note: % column indicates Count substituion*
361

    
362
| Column Title | Column Description | % |
363
| :----------- | :----------------- | :-: |
364
| Name         | "Manifest" to trigger import of manifest file | x |
365
| Count        | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
366
| Organization | Organization name |   |
367
| Manifest File | Path to manifest file |   |
368
| Subscription Name | Name of subscription |   |
369
| Quantity     | Subscription quantity |   |
370
| SKU          | Subscription SKU |   |
371
| Contract Number | Subscription contract number |   |
372
| Account Number  | Subscription account number |   |
373

    
374
## Activation Keys
375

    
376
**Overview**
377
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=activation-keys&state=open)
378
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/activation_keys_test.rb)
379
* Sample data
380
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/activation-keys.csv)
381

    
382
**CSV Columns**
383

    
384
*Note: % column indicates Count substituion*
385

    
386
| Column Title | Column Description | % |
387
| :----------- | :----------------- | :-: |
388
| Name         | Name of the activation keys to update or create | x |
389
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
390
| Organization | Parent organization name |   |
391
| Description | Activation key description |   |
392
| Limit | Usage limit |   |
393
| Environment | Lifecycle environment name |   |
394
| Content View | Content view name |   |
395
| Host Collections | Comma separated list of host collections |   |
396
| Subscriptions | Comma separated list of subscriptions |   |
397

    
398
## Hosts
399

    
400
**Overview**
401
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=hosts&state=open)
402
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/hosts_test.rb)
403
* Sample data
404
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/hosts.csv)
405

    
406
**CSV Columns**
407

    
408
*Note: % column indicates Count substituion*
409

    
410
| Column Title | Column Description | % |
411
| :----------- | :----------------- | :-: |
412
| Name         | Name of the hosts to update or create | x |
413
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
414
| Organization | Organization name |   |
415
| Environment | Puppet environment name |   |
416
| Operating System | Operating system name |   |
417
| Architecture | Architecture name |   |
418
| MAC Address | Unique MAC address | x |
419
| Domain | Domain name |   |
420
| Partition Table | Partition table name |   |
421

    
422
## Content Hosts
423

    
424
| Additional arguments | Description |
425
| ---------------:| :--------------|
426
| --organization | Only process organization matching this name |
427
| --itemized-subscriptions | Export one subscription per row, only process update subscriptions on import |
428

    
429
**Overview**
430
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=content-hosts&state=open)
431
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/content_hosts_test.rb)
432
* Sample data
433
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/content-hosts.csv)
434

    
435
**CSV Columns**
436

    
437
*Note: % column indicates Count substituion*
438

    
439
| Column Title | Column Description | % |
440
| :----------- | :----------------- | :-: |
441
| Name         | Name of the content hosts to update or create | x |
442
| Search | Alternative to Name column to update content hosts matching search results | x |
443
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
444
| Organization | Organization name |   |
445
| Environment | Puppet environment name |   |
446
| Content View | Content view name |   |
447
| Host Collections | Comma separate list of host collectoins |   |
448
| Virtual | Virtual (Yes or No) |   |
449
| Host | Virtual content host name |   |
450
| OS | Operating system name |   |
451
| Arch | Architecture name |   |
452
| Sockets | Number of sockets |   |
453
| RAM | Amount of RAM with units |   |
454
| Cores | Number of cores |   |
455
| SLA | Service Level Agreement |   |
456
| Products | Comma separated list of subscriptions |   |
457
| Subscriptions | Comma separated list of subscriptions |   |
458
| Subscription Name | Applicable for --itemized-subscriptions |
459
| Subscription Type | Applicable for --itemized-subscriptions |
460
| Subscription Quantity | Applicable for --itemized-subscriptions |
461
| Subscription SKU | Applicable for --itemized-subscriptions |
462
| Subscription Contract | Applicable for --itemized-subscriptions |
463
| Subscription Account | Applicable for --itemized-subscriptions |
464
| Subscription Start | Applicable for --itemized-subscriptions |
465
| Subscription End | Applicable for --itemized-subscriptions |
466

    
467
## Reports
468

    
469
**Overview**
470
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=reports&state=open)
471
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/reports_test.rb)
472
* Sample data
473
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/reports.csv)
474

    
475
**CSV Columns**
476

    
477
*Note: % column indicates Count substituion*
478

    
479
| Column Title | Column Description | % |
480
| :----------- | :----------------- | :-: |
481
| Name         | Name of the reports to update or create | x |
482
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
483
| Time | Time of report |   |
484
| Applied |  |   |
485
| Restarted |  |   |
486
| Failed |  |   |
487
| Failed Restarts |  |   |
488
| Skipped |  |   |
489
| Pending |  |   |
490
| Metrics |  |   |
491

    
492
## Roles
493

    
494
**Overview**
495
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=roles&state=open)
496
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/roles_test.rb)
497
* Sample data
498
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/roles.csv)
499

    
500
**CSV Columns**
501

    
502
*Note: % column indicates Count substituion*
503

    
504
| Column Title | Column Description | % |
505
| :----------- | :----------------- | :-: |
506
| Name         | Name of the roles to update or create | x |
507
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
508
| Resource | Resource to apply role to |   |
509
| Search | Search string |   |
510
| Permissions | Role permission |   |
511
| Organizations | Comma separated list of organizations |   |
512
| Locations | Comma separated list of locations |   |
513

    
514
## Users
515

    
516
**Overview**
517
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=users&state=open)
518
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/users_test.rb)
519
* Sample data
520
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/users.csv)
521

    
522
**CSV Columns**
523

    
524
*Note: % column indicates Count substituion*
525

    
526
| Column Title | Column Description | % |
527
| :----------- | :----------------- | :-: |
528
| Name         | Name of the users to update or create | x |
529
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
530
| First Name | First name of user |   |
531
| Last Name | Last name of user |   |
532
| email | Email address |   |
533
| Organizations | Comma separated list of organizations |   |
534
| Locations | Comma separated list of locations |   |
535
| Roles | Comma separated list of role names for user |   |
536

    
537
## Settings
538

    
539
**Overview**
540
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=settings&state=open)
541
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/settings_test.rb)
542
* Sample data
543
  * [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/settings.csv)
544

    
545
**CSV Columns**
546

    
547
*Note: % column indicates Count substituion*
548

    
549
| Column Title | Column Description | % |
550
| :----------- | :----------------- | :-: |
551
| Name         | Setting name to update or create | x |
552
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution |   |
553
| Value | Setting value |   |
554

    
555
**Examples**
556
```
557
Name,Value
558
administrator,admin@megacorp.com
559
idle_timeout,60000
560
```
561

    
562
## Import
563

    
564
**Overview**
565
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=users&state=open)
566
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/users_test.rb)
567

    
568
**Examples**
569

    
570
```
571
% hammer csv import -v --dir test/data --settings
572
Importing settings from 'test/data/settings.csv'
573
Updating setting 'idle_timeout'...done
574
```
575

    
576
# Development
577

    
578
## Code style
579

    
580
    rubocop -R <file>
581

    
582
## Tests
583

    
584
To run all tests using recorded data, run:
585

    
586
    rake test mode=none
587

    
588
To run all tests to record data:
589

    
590
    rake test mode=all
591

    
592
To run a single test using recorded data, run:
593

    
594
    rake test mode=none test=resources/settings
595

    
596
or
597

    
598
    rake test mode=none test=./test/resources/settings_test.rb
599

    
600
To run tests against your live Katello without recording a new cassette set record flag to false (does not apply to mode=none):
601

    
602
    record=false
603

    
604
To see RestClient logs while testing:
605

    
606
    logging=true
607

    
608
Test server configuration is taken from 'test/config.yml'. If that file does not exist then https://localhost with admin / changeme is the default.
609

    
610
    % cat test/config.yml
611

    
612
    :foreman:
613
      :enable_module: true
614
      :host:          'http://katello:3000'
615
      :username:      'admin'
616
      :password:      'changeme'
617
    :katello:
618
      :enable_module: true
619
    :csv:
620
      :enable_module: true
621

    
622

    
623
Note: Since the subscriptions tests rely entirely on having a Red Hat manifest, re-recording these tests is more involved. It requires access to the internal "stage" customer portal and API. To run in recording mode, specify PORTALUSERNAME and PORTALPASSWORD env variables.
624

    
625
    PORTALUSERNAME=thomasmckay PORTALPASSWORD=xyz123 rake test mode=all record=true