Sha256: 42a10c540f3820e4ddd433405e25260132d1640c0299d433f69a668e85c1b2c8

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'hammer_cli'
require 'foreman_api'
require 'hammer_cli_foreman/commands'
require 'hammer_cli_foreman/smart_class_parameter'

module HammerCLIForeman

  class PuppetClass < HammerCLI::Apipie::Command

    resource ForemanApi::Resources::Puppetclass

    class ListCommand < HammerCLIForeman::ListCommand

      output do
        from "puppetclass" do
          field :id, "Id"
          field :name, "Name"
        end
      end

      def retrieve_data
        self.class.unhash_classes(super)
      end

      def self.unhash_classes(classes)
        classes.inject([]) { |list, (pp_module, pp_module_classes)| list + pp_module_classes }
      end

      apipie_options
    end


    class InfoCommand < HammerCLIForeman::InfoCommand

      #FIXME: show environments and hostgroups
      output ListCommand.output_definition do
        from "puppetclass" do
          collection :lookup_keys, "Smart variables" do
            from :lookup_key do
              field :key, "Parameter"
              field :default_value, "Default value"
            end
          end
        end
      end

    end


    class SCParamsCommand < HammerCLIForeman::SmartClassParametersBriefList

      apipie_options :without => [:host_id, :hostgroup_id, :puppetclass_id, :environment_id]
      option ['--id', '--name'], 'PUPPET_CLASS_ID', 'puppet class id/name', 
              :attribute_name => :puppetclass_id, :required => true
    end


    autoload_subcommands
  end

end

HammerCLI::MainCommand.subcommand 'puppet_class', "Search Foreman's puppet modules.", HammerCLIForeman::PuppetClass

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hammer_cli_foreman-0.0.11 lib/hammer_cli_foreman/puppet_class.rb