hammer_cli_foreman 0.18.2 → 0.19.0
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 +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
|
@@ -3,31 +3,29 @@ require 'uri'
|
|
|
3
3
|
module HammerCLIForeman
|
|
4
4
|
module Api
|
|
5
5
|
class SessionAuthenticatorWrapper < ApipieBindings::Authenticators::Base
|
|
6
|
-
SESSION_STORAGE = '~/.hammer/sessions/'
|
|
7
6
|
|
|
8
|
-
attr_reader :session_id
|
|
7
|
+
attr_reader :session_id, :url, :auth_type
|
|
9
8
|
|
|
10
|
-
def initialize(authenticator, url,
|
|
9
|
+
def initialize(authenticator, url, auth_type)
|
|
11
10
|
@authenticator = authenticator
|
|
12
11
|
@url = url
|
|
12
|
+
@auth_type = auth_type
|
|
13
|
+
end
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
@
|
|
16
|
-
|
|
17
|
-
@permissions_ok = check_storage_permissions
|
|
18
|
-
warn _("Can't use session auth due to invalid permissions on session files.") unless @permissions_ok
|
|
15
|
+
def session
|
|
16
|
+
@session ||= Sessions.get(@url)
|
|
19
17
|
end
|
|
20
18
|
|
|
21
19
|
def clear
|
|
22
|
-
|
|
20
|
+
session.destroy
|
|
23
21
|
@authenticator.clear if @authenticator.respond_to?(:clear)
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
def status
|
|
27
|
-
if
|
|
28
|
-
_("Session exists, currently logged in as '%s'.") %
|
|
25
|
+
if session.valid?
|
|
26
|
+
_("Session exists, currently logged in as '%s'.") % session.user_name
|
|
29
27
|
else
|
|
30
|
-
_(
|
|
28
|
+
_('Using sessions, you are currently not logged in.')
|
|
31
29
|
end
|
|
32
30
|
end
|
|
33
31
|
|
|
@@ -40,15 +38,13 @@ module HammerCLIForeman
|
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def authenticate(request, args)
|
|
43
|
-
load_session
|
|
44
|
-
|
|
45
41
|
user = @authenticator.user
|
|
46
42
|
|
|
47
|
-
@user_changed ||= (!user.nil? && user !=
|
|
43
|
+
@user_changed ||= (!user.nil? && user != session.user_name)
|
|
48
44
|
|
|
49
|
-
if !@user_changed && @
|
|
45
|
+
if !@user_changed && Sessions.configured?(@url) && session.id
|
|
50
46
|
jar = HTTP::CookieJar.new
|
|
51
|
-
jar.add(HTTP::Cookie.new('_session_id',
|
|
47
|
+
jar.add(HTTP::Cookie.new('_session_id', session.id, domain: uri.hostname.downcase, path: '/', for_domain: true))
|
|
52
48
|
request['Cookie'] = HTTP::Cookie.cookie_value(jar.cookies)
|
|
53
49
|
request
|
|
54
50
|
else
|
|
@@ -57,12 +53,11 @@ module HammerCLIForeman
|
|
|
57
53
|
end
|
|
58
54
|
|
|
59
55
|
def error(ex)
|
|
60
|
-
|
|
61
|
-
if ex.is_a?(RestClient::Unauthorized) && !@session_id.nil?
|
|
56
|
+
if ex.is_a?(RestClient::Unauthorized) && session.valid?
|
|
62
57
|
if @user_changed
|
|
63
|
-
return UnauthorizedError.new(_("Invalid username or password, continuing with session for '%s'.") %
|
|
58
|
+
return UnauthorizedError.new(_("Invalid username or password, continuing with session for '%s'.") % session.user_name)
|
|
64
59
|
else
|
|
65
|
-
|
|
60
|
+
session.destroy
|
|
66
61
|
return SessionExpired.new(_("Session has expired."))
|
|
67
62
|
end
|
|
68
63
|
else
|
|
@@ -72,81 +67,40 @@ module HammerCLIForeman
|
|
|
72
67
|
|
|
73
68
|
def response(r)
|
|
74
69
|
if (r.cookies['_session_id'] && r.code != 401)
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
session.id = r.cookies['_session_id']
|
|
71
|
+
session.user_name = @authenticator.user
|
|
72
|
+
session.auth_type = @auth_type
|
|
73
|
+
session.store
|
|
77
74
|
end
|
|
78
75
|
@authenticator.response(r)
|
|
79
76
|
end
|
|
80
77
|
|
|
81
78
|
def user(ask=nil)
|
|
82
|
-
|
|
79
|
+
return unless @authenticator.respond_to?(:user)
|
|
80
|
+
if @auth_type == AUTH_TYPES[:basic_auth]
|
|
81
|
+
@authenticator.user(ask)
|
|
82
|
+
elsif @auth_type == AUTH_TYPES[:oauth_authentication_code_grant] ||
|
|
83
|
+
@auth_type = AUTH_TYPES[:oauth_password_grant]
|
|
84
|
+
@authenticator.user
|
|
85
|
+
end
|
|
83
86
|
end
|
|
84
87
|
|
|
85
88
|
def password(ask=nil)
|
|
86
89
|
@authenticator.password(ask) if @authenticator.respond_to?(:password)
|
|
87
90
|
end
|
|
88
91
|
|
|
89
|
-
def
|
|
90
|
-
@
|
|
92
|
+
def set_auth_params(*args)
|
|
93
|
+
if @auth_type == AUTH_TYPES[:basic_auth]
|
|
94
|
+
@authenticator.set_credentials(*args)
|
|
95
|
+
elsif @auth_type == AUTH_TYPES[:oauth_authentication_code_grant] ||
|
|
96
|
+
@auth_type == AUTH_TYPES[:oauth_password_grant]
|
|
97
|
+
@authenticator.set_token(*args)
|
|
98
|
+
end
|
|
91
99
|
end
|
|
92
100
|
|
|
93
|
-
protected
|
|
94
|
-
|
|
95
101
|
def uri
|
|
96
102
|
@uri ||= URI.parse(@url)
|
|
97
103
|
end
|
|
98
|
-
|
|
99
|
-
def session_storage
|
|
100
|
-
"#{@storage_dir}/#{@session_file}"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def load_session
|
|
104
|
-
if File.exist?(session_storage)
|
|
105
|
-
session_data = JSON.parse(File.read(session_storage))
|
|
106
|
-
@user = session_data['user_name']
|
|
107
|
-
@session_id = session_data['session_id']
|
|
108
|
-
end
|
|
109
|
-
rescue JSON::ParserError
|
|
110
|
-
destroy_session
|
|
111
|
-
warn _('Invalid session file format.')
|
|
112
|
-
nil
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def save_session(session_id, user_name)
|
|
116
|
-
File.open(session_storage, 'w', 0600) do |f|
|
|
117
|
-
session = JSON.generate({
|
|
118
|
-
:session_id => session_id,
|
|
119
|
-
:user_name => user_name
|
|
120
|
-
})
|
|
121
|
-
f.write(session)
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def destroy_session
|
|
126
|
-
@user = @session_id = nil
|
|
127
|
-
File.delete(session_storage) if File.exist?(session_storage)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def check_storage_permissions
|
|
131
|
-
Dir.mkdir(@storage_dir, 0700) unless File.exist?(@storage_dir)
|
|
132
|
-
ensure_mode(@storage_dir, '40700') && ensure_mode(session_storage, '100600')
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def ensure_mode(file, expected_mode)
|
|
136
|
-
return true unless File.exist?(file)
|
|
137
|
-
mode = File.stat(file).mode.to_s(8)
|
|
138
|
-
if mode != expected_mode
|
|
139
|
-
warn _("Invalid permissions for %{file}: %{mode}, expected %{expected_mode}.") % {
|
|
140
|
-
:mode => mode,
|
|
141
|
-
:expected_mode => expected_mode,
|
|
142
|
-
:file => file
|
|
143
|
-
}
|
|
144
|
-
false
|
|
145
|
-
else
|
|
146
|
-
true
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
104
|
end
|
|
151
105
|
end
|
|
152
106
|
end
|
|
@@ -1,32 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
require 'hammer_cli_foreman/openid_connect.rb'
|
|
2
|
+
require 'hammer_cli_foreman/authenticate/login.rb'
|
|
2
3
|
|
|
4
|
+
module HammerCLIForeman
|
|
3
5
|
class Auth < HammerCLI::AbstractCommand
|
|
4
|
-
|
|
5
6
|
class LoginCommand < HammerCLI::AbstractCommand
|
|
6
|
-
command_name
|
|
7
|
+
command_name 'login'
|
|
7
8
|
desc _("Set credentials")
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
class Basic < HammerCLI::AbstractCommand
|
|
11
|
+
extend HammerCLIForeman::Authenticate::Login
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
command_name('basic')
|
|
14
|
+
desc('provide username and password')
|
|
15
|
+
|
|
16
|
+
option ["-u", "--username"], "USERNAME", _("Username to access the remote system")
|
|
17
|
+
option ["-p", "--password"], "PASSWORD", _("Password to access the remote system")
|
|
18
|
+
|
|
19
|
+
def execute
|
|
20
|
+
Basic.execute_with_params(
|
|
21
|
+
AUTH_TYPES[:basic_auth],
|
|
22
|
+
option_username || HammerCLI::Settings.get('_params', 'username'),
|
|
23
|
+
option_password || HammerCLI::Settings.get('_params', 'password')
|
|
24
|
+
)
|
|
16
25
|
end
|
|
26
|
+
end
|
|
17
27
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
HammerCLIForeman.foreman_api_connection.authenticator.set_credentials(
|
|
21
|
-
option_username || HammerCLI::Settings.get('_params', 'username'),
|
|
22
|
-
option_password || HammerCLI::Settings.get('_params', 'password')
|
|
23
|
-
)
|
|
24
|
-
HammerCLIForeman.foreman_api_connection.authenticator.force_user_change
|
|
25
|
-
HammerCLIForeman.foreman_api_connection.login
|
|
28
|
+
class Oauth < HammerCLI::AbstractCommand
|
|
29
|
+
extend HammerCLIForeman::Authenticate::Login
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
command_name('oauth')
|
|
32
|
+
desc('supports for both with/without 2fa')
|
|
33
|
+
|
|
34
|
+
option ["-u", "--username"], "USERNAME", _("Username to access the remote system")
|
|
35
|
+
option ["-p", "--password"], "PASSWORD", _("Password to access the remote system")
|
|
36
|
+
option ["-t", "--oidc-token-endpoint"], "OPENIDC-TOKEN-ENDPOINT", _("Openidc provider URL which issues access token")
|
|
37
|
+
option ["-a", "--oidc-authorization-endpoint"], "OPENIDC-AUTHORIZATION-ENDPOINT", _("Openidc provider URL which issues authentication code")
|
|
38
|
+
option ["-c", "--oidc-client-id"], "OPENIDC-CLIENT-ID", _("Client id used in the Openidc provider")
|
|
39
|
+
option ["-f", "--two-factor"], :flag, _("Authenticate with two factor")
|
|
40
|
+
option ["-r", "--oidc-redirect-uri"], "OPENIDC-REDIRECT-URI", _("Redirect URI for the authencation code grant flow")
|
|
41
|
+
|
|
42
|
+
def execute
|
|
43
|
+
if option_two_factor?
|
|
44
|
+
Oauth.execute_with_params(
|
|
45
|
+
AUTH_TYPES[:oauth_authentication_code_grant],
|
|
46
|
+
option_oidc_token_endpoint,
|
|
47
|
+
option_oidc_authorization_endpoint,
|
|
48
|
+
option_oidc_client_id,
|
|
49
|
+
option_oidc_redirect_uri
|
|
50
|
+
)
|
|
51
|
+
else
|
|
52
|
+
Oauth.execute_with_params(
|
|
53
|
+
AUTH_TYPES[:oauth_password_grant],
|
|
54
|
+
option_oidc_token_endpoint,
|
|
55
|
+
option_oidc_client_id,
|
|
56
|
+
option_username || HammerCLI::Settings.get('_params', 'username'),
|
|
57
|
+
option_password || HammerCLI::Settings.get('_params', 'password')
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
autoload_subcommands
|
|
29
62
|
end
|
|
63
|
+
|
|
64
|
+
autoload_subcommands
|
|
30
65
|
end
|
|
31
66
|
|
|
32
67
|
class LogoutCommand < HammerCLI::AbstractCommand
|
|
@@ -52,5 +87,4 @@ module HammerCLIForeman
|
|
|
52
87
|
|
|
53
88
|
autoload_subcommands
|
|
54
89
|
end
|
|
55
|
-
|
|
56
90
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module HammerCLIForeman
|
|
2
|
+
module Authenticate
|
|
3
|
+
module Login
|
|
4
|
+
def execute_with_params(auth_type, *args)
|
|
5
|
+
connection = HammerCLIForeman.foreman_api_reconnect(auth_type)
|
|
6
|
+
if !(connection.authenticator.is_a?(HammerCLIForeman::Api::SessionAuthenticatorWrapper))
|
|
7
|
+
HammerCLI.interactive_output.say(_("Can't perform login. Make sure sessions are enabled in hammer"\
|
|
8
|
+
" configuration file."))
|
|
9
|
+
return HammerCLI::EX_USAGE
|
|
10
|
+
end
|
|
11
|
+
connection.authenticator.set_auth_params(*args)
|
|
12
|
+
connection.authenticator.force_user_change
|
|
13
|
+
connection.login
|
|
14
|
+
|
|
15
|
+
HammerCLI.interactive_output.say(_("Successfully logged in as '%s'.") %
|
|
16
|
+
connection.authenticator.user)
|
|
17
|
+
HammerCLI::EX_OK
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -44,6 +44,7 @@ module HammerCLIForeman
|
|
|
44
44
|
@help_block ||= Proc.new do
|
|
45
45
|
help do |h|
|
|
46
46
|
h.section(_('Provider specific options')) do |h|
|
|
47
|
+
h.note(_('Bold attributes are required.'), richtext: true)
|
|
47
48
|
HammerCLIForeman.compute_resources.each do |name, provider|
|
|
48
49
|
next unless current_providers.include?(name)
|
|
49
50
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module HammerCLIForeman
|
|
2
|
+
module CommandExtensions
|
|
3
|
+
class Ping < HammerCLI::CommandExtensions
|
|
4
|
+
before_print do |data|
|
|
5
|
+
unless data['results']['foreman'].nil?
|
|
6
|
+
status = data['results']['foreman']['database']['active']
|
|
7
|
+
data['results']['foreman']['database']['active'] = status ? 'ok' : 'FAIL'
|
|
8
|
+
duration = data['results']['foreman']['database']['duration_ms']
|
|
9
|
+
data['results']['foreman']['database']['duration_ms'] = _("Duration: %sms") % duration
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module HammerCLIForeman
|
|
2
|
+
module CommandExtensions
|
|
3
|
+
class Status < HammerCLI::CommandExtensions
|
|
4
|
+
before_print do |data|
|
|
5
|
+
return if data['results'].nil?
|
|
6
|
+
|
|
7
|
+
normalize_plugins(data['results']['foreman']['plugins'])
|
|
8
|
+
data['results']['foreman']['smart_proxies'].each do |proxy|
|
|
9
|
+
proxy['features'] = normalize_features(proxy['features'])
|
|
10
|
+
proxy['failed_features'] = normalize_failed_features(proxy['failed_features'])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.normalize_plugins(plugins)
|
|
15
|
+
plugins.map! do |plugin|
|
|
16
|
+
name, version = plugin.split(': ', 2)[1].split(', ', 3)[0..1]
|
|
17
|
+
{ name: name, version: version }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.normalize_features(features)
|
|
22
|
+
active_features = []
|
|
23
|
+
features.each_pair do |name, version|
|
|
24
|
+
active_features << {
|
|
25
|
+
name: name,
|
|
26
|
+
version: version
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
active_features
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.normalize_failed_features(features)
|
|
33
|
+
failed_features = []
|
|
34
|
+
features.each_pair do |name, error|
|
|
35
|
+
failed_features << {
|
|
36
|
+
name: name,
|
|
37
|
+
error: error
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
failed_features
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -3,3 +3,5 @@ require 'hammer_cli_foreman/command_extensions/puppet_environment'
|
|
|
3
3
|
require 'hammer_cli_foreman/command_extensions/puppet_environments'
|
|
4
4
|
require 'hammer_cli_foreman/command_extensions/option_sources'
|
|
5
5
|
require 'hammer_cli_foreman/command_extensions/hosts'
|
|
6
|
+
require 'hammer_cli_foreman/command_extensions/ping'
|
|
7
|
+
require 'hammer_cli_foreman/command_extensions/status'
|
|
@@ -279,7 +279,7 @@ module HammerCLIForeman
|
|
|
279
279
|
meta = resource.action(action).apidoc[:metadata]
|
|
280
280
|
if meta && meta[:search] && respond_to?(:option_search)
|
|
281
281
|
self.class.extend_help do |h|
|
|
282
|
-
h.section(_('Search fields'), id: :search_fields_section) do |h|
|
|
282
|
+
h.section(_('Search / Order fields'), id: :search_fields_section) do |h|
|
|
283
283
|
h.list(search_fields_help(meta[:search]))
|
|
284
284
|
end
|
|
285
285
|
end
|
|
@@ -21,6 +21,22 @@ module HammerCLIForeman
|
|
|
21
21
|
attribute_list.size.times.map { |idx| idx.to_s }.zip(attribute_list).to_h
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def self.alter_interface(interface)
|
|
25
|
+
# move each attribute starting with "compute_" to compute_attributes
|
|
26
|
+
interface.keys.each do |key|
|
|
27
|
+
if key.start_with? 'compute_'
|
|
28
|
+
interface[key.gsub('compute_', '')] = interface.delete(key)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
interface
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.alter_interfaces_list(interfaces_list)
|
|
35
|
+
interfaces_list.collect do |nic|
|
|
36
|
+
alter_interface(nic)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
24
40
|
class Create < HammerCLIForeman::CreateCommand
|
|
25
41
|
desc _('Create compute profile set of values')
|
|
26
42
|
|
|
@@ -41,7 +57,8 @@ module HammerCLIForeman
|
|
|
41
57
|
compute_resource_name = HammerCLIForeman::ComputeResources.resource_provider(options['option_compute_resource_id'])
|
|
42
58
|
interfaces_attr_name = ::HammerCLIForeman.compute_resources[compute_resource_name].interfaces_attrs_name
|
|
43
59
|
params['compute_attribute']['vm_attrs'] = option_compute_attributes || {}
|
|
44
|
-
|
|
60
|
+
interfaces_list = HammerCLIForeman::ComputeAttribute.alter_interfaces_list(options['option_interface_list']) unless options['option_interface_list'].empty?
|
|
61
|
+
params['compute_attribute']['vm_attrs'][interfaces_attr_name]= HammerCLIForeman::ComputeAttribute.attribute_hash(interfaces_list) if interfaces_list
|
|
45
62
|
params['compute_attribute']['vm_attrs']['volumes_attributes'] = HammerCLIForeman::ComputeAttribute.attribute_hash(option_volume_list) unless option_volume_list.empty?
|
|
46
63
|
params
|
|
47
64
|
end
|
|
@@ -69,7 +86,6 @@ module HammerCLIForeman
|
|
|
69
86
|
end
|
|
70
87
|
|
|
71
88
|
def request_params
|
|
72
|
-
|
|
73
89
|
params = HammerCLIForeman::ComputeAttribute.get_params(options)
|
|
74
90
|
compute_resource_name = HammerCLIForeman::ComputeResources.resource_provider(options['option_compute_resource_id'])
|
|
75
91
|
interfaces_attr_name = ::HammerCLIForeman.compute_resources[compute_resource_name].interfaces_attrs_name
|
|
@@ -85,7 +101,8 @@ module HammerCLIForeman
|
|
|
85
101
|
vm_attrs['volumes_attributes'] ||= original_volumes
|
|
86
102
|
vm_attrs[interfaces_attr_name] ||= original_interfaces
|
|
87
103
|
end
|
|
88
|
-
|
|
104
|
+
interfaces_list = HammerCLIForeman::ComputeAttribute.alter_interfaces_list(options['option_interface_list']) unless options['option_interface_list'].empty?
|
|
105
|
+
vm_attrs[interfaces_attr_name] = HammerCLIForeman::ComputeAttribute.attribute_hash(interfaces_list) if interfaces_list
|
|
89
106
|
vm_attrs['volumes_attributes'] = HammerCLIForeman::ComputeAttribute.attribute_hash(options['option_volume_list']) unless options['option_volume_list'].empty?
|
|
90
107
|
params['compute_attribute']['vm_attrs'] = vm_attrs
|
|
91
108
|
params
|
|
@@ -124,7 +141,7 @@ module HammerCLIForeman
|
|
|
124
141
|
params['id'] = params['compute_attribute']['id']
|
|
125
142
|
|
|
126
143
|
params['compute_attribute']['vm_attrs'][interfaces_attr_name] ||= {}
|
|
127
|
-
params['compute_attribute']['vm_attrs'][interfaces_attr_name][new_interface_id] = option_interface
|
|
144
|
+
params['compute_attribute']['vm_attrs'][interfaces_attr_name][new_interface_id] = HammerCLIForeman::ComputeAttribute.alter_interface(option_interface)
|
|
128
145
|
params
|
|
129
146
|
end
|
|
130
147
|
|
|
@@ -161,7 +178,7 @@ module HammerCLIForeman
|
|
|
161
178
|
interfaces_attr_name = ::HammerCLIForeman.compute_resources[compute_resource_name].interfaces_attrs_name
|
|
162
179
|
params['id'] = params['compute_attribute']['id']
|
|
163
180
|
params['compute_attribute']['vm_attrs'][interfaces_attr_name] ||= {}
|
|
164
|
-
params['compute_attribute']['vm_attrs'][interfaces_attr_name][option_interface_id] = option_interface
|
|
181
|
+
params['compute_attribute']['vm_attrs'][interfaces_attr_name][option_interface_id] = HammerCLIForeman::ComputeAttribute.alter_interface(option_interface)
|
|
165
182
|
params
|
|
166
183
|
end
|
|
167
184
|
success_message _('Interface was updated.')
|
|
@@ -3,7 +3,7 @@ module HammerCLIForeman
|
|
|
3
3
|
class Base
|
|
4
4
|
def name; ''; end
|
|
5
5
|
def compute_attributes; []; end
|
|
6
|
-
def interface_attributes; []; end
|
|
6
|
+
def interface_attributes; []; end # all attributes must start with compute_
|
|
7
7
|
def volume_attributes; []; end
|
|
8
8
|
def interfaces_attrs_name; 'interfaces_attributes'; end
|
|
9
9
|
def host_attributes; []; end
|
|
@@ -7,29 +7,32 @@ module HammerCLIForeman
|
|
|
7
7
|
|
|
8
8
|
def compute_attributes
|
|
9
9
|
[
|
|
10
|
-
['cpus', _('Number of CPUs')],
|
|
11
|
-
['memory', _('String, amount of memory, value in bytes')]
|
|
10
|
+
['cpus', _('Number of CPUs'), { bold: true }],
|
|
11
|
+
['memory', _('String, amount of memory, value in bytes'), { bold: true }],
|
|
12
|
+
['cpu_mode', _('Possible values: %{modes}') % { modes: 'default, host-model, host-passthrough' }]
|
|
12
13
|
]
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def host_attributes
|
|
16
17
|
[
|
|
17
|
-
['start',
|
|
18
|
+
['start', _('Boolean (expressed as 0 or 1), whether to start the machine or not')]
|
|
18
19
|
]
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def interface_attributes
|
|
22
23
|
[
|
|
23
|
-
['
|
|
24
|
-
['
|
|
25
|
-
['
|
|
24
|
+
['compute_type', _('Possible values: %s') % 'bridge, network'],
|
|
25
|
+
['compute_bridge', _('Name of interface according to type')],
|
|
26
|
+
['compute_model', _('Possible values: %s') % 'virtio, rtl8139, ne2k_pci, pcnet, e1000'],
|
|
27
|
+
['compute_network'], _('Libvirt instance network, e.g. default')
|
|
26
28
|
]
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def volume_attributes
|
|
30
32
|
[
|
|
31
|
-
['pool_name', _('One of available storage pools')],
|
|
32
|
-
['capacity', _('String value,
|
|
33
|
+
['pool_name', _('One of available storage pools'), { bold: true }],
|
|
34
|
+
['capacity', _('String value, e.g. 10G'), { bold: true }],
|
|
35
|
+
['allocation'], _('Initial allocation, e.g. 0G'),
|
|
33
36
|
['format_type', _('Possible values: %s') % 'raw, qcow2']
|
|
34
37
|
]
|
|
35
38
|
end
|
|
@@ -10,6 +10,7 @@ module HammerCLIForeman
|
|
|
10
10
|
['cluster', _('ID of cluster to use')],
|
|
11
11
|
['template', _('Hardware profile to use')],
|
|
12
12
|
['cores', _('Integer value, number of cores')],
|
|
13
|
+
['sockets', _('Integer value, number of sockets')],
|
|
13
14
|
['memory', _('Amount of memory, integer value in bytes')]
|
|
14
15
|
]
|
|
15
16
|
end
|
|
@@ -22,9 +23,9 @@ module HammerCLIForeman
|
|
|
22
23
|
|
|
23
24
|
def interface_attributes
|
|
24
25
|
[
|
|
25
|
-
['
|
|
26
|
-
['
|
|
27
|
-
['
|
|
26
|
+
['compute_name', _('Compute name, e.g. eth0')],
|
|
27
|
+
['compute_network', _('Select one of available networks for a cluster, must be an ID')],
|
|
28
|
+
['compute_interface', _('Interface type')]
|
|
28
29
|
]
|
|
29
30
|
end
|
|
30
31
|
|
|
@@ -32,7 +33,9 @@ module HammerCLIForeman
|
|
|
32
33
|
[
|
|
33
34
|
['size_gb', _('Volume size in GB, integer value')],
|
|
34
35
|
['storage_domain', _('ID of storage domain')],
|
|
35
|
-
['bootable', _('Boolean, only one volume can be bootable')]
|
|
36
|
+
['bootable', _('Boolean, only one volume can be bootable')],
|
|
37
|
+
['preallocate', _('Boolean, set %s to preallocate') % 'true'],
|
|
38
|
+
['wipe_after_delete', _('Boolean, set %s to wipe disk after delete') % 'true']
|
|
36
39
|
]
|
|
37
40
|
end
|
|
38
41
|
|
|
@@ -9,13 +9,13 @@ module HammerCLIForeman
|
|
|
9
9
|
|
|
10
10
|
def compute_attributes
|
|
11
11
|
[
|
|
12
|
-
['
|
|
13
|
-
['corespersocket', _('Number of cores per socket (applicable to hardware versions < 10 only)')],
|
|
14
|
-
['
|
|
12
|
+
['cluster', _('Cluster ID from VMware'), { bold: true }],
|
|
13
|
+
['corespersocket', _('Number of cores per socket (applicable to hardware versions < 10 only)'), { bold: true }],
|
|
14
|
+
['cpus', _('CPU count'), { bold: true }],
|
|
15
|
+
['memory_mb', _('Integer number, amount of memory in MB'), { bold: true }],
|
|
16
|
+
['path', _('Path to folder'), { bold: true }],
|
|
17
|
+
['resource_pool', _('Resource Pool ID from VMware'), { bold: true }],
|
|
15
18
|
['firmware', 'automatic/bios/efi'],
|
|
16
|
-
['cluster', _('Cluster ID from VMware')],
|
|
17
|
-
['resource_pool', _('Resource Pool ID from VMware')],
|
|
18
|
-
['path', _('Path to folder')],
|
|
19
19
|
['guest_id', _('Guest OS ID form VMware')],
|
|
20
20
|
['hardware_version', _('Hardware version ID from VMware')],
|
|
21
21
|
['memoryHotAddEnabled', _('Must be a 1 or 0, lets you add CPU resources while the machine is on')],
|
|
@@ -78,7 +78,7 @@ module HammerCLIForeman
|
|
|
78
78
|
params['host']['overwrite'] = option_overwrite unless option_overwrite.nil?
|
|
79
79
|
|
|
80
80
|
params['host']['host_parameters_attributes'] = parameter_attributes unless option_parameters.nil?
|
|
81
|
-
params['host']['host_parameters_attributes'] ||=
|
|
81
|
+
params['host']['host_parameters_attributes'] ||= typed_parameter_attributes unless option_typed_parameters.nil?
|
|
82
82
|
params['host']['compute_attributes'] = option_compute_attributes || {}
|
|
83
83
|
|
|
84
84
|
if action == :update
|