1 |
b50ceaa2
|
Tom McKay
|
# hammer-cli-csv [](https://travis-ci.org/Katello/hammer-cli-csv) [](https://coveralls.io/github/Katello/hammer-cli-csv?branch=master)
|
2 |
ab134b85
|
Tom McKay
|
|
3 |
a389840d
|
Tom McKay
|
## Introduction
|
4 |
|
|
|
5 |
2df1e79b
|
Tom McKay
|
[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 |
a389840d
|
Tom McKay
|
|
7 |
b2e88b7c
|
Tom McKay
|
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 |
a389840d
|
Tom McKay
|
|
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 |
74968aff
|
Chris Duryee
|
```bash
|
20 |
d1b29b9c
|
Tom McKay
|
gem install hammer_cli_csv
|
21 |
2df1e79b
|
Tom McKay
|
gem install hammer_cli_katello
|
22 |
d1b29b9c
|
Tom McKay
|
|
23 |
74968aff
|
Chris Duryee
|
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 |
d1b29b9c
|
Tom McKay
|
```
|
34 |
|
|
|
35 |
b2e88b7c
|
Tom McKay
|
## 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 |
a389840d
|
Tom McKay
|
|
39 |
2df1e79b
|
Tom McKay
|
| Option | Description |
|
40 |
2645da78
|
Tom McKay
|
| ---------------:| :--------------|
|
41 |
b2e88b7c
|
Tom McKay
|
| --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 |
2df1e79b
|
Tom McKay
|
| --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 |
3fe1ff94
|
Tom McKay
|
| --continue-on-error | Continue processing even if individual resource error |
|
49 |
2df1e79b
|
Tom McKay
|
|
50 |
bdf6f18c
|
Tom McKay
|
## 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 |
a389840d
|
Tom McKay
|
## 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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
83 |
|
|
| :----------- | :----------------- | :-: |
|
84 |
|
|
| Name | Name of the organization to update or create | x |
|
85 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
86 |
b2e88b7c
|
Tom McKay
|
| Label | Unique organization label | x | |
|
87 |
|
|
| Description | Organization description | |
|
88 |
a389840d
|
Tom McKay
|
|
89 |
d1b29b9c
|
Tom McKay
|
**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 |
a389840d
|
Tom McKay
|
## 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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
131 |
|
|
| :----------- | :----------------- | :-: |
|
132 |
|
|
| Name | Name of the location to update or create | x |
|
133 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
134 |
b2e88b7c
|
Tom McKay
|
| Parent Location | Parent location | |
|
135 |
a389840d
|
Tom McKay
|
|
136 |
|
|
## Puppet Environments
|
137 |
|
|
|
138 |
|
|
**Overview**
|
139 |
088e0854
|
Tom McKay
|
* Due to the implications of removing a puppet environment from an organization or location, this column only adds to what is present already.
|
140 |
a389840d
|
Tom McKay
|
* [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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
150 |
|
|
| :----------- | :----------------- | :-: |
|
151 |
|
|
| Name | Name of the puppet environments to update or create | x |
|
152 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
153 |
b2e88b7c
|
Tom McKay
|
| Organizations | Comma separated list of organizations | |
|
154 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
168 |
|
|
| :----------- | :----------------- | :-: |
|
169 |
|
|
| Name | Name of the operating systems to update or create | x |
|
170 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
171 |
b2e88b7c
|
Tom McKay
|
| 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 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
193 |
|
|
| :----------- | :----------------- | :-: |
|
194 |
|
|
| Name | Name of the domains to update or create | x |
|
195 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
196 |
b2e88b7c
|
Tom McKay
|
| Full Name | Full name of the domain | |
|
197 |
|
|
| Organizations | Comma separated list of organizations | |
|
198 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
212 |
|
|
| :----------- | :----------------- | :-: |
|
213 |
|
|
| Name | Name of the architectures to update or create | x |
|
214 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
215 |
b2e88b7c
|
Tom McKay
|
| Operating Systems | Comma separated list of operating system names | |
|
216 |
a389840d
|
Tom McKay
|
|
217 |
|
|
## Partition Tables
|
218 |
|
|
|
219 |
|
|
**Overview**
|
220 |
088e0854
|
Tom McKay
|
* 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 |
a389840d
|
Tom McKay
|
* [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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
232 |
|
|
| :----------- | :----------------- | :-: |
|
233 |
|
|
| Name | Name of the partition tables to update or create | x |
|
234 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
235 |
b2e88b7c
|
Tom McKay
|
| OS Family | Operating system family | |
|
236 |
|
|
| Operating Systems | Comma separated list of operating system names | |
|
237 |
|
|
| Layout | Disk layout | |
|
238 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
252 |
|
|
| :----------- | :----------------- | :-: |
|
253 |
|
|
| Name | Name of the lifecycle environments to update or create | x |
|
254 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
255 |
b2e88b7c
|
Tom McKay
|
| Organization | Organization name | |
|
256 |
|
|
| Prior Environment | Previous organization name in path | |
|
257 |
|
|
| Description | Lifecycle environment description | |
|
258 |
a389840d
|
Tom McKay
|
|
259 |
|
|
## Host Collections
|
260 |
|
|
|
261 |
2645da78
|
Tom McKay
|
| Additional arguments | Description |
|
262 |
|
|
| ---------------:| :--------------|
|
263 |
|
|
| --organization | Only process organization matching this name |
|
264 |
|
|
|
265 |
a389840d
|
Tom McKay
|
**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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
276 |
|
|
| :----------- | :----------------- | :-: |
|
277 |
|
|
| Name | Name of the host collections to update or create | x |
|
278 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
279 |
b2e88b7c
|
Tom McKay
|
| Organization | Organization name | |
|
280 |
|
|
| Limit | Usage limit | |
|
281 |
|
|
| Description | Host collection description | |
|
282 |
a389840d
|
Tom McKay
|
|
283 |
bdf6f18c
|
Tom McKay
|
## Products
|
284 |
|
|
|
285 |
|
|
| Additional arguments | Description |
|
286 |
|
|
| ---------------:| :--------------|
|
287 |
|
|
| --organization | Only process organization matching this name |
|
288 |
088e0854
|
Tom McKay
|
| --[no-]sync | Sync product repositories (default true) |
|
289 |
bdf6f18c
|
Tom McKay
|
|
290 |
|
|
**Overview**
|
291 |
088e0854
|
Tom McKay
|
* 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 |
bdf6f18c
|
Tom McKay
|
* [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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
302 |
|
|
| :----------- | :----------------- | :-: |
|
303 |
|
|
| Name | Name of the host collections to update or create | x |
|
304 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
305 |
b2e88b7c
|
Tom McKay
|
| Label | Unique label | |
|
306 |
|
|
| Organization | Organization name | |
|
307 |
|
|
| Repository | Repository name | |
|
308 |
|
|
| Repository Url | Repository Url | |
|
309 |
|
|
| Description | Repository description | |
|
310 |
bdf6f18c
|
Tom McKay
|
|
311 |
a389840d
|
Tom McKay
|
## Provisioning Templates
|
312 |
|
|
|
313 |
98d33947
|
Tom McKay
|
| Additional arguments | Description |
|
314 |
|
|
| ---------------:| :--------------|
|
315 |
|
|
| --organization | Only process organization matching this name |
|
316 |
|
|
|
317 |
a389840d
|
Tom McKay
|
**Overview**
|
318 |
98d33947
|
Tom McKay
|
* [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 |
a389840d
|
Tom McKay
|
* Sample data
|
321 |
98d33947
|
Tom McKay
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/provisioning_templates.csv)
|
322 |
a389840d
|
Tom McKay
|
|
323 |
|
|
**CSV Columns**
|
324 |
|
|
|
325 |
|
|
*Note: % column indicates Count substituion*
|
326 |
|
|
|
327 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
328 |
|
|
| :----------- | :----------------- | :-: |
|
329 |
|
|
| Name | Name of the provisioning templates to update or create | x |
|
330 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
331 |
b2e88b7c
|
Tom McKay
|
| 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 |
a389840d
|
Tom McKay
|
|
338 |
|
|
## Subscriptions
|
339 |
|
|
|
340 |
a2eda8bf
|
Tom McKay
|
| Additional arguments | Description |
|
341 |
|
|
| ---------------:| :--------------|
|
342 |
|
|
| --organization | Only process organization matching this name |
|
343 |
|
|
|
344 |
a389840d
|
Tom McKay
|
**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 |
a2eda8bf
|
Tom McKay
|
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 |
a389840d
|
Tom McKay
|
**CSV Columns**
|
359 |
|
|
|
360 |
|
|
*Note: % column indicates Count substituion*
|
361 |
|
|
|
362 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
363 |
|
|
| :----------- | :----------------- | :-: |
|
364 |
a2eda8bf
|
Tom McKay
|
| 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 |
b2e88b7c
|
Tom McKay
|
| Organization | Organization name | |
|
367 |
|
|
| Manifest File | Path to manifest file | |
|
368 |
a2eda8bf
|
Tom McKay
|
| 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 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
387 |
|
|
| :----------- | :----------------- | :-: |
|
388 |
|
|
| Name | Name of the activation keys to update or create | x |
|
389 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
390 |
b2e88b7c
|
Tom McKay
|
| 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 |
a389840d
|
Tom McKay
|
|
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 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
411 |
|
|
| :----------- | :----------------- | :-: |
|
412 |
|
|
| Name | Name of the hosts to update or create | x |
|
413 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
414 |
b2e88b7c
|
Tom McKay
|
| 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 |
a389840d
|
Tom McKay
|
|
422 |
|
|
## Content Hosts
|
423 |
|
|
|
424 |
2645da78
|
Tom McKay
|
| Additional arguments | Description |
|
425 |
|
|
| ---------------:| :--------------|
|
426 |
|
|
| --organization | Only process organization matching this name |
|
427 |
|
|
|
428 |
a389840d
|
Tom McKay
|
**Overview**
|
429 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=content-hosts&state=open)
|
430 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/content_hosts_test.rb)
|
431 |
|
|
* Sample data
|
432 |
|
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/content-hosts.csv)
|
433 |
|
|
|
434 |
|
|
**CSV Columns**
|
435 |
|
|
|
436 |
|
|
*Note: % column indicates Count substituion*
|
437 |
|
|
|
438 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
439 |
|
|
| :----------- | :----------------- | :-: |
|
440 |
|
|
| Name | Name of the content hosts to update or create | x |
|
441 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
442 |
b2e88b7c
|
Tom McKay
|
| Organization | Organization name | |
|
443 |
|
|
| Environment | Puppet environment name | |
|
444 |
|
|
| Content View | Content view name | |
|
445 |
|
|
| Host Collections | Comma separate list of host collectoins | |
|
446 |
|
|
| Virtual | Virtual (Yes or No) | |
|
447 |
|
|
| Host | Virtual content host name | |
|
448 |
|
|
| OS | Operating system name | |
|
449 |
|
|
| Arch | Architecture name | |
|
450 |
|
|
| Sockets | Number of sockets | |
|
451 |
|
|
| RAM | Amount of RAM with units | |
|
452 |
|
|
| Cores | Number of cores | |
|
453 |
|
|
| SLA | Service Level Agreement | |
|
454 |
|
|
| Products | Comma separated list of subscriptions | |
|
455 |
|
|
| Subscriptions | Comma separated list of subscriptions | |
|
456 |
a389840d
|
Tom McKay
|
|
457 |
|
|
## Reports
|
458 |
|
|
|
459 |
|
|
**Overview**
|
460 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=reports&state=open)
|
461 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/reports_test.rb)
|
462 |
|
|
* Sample data
|
463 |
|
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/reports.csv)
|
464 |
|
|
|
465 |
|
|
**CSV Columns**
|
466 |
|
|
|
467 |
|
|
*Note: % column indicates Count substituion*
|
468 |
|
|
|
469 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
470 |
|
|
| :----------- | :----------------- | :-: |
|
471 |
|
|
| Name | Name of the reports to update or create | x |
|
472 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
473 |
b2e88b7c
|
Tom McKay
|
| Time | Time of report | |
|
474 |
|
|
| Applied | | |
|
475 |
|
|
| Restarted | | |
|
476 |
|
|
| Failed | | |
|
477 |
|
|
| Failed Restarts | | |
|
478 |
|
|
| Skipped | | |
|
479 |
|
|
| Pending | | |
|
480 |
|
|
| Metrics | | |
|
481 |
a389840d
|
Tom McKay
|
|
482 |
|
|
## Roles
|
483 |
|
|
|
484 |
|
|
**Overview**
|
485 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=roles&state=open)
|
486 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/roles_test.rb)
|
487 |
|
|
* Sample data
|
488 |
|
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/roles.csv)
|
489 |
|
|
|
490 |
|
|
**CSV Columns**
|
491 |
|
|
|
492 |
|
|
*Note: % column indicates Count substituion*
|
493 |
|
|
|
494 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
495 |
|
|
| :----------- | :----------------- | :-: |
|
496 |
|
|
| Name | Name of the roles to update or create | x |
|
497 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
498 |
b2e88b7c
|
Tom McKay
|
| Resource | Resource to apply role to | |
|
499 |
|
|
| Search | Search string | |
|
500 |
|
|
| Permissions | Role permission | |
|
501 |
|
|
| Organizations | Comma separated list of organizations | |
|
502 |
|
|
| Locations | Comma separated list of locations | |
|
503 |
a389840d
|
Tom McKay
|
|
504 |
|
|
## Users
|
505 |
|
|
|
506 |
|
|
**Overview**
|
507 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=users&state=open)
|
508 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/users_test.rb)
|
509 |
|
|
* Sample data
|
510 |
|
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/users.csv)
|
511 |
|
|
|
512 |
|
|
**CSV Columns**
|
513 |
|
|
|
514 |
|
|
*Note: % column indicates Count substituion*
|
515 |
|
|
|
516 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
517 |
|
|
| :----------- | :----------------- | :-: |
|
518 |
|
|
| Name | Name of the users to update or create | x |
|
519 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
520 |
b2e88b7c
|
Tom McKay
|
| First Name | First name of user | |
|
521 |
|
|
| Last Name | Last name of user | |
|
522 |
|
|
| email | Email address | |
|
523 |
|
|
| Organizations | Comma separated list of organizations | |
|
524 |
|
|
| Locations | Comma separated list of locations | |
|
525 |
|
|
| Roles | Comma separated list of role names for user | |
|
526 |
90d0b5c8
|
Tom McKay
|
|
527 |
02387fb5
|
Tom McKay
|
## Settings
|
528 |
|
|
|
529 |
|
|
**Overview**
|
530 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=settings&state=open)
|
531 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/settings_test.rb)
|
532 |
|
|
* Sample data
|
533 |
|
|
* [Mega Corporation](https://github.com/Katello/hammer-cli-csv/blob/master/test/data/settings.csv)
|
534 |
|
|
|
535 |
|
|
**CSV Columns**
|
536 |
|
|
|
537 |
|
|
*Note: % column indicates Count substituion*
|
538 |
|
|
|
539 |
b2e88b7c
|
Tom McKay
|
| Column Title | Column Description | % |
|
540 |
|
|
| :----------- | :----------------- | :-: |
|
541 |
|
|
| Name | Setting name to update or create | x |
|
542 |
a2eda8bf
|
Tom McKay
|
| Count | Number of times to iterate this CSV row during import, incrementing value for substitution | |
|
543 |
b2e88b7c
|
Tom McKay
|
| Value | Setting value | |
|
544 |
02387fb5
|
Tom McKay
|
|
545 |
|
|
**Examples**
|
546 |
|
|
```
|
547 |
|
|
Name,Value
|
548 |
|
|
administrator,admin@megacorp.com
|
549 |
|
|
idle_timeout,60000
|
550 |
|
|
```
|
551 |
|
|
|
552 |
90d0b5c8
|
Tom McKay
|
## Import
|
553 |
|
|
|
554 |
|
|
**Overview**
|
555 |
|
|
* [Open Issues](https://github.com/Katello/hammer-cli-csv/issues?labels=users&state=open)
|
556 |
|
|
* [Tests](https://github.com/Katello/hammer-cli-csv/blob/master/test/users_test.rb)
|
557 |
|
|
|
558 |
|
|
**Examples**
|
559 |
|
|
|
560 |
9e73e665
|
Daniel Lobato García
|
```
|
561 |
b2e88b7c
|
Tom McKay
|
% hammer csv import -v --dir test/data --settings
|
562 |
|
|
Importing settings from 'test/data/settings.csv'
|
563 |
|
|
Updating setting 'idle_timeout'...done
|
564 |
9e73e665
|
Daniel Lobato García
|
```
|
565 |
90d0b5c8
|
Tom McKay
|
|
566 |
|
|
# Development
|
567 |
|
|
|
568 |
|
|
## Code style
|
569 |
|
|
|
570 |
b50ceaa2
|
Tom McKay
|
rubocop -R <file>
|
571 |
90d0b5c8
|
Tom McKay
|
|
572 |
|
|
## Tests
|
573 |
|
|
|
574 |
b50ceaa2
|
Tom McKay
|
To run all tests using recorded data, run:
|
575 |
90d0b5c8
|
Tom McKay
|
|
576 |
b50ceaa2
|
Tom McKay
|
rake test mode=none
|
577 |
b2e88b7c
|
Tom McKay
|
|
578 |
b50ceaa2
|
Tom McKay
|
To run all tests to record data:
|
579 |
b2e88b7c
|
Tom McKay
|
|
580 |
b50ceaa2
|
Tom McKay
|
rake test mode=all
|
581 |
b2e88b7c
|
Tom McKay
|
|
582 |
b50ceaa2
|
Tom McKay
|
To run a single test using recorded data, run:
|
583 |
b2e88b7c
|
Tom McKay
|
|
584 |
b50ceaa2
|
Tom McKay
|
rake test mode=none test=resources/settings
|
585 |
b2e88b7c
|
Tom McKay
|
|
586 |
b50ceaa2
|
Tom McKay
|
or
|
587 |
|
|
|
588 |
|
|
rake test mode=none test=./test/resources/settings_test.rb
|
589 |
|
|
|
590 |
|
|
To run tests against your live Katello without recording a new cassette set record flag to false (does not apply to mode=none):
|
591 |
|
|
|
592 |
|
|
record=false
|
593 |
|
|
|
594 |
|
|
To see RestClient logs while testing:
|
595 |
|
|
|
596 |
|
|
logging=true
|
597 |
|
|
|
598 |
|
|
Test server configuration is taken from 'test/config.yml'. If that file does not exist then https://localhost with admin / changeme is the default.
|
599 |
|
|
|
600 |
|
|
% cat test/config.yml
|
601 |
|
|
|
602 |
|
|
:foreman:
|
603 |
|
|
:enable_module: true
|
604 |
|
|
:host: 'http://katello:3000'
|
605 |
|
|
:username: 'admin'
|
606 |
|
|
:password: 'changeme'
|
607 |
|
|
:katello:
|
608 |
|
|
:enable_module: true
|
609 |
f5d21adb
|
Tom McKay
|
:csv:
|
610 |
|
|
:enable_module: true
|
611 |
|
|
|
612 |
400832c6
|
Tom McKay
|
|
613 |
|
|
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.
|
614 |
|
|
|
615 |
|
|
PORTALUSERNAME=thomasmckay PORTALPASSWORD=xyz123 rake test mode=all record=true |