Sha256: ac8c8e7483de75b51f98c187a3f04a401e2ab01fd099fcf39129a89b5921e3ed

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

require 'hammer_cli_foreman/smart_proxy'

module HammerCLIForemanPuppet
  class ImportPuppetClassesCommand < HammerCLIForemanPuppet::Command
    resource :smart_proxies
    action :import_puppetclasses

    command_name "import-classes"
    desc _("Import Puppet classes from Puppet proxy")
    option "--dryrun", :flag, _("Do not run the import")


    output do
      field :message, _("Result"), Fields::LongText
      collection :results, _("Changed environments"), :hide_blank => true do
        field :name, nil
        collection :new_puppetclasses, _("New classes"), :hide_blank => true, :numbered => false do
          field nil, nil
        end
        collection :updated_puppetclasses, _("Updated classes"), :hide_blank => true, :numbered => false do
          field nil, nil
        end
        collection :obsolete_puppetclasses, _("Removed classes"), :hide_blank => true, :numbered => false do
          field nil, nil
        end
        collection :ignored_puppetclasses, _("Ignored classes"), :hide_blank => true, :numbered => false do
          field nil, nil
        end
      end
    end

    build_options do |o|
      o.without(:smart_proxy_id, :dryrun)
      o.expand.except(:smart_proxies)
    end

    def request_params
      opts = super
      opts['dryrun'] = option_dryrun? || false
      opts
    end

    def transform_format(data)
      # Overriding the default behavior that tries to remove nesting
      # when there's only {"message": "..."}
      data
    end

    def print_data(record)
      print_record(output_definition, record)
    end

    extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
  end
  HammerCLIForeman::SmartProxy.subcommand 'import-classes',
                                           HammerCLIForemanPuppet::ImportPuppetClassesCommand.desc,
                                           HammerCLIForemanPuppet::ImportPuppetClassesCommand
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hammer_cli_foreman_puppet-0.0.7 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.6 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.5 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.4 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.3 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.2 lib/hammer_cli_foreman_puppet/smart_proxy.rb
hammer_cli_foreman_puppet-0.0.1 lib/hammer_cli_foreman_puppet/smart_proxy.rb