Skip to content

Commit

Permalink
Added option timeout for the Golden Image upload
Browse files Browse the repository at this point in the history
  • Loading branch information
marikrg committed Mar 17, 2017
1 parent 8561df9 commit b033829
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#116](https://github.com/HewlettPackard/oneview-puppet/issues/116) Simplify login to i3s
- [#121](https://github.com/HewlettPackard/oneview-puppet/issues/121) Deployment Plan and Golden Image should use the default uri parser
- [#122](https://github.com/HewlettPackard/oneview-puppet/issues/122) Uri_parsing should support upper case for uri
- [#133](https://github.com/HewlettPackard/oneview-puppet/issues/133) Allow set a timeout for Image_streamer_golden_image upload

# 2.1.0 (2017-02-03)
### Version highlights:
Expand Down
3 changes: 2 additions & 1 deletion examples/image_streamer/golden_image.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
data => {
name => 'Golden_Image_2',
description => 'Golden image added from the file that is uploaded from a local drive',
golden_image_path => 'golden_image.zip' # can be either an absolute or relative path
golden_image_path => 'golden_image.zip', # can be either an absolute or relative path
timeout => 3600
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def exists?
def create
current_resource = @resourcetype.find_by(@client, unique_id).first
return super unless @golden_image_path && !current_resource
@resourcetype.add(@client, @golden_image_path, @data)
timeout = @data.delete('timeout') || OneviewSDK::Rest::READ_TIMEOUT
@resourcetype.add(@client, @golden_image_path, @data, timeout)
true
end

Expand Down
17 changes: 15 additions & 2 deletions spec/unit/provider/image_streamer_golden_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,27 @@
)
end

let(:expected_data) do
{ 'name' => resource['data']['name'],
'description' => resource['data']['description'] }
end

before(:each) do
allow(resourcetype).to receive(:find_by).and_return([test])
provider.exists?
end

it 'should upload the file and add the golden image resource' do
it 'should upload the file and add the golden image resource with default timeout' do
allow(resourcetype).to receive(:find_by).and_return([])
timeout = OneviewSDK::Rest::READ_TIMEOUT
expect(resourcetype).to receive(:add).with(anything, '/path/to/upload/golden_image.zip', expected_data, timeout).and_return(test)
expect(provider.create).to be
end

it 'should upload the file and add the golden image resource with given timeout' do
resource['data']['timeout'] = 7_200
allow(resourcetype).to receive(:find_by).and_return([])
expect(resourcetype).to receive(:add).and_return(test)
expect(resourcetype).to receive(:add).with(anything, '/path/to/upload/golden_image.zip', expected_data, 7_200).and_return(test)
expect(provider.create).to be
end
end
Expand Down

0 comments on commit b033829

Please sign in to comment.