Skip to content

Commit

Permalink
Merge pull request #367 from HewlettPackard/volume_fix
Browse files Browse the repository at this point in the history
Adding query parameter support
  • Loading branch information
madhav-bharadwaj committed Jun 19, 2018
2 parents 0d4f5ea + 350be05 commit a4c1605
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
## v5.6.1(Unreleased)

#### Notes
This release fixes few bugs listed below

#### Bug fixes & Enhancements
- [#366](https://github.com/HewlettPackard/oneview-sdk-ruby/issues/366) Query parameters not working for get_attachable_volumes endpoint

## v5.6.0

#### Notes
Expand Down
5 changes: 4 additions & 1 deletion examples/shared_samples/volume.rb
Expand Up @@ -150,7 +150,10 @@
puts "\nSnapshot removed successfully!"

puts "\nGetting the attachable volumes managed by the appliance"
attachables = volume_class.get_attachable_volumes(@client)
query = {
connections: '<Your parameters here>'
}
attachables = volume_class.get_attachable_volumes(@client, query)
puts "\nAttachable volumes found: #{attachables}"

puts "\nGetting the list of extra managed storage volume paths"
Expand Down
5 changes: 3 additions & 2 deletions lib/oneview-sdk/resource/api200/volume.rb
Expand Up @@ -147,8 +147,9 @@ def get_snapshots
# Gets all the attachable volumes managed by the appliance
# @param [OneviewSDK::Client] client The client object for the OneView appliance
# @return [Array<OneviewSDK::Volume>] Array of volumes
def self.get_attachable_volumes(client)
uri = "#{BASE_URI}/attachable-volumes"
def self.get_attachable_volumes(client, query = nil)
query_uri = build_query(query) if query
uri = "#{BASE_URI}/attachable-volumes#{query_uri}"
find_by(client, {}, uri)
end

Expand Down
6 changes: 4 additions & 2 deletions spec/unit/resource/api200/volume_spec.rb
Expand Up @@ -205,8 +205,10 @@
it 'returns an array of available volumes' do
volumes = [@item]
allow_any_instance_of(OneviewSDK::Client).to receive(:response_handler).and_return('members' => volumes)
expect(@client_200).to receive(:rest_get).with('/rest/storage-volumes/attachable-volumes', {})
items = OneviewSDK::Volume.get_attachable_volumes(@client_200)
allow(@client_200).to receive(:build_query)
.with(@client_200, { 'sort' => 'name:ascending' }, described_class::BASE_URI, {}).and_return('?sort=name:ascending')
expect(@client_200).to receive(:rest_get).with('/rest/storage-volumes/attachable-volumes?sort=name:ascending', {})
items = OneviewSDK::Volume.get_attachable_volumes(@client_200, 'sort' => 'name:ascending')
expect(items.class).to eq(Array)
expect(items.size).to eq(1)
expect(items.first['name']).to eq('volume_name')
Expand Down

0 comments on commit a4c1605

Please sign in to comment.