Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create action for Image #89

Merged
merged 2 commits into from
Sep 26, 2017

Conversation

andyvesel
Copy link
Contributor

Added create method for Image

@andyvesel andyvesel changed the title Add create action for Image [WIP] Add create action for Image Sep 5, 2017
@miq-bot miq-bot added the wip label Sep 5, 2017
@aufi
Copy link
Member

aufi commented Sep 5, 2017

@andyvesel Thanks for PR. Similar as for delete image PR, I'd suggest put there also non-raw method even keep it in same model to keep the consistency. (parent class is generic for all providers so it's not sure whether we want it also there)

And it would be great if you coudl add some basic tests for these methods.

@andyvesel andyvesel force-pushed the add_create_method_for_image branch 2 times, most recently from f02a0de to 02e8664 Compare September 8, 2017 12:22
@andyvesel andyvesel changed the title [WIP] Add create action for Image Add create action for Image Sep 8, 2017
@andyvesel andyvesel changed the title Add create action for Image [WIP]Add create action for Image Sep 8, 2017
@andyvesel andyvesel force-pushed the add_create_method_for_image branch from 02e8664 to 41e91dc Compare September 8, 2017 12:25
@andyvesel
Copy link
Contributor Author

@aufi tests added

@andyvesel andyvesel force-pushed the add_create_method_for_image branch 2 times, most recently from baae0c7 to b151321 Compare September 8, 2017 12:30
@andyvesel andyvesel changed the title [WIP]Add create action for Image Add create action for Image Sep 8, 2017
@miq-bot miq-bot removed the wip label Sep 8, 2017
@miq-bot
Copy link
Member

miq-bot commented Sep 19, 2017

This pull request is not mergeable. Please rebase and repush.

@andyvesel andyvesel force-pushed the add_create_method_for_image branch from b151321 to c4d845d Compare September 19, 2017 15:05
@andyvesel andyvesel force-pushed the add_create_method_for_image branch from c4d845d to 0444795 Compare September 19, 2017 15:13
@aufi aufi self-requested a review September 21, 2017 13:45
@@ -73,6 +73,29 @@ def requires_storage_for_scan?
false
end

def self.raw_create_image(ext_management_system, create_options)
ext_management_system.with_provider_connection(:service => 'Compute') do |service|
service.images.create(create_options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think we usually use request methods (instead of fog model's one), search for image_create at https://github.com/fog/fog-openstack/tree/master/lib/fog/compute/openstack/requests

before do
allow(ExtManagementSystem).to receive(:find).with(ems.id).and_return(ems)
allow(ems).to receive(:with_provider_connection).with(:service => 'Compute').and_yield(service)
allow(service).to receive(:images).and_return(images)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these lines are not needed. E.g. ExtManagementSystem exists in database so it can be found directly from model (created by line 2 and first usage of ems variable). For example take a look at https://gist.github.com/aufi/16acd1f29086eeb211ceabd3bc98625e I don't want push you to rewrite your code much, just for information.


context 'with correct data' do
it 'should create image' do
expect(images).to receive(:create).with(image_attributes).and_return(template_openstack).once
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using service (and its create_image method) directly would be easier, no need to a "double mock" then.

Nit: I'm not sure if we care about returned template_openstack data from Fog call, so we don't have to test it then.

@andyvesel
Copy link
Contributor Author

@aufi thanks for review and comments. Will fix it asap

@andyvesel andyvesel force-pushed the add_create_method_for_image branch from 0444795 to c76ba5e Compare September 22, 2017 08:43
@andyvesel
Copy link
Contributor Author

@aufi fixed

Copy link
Member

@aufi aufi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for update, could you address my few last comments?

@@ -73,6 +73,29 @@ def requires_storage_for_scan?
false
end

def self.raw_create_image(ext_management_system, create_options)
ext_management_system.with_provider_connection(:service => 'Compute') do |service|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, try use Image service instead of Compute.

let(:template_openstack) { FactoryGirl.create :template_openstack, :ext_management_system => ems, :ems_ref => 'one_id' }
let(:service) { double }

context 'when create_image' do
before do
allow(ExtManagementSystem).to receive(:find).with(ems.id).and_return(ems)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is line is not needed, could you check it?

before do
allow(ExtManagementSystem).to receive(:find).with(ems.id).and_return(ems)
allow(ems).to receive(:with_provider_connection).with(:service => 'Compute').and_yield(service)
allow(service).to receive(:images)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is line is not needed, could you check it?

allow(service).to receive(:images)
end

let(:images) { double }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is line is not needed, could you check it?

@andyvesel andyvesel force-pushed the add_create_method_for_image branch from c76ba5e to e63642c Compare September 25, 2017 10:55
@andyvesel andyvesel force-pushed the add_create_method_for_image branch from e63642c to 71f29b3 Compare September 26, 2017 13:11
@miq-bot
Copy link
Member

miq-bot commented Sep 26, 2017

Checked commits andyvesel/manageiq-providers-openstack@b6ec06b~...71f29b3 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@aufi
Copy link
Member

aufi commented Sep 26, 2017

Looks good to me, merging.

@aufi aufi merged commit 5d7d631 into ManageIQ:master Sep 26, 2017
@aufi aufi added this to the Sprint 70 Ending Oct 2, 2017 milestone Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants