hammer_cli_foreman 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of hammer_cli_foreman might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/lib/hammer_cli_foreman.rb +8 -1
- data/lib/hammer_cli_foreman/architecture.rb +10 -21
- data/lib/hammer_cli_foreman/associating_commands.rb +179 -0
- data/lib/hammer_cli_foreman/commands.rb +163 -6
- data/lib/hammer_cli_foreman/common_parameter.rb +4 -5
- data/lib/hammer_cli_foreman/compute_resource.rb +10 -16
- data/lib/hammer_cli_foreman/domain.rb +8 -12
- data/lib/hammer_cli_foreman/environment.rb +3 -9
- data/lib/hammer_cli_foreman/exception_handler.rb +3 -3
- data/lib/hammer_cli_foreman/fact.rb +42 -0
- data/lib/hammer_cli_foreman/host.rb +84 -18
- data/lib/hammer_cli_foreman/hostgroup.rb +30 -13
- data/lib/hammer_cli_foreman/location.rb +18 -15
- data/lib/hammer_cli_foreman/media.rb +11 -18
- data/lib/hammer_cli_foreman/model.rb +66 -0
- data/lib/hammer_cli_foreman/operating_system.rb +21 -21
- data/lib/hammer_cli_foreman/organization.rb +17 -15
- data/lib/hammer_cli_foreman/output.rb +2 -0
- data/lib/hammer_cli_foreman/output/fields.rb +11 -0
- data/lib/hammer_cli_foreman/output/formatters.rb +23 -0
- data/lib/hammer_cli_foreman/parameter.rb +24 -10
- data/lib/hammer_cli_foreman/partition_table.rb +13 -17
- data/lib/hammer_cli_foreman/puppet_class.rb +55 -0
- data/lib/hammer_cli_foreman/report.rb +97 -0
- data/lib/hammer_cli_foreman/resource_supported_test.rb +1 -1
- data/lib/hammer_cli_foreman/smart_proxy.rb +5 -11
- data/lib/hammer_cli_foreman/subnet.rb +5 -11
- data/lib/hammer_cli_foreman/template.rb +15 -19
- data/lib/hammer_cli_foreman/user.rb +12 -15
- data/lib/hammer_cli_foreman/version.rb +1 -1
- metadata +25 -29
| @@ -9,7 +9,6 @@ module HammerCLIForeman | |
| 9 9 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 10 | 
             
                  resource ForemanApi::Resources::CommonParameter, "index"
         | 
| 11 11 |  | 
| 12 | 
            -
                  heading "Global parameter list"
         | 
| 13 12 | 
             
                  output do
         | 
| 14 13 | 
             
                    from "common_parameter" do
         | 
| 15 14 | 
             
                      field :name, "Name"
         | 
| @@ -22,6 +21,9 @@ module HammerCLIForeman | |
| 22 21 |  | 
| 23 22 | 
             
                class SetCommand < HammerCLI::Apipie::WriteCommand
         | 
| 24 23 |  | 
| 24 | 
            +
                  command_name "set"
         | 
| 25 | 
            +
                  desc "Set a global parameter."
         | 
| 26 | 
            +
             | 
| 25 27 | 
             
                  resource ForemanApi::Resources::CommonParameter
         | 
| 26 28 |  | 
| 27 29 | 
             
                  option "--name", "NAME", "parameter name", :required => true
         | 
| @@ -70,10 +72,7 @@ module HammerCLIForeman | |
| 70 72 | 
             
                  apipie_options :without => :id
         | 
| 71 73 | 
             
                end
         | 
| 72 74 |  | 
| 73 | 
            -
                 | 
| 74 | 
            -
                subcommand "set", "Set a global parameter.", HammerCLIForeman::CommonParameter::SetCommand
         | 
| 75 | 
            -
                subcommand "delete", "Delete a global parameter.", HammerCLIForeman::CommonParameter::DeleteCommand
         | 
| 76 | 
            -
             | 
| 75 | 
            +
                autoload_subcommands
         | 
| 77 76 | 
             
              end
         | 
| 78 77 | 
             
            end
         | 
| 79 78 |  | 
| @@ -9,7 +9,6 @@ module HammerCLIForeman | |
| 9 9 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 10 | 
             
                  resource ForemanApi::Resources::ComputeResource, "index"
         | 
| 11 11 |  | 
| 12 | 
            -
                  heading "Compute resource list"
         | 
| 13 12 | 
             
                  output do
         | 
| 14 13 | 
             
                    from "compute_resource" do
         | 
| 15 14 | 
             
                      field :id, "Id"
         | 
| @@ -26,20 +25,20 @@ module HammerCLIForeman | |
| 26 25 |  | 
| 27 26 | 
             
                  PROVIDER_SPECIFIC_FIELDS = {
         | 
| 28 27 | 
             
                    'ovirt' => [
         | 
| 29 | 
            -
                       | 
| 28 | 
            +
                      Fields::DataField.new(:label => 'UUID', :path => ["compute_resource", "uuid"])
         | 
| 30 29 | 
             
                    ],
         | 
| 31 30 | 
             
                    'ec2' => [
         | 
| 32 | 
            -
                       | 
| 31 | 
            +
                      Fields::DataField.new(:label => 'Region', :path => ["compute_resource", "region"])
         | 
| 33 32 | 
             
                    ],
         | 
| 34 33 | 
             
                    'vmware' => [
         | 
| 35 | 
            -
                       | 
| 36 | 
            -
                       | 
| 34 | 
            +
                      Fields::DataField.new(:label => 'UUID', :path => ["compute_resource", "uuid"]),
         | 
| 35 | 
            +
                      Fields::DataField.new(:label => 'Server', :path => ["compute_resource", "server"])
         | 
| 37 36 | 
             
                    ],
         | 
| 38 37 | 
             
                    'openstack' => [
         | 
| 39 | 
            -
                       | 
| 38 | 
            +
                      Fields::DataField.new(:label => 'Tenant', :path => ["compute_resource", "tenant"])
         | 
| 40 39 | 
             
                    ],
         | 
| 41 40 | 
             
                    'rackspace' => [
         | 
| 42 | 
            -
                       | 
| 41 | 
            +
                      Fields::DataField.new(:label => 'Region', :path => ["compute_resource", "region"])
         | 
| 43 42 | 
             
                    ],
         | 
| 44 43 | 
             
                    'libvirt' => [
         | 
| 45 44 | 
             
                    ]
         | 
| @@ -47,18 +46,17 @@ module HammerCLIForeman | |
| 47 46 |  | 
| 48 47 | 
             
                  resource ForemanApi::Resources::ComputeResource, "show"
         | 
| 49 48 |  | 
| 50 | 
            -
                  heading "Compute resource info"
         | 
| 51 49 | 
             
                  output ListCommand.output_definition do
         | 
| 52 50 | 
             
                    from "compute_resource" do
         | 
| 53 51 | 
             
                      field :url, "Url"
         | 
| 54 52 | 
             
                      field :description, "Description"
         | 
| 55 53 | 
             
                      field :user, "User"
         | 
| 56 | 
            -
                      field :created_at, "Created at",  | 
| 57 | 
            -
                      field :updated_at, "Updated at",  | 
| 54 | 
            +
                      field :created_at, "Created at", Fields::Date
         | 
| 55 | 
            +
                      field :updated_at, "Updated at", Fields::Date
         | 
| 58 56 | 
             
                    end
         | 
| 59 57 | 
             
                  end
         | 
| 60 58 |  | 
| 61 | 
            -
                  def print_records | 
| 59 | 
            +
                  def print_records(data)
         | 
| 62 60 | 
             
                    provider = data["compute_resource"]["provider"].downcase
         | 
| 63 61 | 
             
                    output_definition.fields.concat PROVIDER_SPECIFIC_FIELDS[provider]
         | 
| 64 62 | 
             
                    super data
         | 
| @@ -100,11 +98,7 @@ module HammerCLIForeman | |
| 100 98 | 
             
                  apipie_options
         | 
| 101 99 | 
             
                end
         | 
| 102 100 |  | 
| 103 | 
            -
                 | 
| 104 | 
            -
                subcommand "info", "Detailed info about a compute resource.", HammerCLIForeman::ComputeResource::InfoCommand
         | 
| 105 | 
            -
                subcommand "create", "Create new compute resource.", HammerCLIForeman::ComputeResource::CreateCommand
         | 
| 106 | 
            -
                subcommand "update", "Update a compute resource.", HammerCLIForeman::ComputeResource::UpdateCommand
         | 
| 107 | 
            -
                subcommand "delete", "Delete a compute resource.", HammerCLIForeman::ComputeResource::DeleteCommand
         | 
| 101 | 
            +
                autoload_subcommands
         | 
| 108 102 | 
             
              end
         | 
| 109 103 |  | 
| 110 104 | 
             
            end
         | 
| @@ -9,7 +9,6 @@ module HammerCLIForeman | |
| 9 9 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 10 | 
             
                  resource ForemanApi::Resources::Domain, "index"
         | 
| 11 11 |  | 
| 12 | 
            -
                  heading "Domain list"
         | 
| 13 12 | 
             
                  output do
         | 
| 14 13 | 
             
                    from "domain" do
         | 
| 15 14 | 
             
                      field :id, "Id"
         | 
| @@ -31,16 +30,15 @@ module HammerCLIForeman | |
| 31 30 | 
             
                    domain
         | 
| 32 31 | 
             
                  end
         | 
| 33 32 |  | 
| 34 | 
            -
                  heading "Domain info"
         | 
| 35 33 | 
             
                  output ListCommand.output_definition do
         | 
| 36 34 | 
             
                    from "domain" do
         | 
| 37 35 | 
             
                      field :fullname, "Full Name"
         | 
| 38 36 | 
             
                      field :dns_id, "DNS Id"
         | 
| 39 | 
            -
                      field :created_at, "Created at",  | 
| 40 | 
            -
                      field :updated_at, "Updated at",  | 
| 37 | 
            +
                      field :created_at, "Created at", Fields::Date
         | 
| 38 | 
            +
                      field :updated_at, "Updated at", Fields::Date
         | 
| 41 39 | 
             
                    end
         | 
| 42 40 | 
             
                    collection :parameters, "Parameters" do
         | 
| 43 | 
            -
                      field :parameter, nil,  | 
| 41 | 
            +
                      field :parameter, nil, Fields::KeyValue
         | 
| 44 42 | 
             
                    end
         | 
| 45 43 | 
             
                  end
         | 
| 46 44 |  | 
| @@ -79,6 +77,8 @@ module HammerCLIForeman | |
| 79 77 |  | 
| 80 78 | 
             
                class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
         | 
| 81 79 |  | 
| 80 | 
            +
                  desc "Create or update parameter for a domain."
         | 
| 81 | 
            +
             | 
| 82 82 | 
             
                  option "--domain-name", "DOMAIN_NAME", "name of the domain the parameter is being set for"
         | 
| 83 83 | 
             
                  option "--domain-id", "DOMAIN_ID", "id of the domain the parameter is being set for"
         | 
| 84 84 |  | 
| @@ -101,6 +101,8 @@ module HammerCLIForeman | |
| 101 101 |  | 
| 102 102 | 
             
                class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
         | 
| 103 103 |  | 
| 104 | 
            +
                  desc "Delete parameter for a domain."
         | 
| 105 | 
            +
             | 
| 104 106 | 
             
                  option "--domain-name", "DOMAIN_NAME", "name of the domain the parameter is being deleted for"
         | 
| 105 107 | 
             
                  option "--domain-id", "DOMAIN_ID", "id of the domain the parameter is being deleted for"
         | 
| 106 108 |  | 
| @@ -118,13 +120,7 @@ module HammerCLIForeman | |
| 118 120 | 
             
                  end
         | 
| 119 121 | 
             
                end
         | 
| 120 122 |  | 
| 121 | 
            -
                 | 
| 122 | 
            -
                subcommand "info", "Detailed info about a domain.", HammerCLIForeman::Domain::InfoCommand
         | 
| 123 | 
            -
                subcommand "create", "Create a new domain.", HammerCLIForeman::Domain::CreateCommand
         | 
| 124 | 
            -
                subcommand "update", "Update a domain.", HammerCLIForeman::Domain::UpdateCommand
         | 
| 125 | 
            -
                subcommand "delete", "Delete a domain.", HammerCLIForeman::Domain::DeleteCommand
         | 
| 126 | 
            -
                subcommand "set_parameter", "Create or update parameter for a domain.", HammerCLIForeman::Domain::SetParameterCommand
         | 
| 127 | 
            -
                subcommand "delete_parameter", "Delete parameter for a domain.", HammerCLIForeman::Domain::DeleteParameterCommand
         | 
| 123 | 
            +
                autoload_subcommands
         | 
| 128 124 | 
             
              end
         | 
| 129 125 |  | 
| 130 126 | 
             
            end
         | 
| @@ -8,7 +8,6 @@ module HammerCLIForeman | |
| 8 8 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 9 9 | 
             
                  resource ForemanApi::Resources::Environment, "index"
         | 
| 10 10 |  | 
| 11 | 
            -
                  heading "Environments"
         | 
| 12 11 | 
             
                  output do
         | 
| 13 12 | 
             
                    from "environment" do
         | 
| 14 13 | 
             
                      field :id, "Id"
         | 
| @@ -23,11 +22,10 @@ module HammerCLIForeman | |
| 23 22 | 
             
                class InfoCommand < HammerCLIForeman::InfoCommand
         | 
| 24 23 | 
             
                  resource ForemanApi::Resources::Environment, "show"
         | 
| 25 24 |  | 
| 26 | 
            -
                  heading "Environment info"
         | 
| 27 25 | 
             
                  output ListCommand.output_definition do
         | 
| 28 26 | 
             
                    from "environment" do
         | 
| 29 | 
            -
                      field :created_at, "Created at",  | 
| 30 | 
            -
                      field :updated_at, "Updated at",  | 
| 27 | 
            +
                      field :created_at, "Created at", Fields::Date
         | 
| 28 | 
            +
                      field :updated_at, "Updated at", Fields::Date
         | 
| 31 29 | 
             
                    end
         | 
| 32 30 | 
             
                  end
         | 
| 33 31 |  | 
| @@ -63,11 +61,7 @@ module HammerCLIForeman | |
| 63 61 | 
             
                  apipie_options
         | 
| 64 62 | 
             
                end
         | 
| 65 63 |  | 
| 66 | 
            -
                 | 
| 67 | 
            -
                subcommand "info", "Detailed info about an environment.", HammerCLIForeman::Environment::InfoCommand
         | 
| 68 | 
            -
                subcommand "create", "Create new environment.", HammerCLIForeman::Environment::CreateCommand
         | 
| 69 | 
            -
                subcommand "update", "Update an environment.", HammerCLIForeman::Environment::UpdateCommand
         | 
| 70 | 
            -
                subcommand "delete", "Delete an environment.", HammerCLIForeman::Environment::DeleteCommand
         | 
| 64 | 
            +
                autoload_subcommands
         | 
| 71 65 | 
             
              end
         | 
| 72 66 |  | 
| 73 67 | 
             
            end
         | 
| @@ -13,7 +13,7 @@ module HammerCLIForeman | |
| 13 13 |  | 
| 14 14 | 
             
                protected
         | 
| 15 15 |  | 
| 16 | 
            -
                def handle_unprocessable_entity | 
| 16 | 
            +
                def handle_unprocessable_entity(e)
         | 
| 17 17 | 
             
                  response = JSON.parse(e.response)
         | 
| 18 18 | 
             
                  response = response[response.keys[0]]
         | 
| 19 19 |  | 
| @@ -22,13 +22,13 @@ module HammerCLIForeman | |
| 22 22 | 
             
                end
         | 
| 23 23 |  | 
| 24 24 |  | 
| 25 | 
            -
                def handle_argument_error | 
| 25 | 
            +
                def handle_argument_error(e)
         | 
| 26 26 | 
             
                  print_error e.message
         | 
| 27 27 | 
             
                  log_full_error e
         | 
| 28 28 | 
             
                  HammerCLI::EX_USAGE
         | 
| 29 29 | 
             
                end
         | 
| 30 30 |  | 
| 31 | 
            -
                def handle_forbidden | 
| 31 | 
            +
                def handle_forbidden(e)
         | 
| 32 32 | 
             
                  print_error "Forbidden - server refused to process the request"
         | 
| 33 33 | 
             
                  log_full_error e
         | 
| 34 34 | 
             
                  HammerCLI::EX_NOPERM
         | 
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            require 'hammer_cli'
         | 
| 2 | 
            +
            require 'foreman_api'
         | 
| 3 | 
            +
            require 'hammer_cli_foreman/commands'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module HammerCLIForeman
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              class Fact < HammerCLI::AbstractCommand
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  resource ForemanApi::Resources::FactValue, "index"
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  apipie_options
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  output do
         | 
| 16 | 
            +
                    from "fact" do
         | 
| 17 | 
            +
                      field :host, "Host"
         | 
| 18 | 
            +
                      field :fact, "Fact"
         | 
| 19 | 
            +
                      field :value, "Value"
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def retrieve_data
         | 
| 24 | 
            +
                    self.class.unhash_facts(super)
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def self.unhash_facts(facts_hash)
         | 
| 28 | 
            +
                    facts_hash.inject([]) do |list, (host, facts)|
         | 
| 29 | 
            +
                      list + facts.collect do |(fact, value)|
         | 
| 30 | 
            +
                        { :fact => { :host => host, :fact => fact, :value => value } }
         | 
| 31 | 
            +
                      end
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                autoload_subcommands
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            HammerCLI::MainCommand.subcommand 'fact', "Search Foreman's facts.", HammerCLIForeman::Fact
         | 
| @@ -2,6 +2,8 @@ require 'hammer_cli' | |
| 2 2 | 
             
            require 'foreman_api'
         | 
| 3 3 | 
             
            require 'hammer_cli_foreman/commands'
         | 
| 4 4 | 
             
            require 'hammer_cli_foreman/parameter'
         | 
| 5 | 
            +
            require 'hammer_cli_foreman/report'
         | 
| 6 | 
            +
            require 'hammer_cli_foreman/puppet_class'
         | 
| 5 7 |  | 
| 6 8 | 
             
            module HammerCLIForeman
         | 
| 7 9 |  | 
| @@ -9,7 +11,6 @@ module HammerCLIForeman | |
| 9 11 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 12 | 
             
                  resource ForemanApi::Resources::Host, "index"
         | 
| 11 13 |  | 
| 12 | 
            -
                  heading "Host list"
         | 
| 13 14 | 
             
                  output do
         | 
| 14 15 | 
             
                    from "host" do
         | 
| 15 16 | 
             
                      field :id, "Id"
         | 
| @@ -32,11 +33,10 @@ module HammerCLIForeman | |
| 32 33 | 
             
                  def retrieve_data
         | 
| 33 34 | 
             
                    host = super
         | 
| 34 35 | 
             
                    host["host"]["environment_name"] = host["host"]["environment"]["environment"]["name"] rescue nil
         | 
| 35 | 
            -
                    host["parameters"] = HammerCLIForeman::Parameter.get_parameters | 
| 36 | 
            +
                    host["parameters"] = HammerCLIForeman::Parameter.get_parameters(resource_config, host)
         | 
| 36 37 | 
             
                    host
         | 
| 37 38 | 
             
                  end
         | 
| 38 39 |  | 
| 39 | 
            -
                  heading "Host info"
         | 
| 40 40 | 
             
                  output ListCommand.output_definition do
         | 
| 41 41 | 
             
                    from "host" do
         | 
| 42 42 | 
             
                      field :uuid, "UUID"
         | 
| @@ -59,10 +59,10 @@ module HammerCLIForeman | |
| 59 59 | 
             
                      field :sp_subnet, "SP Subnet"
         | 
| 60 60 | 
             
                      field :sp_subnet_id, "SP Subnet Id"
         | 
| 61 61 |  | 
| 62 | 
            -
                      field :created_at, "Created at",  | 
| 63 | 
            -
                      field :updated_at, "Updated at",  | 
| 64 | 
            -
                      field :installed_at, "Installed at",  | 
| 65 | 
            -
                      field :last_report, "Last report",  | 
| 62 | 
            +
                      field :created_at, "Created at", Fields::Date
         | 
| 63 | 
            +
                      field :updated_at, "Updated at", Fields::Date
         | 
| 64 | 
            +
                      field :installed_at, "Installed at", Fields::Date
         | 
| 65 | 
            +
                      field :last_report, "Last report", Fields::Date
         | 
| 66 66 |  | 
| 67 67 | 
             
                      field :puppet_ca_proxy_id, "Puppet CA Proxy Id"
         | 
| 68 68 | 
             
                      field :medium_id, "Medium Id"
         | 
| @@ -80,7 +80,7 @@ module HammerCLIForeman | |
| 80 80 | 
             
                      field :comment, "Comment"
         | 
| 81 81 | 
             
                    end
         | 
| 82 82 | 
             
                    collection :parameters, "Parameters" do
         | 
| 83 | 
            -
                      field :parameter, nil,  | 
| 83 | 
            +
                      field :parameter, nil, Fields::KeyValue
         | 
| 84 84 | 
             
                    end
         | 
| 85 85 | 
             
                  end
         | 
| 86 86 | 
             
                end
         | 
| @@ -88,6 +88,7 @@ module HammerCLIForeman | |
| 88 88 |  | 
| 89 89 | 
             
                class StatusCommand < HammerCLIForeman::InfoCommand
         | 
| 90 90 |  | 
| 91 | 
            +
                  command_name "status"
         | 
| 91 92 | 
             
                  resource ForemanApi::Resources::Host, "status"
         | 
| 92 93 |  | 
| 93 94 | 
             
                  def print_data(records)
         | 
| @@ -98,6 +99,7 @@ module HammerCLIForeman | |
| 98 99 |  | 
| 99 100 | 
             
                class PuppetRunCommand < HammerCLIForeman::InfoCommand
         | 
| 100 101 |  | 
| 102 | 
            +
                  command_name "puppetrun"
         | 
| 101 103 | 
             
                  resource ForemanApi::Resources::Host, "puppetrun"
         | 
| 102 104 |  | 
| 103 105 | 
             
                  def print_data(records)
         | 
| @@ -106,6 +108,74 @@ module HammerCLIForeman | |
| 106 108 | 
             
                end
         | 
| 107 109 |  | 
| 108 110 |  | 
| 111 | 
            +
                class FactsCommand < HammerCLIForeman::ListCommand
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                  command_name "facts"
         | 
| 114 | 
            +
                  resource ForemanApi::Resources::FactValue, "index"
         | 
| 115 | 
            +
                  identifiers :id, :name
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                  apipie_options :without => declared_identifiers.keys
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                  output do
         | 
| 120 | 
            +
                    from "fact" do
         | 
| 121 | 
            +
                      field :fact, "Fact"
         | 
| 122 | 
            +
                      field :value, "Value"
         | 
| 123 | 
            +
                    end
         | 
| 124 | 
            +
                  end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                  def request_params
         | 
| 127 | 
            +
                    params = method_options
         | 
| 128 | 
            +
                    params['host_id'] = get_identifier[0]
         | 
| 129 | 
            +
                    params
         | 
| 130 | 
            +
                  end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                  def retrieve_data
         | 
| 133 | 
            +
                    HammerCLIForeman::Fact::ListCommand.unhash_facts(super)
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
             | 
| 138 | 
            +
             | 
| 139 | 
            +
                class PuppetClassesCommand < HammerCLIForeman::ListCommand
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                  command_name "puppet_classes"
         | 
| 142 | 
            +
                  resource ForemanApi::Resources::Puppetclass
         | 
| 143 | 
            +
             | 
| 144 | 
            +
                  identifiers :id, :name
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                  output HammerCLIForeman::PuppetClass::ListCommand.output_definition
         | 
| 147 | 
            +
             | 
| 148 | 
            +
                  def retrieve_data
         | 
| 149 | 
            +
                    HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(super)
         | 
| 150 | 
            +
                  end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                  def request_params
         | 
| 153 | 
            +
                    params = method_options
         | 
| 154 | 
            +
                    params['host_id'] = get_identifier[0]
         | 
| 155 | 
            +
                    params
         | 
| 156 | 
            +
                  end
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                  apipie_options
         | 
| 159 | 
            +
                end
         | 
| 160 | 
            +
             | 
| 161 | 
            +
             | 
| 162 | 
            +
                class ReportsCommand < HammerCLIForeman::ListCommand
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                  identifiers :id, :name
         | 
| 165 | 
            +
             | 
| 166 | 
            +
                  command_name "reports"
         | 
| 167 | 
            +
                  resource ForemanApi::Resources::Report
         | 
| 168 | 
            +
                  output HammerCLIForeman::Report::ListCommand.output_definition
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                  apipie_options :without => :search
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                  def search
         | 
| 173 | 
            +
                    'host.id = %s' % get_identifier[0].to_s
         | 
| 174 | 
            +
                  end
         | 
| 175 | 
            +
             | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
             | 
| 109 179 | 
             
                class CreateCommand < HammerCLIForeman::CreateCommand
         | 
| 110 180 |  | 
| 111 181 | 
             
                  success_message "Host created"
         | 
| @@ -119,7 +189,7 @@ module HammerCLIForeman | |
| 119 189 | 
             
                  def request_params
         | 
| 120 190 | 
             
                    params = super
         | 
| 121 191 | 
             
                    params['host']['compute_attributes']["nics_attributes"] = {
         | 
| 122 | 
            -
                      "new_nics"=>{"type"=>"bridge", "_delete"=>"", "bridge"=>""}, | 
| 192 | 
            +
                      "new_nics"=>{"type"=>"bridge", "_delete"=>"", "bridge"=>""},
         | 
| 123 193 | 
             
                      "0"=>{"type"=>"network", "_delete"=>"", "network"=>"default", "bridge"=>""}
         | 
| 124 194 | 
             
                    }
         | 
| 125 195 | 
             
                    params
         | 
| @@ -149,6 +219,8 @@ module HammerCLIForeman | |
| 149 219 |  | 
| 150 220 | 
             
                class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
         | 
| 151 221 |  | 
| 222 | 
            +
                  desc "Create or update parameter for a host."
         | 
| 223 | 
            +
             | 
| 152 224 | 
             
                  option "--host-name", "HOST_NAME", "name of the host the parameter is being set for"
         | 
| 153 225 | 
             
                  option "--host-id", "HOST_ID", "id of the host the parameter is being set for"
         | 
| 154 226 |  | 
| @@ -171,6 +243,8 @@ module HammerCLIForeman | |
| 171 243 |  | 
| 172 244 | 
             
                class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
         | 
| 173 245 |  | 
| 246 | 
            +
                  desc "Delete parameter for a host."
         | 
| 247 | 
            +
             | 
| 174 248 | 
             
                  option "--host-name", "HOST_NAME", "name of the host the parameter is being deleted for"
         | 
| 175 249 | 
             
                  option "--host-id", "HOST_ID", "id of the host the parameter is being deleted for"
         | 
| 176 250 |  | 
| @@ -188,15 +262,7 @@ module HammerCLIForeman | |
| 188 262 | 
             
                  end
         | 
| 189 263 | 
             
                end
         | 
| 190 264 |  | 
| 191 | 
            -
                 | 
| 192 | 
            -
                subcommand "info", "Detailed info about host.", HammerCLIForeman::Host::InfoCommand
         | 
| 193 | 
            -
                subcommand "status", "Print host status.", HammerCLIForeman::Host::StatusCommand
         | 
| 194 | 
            -
                subcommand "puppetrun", "Force puppet run on the agent.", HammerCLIForeman::Host::PuppetRunCommand
         | 
| 195 | 
            -
                subcommand "create", "Create a new host.", HammerCLIForeman::Host::CreateCommand
         | 
| 196 | 
            -
                subcommand "update", "Update a host.", HammerCLIForeman::Host::UpdateCommand
         | 
| 197 | 
            -
                subcommand "delete", "Delete a host.", HammerCLIForeman::Host::DeleteCommand
         | 
| 198 | 
            -
                subcommand "set_parameter", "Create or update parameter for a host.", HammerCLIForeman::Host::SetParameterCommand
         | 
| 199 | 
            -
                subcommand "delete_parameter", "Delete parameter for a host.", HammerCLIForeman::Host::DeleteParameterCommand
         | 
| 265 | 
            +
                autoload_subcommands
         | 
| 200 266 | 
             
              end
         | 
| 201 267 |  | 
| 202 268 | 
             
            end
         | 
| @@ -9,7 +9,6 @@ module HammerCLIForeman | |
| 9 9 | 
             
                class ListCommand < HammerCLIForeman::ListCommand
         | 
| 10 10 | 
             
                  resource ForemanApi::Resources::Hostgroup, "index"
         | 
| 11 11 |  | 
| 12 | 
            -
                  heading "Hostgroup list"
         | 
| 13 12 | 
             
                  output do
         | 
| 14 13 | 
             
                    from "hostgroup" do
         | 
| 15 14 | 
             
                      field :id, "Id"
         | 
| @@ -19,7 +18,7 @@ module HammerCLIForeman | |
| 19 18 | 
             
                      field :subnet_id, "Subnet Id"
         | 
| 20 19 | 
             
                      field :domain_id, "Domain Id"
         | 
| 21 20 | 
             
                      field :environment_id, "Environment Id"
         | 
| 22 | 
            -
                      field :puppetclass_ids, "Puppetclass Ids",  | 
| 21 | 
            +
                      field :puppetclass_ids, "Puppetclass Ids", Fields::List
         | 
| 23 22 | 
             
                      field :ancestry, "Ancestry"
         | 
| 24 23 | 
             
                    end
         | 
| 25 24 | 
             
                  end
         | 
| @@ -33,10 +32,9 @@ module HammerCLIForeman | |
| 33 32 |  | 
| 34 33 | 
             
                  identifiers :id
         | 
| 35 34 |  | 
| 36 | 
            -
                  heading "Hostgroup info"
         | 
| 37 35 | 
             
                  output ListCommand.output_definition do
         | 
| 38 36 | 
             
                    collection :parameters, "Parameters" do
         | 
| 39 | 
            -
                      field :parameter, nil,  | 
| 37 | 
            +
                      field :parameter, nil, Fields::KeyValue
         | 
| 40 38 | 
             
                    end
         | 
| 41 39 | 
             
                  end
         | 
| 42 40 |  | 
| @@ -83,8 +81,33 @@ module HammerCLIForeman | |
| 83 81 | 
             
                end
         | 
| 84 82 |  | 
| 85 83 |  | 
| 84 | 
            +
                class PuppetClassesCommand < HammerCLIForeman::ListCommand
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                  command_name "puppet_classes"
         | 
| 87 | 
            +
                  resource ForemanApi::Resources::Puppetclass
         | 
| 88 | 
            +
             | 
| 89 | 
            +
                  identifiers :id
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                  output HammerCLIForeman::PuppetClass::ListCommand.output_definition
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                  def retrieve_data
         | 
| 94 | 
            +
                    HammerCLIForeman::PuppetClass::ListCommand.unhash_classes(super)
         | 
| 95 | 
            +
                  end
         | 
| 96 | 
            +
             | 
| 97 | 
            +
                  def request_params
         | 
| 98 | 
            +
                    params = method_options
         | 
| 99 | 
            +
                    params['hostgroup_id'] = get_identifier[0]
         | 
| 100 | 
            +
                    params
         | 
| 101 | 
            +
                  end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  apipie_options
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
             | 
| 106 | 
            +
             | 
| 86 107 | 
             
                class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
         | 
| 87 108 |  | 
| 109 | 
            +
                  desc "Create or update parameter for a hostgroup."
         | 
| 110 | 
            +
             | 
| 88 111 | 
             
                  option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being set for", :required => true
         | 
| 89 112 |  | 
| 90 113 | 
             
                  success_message_for :update, "Hostgroup parameter updated"
         | 
| @@ -101,6 +124,8 @@ module HammerCLIForeman | |
| 101 124 |  | 
| 102 125 | 
             
                class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
         | 
| 103 126 |  | 
| 127 | 
            +
                  desc "Delete parameter for a hostgroup."
         | 
| 128 | 
            +
             | 
| 104 129 | 
             
                  option "--hostgroup-id", "HOSTGROUP_ID", "id of the hostgroup the parameter is being deleted for", :required => true
         | 
| 105 130 |  | 
| 106 131 | 
             
                  success_message "Hostgroup parameter deleted"
         | 
| @@ -112,15 +137,7 @@ module HammerCLIForeman | |
| 112 137 | 
             
                  end
         | 
| 113 138 | 
             
                end
         | 
| 114 139 |  | 
| 115 | 
            -
             | 
| 116 | 
            -
                subcommand "list", "List hostgroups.", HammerCLIForeman::Hostgroup::ListCommand
         | 
| 117 | 
            -
                subcommand "info", "Detailed info about hostgroup.", HammerCLIForeman::Hostgroup::InfoCommand
         | 
| 118 | 
            -
                subcommand "create", "Create a new hostgroup.", HammerCLIForeman::Hostgroup::CreateCommand
         | 
| 119 | 
            -
                subcommand "update", "Update a hostgroup.", HammerCLIForeman::Hostgroup::UpdateCommand
         | 
| 120 | 
            -
                subcommand "delete", "Delete a hostgroup.", HammerCLIForeman::Hostgroup::DeleteCommand
         | 
| 121 | 
            -
                subcommand "set_parameter", "Create or update parameter for a hostgroup.", HammerCLIForeman::Hostgroup::SetParameterCommand
         | 
| 122 | 
            -
                subcommand "delete_parameter", "Delete parameter for a hostgroup.", HammerCLIForeman::Hostgroup::DeleteParameterCommand
         | 
| 123 | 
            -
             | 
| 140 | 
            +
                autoload_subcommands
         | 
| 124 141 | 
             
              end
         | 
| 125 142 |  | 
| 126 143 | 
             
            end
         |