hammer_cli_foreman 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +5 -0
- data/README.md +1 -15
- data/doc/configuration.md +38 -0
- data/doc/developer_docs.md +4 -3
- data/doc/release_notes.md +18 -0
- data/doc/testing.md +133 -0
- data/lib/hammer_cli_foreman.rb +4 -2
- data/lib/hammer_cli_foreman/api/connection.rb +21 -7
- data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +1 -1
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +6 -1
- data/lib/hammer_cli_foreman/api/void_auth.rb +8 -0
- data/lib/hammer_cli_foreman/auth.rb +1 -1
- data/lib/hammer_cli_foreman/common_parameter.rb +1 -0
- data/lib/hammer_cli_foreman/config_group.rb +45 -0
- data/lib/hammer_cli_foreman/defaults.rb +6 -3
- data/lib/hammer_cli_foreman/exception_handler.rb +36 -7
- data/lib/hammer_cli_foreman/filter.rb +61 -0
- data/lib/hammer_cli_foreman/host.rb +7 -5
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +17 -2
- data/lib/hammer_cli_foreman/output/fields.rb +3 -2
- data/lib/hammer_cli_foreman/output/formatters.rb +3 -2
- data/lib/hammer_cli_foreman/parameter.rb +5 -2
- data/lib/hammer_cli_foreman/references.rb +1 -1
- data/lib/hammer_cli_foreman/role.rb +18 -1
- data/lib/hammer_cli_foreman/template.rb +10 -10
- data/lib/hammer_cli_foreman/testing/api_expectations.rb +108 -8
- data/lib/hammer_cli_foreman/user.rb +25 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/locale/ca/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/de/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/en_GB/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/es/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/fr/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/it/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ja/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ko/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/pt_BR/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/ru/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_CN/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/locale/zh_TW/LC_MESSAGES/hammer-cli-foreman.mo +0 -0
- data/test/data/1.14/_foreman_api.json +1 -0
- data/test/data/1.14/foreman_api.json +1 -0
- data/test/data/1.15/foreman_api.json +1 -0
- data/test/functional/host_test.rb +69 -1
- data/test/functional/role_test.rb +69 -0
- data/test/functional/template_test.rb +4 -4
- data/test/functional/test_helper.rb +0 -3
- data/test/functional/user_test.rb +85 -0
- data/test/test_helper.rb +4 -6
- data/test/unit/api/interactive_basic_auth_test.rb +2 -3
- data/test/unit/api/session_authenticator_wrapper_test.rb +24 -0
- data/test/unit/apipie_resource_mock.rb +180 -0
- data/test/unit/architecture_test.rb +3 -0
- data/test/unit/auth_source_ldap_test.rb +3 -0
- data/test/unit/commands_test.rb +2 -0
- data/test/unit/common_parameter_test.rb +13 -7
- data/test/unit/compute_resource_test.rb +6 -0
- data/test/unit/config_group_test.rb +72 -0
- data/test/unit/defaults_test.rb +28 -24
- data/test/unit/domain_test.rb +3 -0
- data/test/unit/environment_test.rb +3 -0
- data/test/unit/filter_test.rb +10 -2
- data/test/unit/host_test.rb +14 -1
- data/test/unit/hostgroup_test.rb +3 -0
- data/test/unit/image_test.rb +3 -0
- data/test/unit/media_test.rb +3 -0
- data/test/unit/model_test.rb +3 -0
- data/test/unit/partition_table_test.rb +3 -0
- data/test/unit/puppet_class_test.rb +3 -0
- data/test/unit/realm_test.rb +3 -0
- data/test/unit/report_test.rb +3 -0
- data/test/unit/smart_proxy_test.rb +3 -0
- data/test/unit/smart_variable_test.rb +0 -1
- data/test/unit/subnet_test.rb +3 -0
- data/test/unit/template_test.rb +9 -3
- data/test/unit/user_test.rb +6 -0
- data/test/unit/usergroup_test.rb +3 -0
- metadata +69 -577
- data/locale/Makefile +0 -57
- data/locale/README.md +0 -18
- data/locale/ca/hammer-cli-foreman.edit.po +0 -2910
- data/locale/ca/hammer-cli-foreman.po +0 -2823
- data/locale/ca/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/de/hammer-cli-foreman.edit.po +0 -2921
- data/locale/de/hammer-cli-foreman.po +0 -2827
- data/locale/de/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/en/hammer-cli-foreman.edit.po +0 -2865
- data/locale/en/hammer-cli-foreman.po +0 -2167
- data/locale/en/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/en_GB/hammer-cli-foreman.edit.po +0 -2888
- data/locale/en_GB/hammer-cli-foreman.po +0 -2825
- data/locale/en_GB/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/es/hammer-cli-foreman.edit.po +0 -2924
- data/locale/es/hammer-cli-foreman.po +0 -2829
- data/locale/es/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/fr/hammer-cli-foreman.edit.po +0 -2919
- data/locale/fr/hammer-cli-foreman.po +0 -2825
- data/locale/fr/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/hammer-cli-foreman.pot +0 -3080
- data/locale/it/hammer-cli-foreman.edit.po +0 -2909
- data/locale/it/hammer-cli-foreman.po +0 -2824
- data/locale/it/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ja/hammer-cli-foreman.edit.po +0 -2919
- data/locale/ja/hammer-cli-foreman.po +0 -2824
- data/locale/ja/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ko/hammer-cli-foreman.edit.po +0 -2917
- data/locale/ko/hammer-cli-foreman.po +0 -2823
- data/locale/ko/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/pt_BR/hammer-cli-foreman.edit.po +0 -2921
- data/locale/pt_BR/hammer-cli-foreman.po +0 -2826
- data/locale/pt_BR/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/ru/hammer-cli-foreman.edit.po +0 -2921
- data/locale/ru/hammer-cli-foreman.po +0 -2824
- data/locale/ru/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/zanata.xml +0 -28
- data/locale/zh_CN/hammer-cli-foreman.edit.po +0 -2917
- data/locale/zh_CN/hammer-cli-foreman.po +0 -2822
- data/locale/zh_CN/hammer-cli-foreman.po.time_stamp +0 -0
- data/locale/zh_TW/hammer-cli-foreman.edit.po +0 -2917
- data/locale/zh_TW/hammer-cli-foreman.po +0 -2822
- data/locale/zh_TW/hammer-cli-foreman.po.time_stamp +0 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Architecture.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-CommonParameter.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-output.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ComputeResource.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-output.xml +0 -21
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Domain.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Environment.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-ExceptionHandler.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand-parameters.xml +0 -46
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-output.xml +0 -85
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-output.xml +0 -21
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand-output.xml +0 -9
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand-output.xml +0 -9
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand-parameters.xml +0 -40
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Host.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-output.xml +0 -29
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-output.xml +0 -27
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Hostgroup.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Location.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-output.xml +0 -23
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-output.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Medium.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-output.xml +0 -27
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-output.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-resource-disabled.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Organization.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-output.xml +0 -19
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-output.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-PartitionTable.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-output.xml +0 -21
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-output.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-SmartProxy.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-output.xml +0 -43
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-parameters.xml +0 -13
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Subnet.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand-parameters.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand-parameters.xml +0 -12
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-output.xml +0 -15
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand-parameters.xml +0 -9
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-Template.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand-parameters.xml +0 -19
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-output.xml +0 -23
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-output.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-parameters.xml +0 -17
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand-parameters.xml +0 -11
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand.xml +0 -7
- data/test/reports/TEST-HammerCLIForeman-User.xml +0 -7
- data/test/reports/TEST-MiniTest-Spec.xml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d37a2ec65a64506f68335f48ce44b78b113f26e
|
4
|
+
data.tar.gz: 7d4a6b52ec543e70fff320237fffaebdbe5adad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79eaebf4bd95a1c7516fd08af892da46e752ae55c5f6f6815722f382b7c0bf0099bd84d8d0f17968c35283c2eb73ae3ef0befb11855c1c74ebfdfa3c53ae6fe3
|
7
|
+
data.tar.gz: 7dd25990c3bc04af071837f7b6bdaa3cfa00d6830310e09d123e03e82fe0143affe25814720f5a42db560df4147ceeeaffb4d4c21dc88be3fcd2fa8309f5971b
|
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
CHANGED
@@ -37,21 +37,7 @@ look at [the development documentation](doc/developer_docs.md#hammer-development
|
|
37
37
|
|
38
38
|
How to test
|
39
39
|
------------
|
40
|
-
|
41
|
-
```bash
|
42
|
-
$ bundle install
|
43
|
-
$ bundle exec "rake test"
|
44
|
-
```
|
45
|
-
|
46
|
-
Generated coverage reports are stored in ./coverage directory.
|
47
|
-
|
48
|
-
There is support for testing against API documentation (and sample data) generated from different versions of Foreman.
|
49
|
-
The required version of Foreman can be set in env variable `TEST_API_VERSION`. Make sure the requested data are
|
50
|
-
in `test/unit/data/<version>/`.
|
51
|
-
|
52
|
-
```bash
|
53
|
-
$ TEST_API_VERSION=1.10 bundle exec rake test
|
54
|
-
```
|
40
|
+
Please read our [testing documentation](doc/testing.md#testing-hammer-commands) for more information about how to write and run tests.
|
55
41
|
|
56
42
|
|
57
43
|
License
|
data/doc/configuration.md
CHANGED
@@ -11,3 +11,41 @@ from `config/foreman.yml`.
|
|
11
11
|
|
12
12
|
See our [sample config file](https://github.com/theforeman/hammer-cli-foreman/blob/master/config/foreman.yml)
|
13
13
|
that lists all available configuration options with descriptions.
|
14
|
+
|
15
|
+
## Authentication
|
16
|
+
### Basic auth
|
17
|
+
Basic authentication with username and password is currently the only supported method.
|
18
|
+
|
19
|
+
You can save your credentials into hammer config file in your home directory:
|
20
|
+
`~/.hammer/cli.modules.d/foreman.yml`
|
21
|
+
```yaml
|
22
|
+
:foreman:
|
23
|
+
:username: 'admin'
|
24
|
+
:password: 'example'
|
25
|
+
```
|
26
|
+
|
27
|
+
Credentials can be passed directly on the command line too:
|
28
|
+
```bash
|
29
|
+
hammer -u admin -p example ...
|
30
|
+
```
|
31
|
+
|
32
|
+
If there are no credentials in neither config files nor command line, hammer asks for them interactively:
|
33
|
+
```
|
34
|
+
>> hammer host list
|
35
|
+
[Foreman] Username: admin
|
36
|
+
[Foreman] Password for admin:
|
37
|
+
...
|
38
|
+
```
|
39
|
+
|
40
|
+
**Sessions**
|
41
|
+
|
42
|
+
Hammer supports session authentication to reduce the need of entering credentials for each command.
|
43
|
+
It's disabled by default. To turn it on, put following into your config file:
|
44
|
+
```yaml
|
45
|
+
:foreman:
|
46
|
+
:use_sessions: true
|
47
|
+
```
|
48
|
+
Unfortunately retry on session expiry is yet to be implemented. Therefore you'll observe first command to fail
|
49
|
+
after the session expires.
|
50
|
+
|
51
|
+
The default session timeout is 1 hour. This can be changed in the Foreman: `Settings > Authentication > Idle timeout`
|
data/doc/developer_docs.md
CHANGED
@@ -6,9 +6,10 @@ There's a lot of useful information in
|
|
6
6
|
Studying it first can help you to understand the basic principles.
|
7
7
|
|
8
8
|
Foreman plugin extends the Hammer Core in following areas:
|
9
|
-
- [Using HammerCLIForeman::Command](using_hammer_cli_foreman_command.md)
|
10
|
-
- [Building options](option_builder.md#option-
|
11
|
-
- [Automatic name resolution](name_id_resolution.md#name
|
9
|
+
- [Using HammerCLIForeman::Command](using_hammer_cli_foreman_command.md#using-hammercliforeman)
|
10
|
+
- [Building options](option_builder.md#option-builders)
|
11
|
+
- [Automatic name resolution](name_id_resolution.md#name-to-id-resolution)
|
12
|
+
- [Testing commands](testing.md#testing-hammer-commands)
|
12
13
|
|
13
14
|
It's recommended that you set `:refresh_cache: true` in the plugin settings if
|
14
15
|
engaging in API development to enable aggressive apidoc cache checking.
|
data/doc/release_notes.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
Release notes
|
2
2
|
=============
|
3
|
+
|
4
|
+
### 0.10.0 (2017-03-28)
|
5
|
+
* Adding --hidden-value option to parameters (#290) ([#18878](http://projects.theforeman.org/issues/18878))
|
6
|
+
* Add command to clone user role ([#18318](http://projects.theforeman.org/issues/18318))
|
7
|
+
* Default organization/location work with authenticators ([#17936](http://projects.theforeman.org/issues/17936))
|
8
|
+
* Display hostgroup title on host actions ([#18739](http://projects.theforeman.org/issues/18739))
|
9
|
+
* Respect original request_params ([#18790](http://projects.theforeman.org/issues/18790))
|
10
|
+
* Rename config template to provisioning template ([#18654](http://projects.theforeman.org/issues/18654))
|
11
|
+
* User create/update accepts organization/location name ([#17923](http://projects.theforeman.org/issues/17923))
|
12
|
+
* Skip generating option --root-pass for host create ([#18337](http://projects.theforeman.org/issues/18337))
|
13
|
+
* Session authenticator keeps asking for user ([#18170](http://projects.theforeman.org/issues/18170))
|
14
|
+
* Host create uses name options ([#18339](http://projects.theforeman.org/issues/18339))
|
15
|
+
* Only include .mo files below locale/ ([#18439](http://projects.theforeman.org/issues/18439))
|
16
|
+
* Add config group commands ([#7520](http://projects.theforeman.org/issues/7520))
|
17
|
+
* Poweroff hosts when using --force option ([#18319](http://projects.theforeman.org/issues/18319))
|
18
|
+
* Resolve subnet and domain for host create/update (#273) ([#17247](http://projects.theforeman.org/issues/17247))
|
19
|
+
* Prevent from setting taxonomies for non-overriding filters ([#17730](http://projects.theforeman.org/issues/17730))
|
20
|
+
|
3
21
|
### 0.9.0 (2016-12-15)
|
4
22
|
* Auth overrides only unauthorized exception ([PR #271](https://github.com/theforeman/hammer-cli-foreman/pull/271)) ([#17650](http://projects.theforeman.org/issues/17650))
|
5
23
|
* Session auth in hammer ([PR #269](https://github.com/theforeman/hammer-cli-foreman/pull/269)) ([#8016](http://projects.theforeman.org/issues/8016))
|
data/doc/testing.md
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# Testing hammer commands
|
2
|
+
|
3
|
+
Commands from `hammer-cli-foreman` are tested by two types of tests:
|
4
|
+
- *unit tests* - They're placed in `test/unit` and test only basic functionality of the commands like accepted options and field labels printed to stdout. Unit tests for commands are no longer extended.
|
5
|
+
- *functional tests* - They're placed in `test/functional` and aim to test commands in broader context. Functional tests require mocking the api calls and should also test output based on data returned from the api. This is preferable way of testing the commands.
|
6
|
+
|
7
|
+
|
8
|
+
## Running the tests
|
9
|
+
|
10
|
+
```bash
|
11
|
+
bundle install
|
12
|
+
bundle exec rake test
|
13
|
+
```
|
14
|
+
|
15
|
+
Generated coverage reports are stored in ./coverage directory.
|
16
|
+
|
17
|
+
There is support for testing against API documentation generated from different versions of Foreman.
|
18
|
+
The required version of Foreman can be set in env variable `TEST_API_VERSION`. Make sure the requested data are in `test/unit/data/<version>/`.
|
19
|
+
```bash
|
20
|
+
$ TEST_API_VERSION=1.13 bundle exec rake test
|
21
|
+
```
|
22
|
+
|
23
|
+
## Testing API expectations
|
24
|
+
|
25
|
+
`hammer-cli-foreman` comes with a set of helpers and extensions to [Mocha](https://github.com/freerange/mocha) library for easier testing and better error detection.
|
26
|
+
|
27
|
+
The extensions are included in `test/test_helper.rb` by default. It's also possible to include it elswhere when needed:
|
28
|
+
```ruby
|
29
|
+
require 'hammer_cli_foreman/testing/api_expectations'
|
30
|
+
include HammerCLIForeman::Testing::APIExpectations
|
31
|
+
```
|
32
|
+
|
33
|
+
### Available helper functions
|
34
|
+
|
35
|
+
**`api_expects`**`(resource=nil, action=nil, note=nil, &block)`
|
36
|
+
* `resource` Symbol with plural name of the resource.
|
37
|
+
* `action` Symbol with action name.
|
38
|
+
* `note` String with description of the expected call to make its identification easier when the expectation fails.
|
39
|
+
* `&block` Optional block for testing parameters.
|
40
|
+
|
41
|
+
`api_expects` is often used together with `with_params` that set expectation on parameters that need to be included in the call:
|
42
|
+
```ruby
|
43
|
+
describe 'hostgroup create' do
|
44
|
+
it 'passes architecture id' do
|
45
|
+
api_expects(:hostgroups, :create, 'Create hostgroup with architecture_id').with_params('hostgroup' => {
|
46
|
+
'name' => 'hg1',
|
47
|
+
'architecture_id' => 1
|
48
|
+
})
|
49
|
+
|
50
|
+
run_cmd(%w(hostgroup create --name hg1 --architecture-id 1))
|
51
|
+
end
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
The expectation failure is reported with description of the call and expected parameters to make searching for mistakes easier:
|
56
|
+
```
|
57
|
+
unexpected invocation: #<AnyInstance:ApipieBindings::API>.call_action(<Action hostgroups:create>, {'hostgroup' => {'name' => 'hg1', 'architecture_id' => 2}}, {}, {:fake_response => nil})
|
58
|
+
unsatisfied expectations:
|
59
|
+
- expected exactly once, not yet invoked: Create hostgroup with architecture_id
|
60
|
+
#<AnyInstance:ApipieBindings::API>.call_action(:hostgroups, :create, *any_argument)
|
61
|
+
expected params to include: {
|
62
|
+
"hostgroup": {
|
63
|
+
"name": "hg1",
|
64
|
+
"architecture_id": 1
|
65
|
+
}
|
66
|
+
}
|
67
|
+
```
|
68
|
+
|
69
|
+
Alternatively parameters can be tested in a block:
|
70
|
+
```ruby
|
71
|
+
describe 'hostgroup create' do
|
72
|
+
it 'passes architecture id' do
|
73
|
+
api_expects(:hostgroups, :create, 'Create hostgroup with architecture_id') do |p|
|
74
|
+
p['hostgroup']['architecture_id'] == 1 && p['hostgroup']['name'] == 'hg1'
|
75
|
+
end
|
76
|
+
|
77
|
+
run_cmd(%w(hostgroup create --name hg1 --architecture-id 1))
|
78
|
+
end
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
This approach gives more freedom in what is tested and how but can't report what parameters were expected in case of failure.
|
83
|
+
|
84
|
+
**`api_expects_no_call`**
|
85
|
+
|
86
|
+
Makes sure no API call is performed.
|
87
|
+
|
88
|
+
Example:
|
89
|
+
```ruby
|
90
|
+
describe 'hostgroup create' do
|
91
|
+
it "doesn't perform any api request when name is missing" do
|
92
|
+
api_expects_no_call
|
93
|
+
run_cmd(%w(hostgroup create))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
**`api_expects_search`**`(resource=nil, search_options={}, note=nil)`
|
99
|
+
* `resource` Symbol with plural name of the resource.
|
100
|
+
* `search_options` Either hash with options to search by (eg. `:name => 'x86_64'`) or a string with the search query.
|
101
|
+
* `note` String with description of the expected call to make its identification easier when the expectation fails.
|
102
|
+
|
103
|
+
Helper that sets expectation on searching for a resource when hammer translates from name of the resource to its id. It's often used together with `returns` that mocks result of the search query.
|
104
|
+
|
105
|
+
Example:
|
106
|
+
```ruby
|
107
|
+
describe 'hostgroup create' do
|
108
|
+
let(:arch) {{'id' => 1, 'name' => 'arch1'}}
|
109
|
+
|
110
|
+
it 'resolves architecture name' do
|
111
|
+
api_expects_search(:architectures, { :name => 'arch1' }).returns(index_response([arch]))
|
112
|
+
run_cmd(%w(hostgroup create --name hg1 --architecture arch1))
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
116
|
+
|
117
|
+
**`api_connection`**`(options={}, version = '1.15')`
|
118
|
+
* `options` Hash with options for the api connection.
|
119
|
+
* `version` Version of the Foreman apidoc. Available exported versions are located in subdirectories of `test/data/`.
|
120
|
+
|
121
|
+
The function returns instance of `FakeApiConnection` that makes `#authenticator` public and allows setting expectations on it. Useful for injection of api instances into tested objects.
|
122
|
+
|
123
|
+
**`APIExpectationsDecorator`**
|
124
|
+
|
125
|
+
Decorator class that adds helpers for setting expectations on the wrapped api instance.
|
126
|
+
Provides methods `expects_call`, `expects_no_call` and `expects_search` that behave similarly to the helpers described above.
|
127
|
+
|
128
|
+
Example usage:
|
129
|
+
```ruby
|
130
|
+
connection = api_connection
|
131
|
+
api = APIExpectationsDecorator.new(connection.api)
|
132
|
+
api.expects_search(:users, 'login=admin')
|
133
|
+
```
|
data/lib/hammer_cli_foreman.rb
CHANGED
@@ -18,8 +18,6 @@ module HammerCLIForeman
|
|
18
18
|
require 'hammer_cli_foreman/param_filters'
|
19
19
|
require 'hammer_cli_foreman/id_resolver'
|
20
20
|
require 'hammer_cli_foreman/dependency_resolver'
|
21
|
-
require 'hammer_cli_foreman/defaults'
|
22
|
-
|
23
21
|
|
24
22
|
begin
|
25
23
|
require 'hammer_cli_foreman/commands'
|
@@ -27,6 +25,7 @@ module HammerCLIForeman
|
|
27
25
|
require 'hammer_cli_foreman/references'
|
28
26
|
require 'hammer_cli_foreman/parameter'
|
29
27
|
require 'hammer_cli_foreman/common_parameter'
|
28
|
+
require 'hammer_cli_foreman/defaults'
|
30
29
|
|
31
30
|
HammerCLI::MainCommand.lazy_subcommand('auth', _("Foreman connection login/logout."),
|
32
31
|
'HammerCLIForeman::Auth', 'hammer_cli_foreman/auth'
|
@@ -140,6 +139,9 @@ module HammerCLIForeman
|
|
140
139
|
'HammerCLIForeman::Usergroup', 'hammer_cli_foreman/usergroup'
|
141
140
|
)
|
142
141
|
|
142
|
+
HammerCLI::MainCommand.lazy_subcommand('config-group', _("Manipulate config groups."),
|
143
|
+
'HammerCLIForeman::ConfigGroup', 'hammer_cli_foreman/config_group'
|
144
|
+
)
|
143
145
|
|
144
146
|
rescue => e
|
145
147
|
handler = HammerCLIForeman::ExceptionHandler.new(:context => {}, :adapter => :base)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'hammer_cli_foreman/api/session_authenticator_wrapper'
|
2
2
|
require 'hammer_cli_foreman/api/interactive_basic_auth'
|
3
|
+
require 'hammer_cli_foreman/api/void_auth'
|
3
4
|
|
4
5
|
module HammerCLIForeman
|
5
6
|
module Api
|
@@ -30,14 +31,27 @@ module HammerCLIForeman
|
|
30
31
|
protected
|
31
32
|
|
32
33
|
def create_authenticator(uri, settings)
|
33
|
-
return @authenticator
|
34
|
+
return @authenticator if @authenticator
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
if ssl_cert_authentication?(settings) && !use_basic_auth?(settings)
|
37
|
+
@authenticator = VoidAuth.new
|
38
|
+
else
|
39
|
+
@authenticator = InteractiveBasicAuth.new(
|
40
|
+
settings.get(:_params, :username) || ENV['FOREMAN_USERNAME'] || settings.get(:foreman, :username),
|
41
|
+
settings.get(:_params, :password) || ENV['FOREMAN_PASSWORD'] || settings.get(:foreman, :password)
|
42
|
+
)
|
43
|
+
@authenticator = SessionAuthenticatorWrapper.new(@authenticator, uri) if settings.get(:foreman, :use_sessions)
|
44
|
+
@authenticator
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def ssl_cert_authentication?(settings)
|
49
|
+
(settings.get(:_params, :ssl_client_cert) || settings.get(:ssl, :ssl_client_cert)) &&
|
50
|
+
(settings.get(:_params, :ssl_client_key) || settings.get(:ssl, :ssl_client_key))
|
51
|
+
end
|
52
|
+
|
53
|
+
def use_basic_auth?(settings)
|
54
|
+
settings.get(:_params, :ssl_with_basic_auth) || settings.get(:ssl, :ssl_with_basic_auth)
|
41
55
|
end
|
42
56
|
|
43
57
|
def build_default_params(settings, logger, locale)
|
@@ -32,7 +32,8 @@ module HammerCLIForeman
|
|
32
32
|
def authenticate(request, args)
|
33
33
|
load_session
|
34
34
|
|
35
|
-
|
35
|
+
user = @authenticator.user
|
36
|
+
destroy_session if (user && user != @user)
|
36
37
|
|
37
38
|
if @permissions_ok && @session_id
|
38
39
|
jar = HTTP::CookieJar.new
|
@@ -62,6 +63,10 @@ module HammerCLIForeman
|
|
62
63
|
@authenticator.response(r)
|
63
64
|
end
|
64
65
|
|
66
|
+
def user
|
67
|
+
@authenticator.user if @authenticator.respond_to?(:user)
|
68
|
+
end
|
69
|
+
|
65
70
|
protected
|
66
71
|
|
67
72
|
def session_storage
|
@@ -26,6 +26,7 @@ module HammerCLIForeman
|
|
26
26
|
|
27
27
|
option "--name", "NAME", _("parameter name"), :required => true
|
28
28
|
option "--value", "VALUE", _("parameter value"), :required => true
|
29
|
+
option "--hidden-value", "HIDDEN_VALUE", _("should the value be hidden"), :format => HammerCLI::Options::Normalizers::Bool.new
|
29
30
|
|
30
31
|
def action
|
31
32
|
@action ||= parameter_exist? ? :update : :create
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
class ConfigGroup < HammerCLIForeman::Command
|
3
|
+
resource :config_groups
|
4
|
+
|
5
|
+
class ListCommand < HammerCLIForeman::ListCommand
|
6
|
+
output do
|
7
|
+
field :id, _("ID")
|
8
|
+
field :name, _("Name")
|
9
|
+
end
|
10
|
+
|
11
|
+
build_options
|
12
|
+
end
|
13
|
+
|
14
|
+
class InfoCommand < HammerCLIForeman::InfoCommand
|
15
|
+
output ListCommand.output_definition do
|
16
|
+
HammerCLIForeman::References.puppetclasses(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
build_options
|
20
|
+
end
|
21
|
+
|
22
|
+
class CreateCommand < HammerCLIForeman::CreateCommand
|
23
|
+
success_message _("Config group created")
|
24
|
+
failure_message _("Could not create the config group")
|
25
|
+
|
26
|
+
build_options
|
27
|
+
end
|
28
|
+
|
29
|
+
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
30
|
+
success_message _("Config group updated")
|
31
|
+
failure_message _("Could not update the config group")
|
32
|
+
|
33
|
+
build_options
|
34
|
+
end
|
35
|
+
|
36
|
+
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
37
|
+
success_message _("Config group has been deleted")
|
38
|
+
failure_message _("Could not delete the config group")
|
39
|
+
|
40
|
+
build_options
|
41
|
+
end
|
42
|
+
|
43
|
+
autoload_subcommands
|
44
|
+
end
|
45
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'hammer_cli'
|
2
2
|
module HammerCLIForeman
|
3
3
|
class Defaults < HammerCLI::BaseDefaultsProvider
|
4
|
-
def initialize
|
4
|
+
def initialize(api_connection = HammerCLIForeman.foreman_api_connection)
|
5
|
+
@api_connection = api_connection
|
5
6
|
@provider_name = 'foreman'
|
6
7
|
@supported_defaults = [:organization_id, :location_id]
|
7
8
|
@description = _('Use the default organization and/or location from the server')
|
@@ -21,9 +22,11 @@ module HammerCLIForeman
|
|
21
22
|
|
22
23
|
private
|
23
24
|
def get_user
|
24
|
-
|
25
|
+
login = @api_connection.authenticator.user
|
26
|
+
users = @api_connection.resource(:users).action(:index).call(:search => "login=#{login}")
|
27
|
+
users
|
25
28
|
end
|
26
29
|
end
|
27
|
-
HammerCLI.defaults.register_provider(Defaults.new())
|
28
30
|
|
31
|
+
HammerCLI.defaults.register_provider(Defaults.new)
|
29
32
|
end
|