hammer_cli_foreman 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/configuration.md +2 -2
- data/doc/name_id_resolution.md +26 -1
- data/doc/release_notes.md +24 -0
- data/lib/hammer_cli_foreman.rb +30 -29
- data/lib/hammer_cli_foreman/api/connection.rb +1 -1
- data/lib/hammer_cli_foreman/api/interactive_basic_auth.rb +3 -3
- data/lib/hammer_cli_foreman/api/session_authenticator_wrapper.rb +9 -8
- data/lib/hammer_cli_foreman/api/void_auth.rb +7 -0
- data/lib/hammer_cli_foreman/architecture.rb +3 -5
- data/lib/hammer_cli_foreman/associating_commands.rb +32 -32
- data/lib/hammer_cli_foreman/auth.rb +2 -2
- data/lib/hammer_cli_foreman/auth_source_ldap.rb +4 -4
- data/lib/hammer_cli_foreman/commands.rb +23 -55
- data/lib/hammer_cli_foreman/common_parameter.rb +5 -5
- data/lib/hammer_cli_foreman/compute_resource.rb +17 -7
- data/lib/hammer_cli_foreman/config_group.rb +3 -3
- data/lib/hammer_cli_foreman/domain.rb +6 -8
- data/lib/hammer_cli_foreman/environment.rb +3 -3
- data/lib/hammer_cli_foreman/exception_handler.rb +27 -4
- data/lib/hammer_cli_foreman/external_usergroup.rb +3 -4
- data/lib/hammer_cli_foreman/filter.rb +20 -21
- data/lib/hammer_cli_foreman/host.rb +43 -18
- data/lib/hammer_cli_foreman/hostgroup.rb +24 -19
- data/lib/hammer_cli_foreman/hosts/common_update_options.rb +4 -6
- data/lib/hammer_cli_foreman/id_resolver.rb +86 -50
- data/lib/hammer_cli_foreman/image.rb +3 -4
- data/lib/hammer_cli_foreman/interface.rb +7 -9
- data/lib/hammer_cli_foreman/location.rb +6 -9
- data/lib/hammer_cli_foreman/media.rb +3 -6
- data/lib/hammer_cli_foreman/model.rb +3 -6
- data/lib/hammer_cli_foreman/operating_system.rb +11 -12
- data/lib/hammer_cli_foreman/option_sources.rb +4 -0
- data/lib/hammer_cli_foreman/option_sources/id_params.rb +51 -0
- data/lib/hammer_cli_foreman/option_sources/ids_params.rb +30 -0
- data/lib/hammer_cli_foreman/option_sources/self_param.rb +16 -0
- data/lib/hammer_cli_foreman/option_sources/user_params.rb +59 -0
- data/lib/hammer_cli_foreman/organization.rb +6 -9
- data/lib/hammer_cli_foreman/output/formatters.rb +1 -1
- data/lib/hammer_cli_foreman/parameter.rb +3 -5
- data/lib/hammer_cli_foreman/partition_table.rb +5 -6
- data/lib/hammer_cli_foreman/realm.rb +3 -3
- data/lib/hammer_cli_foreman/report.rb +1 -4
- data/lib/hammer_cli_foreman/role.rb +4 -7
- data/lib/hammer_cli_foreman/settings.rb +1 -1
- data/lib/hammer_cli_foreman/smart_class_parameter.rb +24 -14
- data/lib/hammer_cli_foreman/smart_proxy.rb +5 -7
- data/lib/hammer_cli_foreman/smart_variable.rb +24 -12
- data/lib/hammer_cli_foreman/ssh_keys.rb +56 -0
- data/lib/hammer_cli_foreman/subnet.rb +6 -9
- data/lib/hammer_cli_foreman/template.rb +16 -9
- data/lib/hammer_cli_foreman/user.rb +10 -52
- data/lib/hammer_cli_foreman/usergroup.rb +3 -3
- data/lib/hammer_cli_foreman/version.rb +1 -1
- data/test/data/1.15/foreman_api.json +1 -1
- data/test/data/1.16/foreman_api.json +1 -0
- data/test/functional/compute_resource_test.rb +117 -0
- data/test/functional/filter_test.rb +2 -2
- data/test/functional/host_test.rb +61 -10
- data/test/functional/location_test.rb +5 -5
- data/test/functional/organization_test.rb +7 -7
- data/test/functional/role_test.rb +3 -3
- data/test/functional/smart_class_parameter_test.rb +5 -5
- data/test/functional/smart_variable_test.rb +1 -1
- data/test/functional/ssh_keys_test.rb +105 -0
- data/test/functional/template_test.rb +30 -4
- data/test/functional/user_test.rb +5 -5
- 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/unit/api/interactive_basic_auth_test.rb +20 -1
- data/test/unit/api/session_authenticator_wrapper_test.rb +23 -8
- data/test/unit/api/void_auth_test.rb +11 -0
- data/test/unit/commands_test.rb +1 -1
- data/test/unit/exception_handler_test.rb +24 -3
- data/test/unit/helpers/command.rb +6 -2
- data/test/unit/host_test.rb +2 -2
- data/test/unit/hostgroup_test.rb +5 -3
- data/test/unit/id_resolver_test.rb +53 -5
- data/test/unit/media_test.rb +2 -2
- data/test/unit/option_sources/id_params_test.rb +30 -0
- data/test/unit/option_sources/ids_params_test.rb +30 -0
- data/test/unit/output/formatters_test.rb +4 -0
- data/test/unit/smart_class_parameter_test.rb +4 -4
- data/test/unit/smart_variable_test.rb +2 -2
- data/test/unit/user_test.rb +1 -2
- metadata +569 -69
@@ -78,7 +78,7 @@ module HammerCLIForeman
|
|
78
78
|
|
79
79
|
include HammerCLIForeman::Image::ComputeResourceOptions
|
80
80
|
|
81
|
-
success_message _("Image created")
|
81
|
+
success_message _("Image created.")
|
82
82
|
failure_message _("Could not create the image")
|
83
83
|
end
|
84
84
|
|
@@ -87,7 +87,7 @@ module HammerCLIForeman
|
|
87
87
|
|
88
88
|
include HammerCLIForeman::Image::ComputeResourceOptions
|
89
89
|
|
90
|
-
success_message _("Image updated")
|
90
|
+
success_message _("Image updated.")
|
91
91
|
failure_message _("Could not update the image")
|
92
92
|
end
|
93
93
|
|
@@ -96,7 +96,7 @@ module HammerCLIForeman
|
|
96
96
|
|
97
97
|
include HammerCLIForeman::Image::ComputeResourceOptions
|
98
98
|
|
99
|
-
success_message _("Image deleted")
|
99
|
+
success_message _("Image deleted.")
|
100
100
|
failure_message _("Could not delete the image")
|
101
101
|
end
|
102
102
|
|
@@ -104,4 +104,3 @@ module HammerCLIForeman
|
|
104
104
|
end
|
105
105
|
|
106
106
|
end
|
107
|
-
|
@@ -74,8 +74,8 @@ module HammerCLIForeman
|
|
74
74
|
module InterfaceUpdate
|
75
75
|
|
76
76
|
def self.included(base)
|
77
|
-
base.option "--primary", :flag, _("Should this interface be used for constructing the FQDN of the host? Each managed hosts needs to have one primary interface
|
78
|
-
base.option "--provision", :flag, _("Should this interface be used for TFTP of PXELinux (or SSH for image-based hosts)? Each managed hosts needs to have one provision interface
|
77
|
+
base.option "--primary", :flag, _("Should this interface be used for constructing the FQDN of the host? Each managed hosts needs to have one primary interface")
|
78
|
+
base.option "--provision", :flag, _("Should this interface be used for TFTP of PXELinux (or SSH for image-based hosts)? Each managed hosts needs to have one provision interface")
|
79
79
|
end
|
80
80
|
|
81
81
|
def get_interfaces(host_id)
|
@@ -125,10 +125,10 @@ module HammerCLIForeman
|
|
125
125
|
|
126
126
|
|
127
127
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
128
|
-
success_message _("Interface created")
|
128
|
+
success_message _("Interface created.")
|
129
129
|
failure_message _("Could not create the interface")
|
130
130
|
|
131
|
-
option "--compute-attributes", "COMPUTE_ATTRS", _("Compute resource specific attributes
|
131
|
+
option "--compute-attributes", "COMPUTE_ATTRS", _("Compute resource specific attributes"),
|
132
132
|
:format => HammerCLI::Options::Normalizers::KeyValueList.new
|
133
133
|
|
134
134
|
include InterfaceUpdate
|
@@ -138,10 +138,10 @@ module HammerCLIForeman
|
|
138
138
|
|
139
139
|
|
140
140
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
141
|
-
success_message _("Interface updated")
|
141
|
+
success_message _("Interface updated.")
|
142
142
|
failure_message _("Could not update the interface")
|
143
143
|
|
144
|
-
option "--compute-attributes", "COMPUTE_ATTRS", _("Compute resource specific attributes
|
144
|
+
option "--compute-attributes", "COMPUTE_ATTRS", _("Compute resource specific attributes"),
|
145
145
|
:format => HammerCLI::Options::Normalizers::KeyValueList.new
|
146
146
|
|
147
147
|
include InterfaceUpdate
|
@@ -151,7 +151,7 @@ module HammerCLIForeman
|
|
151
151
|
|
152
152
|
|
153
153
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
154
|
-
success_message _("Interface deleted")
|
154
|
+
success_message _("Interface deleted.")
|
155
155
|
failure_message _("Could not delete the interface")
|
156
156
|
|
157
157
|
build_options
|
@@ -161,5 +161,3 @@ module HammerCLIForeman
|
|
161
161
|
end
|
162
162
|
|
163
163
|
end
|
164
|
-
|
165
|
-
|
@@ -52,7 +52,7 @@ module HammerCLIForeman
|
|
52
52
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
53
53
|
include HammerCLIForeman::ResourceSupportedTest
|
54
54
|
|
55
|
-
success_message _("Location created")
|
55
|
+
success_message _("Location created.")
|
56
56
|
failure_message _("Could not create the location")
|
57
57
|
|
58
58
|
build_options
|
@@ -64,7 +64,7 @@ module HammerCLIForeman
|
|
64
64
|
|
65
65
|
option '--id', 'ID', _("Location numeric id to search by")
|
66
66
|
|
67
|
-
success_message _("Location updated")
|
67
|
+
success_message _("Location updated.")
|
68
68
|
failure_message _("Could not update the location")
|
69
69
|
|
70
70
|
build_options
|
@@ -76,7 +76,7 @@ module HammerCLIForeman
|
|
76
76
|
|
77
77
|
option '--id', 'ID', _("Location numeric id to search by")
|
78
78
|
|
79
|
-
success_message _("Location deleted")
|
79
|
+
success_message _("Location deleted.")
|
80
80
|
failure_message _("Could not delete the location")
|
81
81
|
|
82
82
|
build_options do |o|
|
@@ -86,7 +86,7 @@ module HammerCLIForeman
|
|
86
86
|
|
87
87
|
|
88
88
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
89
|
-
desc _("Create or update parameter for a location
|
89
|
+
desc _("Create or update parameter for a location")
|
90
90
|
|
91
91
|
success_message_for :update, _("Parameter [%{name}] updated to value [%{value}]")
|
92
92
|
success_message_for :create, _("Parameter [%{name}] created with value [%{value}]")
|
@@ -97,9 +97,9 @@ module HammerCLIForeman
|
|
97
97
|
|
98
98
|
|
99
99
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
100
|
-
desc _("Delete parameter for a location
|
100
|
+
desc _("Delete parameter for a location")
|
101
101
|
|
102
|
-
success_message _("Parameter [%{name}] deleted")
|
102
|
+
success_message _("Parameter [%{name}] deleted.")
|
103
103
|
failure_message _("Could not delete location parameter")
|
104
104
|
|
105
105
|
build_options
|
@@ -120,6 +120,3 @@ module HammerCLIForeman
|
|
120
120
|
end
|
121
121
|
|
122
122
|
end
|
123
|
-
|
124
|
-
|
125
|
-
|
@@ -29,7 +29,7 @@ module HammerCLIForeman
|
|
29
29
|
|
30
30
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
31
31
|
|
32
|
-
success_message _("Installation medium created")
|
32
|
+
success_message _("Installation medium created.")
|
33
33
|
failure_message _("Could not create the installation medium")
|
34
34
|
|
35
35
|
build_options
|
@@ -38,7 +38,7 @@ module HammerCLIForeman
|
|
38
38
|
|
39
39
|
|
40
40
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
41
|
-
success_message _("Installation medium updated")
|
41
|
+
success_message _("Installation medium updated.")
|
42
42
|
failure_message _("Could not update the installation media")
|
43
43
|
|
44
44
|
build_options
|
@@ -47,7 +47,7 @@ module HammerCLIForeman
|
|
47
47
|
|
48
48
|
|
49
49
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
50
|
-
success_message _("Installation medium deleted")
|
50
|
+
success_message _("Installation medium deleted.")
|
51
51
|
failure_message _("Could not delete the installation media")
|
52
52
|
|
53
53
|
build_options
|
@@ -60,6 +60,3 @@ module HammerCLIForeman
|
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
63
|
-
|
64
|
-
|
65
|
-
|
@@ -28,14 +28,14 @@ module HammerCLIForeman
|
|
28
28
|
|
29
29
|
|
30
30
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
31
|
-
success_message _("Hardware model created")
|
31
|
+
success_message _("Hardware model created.")
|
32
32
|
failure_message _("Could not create the hardware model")
|
33
33
|
|
34
34
|
build_options
|
35
35
|
end
|
36
36
|
|
37
37
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
38
|
-
success_message _("Hardware model deleted")
|
38
|
+
success_message _("Hardware model deleted.")
|
39
39
|
failure_message _("Could not delete the hardware model")
|
40
40
|
|
41
41
|
build_options
|
@@ -43,7 +43,7 @@ module HammerCLIForeman
|
|
43
43
|
|
44
44
|
|
45
45
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
46
|
-
success_message _("Hardware model updated")
|
46
|
+
success_message _("Hardware model updated.")
|
47
47
|
failure_message _("Could not update the hardware model")
|
48
48
|
|
49
49
|
build_options
|
@@ -54,6 +54,3 @@ module HammerCLIForeman
|
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
@@ -41,7 +41,7 @@ module HammerCLIForeman
|
|
41
41
|
|
42
42
|
|
43
43
|
class CreateCommand < HammerCLIForeman::CreateCommand
|
44
|
-
success_message _("Operating system created")
|
44
|
+
success_message _("Operating system created.")
|
45
45
|
failure_message _("Could not create the operating system")
|
46
46
|
|
47
47
|
build_options
|
@@ -49,7 +49,7 @@ module HammerCLIForeman
|
|
49
49
|
|
50
50
|
|
51
51
|
class UpdateCommand < HammerCLIForeman::UpdateCommand
|
52
|
-
success_message _("Operating system updated")
|
52
|
+
success_message _("Operating system updated.")
|
53
53
|
failure_message _("Could not update the operating system")
|
54
54
|
|
55
55
|
build_options
|
@@ -57,7 +57,7 @@ module HammerCLIForeman
|
|
57
57
|
|
58
58
|
|
59
59
|
class DeleteCommand < HammerCLIForeman::DeleteCommand
|
60
|
-
success_message _("Operating system deleted")
|
60
|
+
success_message _("Operating system deleted.")
|
61
61
|
failure_message _("Could not delete the operating system")
|
62
62
|
|
63
63
|
build_options
|
@@ -65,7 +65,7 @@ module HammerCLIForeman
|
|
65
65
|
|
66
66
|
|
67
67
|
class SetParameterCommand < HammerCLIForeman::Parameter::SetCommand
|
68
|
-
desc _("Create or update parameter for an operating system
|
68
|
+
desc _("Create or update parameter for an operating system")
|
69
69
|
|
70
70
|
success_message_for :update, _("Operating system parameter updated")
|
71
71
|
success_message_for :create, _("New operating system parameter created")
|
@@ -81,9 +81,9 @@ module HammerCLIForeman
|
|
81
81
|
|
82
82
|
|
83
83
|
class DeleteParameterCommand < HammerCLIForeman::Parameter::DeleteCommand
|
84
|
-
desc _("Delete parameter for an operating system
|
84
|
+
desc _("Delete parameter for an operating system")
|
85
85
|
|
86
|
-
success_message _("operating system parameter deleted")
|
86
|
+
success_message _("operating system parameter deleted.")
|
87
87
|
|
88
88
|
def validate_options
|
89
89
|
super
|
@@ -98,11 +98,11 @@ module HammerCLIForeman
|
|
98
98
|
command_name "set-default-template"
|
99
99
|
resource :os_default_templates
|
100
100
|
|
101
|
-
option "--id", "OS ID", _("
|
102
|
-
option "--config-template-id", "TPL ID", _("
|
101
|
+
option "--id", "OS ID", _("Operatingsystem id"), :required => true, :referenced_resource => 'operatingsystem'
|
102
|
+
option "--config-template-id", "TPL ID", _("Config template id to be set"), :required => true
|
103
103
|
|
104
104
|
|
105
|
-
success_message _("[%{config_template_name}] was set as default %{template_kind_name} template")
|
105
|
+
success_message _("[%{config_template_name}] was set as default %{template_kind_name} template.")
|
106
106
|
failure_message _("Could not set the os default template")
|
107
107
|
|
108
108
|
def option_type_name
|
@@ -164,10 +164,10 @@ module HammerCLIForeman
|
|
164
164
|
command_name "delete-default-template"
|
165
165
|
resource :os_default_templates
|
166
166
|
|
167
|
-
option "--id", "OS ID", _("
|
167
|
+
option "--id", "OS ID", _("Operatingsystem id"), :required => true, :referenced_resource => 'operatingsystem'
|
168
168
|
option "--type", "TPL TYPE", _("Type of the config template"), :required => true
|
169
169
|
|
170
|
-
success_message _("Default template deleted")
|
170
|
+
success_message _("Default template deleted.")
|
171
171
|
failure_message _("Could not delete the default template")
|
172
172
|
|
173
173
|
def execute
|
@@ -204,4 +204,3 @@ module HammerCLIForeman
|
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
207
|
-
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
module OptionSources
|
3
|
+
class IdParams
|
4
|
+
def initialize(command)
|
5
|
+
@command = command
|
6
|
+
end
|
7
|
+
|
8
|
+
def param_updatable?(param_resource)
|
9
|
+
param_resource && @command.respond_to?(HammerCLI.option_accessor_name("#{param_resource.singular_name}_id"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def available_id_params
|
13
|
+
IdParamsFilter.new(:only_required => false).for_action(@command.resource.action(@command.action))
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_options(defined_options, result)
|
17
|
+
# resolve all '<resource_name>_id' parameters if they are defined as options
|
18
|
+
# (they can be skipped using .without or .expand.except)
|
19
|
+
return result if @command.action.nil?
|
20
|
+
available_id_params.each do |api_param|
|
21
|
+
param_resource = HammerCLIForeman.param_to_resource(api_param.name)
|
22
|
+
if result[HammerCLI.option_accessor_name(api_param.name)].nil? && param_updatable?(param_resource)
|
23
|
+
resource_id = @command.get_resource_id(param_resource, :scoped => true, :required => api_param.required?, :all_options => result)
|
24
|
+
result[HammerCLI.option_accessor_name(api_param.name)] = resource_id if resource_id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
result
|
28
|
+
|
29
|
+
rescue HammerCLIForeman::MissingSearchOptions => e
|
30
|
+
|
31
|
+
switches = @command.class.find_options(:referenced_resource => e.resource.singular_name).map(&:long_switch)
|
32
|
+
|
33
|
+
if switches.empty?
|
34
|
+
error_message = _("Could not find %{resource}. Some search options were missing, please see --help.")
|
35
|
+
elsif switches.length == 1
|
36
|
+
error_message = _("Could not find %{resource}, please set option %{switches}.")
|
37
|
+
else
|
38
|
+
error_message = _("Could not find %{resource}, please set one of options %{switches}.")
|
39
|
+
end
|
40
|
+
|
41
|
+
raise MissingSearchOptions.new(
|
42
|
+
error_message % {
|
43
|
+
:resource => e.resource.singular_name,
|
44
|
+
:switches => switches.join(", ")
|
45
|
+
},
|
46
|
+
e.resource
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
module OptionSources
|
3
|
+
class IdsParams
|
4
|
+
def initialize(command)
|
5
|
+
@command = command
|
6
|
+
end
|
7
|
+
|
8
|
+
def param_updatable?(param_resource)
|
9
|
+
param_resource && @command.respond_to?(HammerCLI.option_accessor_name("#{param_resource.singular_name}_ids"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def available_ids_params
|
13
|
+
IdArrayParamsFilter.new(:only_required => false).for_action(@command.resource.action(@command.action))
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_options(defined_options, result)
|
17
|
+
return result if @command.action.nil?
|
18
|
+
# resolve all '<resource_name>_ids' parameters if they are defined as options
|
19
|
+
available_ids_params.each do |api_param|
|
20
|
+
param_resource = HammerCLIForeman.param_to_resource(api_param.name)
|
21
|
+
if result[HammerCLI.option_accessor_name(api_param.name)].nil? && param_updatable?(param_resource)
|
22
|
+
resource_ids = @command.get_resource_ids(param_resource, :scoped => true, :required => api_param.required?, :all_options => result)
|
23
|
+
result[HammerCLI.option_accessor_name(api_param.name)] = resource_ids if resource_ids
|
24
|
+
end
|
25
|
+
end
|
26
|
+
result
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
module OptionSources
|
3
|
+
class SelfParam
|
4
|
+
def initialize(command)
|
5
|
+
@command = command
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_options(defined_options, result)
|
9
|
+
# resolve 'id' parameter if it's defined as an option
|
10
|
+
id_option_name = HammerCLI.option_accessor_name('id')
|
11
|
+
result[id_option_name] ||= @command.get_identifier(result) if @command.respond_to?(id_option_name)
|
12
|
+
result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module HammerCLIForeman
|
2
|
+
module OptionSources
|
3
|
+
class UserParams
|
4
|
+
def initialize(command)
|
5
|
+
@command = command
|
6
|
+
end
|
7
|
+
|
8
|
+
def get_options(defined_options, result)
|
9
|
+
org_id = organization_id(result[option_name(:default_organization)])
|
10
|
+
result[option_name(:default_organization_id)] ||= org_id unless org_id.nil?
|
11
|
+
loc_id = location_id(result[option_name(:default_location)])
|
12
|
+
result[option_name(:default_location_id)] ||= loc_id unless loc_id.nil?
|
13
|
+
|
14
|
+
if @command.action == :update
|
15
|
+
if result[option_name(:password)] || result[option_name(:ask_password)]
|
16
|
+
if current_logged_user["id"].to_s == result[option_name(:id)].to_s
|
17
|
+
unless result[option_name(:current_password)]
|
18
|
+
result[option_name(:current_password)] = ask_password(:current)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if result[option_name(:ask_password)]
|
25
|
+
result[option_name(:password)] = ask_password(:new)
|
26
|
+
end
|
27
|
+
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def option_name(opt_name)
|
34
|
+
HammerCLI.option_accessor_name(opt_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def ask_password(type)
|
38
|
+
if type == :current
|
39
|
+
prompt = _("Enter user's current password:") + " "
|
40
|
+
elsif type == :new
|
41
|
+
prompt = _("Enter user's new password:") + " "
|
42
|
+
end
|
43
|
+
ask(prompt) {|q| q.echo = false}
|
44
|
+
end
|
45
|
+
|
46
|
+
def organization_id(name)
|
47
|
+
@command.resolver.organization_id('option_name' => name) if name
|
48
|
+
end
|
49
|
+
|
50
|
+
def location_id(name)
|
51
|
+
@command.resolver.location_id('option_name' => name) if name
|
52
|
+
end
|
53
|
+
|
54
|
+
def current_logged_user
|
55
|
+
HammerCLIForeman.foreman_api_connection.resource(:users).call(:show, :id => HammerCLIForeman.foreman_api_connection.authenticator.user(true))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|