Class: HammerCLICsv::CsvCommand::ExportCommand
- Inherits:
-
HammerCLI::Apipie::Command
- Object
- HammerCLI::Apipie::Command
- HammerCLICsv::CsvCommand::ExportCommand
- Defined in:
- lib/hammer_cli_csv/export.rb
Constant Summary collapse
- RESOURCES =
%w( organizations locations puppet_environments operating_systems domains architectures partition_tables lifecycle_environments host_collections provisioning_templates subscriptions activation_keys hosts content_hosts reports roles users )
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/hammer_cli_csv/export.rb', line 35 def execute @api = ApipieBindings::API.new({ :uri => option_server || HammerCLI::Settings.get(:csv, :host), :username => option_username || HammerCLI::Settings.get(:csv, :username), :password => option_password || HammerCLI::Settings.get(:csv, :password), :api_version => 2 }) # Swing the hammers RESOURCES.each do |resource| hammer_resource(resource) end HammerCLI::EX_OK end |
#hammer(context = nil) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/hammer_cli_csv/export.rb', line 51 def hammer(context = nil) context ||= { :interactive => false, :username => 'admin', # TODO: this needs to come from config/settings :password => 'changeme' # TODO: this needs to come from config/settings } HammerCLI::MainCommand.new('', context) end |
#hammer_resource(resource) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/hammer_cli_csv/export.rb', line 61 def hammer_resource(resource) return if !self.send("option_#{resource}") && !option_dir = self.send("option_#{resource}") || "#{option_dir}/#{resource.sub('_', '-')}.csv" args = %W( csv #{resource.sub('_', '-')} --csv-export --csv-file #{} ) args << '-v' if option_verbose? args += %W( --threads #{option_threads} ) args += %W( --server #{option_server} ) if option_server hammer.run(args) end |