Project

General

Profile

Revision f8ecc788

Added by Thomas McKay almost 9 years ago

csv-scope - lots of cleanup

View differences:

.rubocop.yml
68 68
    - config/navigation.rb
69 69

  
70 70
MethodLength:
71
  Description: 'Avoid methods longer than 30 lines of code.'
72
  Max: 50
71
  Max: 250
73 72

  
74 73
SpaceInsideHashLiteralBraces:
75 74
  EnforcedStyleIsWithSpaces: false
lib/hammer_cli_csv.rb
21 21
  require 'hammer_cli_csv/base'
22 22
  require 'hammer_cli_csv/exception_handler'
23 23

  
24
  require 'hammer_cli_csv/csv'
24 25
  require 'hammer_cli_csv/activation_keys'
25 26
  require 'hammer_cli_csv/architectures'
26 27
  require 'hammer_cli_csv/domains'
lib/hammer_cli_csv/activation_keys.rb
170 170

  
171 171
  end
172 172

  
173
  HammerCLI::MainCommand.subcommand("csv:activationkeys", "import/export activation keys", HammerCLICsv::ActivationKeysCommand)
173
  HammerCLICsv::CsvCommand.subcommand("activation-keys",
174
                                      "import or export activation keys",
175
                                      HammerCLICsv::ActivationKeysCommand)
174 176
end
lib/hammer_cli_csv/architectures.rb
89 89
    end
90 90
  end
91 91

  
92
  HammerCLI::MainCommand.subcommand("csv:architectures", "ping the katello server", HammerCLICsv::ArchitecturesCommand)
92
  HammerCLICsv::CsvCommand.subcommand("architectures",
93
                                      "import or export architectures",
94
                                      HammerCLICsv::ArchitecturesCommand)
93 95
end
lib/hammer_cli_csv/base.rb
13 13
require 'hammer_cli'
14 14
require 'json'
15 15
require 'csv'
16
require 'hammer_cli_csv/csv'
16 17

  
17 18
module HammerCLICsv
18 19
  class BaseCommand < HammerCLI::Apipie::Command
19 20
    NAME = 'Name'
20 21
    COUNT = 'Count'
21 22

  
23
    def request_help(help_command = 'hammer csv', help_options = '')
24
      puts "TODO: write some help!"
25
      exit(HammerCLI::EX_OK)
26
    end
27

  
22 28
    option %w(-v --verbose), :flag, 'be verbose'
23 29
    option %w(--threads), 'THREAD_COUNT', 'Number of threads to hammer with', :default => 1
24 30
    option %w(--csv-export), :flag, 'Export current data instead of importing'
lib/hammer_cli_csv/content_views.rb
103 103
    end
104 104
  end
105 105

  
106
  HammerCLI::MainCommand.subcommand("csv:contentviews", "import/export content views", HammerCLICsv::ContentViewsCommand)
106
  HammerCLICsv::CsvCommand.subcommand("content-views",
107
                                      "import or export content-views",
108
                                      HammerCLICsv::ContentViewsCommand)
107 109
end
lib/hammer_cli_csv/csv.rb
1

  
2
# Copyright 2013-2014 Red Hat, Inc.
3
#
4
# This software is licensed to you under the GNU General Public
5
# License as published by the Free Software Foundation; either version
6
# 2 of the License (GPLv2) or (at your option) any later version.
7
# There is NO WARRANTY for this software, express or implied,
8
# including the implied warranties of MERCHANTABILITY,
9
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
10
# have received a copy of GPLv2 along with this software; if not, see
11
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12

  
13
require 'hammer_cli'
14
require 'hammer_cli/exit_codes'
15

  
16
module HammerCLICsv
17
  class CsvCommand < HammerCLI::AbstractCommand
18
    # def request_help
19
    #   puts _("import to, or export from a running foretello server")
20
    #   exit(HammerCLI::EX_OK)
21
    # end
22
  end
23

  
24
  HammerCLI::MainCommand.subcommand("csv",
25
                                    _("import to, or export from a running foretello server"),
26
                                    HammerCLICsv::CsvCommand)
27
end
lib/hammer_cli_csv/domains.rb
97 97
    end
98 98
  end
99 99

  
100
  HammerCLI::MainCommand.subcommand("csv:domains", "ping the katello server", HammerCLICsv::DomainsCommand)
100
  HammerCLICsv::CsvCommand.subcommand("domains",
101
                                      "import or export domains",
102
                                      HammerCLICsv::DomainsCommand)
101 103
end
lib/hammer_cli_csv/hosts.rb
116 116
    end
117 117
  end
118 118

  
119
  HammerCLI::MainCommand.subcommand("csv:hosts", "import/export hosts", HammerCLICsv::HostsCommand)
119
  HammerCLICsv::CsvCommand.subcommand("hosts",
120
                                      "import or export hosts",
121
                                      HammerCLICsv::HostsCommand)
120 122
end
lib/hammer_cli_csv/lifecycle_environments.rb
105 105
    end
106 106
  end
107 107

  
108
  HammerCLI::MainCommand.subcommand("csv:lifecycleenv", "Import or export lifecycle environments", HammerCLICsv::LifecycleEnvironmentsCommand)
108
  HammerCLICsv::CsvCommand.subcommand("lifecycle-environment",
109
                                      "import or export lifecycle environments",
110
                                      HammerCLICsv::LifecycleEnvironmentsCommand)
109 111
end
lib/hammer_cli_csv/locations.rb
78 78
    end
79 79
  end
80 80

  
81
  HammerCLI::MainCommand.subcommand("csv:locations", "ping the katello server", HammerCLICsv::LocationsCommand)
81
  HammerCLICsv::CsvCommand.subcommand("locations",
82
                                      "import or export locations",
83
                                      HammerCLICsv::LocationsCommand)
82 84
end
lib/hammer_cli_csv/operating_systems.rb
89 89
    end
90 90
  end
91 91

  
92
  HammerCLI::MainCommand.subcommand("csv:operatingsystems", "ping the katello server", HammerCLICsv::OperatingSystemsCommand)
92
  HammerCLICsv::CsvCommand.subcommand("operating-systems",
93
                                      "import or export operating systems",
94
                                      HammerCLICsv::OperatingSystemsCommand)
93 95
end
lib/hammer_cli_csv/organizations.rb
32 32

  
33 33
module HammerCLICsv
34 34
  class OrganizationsCommand < BaseCommand
35

  
36 35
    ORGLABEL = 'Org Label'
37 36
    DESCRIPTION = 'Description'
38 37

  
39 38
    def export
40 39
      CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
41 40
        csv << [NAME, COUNT, ORGLABEL, DESCRIPTION]
42
        @api.resource(:organization).call(:index, {:per_page => 999999})['results'].each do |organization|
41
        @api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
43 42
          csv << [organization['name'], 1, organization['label'], organization['description']]
44 43
        end
45 44
      end
......
79 78
    end
80 79
  end
81 80

  
82
  HammerCLI::MainCommand.subcommand("csv:organizations", "ping the katello server", HammerCLICsv::OrganizationsCommand)
81
  HammerCLICsv::CsvCommand.subcommand('organizations',
82
                                      'import or export organizations',
83
                                      HammerCLICsv::OrganizationsCommand)
83 84
end
lib/hammer_cli_csv/partition_tables.rb
93 93
    end
94 94
  end
95 95

  
96
  HammerCLI::MainCommand.subcommand("csv:partitiontables", "ping the katello server", HammerCLICsv::PartitionTablesCommand)
96
  HammerCLICsv::CsvCommand.subcommand("partition-tables",
97
                                      "import or export partition tables",
98
                                      HammerCLICsv::PartitionTablesCommand)
97 99
end
lib/hammer_cli_csv/permissions.rb
140 140
    end
141 141
  end
142 142

  
143
  HammerCLI::MainCommand.subcommand("csv:permissions", "ping the katello server", HammerCLICsv::PermissionsCommand)
143
  HammerCLICsv::CsvCommand.subcommand("permissions",
144
                                      "import or export permissions",
145
                                      HammerCLICsv::PermissionsCommand)
144 146
end
lib/hammer_cli_csv/products.rb
20 20
#   Count
21 21
#     - Number of times to iterate on this line of the CSV file
22 22

  
23

  
24 23
require 'hammer_cli'
25 24
require 'json'
26 25
require 'csv'
......
28 27

  
29 28
module HammerCLICsv
30 29
  class ProductsCommand < BaseCommand
31

  
30
    LABEL = 'Label'
32 31
    ORGANIZATION = 'Organization'
33 32
    REPOSITORY = 'Repository'
34 33
    REPOSITORY_TYPE = 'Repository Type'
35 34
    REPOSITORY_URL = 'Repository Url'
35
    DESCRIPTION = 'Description'
36 36

  
37 37
    def export
38
      # TODO
38
      CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
39
        csv << [NAME, COUNT, LABEL, ORGANIZATION, REPOSITORY, REPOSITORY_TYPE, REPOSITORY_URL]
40
        @api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
41
          @api.resource(:products).call(:index, {
42
                                          'per_page' => 999999,
43
                                          'enabled' => true,
44
                                          'organization_id' => katello_organization(:name => organization['name'])
45
                                        })['results'].each do |product|
46
            # product = @api.resource(:products).call(:show, {
47
            #                                           'id' => product['id'],
48
            #                                           'fields' => 'full'
49
            #                                         })
50
            product['library_repositories'].each do |repository|
51
              if repository['sync_state'] != 'not_synced'
52
                repository_type = "#{repository['product_type'] == 'custom' ? 'Custom' : 'Red Hat'} #{repository['content_type'].capitalize}"
53
                csv << [namify(product['name'], 1), 1, product['label'], organization['name'], repository['name'],
54
                        repository_type, repository['feed']]
55
                #puts "  HTTPS:                     #{repository['unprotected'] ? 'No' : 'Yes'}"
56
              end
57
            end
58

  
59
          end
60
        end
61
      end
39 62
    end
40 63

  
41 64
    def import
......
65 88
                                      'library' => true,
66 89
                                      'page_size' => 999999, 'paged' => true
67 90
                                    })['results'].each do |repository|
68
              @existing_repositories[line[ORGANIZATION]+product['name']] ||= {}
69
              @existing_repositories[line[ORGANIZATION]+product['name']][repository['label']] = repository['id']
91
              @existing_repositories[line[ORGANIZATION] + product['name']] ||= {}
92
              @existing_repositories[line[ORGANIZATION] + product['name']][repository['label']] = repository['id']
70 93
            end
71 94
          end
72 95
        end
......
75 98
      # Only creating products, not updating
76 99
      line[COUNT].to_i.times do |number|
77 100
        name = namify(line[NAME], number)
101
        puts @existing_products
78 102
        product_id = @existing_products[line[ORGANIZATION]][name]
79 103
        if !product_id
80 104
          print "Creating product '#{name}'..." if option_verbose?
105
          if line[REPOSITORY_TYPE] =~ /Red Hat/
106
            raise "Red Hat product '#{name}' does not exist in '#{line[ORGANIZATION]}'"
107
          end
108

  
81 109
          product_id = @api.resource(:products).call(:create, {
82 110
                                               'organization_id' => katello_organization(:name => line[ORGANIZATION]),
83 111
                                               'name' => name
......
87 115
          # Nothing to update for products
88 116
          print "Updating product '#{name}'..." if option_verbose?
89 117
        end
118
        @existing_repositories[line[ORGANIZATION] + name] = {}
90 119
        print "done\n" if option_verbose?
91
        @existing_repositories[line[ORGANIZATION] + name] ||= {}
92 120

  
93
        # Only creating repositories, not updating
94 121
        repository_name = namify(line[REPOSITORY], number)
95
        if !@existing_repositories[line[ORGANIZATION] + name][labelize(repository_name)]
122

  
123
        # Hash the existing repositories for the product
124
        if !@existing_repositories[line[ORGANIZATION] + name][repository_name]
125
          @api.resource(:repositories).call(:index, {
126
                                              'organization_id' => katello_organization(:name => line[ORGANIZATION]),
127
                                              'library' => true,
128
                                              'all' => false,
129
                                              'product_id' => product_id
130
                                            })['results'].each do |repository|
131
            @existing_repositories[line[ORGANIZATION] + name][repository['name']] = repository
132
          end
133
        end
134

  
135
        if !@existing_repositories[line[ORGANIZATION] + name][repository_name]
96 136
          print "Creating repository '#{repository_name}' in product '#{name}'..." if option_verbose?
97
          @api.resource(:repositories).call(:create, {
98
                                     'organization_id' => katello_organization(:name => line[ORGANIZATION]),
99
                                     'name' => repository_name,
100
                                     'label' => labelize(repository_name),
101
                                     'product_id' => product_id,
102
                                     'url' => line[REPOSITORY_URL],
103
                                     'content_type' => line[REPOSITORY_TYPE]
104
                                   })
137
          if line[REPOSITORY_TYPE] =~ /Red Hat/
138
            # TMP
139
            puts "TMP"
140
            @api.resource(:repositories).call(:index, {
141
                                                'organization_id' => katello_organization(:name => line[ORGANIZATION]),
142
                                                'library' => true,
143
                                                'all' => true,
144
                                                'product_id' => product_id
145
                                              })['results'].each do |repository|
146
              puts repository if repository['name'] == repository_name
147
            end
148
            puts "END TMP"
149
            #repository_id = redhat_create_repository(product_id, repository_name)
150

  
151
          else
152
            repository_id = @api.resource(:repositories).call(:create, {
153
                                       'organization_id' => katello_organization(:name => line[ORGANIZATION]),
154
                                       'name' => repository_name,
155
                                       'label' => labelize(repository_name),
156
                                       'product_id' => product_id,
157
                                       'url' => line[REPOSITORY_URL],
158
                                       'content_type' => content_type(line[REPOSITORY_TYPE])
159
                                     })['id']
160
          end
161
          @existing_repositories[line[ORGANIZATION] + name][line[LABEL]] = repository_id
162

  
163
          puts "TODO: skipping sync"
164
          # task_id = @api.resource(:repositories).call(:sync, {
165
          #                                               'organization_id' => katello_organization(:name => line[ORGANIZATION]),
166
          #                                               'id' => repository_id
167
          #                                             })['id']
168
          # TODO: wait for sync task
105 169
          print "done\n" if option_verbose?
106 170
        end
107 171
      end
......
109 173
    rescue RuntimeError => e
110 174
      raise "#{e}\n       #{line}"
111 175
    end
176

  
177
    private
178

  
179
    def redhat_create_repository(product_id, repository_name)
180
      @api.resource(:repository_sets).call(:index, {
181
                                             'product_id' => product_id
182
                                           })['results'].each do |repository|
183
        puts repository
184
        puts @api.resource(:repository_sets).call(:show, {
185
                                                    'product_id' => product_id,
186
                                                    'id' => repository['id']})
187
        return
188
        if repository['name'] == repository_name
189
          puts repository
190
          @api.resource(:repository_sets).call(:enable, {
191
                                                 'product_id' => product_id,
192
                                                 'repository_id' => repository['id']
193
                                               })
194
          return
195
        end
196
        raise "Repository '#{repository_name}' does not exist"
197
      end
198
    end
199

  
200
    def content_type(repository_type)
201
      case repository_type
202
        when /Yum/
203
          'yum'
204
        when /Puppet/
205
          'puppet'
206
        else
207
        raise "Unrecognized repository type '#{repository_type}'"
208
      end
209
    end
112 210
  end
113 211

  
114
  HammerCLI::MainCommand.subcommand("csv:products", "import/export products and repositories",
115
                                    HammerCLICsv::ProductsCommand)
212
  HammerCLICsv::CsvCommand.subcommand('products',
213
                                      'import or export products',
214
                                      HammerCLICsv::ProductsCommand)
116 215
end
lib/hammer_cli_csv/puppet_environments.rb
99 99
    end
100 100
  end
101 101

  
102
  HammerCLI::MainCommand.subcommand("csv:puppetenvironments", "Import or export puppet environments", HammerCLICsv::PuppetEnvironmentsCommand)
102
  HammerCLICsv::CsvCommand.subcommand("puppet-environments",
103
                                      "import or export puppet environments",
104
                                      HammerCLICsv::PuppetEnvironmentsCommand)
103 105
end
lib/hammer_cli_csv/puppet_facts.rb
90 90
    end
91 91
  end
92 92

  
93
  HammerCLI::MainCommand.subcommand("csv:puppetfacts", "ping the katello server", HammerCLICsv::PuppetFactsCommand)
93
  HammerCLICsv::CsvCommand.subcommand("puppet-facts",
94
                                      "import or export puppet facts",
95
                                      HammerCLICsv::PuppetFactsCommand)
94 96
end
lib/hammer_cli_csv/puppet_reports.rb
222 222

  
223 223
  end
224 224

  
225
  HammerCLI::MainCommand.subcommand("csv:puppetreports", "import/export puppet reports", HammerCLICsv::PuppetReportsCommand)
225
  HammerCLICsv::CsvCommand.subcommand("puppet-reports",
226
                                      "import or export puppet reports",
227
                                      HammerCLICsv::PuppetReportsCommand)
226 228
end
lib/hammer_cli_csv/reports.rb
97 97
    end
98 98
  end
99 99

  
100
  HammerCLI::MainCommand.subcommand("csv:reports", "import / export reports", HammerCLICsv::ReportsCommand)
100
  HammerCLICsv::CsvCommand.subcommand("reports",
101
                                      "import or export reports",
102
                                      HammerCLICsv::ReportsCommand)
101 103
end
lib/hammer_cli_csv/roles.rb
138 138
    end
139 139
  end
140 140

  
141
  HammerCLI::MainCommand.subcommand("csv:roles", "import / export roles", HammerCLICsv::RolesCommand)
141
  HammerCLICsv::CsvCommand.subcommand("roles",
142
                                      "import or export roles",
143
                                      HammerCLICsv::RolesCommand)
142 144
end
lib/hammer_cli_csv/subscriptions.rb
49 49
    end
50 50
  end
51 51

  
52
  HammerCLI::MainCommand.subcommand("csv:subscriptions", "import subscriptions", HammerCLICsv::SubscriptionsCommand)
52
  HammerCLICsv::CsvCommand.subcommand("subscriptions",
53
                                      "import or export subscriptions",
54
                                      HammerCLICsv::SubscriptionsCommand)
53 55
end
lib/hammer_cli_csv/system_groups.rb
90 90
    end
91 91
  end
92 92

  
93
  HammerCLI::MainCommand.subcommand("csv:systemgroups", "system groups", HammerCLICsv::SystemGroupsCommand)
93
  HammerCLICsv::CsvCommand.subcommand("system-groups",
94
                                      "import or export system groups",
95
                                      HammerCLICsv::SystemGroupsCommand)
94 96
end
lib/hammer_cli_csv/systems.rb
229 229
    end
230 230
  end
231 231

  
232
  HammerCLI::MainCommand.subcommand('csv:systems', 'import/export systems', HammerCLICsv::SystemsCommand)
232
  HammerCLICsv::CsvCommand.subcommand('systems',
233
                                      'import or export systems',
234
                                      HammerCLICsv::SystemsCommand)
233 235
end
lib/hammer_cli_csv/users.rb
71 71

  
72 72
        roles = CSV.parse_line(line[ROLES], {:skip_blanks => true}).collect do |role|
73 73
          foreman_role(:name => namify(role, number))
74
        end if line[ROLES]
74
        end if line[ROLES] && !line[ROLES].empty?
75 75
        organizations = CSV.parse_line(line[ORGANIZATIONS], {:skip_blanks => true}).collect do |organization|
76 76
          foreman_organization(:name => organization)
77
        end if line[ORGANIZATIONS]
77
        end if line[ORGANIZATIONS] && !line[ORGANIZATIONS].empty?
78 78
        locations = CSV.parse_line(line[LOCATIONS], {:skip_blanks => true}).collect do |location|
79 79
          foreman_location(:name => location)
80
        end if line[LOCATIONS]
80
        end if line[LOCATIONS] && !line[LOCATIONS].empty?
81 81

  
82 82
        if !@existing.include? name
83 83
          create_user(line, name, roles, organizations, locations)
......
125 125
    end
126 126
  end
127 127

  
128
  HammerCLI::MainCommand.subcommand('csv:users',
129
                                    'import or export users as CSV',
130
                                    HammerCLICsv::UsersCommand)
128
  HammerCLICsv::CsvCommand.subcommand('users',
129
                                      'import or export users',
130
                                      HammerCLICsv::UsersCommand)
131 131
end
test/organizations_test.rb
1
require File.join(File.dirname(__FILE__), 'csv_test_helper')
2

  
3
describe 'organizations' do
4

  
5
  extend CommandTestHelper
6

  
7
  before :each do
8
    HammerCLI::Settings.load_from_file 'test/config.yml'
9

  
10
    @api = ApipieBindings::API.new({
11
                                     :uri => HammerCLI::Settings.get(:csv, :host),
12
                                     :username => HammerCLI::Settings.get(:csv, :username),
13
                                     :password => HammerCLI::Settings.get(:csv, :password),
14
                                     :api_version => 2
15
                                   })
16

  
17
  end
18

  
19
  context "organizations CRUD" do
20

  
21
    it "create, update, delete" do
22

  
23
      name = "host#{rand(10000)}"
24

  
25
      # Create organization
26
      file = Tempfile.new('organizations_test')
27
      file.write("Name,Count,Org Label,Description\n")
28
      file.write("#{name},1,#{name},A test organization\n")
29
      file.rewind
30

  
31
      stdout,stderr = capture {
32
        hammer.run(%W{csv organizations -v --csv-file #{file.path}})
33
      }
34
      stderr.must_equal ''
35
      stdout[0..-2].must_equal "Creating organization '#{name}'... done"
36
      file.unlink
37

  
38
      # Update organization
39
      file = Tempfile.new('organizations_test')
40
      file.write("Name,Count,Org Label,Description\n")
41
      file.write("#{name},1,#{name},An updated test organization\n")
42
      file.rewind
43

  
44
      stdout,stderr = capture {
45
        hammer.run(%W{csv organizations -v --csv-file #{file.path}})
46
      }
47
      stderr.must_equal ''
48
      stdout[0..-2].must_equal "Updating organization '#{name}'... done"
49
      file.unlink
50

  
51
      # Verify organization
52
      organization = @api.resource(:organizations).call(:index, {
53
                                              'search' => "name=\"#{name}\""
54
                                            })['results']
55
      organization.wont_be_nil
56
      organization.wont_be_empty
57
      organization[0]['name'].must_equal name
58

  
59
      # Clean up
60
      @api.resource(:organizations).call(:destroy, {
61
                                              'id' => organization[0]['id']
62
                                             })
63

  
64
      # Verify organization
65
      organization = @api.resource(:organizations).call(:index, {
66
                                              'search' => "name=\"#{name}\""
67
                                            })['results']
68
      organization.wont_be_nil
69
      organization.will_be_empty
70

  
71
    end
72

  
73
  end
74
end
test/setup_test.rb
9 9
  end
10 10

  
11 11
  context 'Setup Organizations' do
12
    it "hammer -v csv:organizations --csv-file test/data/organizations.csv" do
12
    it "hammer csv organizations -v --csv-file test/data/organizations.csv" do
13 13
      stdout,stderr = capture {
14
        hammer.run(%W{-v csv:organizations --csv-file test/data/organizations.csv})
14
        hammer.run(%W{csv organizations -v --csv-file test/data/organizations.csv})
15 15
      }
16 16
      stderr.must_equal ''
17 17
      stdout.must_match /.*organization 'Mega Corporation'.*/
......
19 19
  end
20 20

  
21 21
  context 'Setup Locations' do
22
    it "hammer -v csv:locations --csv-file test/data/locations.csv" do
22
    it "hammer csv locations -v --csv-file test/data/locations.csv" do
23 23
      stdout,stderr = capture {
24
        hammer.run(%W{-v csv:locations --csv-file test/data/locations.csv})
24
        hammer.run(%W{csv locations -v --csv-file test/data/locations.csv})
25 25
      }
26 26
      stderr.must_equal ''
27 27
      stdout.must_match /.*Asia Pacific.*/
......
29 29
  end
30 30

  
31 31
  context 'Setup' do
32
    it "hammer -v csv:operatingsystems --csv-file test/data/operatingsystems.csv" do
32
    it "hammer csv operating-systems -v --csv-file test/data/operatingsystems.csv" do
33 33
      stdout,stderr = capture {
34
        hammer.run(%W{-v csv:operatingsystems --csv-file test/data/operatingsystems.csv})
34
        hammer.run(%W{csv operating-systems -v --csv-file test/data/operatingsystems.csv})
35 35
      }
36 36
      stderr.must_equal ''
37 37
      stdout.must_match /.*operating system 'Fedora 18'.*/
......
39 39
  end
40 40

  
41 41
  context 'Setup' do
42
    it "hammer -v csv:architectures --csv-file test/data/architectures.csv" do
42
    it "hammer csv architectures -v --csv-file test/data/architectures.csv" do
43 43
      stdout,stderr = capture {
44
        hammer.run(%W{-v csv:architectures --csv-file test/data/architectures.csv})
44
        hammer.run(%W{csv architectures -v --csv-file test/data/architectures.csv})
45 45
      }
46 46
      stderr.must_equal ''
47 47
      stdout.must_match /.*architecture 'x86_64'.*/
......
49 49
  end
50 50

  
51 51
  context 'Setup' do
52
    it "hammer -v csv:partitiontables --csv-file test/data/partitiontables.csv" do
52
    it "hammer csv partitiontables -v --csv-file test/data/partitiontables.csv" do
53 53
      stdout,stderr = capture {
54
        hammer.run(%W{-v csv:partitiontables --csv-file test/data/partitiontables.csv})
54
        hammer.run(%W{csv partition-tables -v --csv-file test/data/partitiontables.csv})
55 55
      }
56 56
      stderr.must_equal ''
57 57
      stdout.must_match /.*ptable 'ext4 default'.*/
......
59 59
  end
60 60

  
61 61
  context 'Setup' do
62
    it "hammer -v csv:domains --csv-file test/data/domains.csv" do
62
    it "hammer csv domains -v --csv-file test/data/domains.csv" do
63 63
      stdout,stderr = capture {
64
        hammer.run(%W{-v csv:domains --csv-file test/data/domains.csv})
64
        hammer.run(%W{csv domains -v --csv-file test/data/domains.csv})
65 65
      }
66 66
      stderr.must_equal ''
67 67
      stdout.must_match /.*domain 'megacorp.com'.*/
......
69 69
  end
70 70

  
71 71
  context 'Setup' do
72
    it "hammer -v csv:puppetenvironments --csv-file test/data/puppetenvironments.csv" do
72
    it "hammer csv puppet-environments -v --csv-file test/data/puppetenvironments.csv" do
73 73
      stdout,stderr = capture {
74
        hammer.run(%W{-v csv:puppetenvironments --csv-file test/data/puppetenvironments.csv})
74
        hammer.run(%W{csv puppet-environments -v --csv-file test/data/puppetenvironments.csv})
75 75
      }
76 76
      stderr.must_equal ''
77 77
      stdout.must_match /.*environment 'Development'.*/
......
79 79
  end
80 80

  
81 81
  context 'Setup' do
82
    it "hammer -v csv:hosts --csv-file test/data/hosts.csv" do
82
    it "hammer csv hosts -v --csv-file test/data/hosts.csv" do
83 83
      stdout,stderr = capture {
84
        hammer.run(%W{-v csv:hosts --csv-file test/data/hosts.csv})
84
        hammer.run(%W{csv hosts -v --csv-file test/data/hosts.csv})
85 85
      }
86 86
      stderr.must_equal ''
87 87
      stdout.split("\n").length.must_equal 255
......
90 90
  end
91 91

  
92 92
  context 'Setup' do
93
    it "hammer -v csv:puppetfacts --csv-file test/data/puppetfacts.csv" do
93
    it "hammer csv puppet-facts -v --csv-file test/data/puppetfacts.csv" do
94 94
      stdout,stderr = capture {
95
        hammer.run(%W{-v csv:puppetfacts --csv-file test/data/puppetfacts.csv})
95
        hammer.run(%W{csv puppet-facts -v --csv-file test/data/puppetfacts.csv})
96 96
      }
97 97
      stderr.must_equal ''
98 98
      stdout.must_match /.*puppetfacts 'dhcp129-000.megacorp.com'.*/
......
100 100
  end
101 101

  
102 102
  context 'subscription setup' do
103
    it "hammer -v subscription upload --organization-id megacorp --file test/data/megacorp.zip" do
103
    it "hammer subscription upload -v --organization-id megacorp --file test/data/megacorp.zip" do
104 104
      # TODO: http://projects.theforeman.org/issues/4748
105 105
      "".must_equal "TODO: Bug #4748 - errors on import manifest should complete dynflow task and display information to user"
106 106
      stdout,stderr = capture {
......
112 112
  end
113 113

  
114 114
  context 'Setup' do
115
    it "hammer -v csv:products --csv-file test/data/products.csv" do
115
    it "hammer csv products -v --csv-file test/data/products.csv" do
116 116
      stdout,stderr = capture {
117
        hammer.run(%W{-v csv:products --csv-file test/data/products.csv})
117
        hammer.run(%W{csv products -v --csv-file test/data/products.csv})
118 118
      }
119 119
      stderr.must_equal ''
120 120
      stdout.must_match /.*product 'Point of Sale'.*/
......
122 122
  end
123 123

  
124 124
  context 'Setup' do
125
    it "hammer -v csv:lifecycleenv --csv-file test/data/lifecycleenvironments.csv" do
125
    it "hammer csv lifecycle-environments -v --csv-file test/data/lifecycleenvironments.csv" do
126 126
      stdout,stderr = capture {
127
        hammer.run(%W{-v csv:lifecycleenv --csv-file test/data/lifecycleenvironments.csv})
127
        hammer.run(%W{csv lifecycle-environments -v --csv-file test/data/lifecycleenvironments.csv})
128 128
      }
129 129
      stderr.must_equal ''
130 130
      stdout.must_match /.*environment 'Development'.*/
......
132 132
  end
133 133

  
134 134
  context 'Setup' do
135
    it "hammer -v csv:systemgroups --csv-file test/data/systemgroups.csv" do
135
    it "hammer csv system-groups -v --csv-file test/data/systemgroups.csv" do
136 136
      stdout,stderr = capture {
137
        hammer.run(%W{-v csv:systemgroups --csv-file test/data/systemgroups.csv})
137
        hammer.run(%W{csv system-groups -v --csv-file test/data/systemgroups.csv})
138 138
      }
139 139
      stderr.must_equal ''
140 140
      stdout.must_match /.*system group 'Mega Corp HQ'.*/
......
142 142
  end
143 143

  
144 144
  context 'Setup' do
145
    it "hammer -v csv:systems --csv-file test/data/systems.csv" do
145
    it "hammer csv systems -v --csv-file test/data/systems.csv" do
146 146
      stdout,stderr = capture {
147
        hammer.run(%W{-v csv:systems --csv-file test/data/systems.csv})
147
        hammer.run(%W{csv systems -v --csv-file test/data/systems.csv})
148 148
      }
149 149
      stderr.must_equal ''
150 150
      stdout.must_match /.*system 'host0'.*/
......
152 152
  end
153 153

  
154 154
  context 'Setup' do
155
    it "hammer -v csv:activationkeys --csv-file test/data/activationkeys.csv" do
155
    it "hammer csv activation-keys -v --csv-file test/data/activationkeys.csv" do
156 156
      stdout,stderr = capture {
157
        hammer.run(%W{-v csv:activationkeys --csv-file test/data/activationkeys.csv})
157
        hammer.run(%W{csv activation-keys -v --csv-file test/data/activationkeys.csv})
158 158
      }
159 159
      stderr.must_equal ''
160 160
      stdout.must_match /.*activation key 'damon\.dials@megacorp\.com'.*/
test/users_test.rb
24 24
      file.rewind
25 25

  
26 26
      stdout,stderr = capture {
27
        hammer.run(%W{-v csv:users --csv-file #{file.path}})
27
        hammer.run(%W{csv users -v --csv-file #{file.path}})
28 28
      }
29 29
      stderr.must_equal ''
30 30
      stdout[0..-2].must_equal 'Updating user \'damon.dials@megacorp.com\'... done'

Also available in: Unified diff