diff --git a/lib/hammer_cli_foreman/compute_resource.rb b/lib/hammer_cli_foreman/compute_resource.rb index 3fb93d0df..a1a640fac 100644 --- a/lib/hammer_cli_foreman/compute_resource.rb +++ b/lib/hammer_cli_foreman/compute_resource.rb @@ -208,6 +208,19 @@ class AvailableStorageDomainsCommand < HammerCLIForeman::ListCommand extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params])) end + class AvailableStorageDomainInfoCommand < HammerCLIForeman::InfoCommand + action :storage_domain + command_name 'storage-domain-info' + + option '--storage-domain', 'Storage domain', _('Name of the storage domain'), attribute_name: :option_storage_domain_id + + output HammerCLIForeman::ComputeResource::AvailableStorageDomainsCommand.output_definition + + build_options do |o| + o.without('storage_domain_id') + end + end + class AvailableStoragePodsCommand < HammerCLIForeman::ListCommand action :available_storage_pods command_name 'storage-pods' @@ -222,6 +235,15 @@ class AvailableStoragePodsCommand < HammerCLIForeman::ListCommand extend_with(HammerCLIForeman::CommandExtensions::ComputeResourceSubcommand.new(only: %i[option request_params])) end + class AvailableStoragePodInfoCommand < HammerCLIForeman::InfoCommand + action :storage_pod + command_name 'storage-pod-info' + + output HammerCLIForeman::ComputeResource::AvailableStoragePodsCommand.output_definition + + build_options + end + class AvailableSecurityGroupsCommand < HammerCLIForeman::ListCommand action :available_security_groups command_name 'security-groups' diff --git a/test/functional/compute_resource_test.rb b/test/functional/compute_resource_test.rb index 508e94804..9155f7aa8 100644 --- a/test/functional/compute_resource_test.rb +++ b/test/functional/compute_resource_test.rb @@ -358,6 +358,51 @@ end end + describe 'storage_pod_info' do + let(:cmd) { base_cmd << 'storage-pod-info' } + let(:storage_pod) do + { id: 'group-1', name: 'storage_pod1', datacenter: 'datacenter1' } + end + + it 'shows information about a storage pod' do + api_expects(:compute_resources, :storage_pod).with_params( + 'id' => '1', 'storage_pod_id' => 'group-1' + ).returns(storage_pod) + + output = OutputMatcher.new( + "Id: group-1\n" \ + "Name: storage_pod1\n" \ + "Datacenter: datacenter1\n" + ) + expected_result = success_result(output) + + result = run_cmd(cmd + base_params + ['--storage-pod-id=group-1']) + assert_cmd(expected_result, result) + end + end + + describe 'storage_domain_info' do + let(:cmd) { base_cmd << 'storage-domain-info' } + let(:storage_domain) do + { id: 'data-1', name: 'storage_domain1' } + end + + it 'shows information about a storage domain' do + api_expects(:compute_resources, :storage_domain).with_params( + 'id' => '1', 'storage_domain_id' => 'storage_domain1' + ).returns(storage_domain) + + output = OutputMatcher.new( + "Id: data-1\n" \ + "Name: storage_domain1\n" + ) + expected_result = success_result(output) + + result = run_cmd(cmd + base_params + ['--storage-domain=storage_domain1']) + assert_cmd(expected_result, result) + end + end + describe 'security_groups' do let(:cmd) { base_cmd << 'security-groups' } let(:security_group1) { { id: 1, name: 'security_group1' } }