Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/hammer_cli_foreman/compute_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
45 changes: 45 additions & 0 deletions test/functional/compute_resource_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' } }
Expand Down
Loading