hammer_cli_foreman 0.18.2 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/foreman.yml +20 -0
- data/doc/host_create.md +19 -10
- data/doc/release_notes.md +12 -4
- data/lib/hammer_cli_foreman/api/authenticator.rb +81 -0
- data/lib/hammer_cli_foreman/api/connection.rb +48 -33
- data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +2 -2
- data/lib/hammer_cli_foreman/api/oauth/authentication_code_grant.rb +100 -0
- data/lib/hammer_cli_foreman/api/oauth/password_grant.rb +81 -0
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +34 -80
- data/lib/hammer_cli_foreman/auth.rb +54 -20
- data/lib/hammer_cli_foreman/authenticate/login.rb +21 -0
- data/lib/hammer_cli_foreman/command_extensions/hosts/help/compute_resources.rb +1 -0
- data/lib/hammer_cli_foreman/command_extensions/ping.rb +14 -0
- data/lib/hammer_cli_foreman/command_extensions/status.rb +44 -0
- data/lib/hammer_cli_foreman/command_extensions.rb +2 -0
- data/lib/hammer_cli_foreman/commands.rb +1 -1
- data/lib/hammer_cli_foreman/compute_attribute.rb +22 -5
- data/lib/hammer_cli_foreman/compute_resource/base.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/ec2.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/gce.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/libvirt.rb +11 -8
- data/lib/hammer_cli_foreman/compute_resource/openstack.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/ovirt.rb +7 -4
- data/lib/hammer_cli_foreman/compute_resource/rackspace.rb +1 -1
- data/lib/hammer_cli_foreman/compute_resource/vmware.rb +6 -6
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +1 -1
- data/lib/hammer_cli_foreman/location.rb +1 -1
- data/lib/hammer_cli_foreman/openid_connect.rb +68 -0
- data/lib/hammer_cli_foreman/organization.rb +1 -1
- data/lib/hammer_cli_foreman/output/formatters.rb +4 -5
- data/lib/hammer_cli_foreman/partition_table.rb +1 -0
- data/lib/hammer_cli_foreman/ping.rb +24 -0
- data/lib/hammer_cli_foreman/report_template.rb +3 -2
- data/lib/hammer_cli_foreman/sessions.rb +92 -0
- data/lib/hammer_cli_foreman/status.rb +53 -0
- data/lib/hammer_cli_foreman/subnet.rb +1 -0
- data/lib/hammer_cli_foreman/template.rb +1 -0
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/lib/hammer_cli_foreman.rb +8 -0
- 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.24/foreman_api.json +1 -0
- data/test/data/README.md +2 -2
- data/test/functional/commands/list_test.rb +2 -2
- data/test/functional/host_test.rb +0 -20
- data/test/functional/ping_test.rb +34 -0
- data/test/functional/status_test.rb +46 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Architecture.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter-SetCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-CommonParameter.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ComputeResource.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Domain-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Domain.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Environment-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Environment.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-ExceptionHandler.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand-parameters.xml +46 -0
- data/test/reports/TEST-HammerCLIForeman-Host-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Host-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-output.xml +85 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Host-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Host-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand-output.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Host-PuppetRunCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Host-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand-output.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Host-StatusCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand-parameters.xml +40 -0
- data/test/reports/TEST-HammerCLIForeman-Host-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Host.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-output.xml +29 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-output.xml +27 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Hostgroup.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Location-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Location.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-output.xml +23 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Medium-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Medium.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-DeleteParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-output.xml +27 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-SetParameterCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-OperatingSystem.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-output.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand-resource-disabled.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Organization-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Organization.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-DumpCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-output.xml +19 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-PartitionTable.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-output.xml +21 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-SmartProxy.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-output.xml +43 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand-parameters.xml +13 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Subnet.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand-parameters.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Template-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand-parameters.xml +12 -0
- data/test/reports/TEST-HammerCLIForeman-Template-DumpCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-output.xml +15 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand-parameters.xml +9 -0
- data/test/reports/TEST-HammerCLIForeman-Template-ListKindsCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-Template-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-Template.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand-parameters.xml +19 -0
- data/test/reports/TEST-HammerCLIForeman-User-CreateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-DeleteCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-output.xml +23 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-InfoCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-output.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand-parameters.xml +17 -0
- data/test/reports/TEST-HammerCLIForeman-User-ListCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand-parameters.xml +11 -0
- data/test/reports/TEST-HammerCLIForeman-User-UpdateCommand.xml +7 -0
- data/test/reports/TEST-HammerCLIForeman-User.xml +7 -0
- data/test/reports/TEST-MiniTest-Spec.xml +7 -0
- data/test/test_helper.rb +1 -1
- data/test/unit/api/interactive_basic_auth_test.rb +1 -1
- data/test/unit/api/oauth/oauth_authentication_code_grant_test.rb +88 -0
- data/test/unit/api/oauth/oauth_password_grant_test.rb +92 -0
- data/test/unit/api/session_authenticator_wrapper_test.rb +85 -70
- data/test/unit/sessions_test.rb +199 -0
- metadata +600 -81
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
module HammerCLIForeman
|
4
|
+
class OpenidConnect
|
5
|
+
def initialize(url, oidc_client_id)
|
6
|
+
@url = url
|
7
|
+
@oidc_client_id = oidc_client_id
|
8
|
+
end
|
9
|
+
|
10
|
+
def get_token(username, password)
|
11
|
+
uri = URI.parse(@url)
|
12
|
+
request = Net::HTTP::Post.new(uri)
|
13
|
+
request.content_type = 'application/x-www-form-urlencoded'
|
14
|
+
request.set_form_data(
|
15
|
+
'username' => username,
|
16
|
+
'password' => password,
|
17
|
+
'grant_type' => 'password',
|
18
|
+
'client_id' => @oidc_client_id
|
19
|
+
)
|
20
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https|
|
21
|
+
https.request(request)
|
22
|
+
end
|
23
|
+
json_response = JSON.parse(response.body)
|
24
|
+
if json_response.is_a?(Hash)
|
25
|
+
json_response['access_token']
|
26
|
+
else
|
27
|
+
raise _("Invalid access token response.")
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
rescue JSON::ParserError => e
|
31
|
+
raise _('Invalid access token')
|
32
|
+
nil
|
33
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
34
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
35
|
+
raise _("Failed to recieve acess token, please check your connectivity with OpenID provider: %s") % e
|
36
|
+
nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_token_via_2fa(code, oidc_redirect_uri)
|
40
|
+
uri = URI.parse(@url)
|
41
|
+
request = Net::HTTP::Post.new(uri)
|
42
|
+
request.content_type = 'application/x-www-form-urlencoded'
|
43
|
+
request.set_form_data(
|
44
|
+
'client_id' => @oidc_client_id,
|
45
|
+
'code' => code,
|
46
|
+
'grant_type' => 'authorization_code',
|
47
|
+
'redirect_uri' => oidc_redirect_uri
|
48
|
+
)
|
49
|
+
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |https|
|
50
|
+
https.request(request)
|
51
|
+
end
|
52
|
+
json_response = JSON.parse(response.body)
|
53
|
+
if json_response.is_a?(Hash)
|
54
|
+
json_response['access_token']
|
55
|
+
else
|
56
|
+
raise _("Invalid access token response.")
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
rescue JSON::ParserError => e
|
60
|
+
raise _('Invalid access token')
|
61
|
+
nil
|
62
|
+
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
|
63
|
+
Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
|
64
|
+
raise _("Failed to recieve acess token, please check your connectivity with OpenID provider: %s") % e
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module HammerCLIForeman::Output
|
2
2
|
module Formatters
|
3
3
|
class ReferenceFormatter < HammerCLI::Output::Formatters::FieldFormatter
|
4
|
-
def
|
5
|
-
[
|
4
|
+
def required_features
|
5
|
+
%i[serialized]
|
6
6
|
end
|
7
7
|
|
8
8
|
# Parameters:
|
@@ -51,8 +51,8 @@ module HammerCLIForeman::Output
|
|
51
51
|
end
|
52
52
|
|
53
53
|
class StructuredReferenceFormatter < HammerCLI::Output::Formatters::FieldFormatter
|
54
|
-
def
|
55
|
-
[
|
54
|
+
def required_features
|
55
|
+
%i[structured]
|
56
56
|
end
|
57
57
|
|
58
58
|
# Parameters:
|
@@ -103,4 +103,3 @@ module HammerCLIForeman::Output
|
|
103
103
|
HammerCLI::Output::Output.register_formatter(StructuredReferenceFormatter.new, :Template)
|
104
104
|
end
|
105
105
|
end
|
106
|
-
|
@@ -18,6 +18,7 @@ module HammerCLIForeman
|
|
18
18
|
|
19
19
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
20
20
|
output ListCommand.output_definition do
|
21
|
+
field :description, _('Description'), Fields::Text
|
21
22
|
field :locked, _("Locked"), Fields::Boolean
|
22
23
|
HammerCLIForeman::References.operating_systems(self)
|
23
24
|
HammerCLIForeman::References.timestamps(self)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
class PingCommand < HammerCLIForeman::Command
|
3
|
+
resource :ping
|
4
|
+
|
5
|
+
class ForemanCommand < HammerCLIForeman::Command
|
6
|
+
action :ping
|
7
|
+
command_name 'foreman'
|
8
|
+
|
9
|
+
output do
|
10
|
+
from 'foreman' do
|
11
|
+
field :database, _('database'), Fields::Label do
|
12
|
+
field :active, _('Status')
|
13
|
+
field :duration_ms, _('Server Response')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
extend_with(HammerCLIForeman::CommandExtensions::Ping.new)
|
19
|
+
end
|
20
|
+
|
21
|
+
self.default_subcommand = 'foreman'
|
22
|
+
autoload_subcommands
|
23
|
+
end
|
24
|
+
end
|
@@ -14,6 +14,7 @@ module HammerCLIForeman
|
|
14
14
|
|
15
15
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
16
16
|
output ListCommand.output_definition do
|
17
|
+
field :description, _('Description'), Fields::Text
|
17
18
|
field :locked, _("Locked"), Fields::Boolean
|
18
19
|
field :default, _("Default"), Fields::Boolean
|
19
20
|
HammerCLIForeman::References.timestamps(self)
|
@@ -162,7 +163,7 @@ module HammerCLIForeman
|
|
162
163
|
end
|
163
164
|
|
164
165
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
165
|
-
option ['
|
166
|
+
option ['-i', '--interactive'], :flag, _('Open empty template in an $EDITOR. Upload the result')
|
166
167
|
option "--file", "LAYOUT", _("Path to a file that contains the report template content"),
|
167
168
|
:attribute_name => :option_template, :format => HammerCLI::Options::Normalizers::File.new
|
168
169
|
|
@@ -187,7 +188,7 @@ module HammerCLIForeman
|
|
187
188
|
|
188
189
|
|
189
190
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
190
|
-
option ['
|
191
|
+
option ['-i', '--interactive'], :flag, _('Dump existing template and open it in an $EDITOR. Update with the result')
|
191
192
|
option '--file', 'REPORT', _("Path to a file that contains the report template content"), :attribute_name => :option_template,
|
192
193
|
:format => HammerCLI::Options::Normalizers::File.new
|
193
194
|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'uri'
|
2
|
+
module HammerCLIForeman
|
3
|
+
class Sessions
|
4
|
+
|
5
|
+
STORAGE_DIR = File.expand_path('~/.hammer/sessions/')
|
6
|
+
|
7
|
+
def self.get(url)
|
8
|
+
raise _('Sessions are not enabled, please check your Hammer settings.') unless enabled?
|
9
|
+
|
10
|
+
unless File.exist?(storage)
|
11
|
+
FileUtils.mkdir_p(storage, mode: 0700)
|
12
|
+
end
|
13
|
+
unless configured?(url)
|
14
|
+
warn _('Using session auth with invalid permissions on session files is not recommended.')
|
15
|
+
end
|
16
|
+
HammerCLIForeman::Session.new(session_file(url))
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.storage
|
20
|
+
STORAGE_DIR
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.enabled?
|
24
|
+
HammerCLI::Settings.get(:foreman, :use_sessions)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.session_file(url)
|
28
|
+
raise _('The url is empty. Session can not be created.') if url.nil? || url.empty?
|
29
|
+
|
30
|
+
uri = URI.parse(url)
|
31
|
+
File.join(storage, "#{uri.scheme}_#{uri.host}")
|
32
|
+
rescue URI::InvalidURIError
|
33
|
+
raise _('The url (%s) is not a valid URL. Session can not be created.') % url
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.configured?(url)
|
37
|
+
ensure_mode(storage, '40700') && ensure_mode(session_file(url), '100600')
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.ensure_mode(file, expected_mode)
|
41
|
+
return true unless File.exist?(file)
|
42
|
+
|
43
|
+
mode = File.stat(file).mode.to_s(8)
|
44
|
+
if mode != expected_mode
|
45
|
+
warn _("Invalid permissions for %{file}: %{mode}, expected %{expected_mode}.") % {
|
46
|
+
:mode => mode,
|
47
|
+
:expected_mode => expected_mode,
|
48
|
+
:file => file
|
49
|
+
}
|
50
|
+
false
|
51
|
+
else
|
52
|
+
true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Session
|
58
|
+
attr_accessor :id, :user_name, :auth_type
|
59
|
+
|
60
|
+
def initialize(session_path)
|
61
|
+
@session_path = File.expand_path(session_path)
|
62
|
+
if File.exist?(@session_path) && !File.zero?(@session_path)
|
63
|
+
session_data = JSON.parse(File.read(@session_path))
|
64
|
+
@id = session_data['id']
|
65
|
+
@user_name = session_data['user_name']
|
66
|
+
@auth_type = session_data['auth_type']
|
67
|
+
end
|
68
|
+
rescue JSON::ParserError
|
69
|
+
warn _('Invalid session data. Resetting the session.')
|
70
|
+
end
|
71
|
+
|
72
|
+
def store
|
73
|
+
File.open(@session_path,"w") do |f|
|
74
|
+
f.write({
|
75
|
+
id: id,
|
76
|
+
auth_type: auth_type,
|
77
|
+
user_name: user_name
|
78
|
+
}.to_json)
|
79
|
+
end
|
80
|
+
File.chmod(0600, @session_path)
|
81
|
+
end
|
82
|
+
|
83
|
+
def destroy
|
84
|
+
@id = nil
|
85
|
+
store
|
86
|
+
end
|
87
|
+
|
88
|
+
def valid?
|
89
|
+
!id.nil? && !id.empty?
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
class StatusCommand < HammerCLIForeman::Command
|
3
|
+
resource :ping
|
4
|
+
|
5
|
+
class ForemanCommand < HammerCLIForeman::Command
|
6
|
+
action :statuses
|
7
|
+
command_name 'foreman'
|
8
|
+
|
9
|
+
output do
|
10
|
+
from 'foreman' do
|
11
|
+
field :version, _('Version')
|
12
|
+
from 'api' do
|
13
|
+
field :version, _('API Version')
|
14
|
+
end
|
15
|
+
field :database, _('Database'), Fields::Label do
|
16
|
+
field :active, _('Status')
|
17
|
+
field :duration_ms, _('Server Response')
|
18
|
+
end
|
19
|
+
collection :plugins, _('Plugins') do
|
20
|
+
field :name, _('Name')
|
21
|
+
field :version, _('Version')
|
22
|
+
end
|
23
|
+
collection :smart_proxies, _('Smart Proxies') do
|
24
|
+
field :name, _('Name')
|
25
|
+
field :version, _('Version')
|
26
|
+
field :status, _('Status')
|
27
|
+
collection :features, _('Features'), hide_blank: true do
|
28
|
+
field :name, _('Name')
|
29
|
+
field :version, _('Version')
|
30
|
+
end
|
31
|
+
collection :failed_features, _('Failed features'), hide_blank: true do
|
32
|
+
field :name, _('Name')
|
33
|
+
field :error, _('Error')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
collection :compute_resources, _('Compute Resources') do
|
37
|
+
field :name, _('Name')
|
38
|
+
field :status, _('Status')
|
39
|
+
collection :errors, _('Errors'), hide_blank: true do
|
40
|
+
field nil, nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
extend_with(HammerCLIForeman::CommandExtensions::Ping.new(only: :data))
|
47
|
+
extend_with(HammerCLIForeman::CommandExtensions::Status.new(only: :data))
|
48
|
+
end
|
49
|
+
|
50
|
+
self.default_subcommand = 'foreman'
|
51
|
+
autoload_subcommands
|
52
|
+
end
|
53
|
+
end
|
@@ -52,6 +52,7 @@ module HammerCLIForeman
|
|
52
52
|
class InfoCommand < HammerCLIForeman::InfoCommand
|
53
53
|
|
54
54
|
output ListCommand.output_definition do
|
55
|
+
field :description, _('Description'), Fields::Text
|
55
56
|
field :locked, _("Locked"), Fields::Boolean
|
56
57
|
HammerCLIForeman::References.operating_systems(self)
|
57
58
|
HammerCLIForeman::References.taxonomies(self)
|
data/lib/hammer_cli_foreman.rb
CHANGED
@@ -20,6 +20,7 @@ module HammerCLIForeman
|
|
20
20
|
require 'hammer_cli_foreman/dependency_resolver'
|
21
21
|
require 'hammer_cli_foreman/option_sources'
|
22
22
|
require 'hammer_cli_foreman/logger'
|
23
|
+
require 'hammer_cli_foreman/sessions'
|
23
24
|
|
24
25
|
begin
|
25
26
|
require 'hammer_cli_foreman/command_extensions'
|
@@ -168,6 +169,13 @@ module HammerCLIForeman
|
|
168
169
|
'HammerCLIForeman::ConfigGroup', 'hammer_cli_foreman/config_group'
|
169
170
|
)
|
170
171
|
|
172
|
+
HammerCLI::MainCommand.lazy_subcommand('ping', _("Get the status of the server and/or it's subcomponents"),
|
173
|
+
'HammerCLIForeman::PingCommand', 'hammer_cli_foreman/ping'
|
174
|
+
)
|
175
|
+
|
176
|
+
HammerCLI::MainCommand.lazy_subcommand('status', _("Get the complete status of the server and/or it's subcomponents"),
|
177
|
+
'HammerCLIForeman::StatusCommand', 'hammer_cli_foreman/status'
|
178
|
+
)
|
171
179
|
rescue => e
|
172
180
|
handler = HammerCLIForeman::ExceptionHandler.new(:context => {}, :adapter => :base)
|
173
181
|
handler.handle_exception(e)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|