hammer_cli_foreman_puppet 0.0.2 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23ceda7a1d63401f7a15dd6773535033a8035f68cc07a062296d386d74b79934
4
- data.tar.gz: 85fc2c88f84d795e9d0295f7aff7c62802747464c88cdeac276417d638411e0d
3
+ metadata.gz: cb434e53e9e04daa2080f72e8194162bbd4f336e242387ee59324dbb3cd59946
4
+ data.tar.gz: a09d9b608bd2ed784d7a75fdc4a156d46102b15cceb152bc5ac3dd8625e80615
5
5
  SHA512:
6
- metadata.gz: 6242eeb1ad31043327c91b03832a46201fae737f9f38ba89c79b68a2af430aaeb33ebd97209ebf07d695963cee4972cf20573cff58f6bb7b2c56655e4c030e0f
7
- data.tar.gz: 46ef344524a9bcf11c6fab314684ede279da4b0ed71022ab6e3cdd2353c7f8a247b0a667c7ad088b2815a15721cb5a61b818958fa17c765d6393eb9e51c07989
6
+ metadata.gz: fb79af2cd152c7c74abbff609b07515b2cd4bd1e84da31f147676963ff5c152ac7c0045ab9486aedc0be4d2ab01a5768858d3a28a88337c5579f86c1374abc71
7
+ data.tar.gz: ff88674f1581845eb009a482fa1266102327f370248493181a3f3faf39c8336d5d2213c010cdafb60c86425ef2f7ae1f18cab9fa51de3ac34c6466491471a801
data/README.md CHANGED
@@ -1,20 +1,32 @@
1
- [WIP] hammer_cli_foreman_puppet
2
- =========================================
1
+ # Hammer CLI Foreman Puppet
3
2
 
4
- This [Hammer CLI](https://github.com/theforeman/hammer-cli) plugin contains
5
- set of commands for puppet.
6
- Configuration
7
- -------------
3
+ This Hammer CLI plugin contains a set of commands for [foreman_puppet](https://github.com/theforeman/foreman_puppet), a plugin that adds Puppet functionality to Foreman.
8
4
 
9
- Configuration is expected to be placed in one of hammer's configuration directories for plugins:
10
- - `/etc/hammer/cli.modules.d/`
11
- - `~/.hammer/cli.modules.d/`
12
- - `./.config/cli.modules.d/` (config dir in CWD)
5
+ ## Compatibility
13
6
 
14
- If you install `hammer_cli_foreman_puppet` from source you'll have to copy the config file manually
15
- from `config/foreman_puppet.yml`.
7
+ This is the list of which version of Foreman Puppet and Foreman are needed for which version of this plugin.
16
8
 
17
- License
18
- -------
9
+ |foreman |foreman_puppet|hammer-cli-puppet | Notes |
10
+ |---------------|--------------|----------------- |--------------------------- |
11
+ | >= 3.0 | ~> 1.0 | >= 0.0.3 | Required |
12
+ | <= 2.5 | ~> 0.1 | - | Not supported (functionality is in [hammer-cli-foreman](https://github.com/theforeman/hammer-cli-foreman)) |
19
13
 
20
- This project is licensed under the GPLv3+.
14
+ ## Installation
15
+
16
+ $ gem install hammer_cli_foreman_puppet
17
+
18
+ $ mkdir -p ~/.hammer/cli.modules.d/
19
+
20
+ $ cat <<EOQ > ~/.hammer/cli.modules.d/foreman_puppet.yml
21
+ :foreman_puppet:
22
+ :enable_module: true
23
+ EOQ
24
+
25
+ ## Problems
26
+
27
+ Please feel free to open a [new Github issue](https://github.com/theforeman/hammer-cli-foreman-puppet/issues/new) if you encounter any bugs/issues using this plugin.
28
+
29
+ ## More info
30
+
31
+ See our [Hammer CLI installation and configuration instuctions](
32
+ https://github.com/theforeman/hammer-cli/blob/master/doc/installation.md#installation).
@@ -1,13 +1,36 @@
1
1
 
2
2
  require 'hammer_cli_foreman/combination'
3
+ require 'hammer_cli_foreman_puppet/command_extensions/combination'
3
4
 
4
5
  module HammerCLIForemanPuppet
6
+ class Combination < HammerCLIForemanPuppet::Command
7
+ class ListCommand < HammerCLIForemanPuppet::ListCommand
8
+ output do
9
+ field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
10
+ end
11
+ end
12
+
13
+ class InfoCommand < HammerCLIForemanPuppet::InfoCommand
14
+ include EnvironmentNameMapping
15
+ output ListCommand.output_definition do
16
+ field :environment_id, _('Puppet Environment ID')
17
+ field :environment_name, _('Puppet Environment name')
18
+ end
19
+ end
20
+ end
21
+
22
+ HammerCLIForeman::Combination::ListCombination.extend_with(
23
+ HammerCLIForemanPuppet::CommandExtensions::ListCombination.new
24
+ )
5
25
  HammerCLIForeman::Combination::InfoCombination.extend_with(
26
+ HammerCLIForemanPuppet::CommandExtensions::InfoCombination.new,
6
27
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
7
28
  )
29
+ HammerCLIForeman::Combination::UpdateCombination.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
8
30
  HammerCLIForeman::Combination::UpdateCombination.extend_with(
9
31
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
10
32
  )
33
+ HammerCLIForeman::Combination::CreateCombination.include(HammerCLIForemanPuppet::EnvironmentNameMapping)
11
34
  HammerCLIForeman::Combination::CreateCombination.extend_with(
12
35
  HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
13
36
  )
@@ -0,0 +1,15 @@
1
+ module HammerCLIForemanPuppet
2
+ module CommandExtensions
3
+ class ListCombination < HammerCLI::CommandExtensions
4
+ output do |definition|
5
+ definition.insert(:after, :hostgroup, HammerCLIForemanPuppet::Combination::ListCommand.output_definition.fields)
6
+ end
7
+ end
8
+
9
+ class InfoCombination < HammerCLI::CommandExtensions
10
+ output do |definition|
11
+ definition.insert(:after, :hostgroup_name, HammerCLIForemanPuppet::Combination::InfoCommand.output_definition.fields)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -17,8 +17,12 @@ module HammerCLIForemanPuppet
17
17
  child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
18
18
  attribute_name: :option_puppetclass_names
19
19
  end
20
- option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', _('Name of Puppet CA proxy')
21
- option '--puppet-proxy', 'PUPPET_PROXY_NAME', _('Name of Puppet proxy')
20
+ option_family associate: 'puppet_proxy' do
21
+ child '--puppet-proxy', 'PUPPET_PROXY_NAME', _('Name of Puppet proxy')
22
+ end
23
+ option_family associate: 'puppet_ca_proxy' do
24
+ child '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', _('Name of Puppet CA proxy')
25
+ end
22
26
 
23
27
  request_params do |params, command_object|
24
28
  if command_object.option_puppet_proxy
@@ -1,5 +1,4 @@
1
1
  require 'hammer_cli_foreman/hostgroup'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/hostgroup.rb'
4
3
 
5
4
  module HammerCLIForemanPuppet
@@ -42,7 +41,7 @@ module HammerCLIForemanPuppet
42
41
  field nil, _("Puppet Environment"), Fields::SingleReference, :key => :environment
43
42
  field nil, _("Puppet CA Proxy"), Fields::SingleReference, :key => :puppet_ca_proxy
44
43
  field nil, _("Puppet Master Proxy"), Fields::SingleReference, :key => :puppet_proxy
45
- HammerCLIForemanPuppet::References.puppetclasses(self)
44
+ HammerCLIForemanPuppet::PuppetReferences.puppetclasses(self)
46
45
  end
47
46
  end
48
47
  end
@@ -0,0 +1,26 @@
1
+ #frozen_string_literal: true
2
+
3
+ require 'hammer_cli/i18n'
4
+ module HammerCLIForemanPuppet
5
+ module I18n
6
+ class LocaleDomain < HammerCLI::I18n::LocaleDomain
7
+ def translated_files
8
+ Dir.glob(File.join(File.dirname(__FILE__), '../**/*.rb'))
9
+ end
10
+
11
+ def locale_dir
12
+ File.join(File.dirname(__FILE__), '../../locale')
13
+ end
14
+
15
+ def domain_name
16
+ 'hammer-cli-foreman-puppet'
17
+ end
18
+
19
+ def type
20
+ :mo
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ HammerCLI::I18n.add_domain(HammerCLIForemanPuppet::I18n::LocaleDomain.new)
@@ -1,19 +1,11 @@
1
1
  require 'hammer_cli_foreman/location'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/location'
4
3
 
5
4
  module HammerCLIForemanPuppet
6
- module LocationAddAssociatedCommand
7
- def self.included(base)
8
- HammerCLIForemanPuppet::AssociatingCommands::PuppetEnvironment.extend_command(base)
9
- base.create_subcommand
10
- end
11
- end
12
-
13
5
  class Location < HammerCLIForemanPuppet::Command
14
6
  class InfoCommand < HammerCLIForemanPuppet::InfoCommand
15
7
  output do
16
- HammerCLIForemanPuppet::References.environments(self)
8
+ HammerCLIForemanPuppet::PuppetReferences.environments(self)
17
9
  end
18
10
  end
19
11
  end
@@ -27,9 +19,4 @@ module HammerCLIForemanPuppet
27
19
  HammerCLIForeman::Location::InfoCommand.extend_with(
28
20
  HammerCLIForemanPuppet::CommandExtensions::LocationInfo.new
29
21
  )
30
-
31
- HammerCLIForeman::Location.class_eval do
32
- extend HammerCLIForemanPuppet::AssociatingCommands::ExtendCommands
33
- include HammerCLIForemanPuppet::LocationAddAssociatedCommand
34
- end
35
22
  end
@@ -1,19 +1,11 @@
1
1
  require 'hammer_cli_foreman/organization'
2
- require 'hammer_cli_foreman_puppet/references'
3
2
  require 'hammer_cli_foreman_puppet/command_extensions/organization'
4
3
 
5
4
  module HammerCLIForemanPuppet
6
- module OrganizationAddAssociatedCommand
7
- def self.included(base)
8
- HammerCLIForemanPuppet::AssociatingCommands::PuppetEnvironment.extend_command(base)
9
- base.create_subcommand
10
- end
11
- end
12
-
13
5
  class Organization < HammerCLIForemanPuppet::Command
14
6
  class InfoCommand < HammerCLIForemanPuppet::InfoCommand
15
7
  output do
16
- HammerCLIForemanPuppet::References.environments(self)
8
+ HammerCLIForemanPuppet::PuppetReferences.environments(self)
17
9
  end
18
10
  end
19
11
  end
@@ -27,9 +19,4 @@ module HammerCLIForemanPuppet
27
19
  HammerCLIForeman::Organization::InfoCommand.extend_with(
28
20
  HammerCLIForemanPuppet::CommandExtensions::OrganizationInfo.new
29
21
  )
30
-
31
- HammerCLIForeman::Organization.class_eval do
32
- extend HammerCLIForemanPuppet::AssociatingCommands::ExtendCommands
33
- include HammerCLIForemanPuppet::OrganizationAddAssociatedCommand
34
- end
35
22
  end
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForemanPuppet
2
2
  def self.version
3
- @version ||= Gem::Version.new '0.0.2'
3
+ @version ||= Gem::Version.new '0.0.5'
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  module HammerCLIForemanPuppet
2
2
  require 'hammer_cli'
3
+ require 'hammer_cli/logger'
3
4
  require 'hammer_cli_foreman'
4
5
 
5
6
  require 'hammer_cli_foreman_puppet/version'
@@ -8,7 +9,6 @@ module HammerCLIForemanPuppet
8
9
  require 'hammer_cli_foreman_puppet/commands'
9
10
  require 'hammer_cli_foreman_puppet/command_extensions'
10
11
  require 'hammer_cli_foreman_puppet/option_sources'
11
- require 'hammer_cli_foreman_puppet/associating_commands'
12
12
  require 'hammer_cli_foreman_puppet/id_resolver'
13
13
 
14
14
  # Puppet commands
@@ -10,10 +10,10 @@ describe 'template' do
10
10
  params = ['create', '--provisioning-template-id=10', '--hostgroup-id=1', '--puppet-environment-id=1']
11
11
  expected_result = success_result("Template combination created.\n")
12
12
  api_expects(:template_combinations, :create, 'Create template combination') do |p|
13
- p['provisioning_template_id'] == 10 &&
14
- p['hostgroup_id'] == 1 &&
13
+ p['provisioning_template_id'] == '10' &&
14
+ p['hostgroup_id'] == '1' &&
15
15
  p['environment_id'] == 1 &&
16
- p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
16
+ p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => '1' }
17
17
  end
18
18
 
19
19
  result = run_cmd(@cmd + params)
@@ -25,10 +25,10 @@ describe 'template' do
25
25
  expected_result = success_result("Template combination updated.\n")
26
26
  api_expects(:template_combinations, :update, 'Update template combination') do |p|
27
27
  p['id'] == '3' &&
28
- p['provisioning_template_id'] == 10 &&
29
- p['hostgroup_id'] == 1 &&
28
+ p['provisioning_template_id'] == '10' &&
29
+ p['hostgroup_id'] == '1' &&
30
30
  p['environment_id'] == 1 &&
31
- p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => 1 }
31
+ p['template_combination'] == { 'environment_id' => 1, 'hostgroup_id' => '1' }
32
32
  end
33
33
 
34
34
  result = run_cmd(@cmd + params)
metadata CHANGED
@@ -1,22 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amir Fefer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-02 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hammer_cli_foreman
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0.pre.develop
19
+ version: 2.6.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.0.0
@@ -24,9 +24,9 @@ dependencies:
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
27
+ - - ">"
28
28
  - !ruby/object:Gem::Version
29
- version: 3.0.0.pre.develop
29
+ version: 2.6.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.0.0
@@ -42,10 +42,10 @@ files:
42
42
  - config/foreman_puppet.yml
43
43
  - lib/hammer_cli_foreman_puppet.rb
44
44
  - lib/hammer_cli_foreman_puppet/associating_commands.rb
45
- - lib/hammer_cli_foreman_puppet/associating_commands/associating_commands.rb
46
45
  - lib/hammer_cli_foreman_puppet/class.rb
47
46
  - lib/hammer_cli_foreman_puppet/combination.rb
48
47
  - lib/hammer_cli_foreman_puppet/command_extensions.rb
48
+ - lib/hammer_cli_foreman_puppet/command_extensions/combination.rb
49
49
  - lib/hammer_cli_foreman_puppet/command_extensions/environment.rb
50
50
  - lib/hammer_cli_foreman_puppet/command_extensions/environments.rb
51
51
  - lib/hammer_cli_foreman_puppet/command_extensions/host.rb
@@ -58,13 +58,13 @@ files:
58
58
  - lib/hammer_cli_foreman_puppet/environment_name_mapping.rb
59
59
  - lib/hammer_cli_foreman_puppet/host.rb
60
60
  - lib/hammer_cli_foreman_puppet/hostgroup.rb
61
+ - lib/hammer_cli_foreman_puppet/i18n.rb
61
62
  - lib/hammer_cli_foreman_puppet/id_resolver.rb
62
63
  - lib/hammer_cli_foreman_puppet/location.rb
63
64
  - lib/hammer_cli_foreman_puppet/option_sources.rb
64
65
  - lib/hammer_cli_foreman_puppet/option_sources/puppet_environment_params.rb
65
66
  - lib/hammer_cli_foreman_puppet/organization.rb
66
67
  - lib/hammer_cli_foreman_puppet/puppet_references.rb
67
- - lib/hammer_cli_foreman_puppet/references.rb
68
68
  - lib/hammer_cli_foreman_puppet/smart_class_parameter.rb
69
69
  - lib/hammer_cli_foreman_puppet/smart_proxy.rb
70
70
  - lib/hammer_cli_foreman_puppet/version.rb
@@ -110,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubyforge_project:
114
- rubygems_version: 2.7.6.2
113
+ rubygems_version: 3.1.2
115
114
  signing_key:
116
115
  specification_version: 4
117
116
  summary: Foreman Puppet plugin for Hammer CLI
@@ -119,23 +118,23 @@ test_files:
119
118
  - test/data/2.1/foreman_api.json
120
119
  - test/data/3.0/foreman_api.json
121
120
  - test/data/README.md
121
+ - test/test_helper.rb
122
+ - test/unit/apipie_resource_mock.rb
122
123
  - test/unit/helpers/command.rb
123
124
  - test/unit/helpers/fake_searchables.rb
124
125
  - test/unit/helpers/resource_disabled.rb
125
- - test/unit/apipie_resource_mock.rb
126
- - test/unit/config_group_test.rb
127
126
  - test/unit/puppet_class_test.rb
128
127
  - test/unit/puppet_environment_test.rb
129
128
  - test/unit/smart_class_parameter_test.rb
130
129
  - test/unit/test_helper.rb
131
130
  - test/unit/test_output_adapter.rb
131
+ - test/unit/config_group_test.rb
132
+ - test/functional/config_group_test.rb
132
133
  - test/functional/host/create_test.rb
133
134
  - test/functional/host/update_test.rb
134
135
  - test/functional/hostgroup/create_test.rb
135
136
  - test/functional/hostgroup/update_test.rb
136
- - test/functional/config_group_test.rb
137
137
  - test/functional/proxy_test.rb
138
138
  - test/functional/smart_class_parameter_test.rb
139
- - test/functional/template_test.rb
140
139
  - test/functional/test_helper.rb
141
- - test/test_helper.rb
140
+ - test/functional/template_test.rb
@@ -1,40 +0,0 @@
1
- module HammerCLIForemanPuppet
2
- module AssociatingCommands
3
- module ExtendCommands
4
- def create_subcommand(name = :PuppetEnvironment)
5
- commands = constants.select { |c| c.to_s.include? name.to_s }.map { |p| const_get(p)}
6
- commands.each do |command|
7
- subcommand(command.command_name, command.desc, command, warning: command.warning)
8
- end
9
- end
10
- end
11
-
12
- module PuppetEnvironment
13
- extend HammerCLIForeman::AssociatingCommands::CommandExtension
14
-
15
- class AddPuppetEnvironmentCommand < HammerCLIForemanPuppet::AddAssociatedCommand
16
- include EnvironmentNameMapping
17
- associated_resource :environments
18
- desc _('Associate a Puppet environment')
19
- command_name "add-environment"
20
-
21
- success_message _("The environment has been associated.")
22
- failure_message _("Could not associate the environment")
23
-
24
- extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
25
- end
26
-
27
- class RemovePuppetEnvironmentCommand < HammerCLIForemanPuppet::RemoveAssociatedCommand
28
- include EnvironmentNameMapping
29
- associated_resource :environments
30
- desc _('Disassociate a Puppet environment')
31
- command_name "remove-environment"
32
-
33
- success_message _("The environment has been disassociated.")
34
- failure_message _("Could not disassociate the environment")
35
-
36
- extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
37
- end
38
- end
39
- end
40
- end
@@ -1,22 +0,0 @@
1
- module HammerCLIForemanPuppet
2
-
3
- module References
4
-
5
- def self.environments(dsl)
6
- dsl.build do
7
- collection :environments, _("Environments"), :numbered => false do
8
- custom_field Fields::Reference
9
- end
10
- end
11
- end
12
-
13
- def self.puppetclasses(dsl)
14
- dsl.build do
15
- collection :puppetclasses, _("Puppetclasses"), :numbered => false do
16
- custom_field Fields::Reference
17
- end
18
- end
19
- end
20
-
21
- end
22
- end