Revision c06f1783
Added by Thomas McKay over 6 years ago
lib/hammer_cli_csv/compute_resources.rb | ||
---|---|---|
14 | 14 |
PROVIDER = 'Provider' |
15 | 15 |
URL = 'URL' |
16 | 16 |
|
17 |
def export |
|
18 |
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv| |
|
19 |
csv << [NAME, ORGANIZATIONS, LOCATIONS, DESCRIPTION, PROVIDER, URL] |
|
20 |
@api.resource(:compute_resources).call(:index, {:per_page => 999999})['results'].each do |compute_resource| |
|
21 |
compute_resource = @api.resource(:compute_resources).call(:show, {'id' => compute_resource['id']}) |
|
17 |
def export(csv) |
|
18 |
csv << [NAME, ORGANIZATIONS, LOCATIONS, DESCRIPTION, PROVIDER, URL] |
|
19 |
@api.resource(:compute_resources).call(:index, {:per_page => 999999})['results'].each do |compute_resource| |
|
20 |
compute_resource = @api.resource(:compute_resources).call(:show, {'id' => compute_resource['id']}) |
|
22 | 21 |
|
23 |
name = compute_resource['name'] |
|
24 |
organizations = export_column(compute_resource, 'organizations', 'name') |
|
25 |
locations = export_column(compute_resource, 'locations', 'name') |
|
26 |
description = compute_resource['description'] |
|
27 |
provider = compute_resource['provider'] |
|
28 |
url = compute_resource['url'] |
|
29 |
csv << [name, organizations, locations, description, provider, url] |
|
30 |
end |
|
22 |
name = compute_resource['name'] |
|
23 |
organizations = export_column(compute_resource, 'organizations', 'name') |
|
24 |
locations = export_column(compute_resource, 'locations', 'name') |
|
25 |
description = compute_resource['description'] |
|
26 |
provider = compute_resource['provider'] |
|
27 |
url = compute_resource['url'] |
|
28 |
csv << [name, organizations, locations, description, provider, url] |
|
31 | 29 |
end |
32 | 30 |
end |
33 | 31 |
|
Also available in: Unified diff
fixes #15743 - import and export of subscriptions one-per-line