hammer_cli_foreman_puppet 0.0.1
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 +7 -0
- data/LICENSE +5 -0
- data/README.md +20 -0
- data/config/foreman_puppet.yml +2 -0
- data/lib/hammer_cli_foreman_puppet.rb +57 -0
- data/lib/hammer_cli_foreman_puppet/associating_commands.rb +1 -0
- data/lib/hammer_cli_foreman_puppet/associating_commands/associating_commands.rb +40 -0
- data/lib/hammer_cli_foreman_puppet/class.rb +54 -0
- data/lib/hammer_cli_foreman_puppet/combination.rb +14 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions.rb +2 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/discovery.rb +8 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/environment.rb +24 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/environments.rb +24 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/host.rb +41 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/hostgroup.rb +47 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/location.rb +9 -0
- data/lib/hammer_cli_foreman_puppet/command_extensions/organization.rb +9 -0
- data/lib/hammer_cli_foreman_puppet/commands.rb +76 -0
- data/lib/hammer_cli_foreman_puppet/config_group.rb +45 -0
- data/lib/hammer_cli_foreman_puppet/discovery.rb +11 -0
- data/lib/hammer_cli_foreman_puppet/environment.rb +59 -0
- data/lib/hammer_cli_foreman_puppet/environment_name_mapping.rb +20 -0
- data/lib/hammer_cli_foreman_puppet/host.rb +70 -0
- data/lib/hammer_cli_foreman_puppet/hostgroup.rb +76 -0
- data/lib/hammer_cli_foreman_puppet/id_resolver.rb +73 -0
- data/lib/hammer_cli_foreman_puppet/location.rb +35 -0
- data/lib/hammer_cli_foreman_puppet/option_sources.rb +1 -0
- data/lib/hammer_cli_foreman_puppet/option_sources/puppet_environment_params.rb +60 -0
- data/lib/hammer_cli_foreman_puppet/organization.rb +35 -0
- data/lib/hammer_cli_foreman_puppet/puppet_references.rb +20 -0
- data/lib/hammer_cli_foreman_puppet/references.rb +22 -0
- data/lib/hammer_cli_foreman_puppet/smart_class_parameter.rb +182 -0
- data/lib/hammer_cli_foreman_puppet/smart_proxy.rb +58 -0
- data/lib/hammer_cli_foreman_puppet/version.rb +5 -0
- data/test/data/2.1/foreman_api.json +1 -0
- data/test/data/3.0/foreman_api.json +1 -0
- data/test/data/README.md +27 -0
- data/test/functional/config_group_test.rb +28 -0
- data/test/functional/host/create_test.rb +164 -0
- data/test/functional/host/update_test.rb +97 -0
- data/test/functional/hostgroup/create_test.rb +149 -0
- data/test/functional/hostgroup/update_test.rb +97 -0
- data/test/functional/proxy_test.rb +86 -0
- data/test/functional/smart_class_parameter_test.rb +97 -0
- data/test/functional/template_test.rb +38 -0
- data/test/functional/test_helper.rb +7 -0
- data/test/test_helper.rb +29 -0
- data/test/unit/apipie_resource_mock.rb +186 -0
- data/test/unit/config_group_test.rb +81 -0
- data/test/unit/helpers/command.rb +163 -0
- data/test/unit/helpers/fake_searchables.rb +19 -0
- data/test/unit/helpers/resource_disabled.rb +24 -0
- data/test/unit/puppet_class_test.rb +72 -0
- data/test/unit/puppet_environment_test.rb +116 -0
- data/test/unit/smart_class_parameter_test.rb +114 -0
- data/test/unit/test_helper.rb +18 -0
- data/test/unit/test_output_adapter.rb +22 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c8cf103215c0693d5edeedfba47ce25c89a894b042ab4da48d16839d414b49c0
|
4
|
+
data.tar.gz: 740d0819a7ca0142f7f962df9aef29a0bd6f6cc27e8ac8bfdf5ae8f246b027d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4ca662500bc6c2fea49c077daadfa82b4cceb26af0f3668adb21f6b013579e6ef07397d230a1b4928c5993c6b49bb07d350ffbfe7488e9aa5cc0b9d893c24fca
|
7
|
+
data.tar.gz: ecbd3bae2f043ae3e5bba7887343aee0d121bbc1523454b8ec3644ace72465203aead339ac6ab489c2f4d347ebab19aa2cb17b815e2a4d521950b300b82a33a6
|
data/LICENSE
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
This program and entire repository is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
|
2
|
+
|
3
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
4
|
+
|
5
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
[WIP] hammer_cli_foreman_puppet
|
2
|
+
=========================================
|
3
|
+
|
4
|
+
This [Hammer CLI](https://github.com/theforeman/hammer-cli) plugin contains
|
5
|
+
set of commands for puppet.
|
6
|
+
Configuration
|
7
|
+
-------------
|
8
|
+
|
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)
|
13
|
+
|
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`.
|
16
|
+
|
17
|
+
License
|
18
|
+
-------
|
19
|
+
|
20
|
+
This project is licensed under the GPLv3+.
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
require 'hammer_cli'
|
3
|
+
require 'hammer_cli_foreman'
|
4
|
+
|
5
|
+
require 'hammer_cli_foreman_puppet/version'
|
6
|
+
require 'hammer_cli_foreman_puppet/puppet_references'
|
7
|
+
require 'hammer_cli_foreman_puppet/environment_name_mapping'
|
8
|
+
require 'hammer_cli_foreman_puppet/commands'
|
9
|
+
require 'hammer_cli_foreman_puppet/command_extensions'
|
10
|
+
require 'hammer_cli_foreman_puppet/option_sources'
|
11
|
+
require 'hammer_cli_foreman_puppet/associating_commands'
|
12
|
+
require 'hammer_cli_foreman_puppet/id_resolver'
|
13
|
+
|
14
|
+
# Puppet commands
|
15
|
+
require 'hammer_cli_foreman_puppet/smart_class_parameter'
|
16
|
+
require 'hammer_cli_foreman_puppet/environment'
|
17
|
+
require 'hammer_cli_foreman_puppet/config_group'
|
18
|
+
require 'hammer_cli_foreman_puppet/class'
|
19
|
+
|
20
|
+
# extensions to hammer_cli_foreman commands
|
21
|
+
require 'hammer_cli_foreman_puppet/host'
|
22
|
+
require 'hammer_cli_foreman_puppet/organization'
|
23
|
+
require 'hammer_cli_foreman_puppet/location'
|
24
|
+
require 'hammer_cli_foreman_puppet/smart_proxy'
|
25
|
+
require 'hammer_cli_foreman_puppet/combination'
|
26
|
+
require 'hammer_cli_foreman_puppet/hostgroup'
|
27
|
+
|
28
|
+
HammerCLI::MainCommand.lazy_subcommand(
|
29
|
+
'puppet-class',
|
30
|
+
_('Manage Foreman Puppet classes'),
|
31
|
+
'HammerCLIForemanPuppet::PuppetClass',
|
32
|
+
'hammer_cli_foreman_puppet/class'
|
33
|
+
)
|
34
|
+
HammerCLI::MainCommand.lazy_subcommand(
|
35
|
+
'puppet-environment',
|
36
|
+
_('Manage Foreman Puppet environments'),
|
37
|
+
'HammerCLIForemanPuppet::PuppetEnvironment',
|
38
|
+
'hammer_cli_foreman_puppet/environment'
|
39
|
+
)
|
40
|
+
HammerCLI::MainCommand.lazy_subcommand(
|
41
|
+
'config-group',
|
42
|
+
_('Manage Foreman config groups'),
|
43
|
+
'HammerCLIForemanPuppet::ConfigGroup',
|
44
|
+
'hammer_cli_foreman_puppet/config_group'
|
45
|
+
)
|
46
|
+
HammerCLI::MainCommand.lazy_subcommand(
|
47
|
+
'sc-param',
|
48
|
+
_('Manage Foreman Puppet smart class parameters'),
|
49
|
+
'HammerCLIForemanPuppet::SmartClassParameter',
|
50
|
+
'hammer_cli_foreman_puppet/smart_class_parameter'
|
51
|
+
)
|
52
|
+
|
53
|
+
# plugins extensions
|
54
|
+
begin
|
55
|
+
require 'hammer_cli_foreman_puppet/discovery'
|
56
|
+
rescue LoadError
|
57
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'hammer_cli_foreman_puppet/associating_commands/associating_commands'
|
@@ -0,0 +1,40 @@
|
|
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
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
class PuppetClass < HammerCLIForemanPuppet::Command
|
3
|
+
|
4
|
+
resource :puppetclasses
|
5
|
+
|
6
|
+
class ListCommand < HammerCLIForemanPuppet::ListCommand
|
7
|
+
output do
|
8
|
+
field :id, _("Id")
|
9
|
+
field :name, _("Name")
|
10
|
+
end
|
11
|
+
|
12
|
+
def send_request
|
13
|
+
self.class.unhash_classes(super)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.unhash_classes(classes)
|
17
|
+
clss = classes.first.inject([]) { |list, (pp_module, pp_module_classes)| list + pp_module_classes }
|
18
|
+
|
19
|
+
HammerCLI::Output::RecordCollection.new(clss, :meta => classes.meta)
|
20
|
+
end
|
21
|
+
|
22
|
+
build_options
|
23
|
+
|
24
|
+
extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
|
25
|
+
end
|
26
|
+
|
27
|
+
class InfoCommand < HammerCLIForemanPuppet::InfoCommand
|
28
|
+
output ListCommand.output_definition do
|
29
|
+
collection :smart_class_parameters, _('Smart class parameters'), :numbered => false do
|
30
|
+
custom_field Fields::Reference, :name_key => :parameter
|
31
|
+
end
|
32
|
+
HammerCLIForeman::References.hostgroups(self)
|
33
|
+
HammerCLIForemanPuppet::PuppetReferences.environments(self)
|
34
|
+
HammerCLIForeman::References.parameters(self)
|
35
|
+
end
|
36
|
+
|
37
|
+
build_options
|
38
|
+
|
39
|
+
extend_with(HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
class SCParamsCommand < HammerCLIForemanPuppet::SmartClassParametersBriefList
|
44
|
+
build_options_for :puppetclasses
|
45
|
+
|
46
|
+
def validate_options
|
47
|
+
super
|
48
|
+
validator.any(:option_puppetclass_name, :option_puppetclass_id).required
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
autoload_subcommands
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
require 'hammer_cli_foreman/combination'
|
3
|
+
|
4
|
+
module HammerCLIForemanPuppet
|
5
|
+
HammerCLIForeman::Combination::InfoCombination.extend_with(
|
6
|
+
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
|
7
|
+
)
|
8
|
+
HammerCLIForeman::Combination::UpdateCombination.extend_with(
|
9
|
+
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
|
10
|
+
)
|
11
|
+
HammerCLIForeman::Combination::CreateCombination.extend_with(
|
12
|
+
HammerCLIForemanPuppet::CommandExtensions::PuppetEnvironment.new
|
13
|
+
)
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class PuppetEnvironment < HammerCLI::CommandExtensions
|
4
|
+
# FIXME: Temp workaround for option builders in case of multiple plugins
|
5
|
+
# extensions of the same command
|
6
|
+
option_family do
|
7
|
+
parent '--puppet-environment-id', 'PUPPET_ENVIRONMENT_ID', _('ID of associated Puppet environment'),
|
8
|
+
format: HammerCLI::Options::Normalizers::Number.new,
|
9
|
+
attribute_name: :option_environment_id
|
10
|
+
child '--puppet-environment', 'PUPPET_ENVIRONMENT_NAME', _('Name of associated Puppet environment'),
|
11
|
+
attribute_name: :option_environment_name
|
12
|
+
end
|
13
|
+
|
14
|
+
option_sources do |sources, command|
|
15
|
+
sources.find_by_name('IdResolution').insert_relative(
|
16
|
+
:after,
|
17
|
+
'IdParams',
|
18
|
+
HammerCLIForemanPuppet::OptionSources::PuppetEnvironmentParams.new(command)
|
19
|
+
)
|
20
|
+
sources
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class PuppetEnvironments < HammerCLI::CommandExtensions
|
4
|
+
# FIXME: Temp workaround for option builders in case of multiple plugins
|
5
|
+
# extensions of the same command
|
6
|
+
option_family do
|
7
|
+
parent '--puppet-environment-ids', 'PUPPET_ENVIRONMENT_IDS', _('IDs of associated Puppet environment'),
|
8
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
9
|
+
attribute_name: :option_environment_ids
|
10
|
+
child '--puppet-environments', 'PUPPET_ENVIRONMENT_NAMES', _('Names of associated Puppet environment'),
|
11
|
+
attribute_name: :option_environment_names
|
12
|
+
end
|
13
|
+
|
14
|
+
option_sources do |sources, command|
|
15
|
+
sources.find_by_name('IdResolution').insert_relative(
|
16
|
+
:after,
|
17
|
+
'IdsParams',
|
18
|
+
HammerCLIForemanPuppet::OptionSources::PuppetEnvironmentParams.new(command)
|
19
|
+
)
|
20
|
+
sources
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class Host < HammerCLI::CommandExtensions
|
4
|
+
output do |definition|
|
5
|
+
definition.insert(:after, :location, HammerCLIForemanPuppet::Host::InfoCommand.output_definition.fields)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class HostPuppetProxy < HammerCLI::CommandExtensions
|
10
|
+
option_family(
|
11
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
12
|
+
aliased_resource: 'puppet-class',
|
13
|
+
description: 'Names/Ids of associated Puppet classes'
|
14
|
+
) do
|
15
|
+
parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', _('List of Puppet class ids'),
|
16
|
+
attribute_name: :option_puppetclass_ids
|
17
|
+
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
18
|
+
attribute_name: :option_puppetclass_names
|
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')
|
22
|
+
|
23
|
+
request_params do |params, command_object|
|
24
|
+
if command_object.option_puppet_proxy
|
25
|
+
params['host']['puppet_proxy_id'] ||= HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.proxy_id(
|
26
|
+
command_object.resolver, command_object.option_puppet_proxy
|
27
|
+
)
|
28
|
+
end
|
29
|
+
if command_object.option_puppet_ca_proxy
|
30
|
+
params['host']['puppet_ca_proxy_id'] ||= HammerCLIForemanPuppet::CommandExtensions::HostPuppetProxy.proxy_id(
|
31
|
+
command_object.resolver, command_object.option_puppet_ca_proxy
|
32
|
+
)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.proxy_id(resolver, name)
|
37
|
+
resolver.smart_proxy_id('option_name' => name)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class HostgroupInfo < HammerCLI::CommandExtensions
|
4
|
+
output do |definition|
|
5
|
+
definition.insert(:after, :compute_resource, HammerCLIForemanPuppet::Hostgroup::InfoCommand.output_definition.fields)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class HostgroupList < HammerCLI::CommandExtensions
|
10
|
+
output do |definition|
|
11
|
+
definition.insert(:after, :operatingsystem, HammerCLIForemanPuppet::Hostgroup::ListCommand.output_definition.fields)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class HostgroupPuppetProxy < HammerCLI::CommandExtensions
|
16
|
+
option_family(
|
17
|
+
format: HammerCLI::Options::Normalizers::List.new,
|
18
|
+
aliased_resource: 'puppet-class',
|
19
|
+
description: 'Names/Ids of associated Puppet classes'
|
20
|
+
) do
|
21
|
+
parent '--puppet-class-ids', 'PUPPET_CLASS_IDS', _('List of Puppet class ids'),
|
22
|
+
attribute_name: :option_puppetclass_ids
|
23
|
+
child '--puppet-classes', 'PUPPET_CLASS_NAMES', '',
|
24
|
+
attribute_name: :option_puppetclass_names
|
25
|
+
end
|
26
|
+
option '--puppet-ca-proxy', 'PUPPET_CA_PROXY_NAME', _('Name of Puppet CA proxy')
|
27
|
+
option '--puppet-proxy', 'PUPPET_PROXY_NAME', _('Name of Puppet proxy')
|
28
|
+
|
29
|
+
request_params do |params, command_object|
|
30
|
+
if command_object.option_puppet_proxy
|
31
|
+
params['hostgroup']['puppet_proxy_id'] ||= HammerCLIForemanPuppet::CommandExtensions::HostgroupPuppetProxy.proxy_id(
|
32
|
+
command_object.resolver, command_object.option_puppet_proxy
|
33
|
+
)
|
34
|
+
end
|
35
|
+
if command_object.option_puppet_ca_proxy
|
36
|
+
params['hostgroup']['puppet_ca_proxy_id'] ||= HammerCLIForemanPuppet::CommandExtensions::HostgroupPuppetProxy.proxy_id(
|
37
|
+
command_object.resolver, command_object.option_puppet_ca_proxy
|
38
|
+
)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.proxy_id(resolver, name)
|
43
|
+
resolver.smart_proxy_id('option_name' => name)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class LocationInfo < HammerCLI::CommandExtensions
|
4
|
+
output do |definition|
|
5
|
+
definition.insert(:after, :realms, HammerCLIForemanPuppet::Location::InfoCommand.output_definition.fields)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
module CommandExtensions
|
3
|
+
class OrganizationInfo < HammerCLI::CommandExtensions
|
4
|
+
output do |definition|
|
5
|
+
definition.insert(:after, :realms, HammerCLIForemanPuppet::Organization::InfoCommand.output_definition.fields)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module HammerCLIForemanPuppet
|
2
|
+
RESOURCE_NAME_MAPPING = {
|
3
|
+
:puppetclass => :puppet_class,
|
4
|
+
:puppetclasses => :puppet_classes,
|
5
|
+
:environment => :puppet_environment,
|
6
|
+
:environments => :puppet_environments
|
7
|
+
}.freeze
|
8
|
+
|
9
|
+
RESOURCE_ALIAS_NAME_MAPPING = {
|
10
|
+
environment: :puppet_environment,
|
11
|
+
environments: :puppet_environments
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
module ResolverCommons
|
15
|
+
def self.included(base)
|
16
|
+
base.extend(ClassMethods)
|
17
|
+
end
|
18
|
+
module ClassMethods
|
19
|
+
|
20
|
+
def api_connection
|
21
|
+
if HammerCLI.context[:api_connection]
|
22
|
+
HammerCLI.context[:api_connection].get("foreman")
|
23
|
+
else
|
24
|
+
HammerCLI::Connection.get("foreman").api
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def resolver
|
29
|
+
HammerCLIForemanPuppet::IdResolver.new(
|
30
|
+
api_connection,
|
31
|
+
HammerCLIForemanPuppet::Searchables.new
|
32
|
+
)
|
33
|
+
end
|
34
|
+
def resource_name_mapping
|
35
|
+
HammerCLIForemanPuppet::RESOURCE_NAME_MAPPING.dup
|
36
|
+
end
|
37
|
+
|
38
|
+
def searchables
|
39
|
+
@searchables ||= HammerCLIForemanPuppet::Searchables.new
|
40
|
+
@searchables
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Command < HammerCLIForeman::Command
|
46
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
47
|
+
end
|
48
|
+
|
49
|
+
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
50
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
51
|
+
end
|
52
|
+
|
53
|
+
class InfoCommand < HammerCLIForeman::InfoCommand
|
54
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
55
|
+
end
|
56
|
+
|
57
|
+
class CreateCommand < HammerCLIForeman::CreateCommand
|
58
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
59
|
+
end
|
60
|
+
|
61
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
62
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
63
|
+
end
|
64
|
+
|
65
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
66
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
67
|
+
end
|
68
|
+
|
69
|
+
class AddAssociatedCommand < HammerCLIForeman::AddAssociatedCommand
|
70
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
71
|
+
end
|
72
|
+
|
73
|
+
class RemoveAssociatedCommand < HammerCLIForeman::RemoveAssociatedCommand
|
74
|
+
include HammerCLIForemanPuppet::ResolverCommons
|
75
|
+
end
|
76
|
+
end
|